diff --git a/Assets/HappyFunTimes-README.txt b/Assets/HappyFunTimes-README.txt index 5258529..6fe3830 100644 --- a/Assets/HappyFunTimes-README.txt +++ b/Assets/HappyFunTimes-README.txt @@ -38,6 +38,7 @@ Assets └── HappyFunTimes ├── 3rdparty see below ├── controllers + │   ├── camera deletable │   ├── character-select deletable │   ├── clean deletable │   ├── gamepad see below @@ -104,6 +105,30 @@ http://docs.happyfuntimes.net/docs/unity/rendezvous-server.html ## Change List +* 2.1.4 + + * Added MoreSamples/Camera sample + +* 2.1.3 + + * Updated for 2017 + +* 2.1.2 + + * Fix sounds example + +* 2.1.1 + + * Disable auto connect on iOS installation mode. + + Apple either removed or broke this feature on iOS + + * Upadte to Unity 5.6.1 + +* 2.1.0 + + * Add Character example + * 2.0.6 * Update to Unity 5.6 diff --git a/Assets/HappyFunTimes/MoreSamples/camera.meta b/Assets/HappyFunTimes/MoreSamples/camera.meta new file mode 100644 index 0000000..8e81662 --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9ac27e66d78a14ea58b20de8f413028a +folderAsset: yes +timeCreated: 1511756490 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Materials.meta b/Assets/HappyFunTimes/MoreSamples/camera/Materials.meta new file mode 100644 index 0000000..f20bbb8 --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Materials.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1447f435dad4743eba88656926974dc6 +folderAsset: yes +timeCreated: 1511756732 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Prefabs.meta b/Assets/HappyFunTimes/MoreSamples/camera/Prefabs.meta new file mode 100644 index 0000000..75e98bb --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Prefabs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e80db2ee453354be484edf5bdb9c5e34 +folderAsset: yes +timeCreated: 1511756716 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Prefabs/PrefabForExampleCamera.prefab b/Assets/HappyFunTimes/MoreSamples/camera/Prefabs/PrefabForExampleCamera.prefab new file mode 100644 index 0000000..3286b5b Binary files /dev/null and b/Assets/HappyFunTimes/MoreSamples/camera/Prefabs/PrefabForExampleCamera.prefab differ diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Prefabs/PrefabForExampleCamera.prefab.meta b/Assets/HappyFunTimes/MoreSamples/camera/Prefabs/PrefabForExampleCamera.prefab.meta new file mode 100644 index 0000000..06b0101 --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Prefabs/PrefabForExampleCamera.prefab.meta @@ -0,0 +1,6 @@ +fileFormatVersion: 2 +guid: 7cf4a4f04d4e24d4dbf6d6916575f949 +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Scenes.meta b/Assets/HappyFunTimes/MoreSamples/camera/Scenes.meta new file mode 100644 index 0000000..dd798ec --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Scenes.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: afbd1386164564ddaaafbf57997135b5 +folderAsset: yes +timeCreated: 1511756684 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample-README.txt b/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample-README.txt new file mode 100644 index 0000000..c7eb78b --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample-README.txt @@ -0,0 +1,21 @@ +# Camera Example + +This sample is based of the Simple Example in `Assets/HappyFunTimes/MoreSamples/Simple` +It shows letting the user take or select an image on their camera then +sending that image to the game and using it as a texture. + +It uses a custom controller found in +`Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/controller.html` + +Tersely, if you select the `ExampleCameraSpawner` GameObject you'll see it has a `PlayerSpawner` +component set to spawn the `PrefabForExampleCamera` prefab anytime a player connects their phone. + +The `PrefabForExampleCamera` prefab has the `ExampleCameraPlayer` script which uses the `NetPlayer` +object passed to it to send and receive messages from the phone. + +The code in `Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/controller.html` +uses an input type=file tag to ask the user to select an image. It then scales that image to 256x256, +using a 2D canvas, converts it to a dataUrl and sends it to the game. The game converts the dataUrl +to binary and passes it to `Texture2D.Load` in unity. + +For more info see [http://docs.happyfuntimes.net/docs/unity/](http://docs.happyfuntimes.net/docs/unity/). diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample-README.txt.meta b/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample-README.txt.meta new file mode 100644 index 0000000..245ec04 --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample-README.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bedb0c1a14c924758884d9e7863ce71c +timeCreated: 1465053929 +licenseType: Free +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample.unity b/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample.unity new file mode 100644 index 0000000..ad4fb67 Binary files /dev/null and b/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample.unity differ diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample.unity.meta b/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample.unity.meta new file mode 100644 index 0000000..b1fd6ce --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Scenes/HappyFunTimesCameraExample.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0b5a450f9afc149a2ac6aed56ca34015 +timeCreated: 1511756684 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Scripts.meta b/Assets/HappyFunTimes/MoreSamples/camera/Scripts.meta new file mode 100644 index 0000000..75d6d96 --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Scripts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e31ac49faa1234c81b367532f47a5a9e +folderAsset: yes +timeCreated: 1511756723 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraGameSettings.cs b/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraGameSettings.cs new file mode 100644 index 0000000..b08e4f9 --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraGameSettings.cs @@ -0,0 +1,40 @@ +using UnityEngine; + +namespace HappyFunTimesExample { + +// A Singlton-ish class for some global settings. +// PS: I know Singltons suck but dependency injection is hard +// in Unity. +public class ExampleCameraGameSettings : MonoBehaviour { + + public int areaWidth = 300; // matches JavaScript + public int areaHeight = 300; + + public static ExampleCameraGameSettings settings() { + return s_settings; + } + + static private ExampleCameraGameSettings s_settings; + + void Awake() { + if (s_settings != null) { + throw new System.InvalidProgramException("there is more than one game settings object!"); + } + s_settings = this; + } + + void Cleanup() { + s_settings = null; + } + + void OnDestroy() { + Cleanup(); + } + + void OnApplicationExit() { + Cleanup(); + } +} + +} // namespace HappyFunTimesExample + diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraGameSettings.cs.meta b/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraGameSettings.cs.meta new file mode 100644 index 0000000..585c15e --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraGameSettings.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: da9ce00fa210f403d8df3e2f4693f869 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraPlayer.cs b/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraPlayer.cs new file mode 100644 index 0000000..1110f5c --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraPlayer.cs @@ -0,0 +1,133 @@ +using UnityEngine; +using System; +using System.Collections; +using System.Collections.Generic; +using HappyFunTimes; +using CSSParse; + +namespace HappyFunTimesExample { + +class ExampleCameraPlayer : MonoBehaviour { + private class MessageMove { + public float x = 0; + public float y = 0; + }; + + private class MessagePic { + public string dataUrl; + } + + void InitializeNetPlayer(SpawnInfo spawnInfo) { + // Save the netplayer object so we can use it send messages to the phone + m_netPlayer = spawnInfo.netPlayer; + + // Register handler to call if the player disconnects from the game. + m_netPlayer.OnDisconnect += Remove; + + // Track name changes + m_playerNameManager = new HFTPlayerNameManager(m_netPlayer); + m_playerNameManager.OnNameChange += ChangeName; + + // Setup events for the different messages. + m_netPlayer.RegisterCmdHandler("move", OnMove); + m_netPlayer.RegisterCmdHandler("pic", OnPicture); + + ExampleCameraGameSettings settings = ExampleCameraGameSettings.settings(); + m_position = new Vector3(UnityEngine.Random.Range(0, settings.areaWidth), 0, UnityEngine.Random.Range(0, settings.areaHeight)); + transform.localPosition = m_position; + + SetName(m_playerNameManager.Name); + } + + void Start() { + m_renderer = gameObject.GetComponent(); + m_position = gameObject.transform.localPosition; + SetColor(new Color(0.0f, 1.0f, 0.0f)); + } + + void Update() { + } + + void OnDestroy() { + if (m_playerNameManager != null) { + m_playerNameManager.Close(); + m_playerNameManager = null; + } + } + + void OnGUI() + { + Vector2 size = m_guiStyle.CalcSize(m_guiName); + Vector3 coords = Camera.main.WorldToScreenPoint(transform.position); + m_nameRect.x = coords.x - size.x * 0.5f - 5.0f; + m_nameRect.y = Screen.height - coords.y - 30.0f; + GUI.Box(m_nameRect, m_name, m_guiStyle); + } + + void SetName(string name) { + m_name = name; + gameObject.name = "Player-" + m_name; + m_guiName = new GUIContent(m_name); + m_guiStyle.normal.textColor = Color.black; + m_guiStyle.contentOffset = new Vector2(4.0f, 2.0f); + Vector2 size = m_guiStyle.CalcSize(m_guiName); + m_nameRect.width = size.x + 12; + m_nameRect.height = size.y + 5; + } + + void SetColor(Color color) + { + m_color = color; + m_renderer.material.color = m_color; + Color[] pix = new Color[1]; + pix[0] = color; + Texture2D tex = new Texture2D(1, 1); + tex.SetPixels(pix); + tex.Apply(); + m_guiStyle.normal.background = tex; + } + + void SetTexture(Byte[] binaryData) + { + Texture2D tex = new Texture2D(4, 4); + tex.LoadImage(binaryData); + m_renderer.material.mainTexture = tex; + m_renderer.material.color = Color.white; + } + + private void Remove(object sender, EventArgs e) { + Destroy(gameObject); + } + + + private static string s_dataUrlHeader = "data:image/png;base64,"; + + private void OnPicture(MessagePic data) { + SetTexture(Convert.FromBase64String(data.dataUrl.Substring(s_dataUrlHeader.Length))); + } + + private void OnMove(MessageMove data) { + ExampleCameraGameSettings settings = ExampleCameraGameSettings.settings(); + m_position.x = data.x * settings.areaWidth; + m_position.z = settings.areaHeight - (data.y * settings.areaHeight) - 1; // because in 2D down is positive. + + gameObject.transform.localPosition = m_position; + } + + private void ChangeName(string name) { + SetName(name); + } + + private NetPlayer m_netPlayer; + private HFTPlayerNameManager m_playerNameManager; + private Renderer m_renderer; + private Vector3 m_position; + private Color m_color; + private string m_name; + private GUIStyle m_guiStyle = new GUIStyle(); + private GUIContent m_guiName = new GUIContent(""); + private Rect m_nameRect = new Rect(0,0,0,0); +} + +} // namespace HappyFunTimesExample + diff --git a/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraPlayer.cs.meta b/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraPlayer.cs.meta new file mode 100644 index 0000000..38b187f --- /dev/null +++ b/Assets/HappyFunTimes/MoreSamples/camera/Scripts/ExampleCameraPlayer.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 6d013b8addbe245baab48e0e5c55e484 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/__dir__.txt b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/__dir__.txt index c72a7b8..f05ad36 100644 --- a/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/__dir__.txt +++ b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/__dir__.txt @@ -1 +1 @@ -["icon-16.png","3rdparty/audiomanager-min.js","3rdparty/audiomanager.js","3rdparty/chroma.min.js","3rdparty/game-utils-min.js","3rdparty/game-utils.js","3rdparty/gyronorm.complete.min.js","controllers/character-select/controller.html","controllers/character-select/css/controller.css","controllers/character-select/images/cube.svg","controllers/character-select/images/cylinder.svg","controllers/character-select/images/sphere.svg","controllers/character-select/scripts/controller.js","controllers/clean/controller.html","controllers/gamepad/controller.html","controllers/gamepad/css/controller.css","controllers/gamepad/images/bird.png","controllers/gamepad/images/hft-circle-button.svg","controllers/gamepad/images/hft-down-arrow-button.svg","controllers/gamepad/images/hft-left-arrow-button.svg","controllers/gamepad/images/hft-right-arrow-button.svg","controllers/gamepad/images/hft-up-arrow-button.svg","controllers/gamepad/scripts/controller.js","controllers/gamepad/sounds/explosion.mp3","controllers/gamepad/sounds/gameover.mp3","controllers/gamepad/sounds/launch.mp3","controllers/gamepad/sounds/sounds.jsfx.txt","controllers/multi-machine/controller.html","controllers/multi-machine/css/controller.css","controllers/multi-machine/images/bird.png","controllers/multi-machine/images/hft-circle-button.svg","controllers/multi-machine/images/hft-down-arrow-button.svg","controllers/multi-machine/images/hft-left-arrow-button.svg","controllers/multi-machine/images/hft-right-arrow-button.svg","controllers/multi-machine/images/hft-up-arrow-button.svg","controllers/multi-machine/scripts/controller.js","controllers/simple/controller.html","controllers/simple/css/controller.css","controllers/simple/scripts/controller.js","controllers/syncedclock/controller.html","controllers/syncedclock/assets/clocktick.mp3","controllers/syncedclock/assets/clocktick.ogg","controllers/syncedclock/css/controller.css","controllers/syncedclock/scripts/controller.js","hft/hft-min.js","hft/hft.js","hft/missing.html","hft/assets/gear-icon.svg","hft/captive-portal/captive-portal.html","hft/captive-portal/game-login.html","hft/captive-portal/login.css","hft/captive-portal/xtra2.bin","sample-ui/sample-ui-min.js","sample-ui/sample-ui.css","sample-ui/sample-ui.js"] \ No newline at end of file +["icon-16.png","3rdparty/audiomanager-min.js","3rdparty/audiomanager.js","3rdparty/chroma.min.js","3rdparty/game-utils-min.js","3rdparty/game-utils.js","3rdparty/gyronorm.complete.min.js","controllers/camera/controller.html","controllers/camera/css/controller.css","controllers/camera/scripts/controller.js","controllers/character-select/controller.html","controllers/character-select/css/controller.css","controllers/character-select/images/cube.svg","controllers/character-select/images/cylinder.svg","controllers/character-select/images/sphere.svg","controllers/character-select/scripts/controller.js","controllers/clean/controller.html","controllers/gamepad/controller.html","controllers/gamepad/css/controller.css","controllers/gamepad/images/bird.png","controllers/gamepad/images/hft-circle-button.svg","controllers/gamepad/images/hft-down-arrow-button.svg","controllers/gamepad/images/hft-left-arrow-button.svg","controllers/gamepad/images/hft-right-arrow-button.svg","controllers/gamepad/images/hft-up-arrow-button.svg","controllers/gamepad/scripts/controller.js","controllers/gamepad/sounds/explosion.mp3","controllers/gamepad/sounds/gameover.mp3","controllers/gamepad/sounds/launch.mp3","controllers/gamepad/sounds/sounds.jsfx.txt","controllers/multi-machine/controller.html","controllers/multi-machine/css/controller.css","controllers/multi-machine/images/bird.png","controllers/multi-machine/images/hft-circle-button.svg","controllers/multi-machine/images/hft-down-arrow-button.svg","controllers/multi-machine/images/hft-left-arrow-button.svg","controllers/multi-machine/images/hft-right-arrow-button.svg","controllers/multi-machine/images/hft-up-arrow-button.svg","controllers/multi-machine/scripts/controller.js","controllers/simple/controller.html","controllers/simple/css/controller.css","controllers/simple/scripts/controller.js","controllers/syncedclock/controller.html","controllers/syncedclock/assets/clocktick.mp3","controllers/syncedclock/assets/clocktick.ogg","controllers/syncedclock/css/controller.css","controllers/syncedclock/scripts/controller.js","hft/hft-min.js","hft/hft.js","hft/missing.html","hft/assets/gear-icon.svg","hft/captive-portal/captive-portal.html","hft/captive-portal/game-login.html","hft/captive-portal/login.css","hft/captive-portal/xtra2.bin","sample-ui/sample-ui-min.js","sample-ui/sample-ui.css","sample-ui/sample-ui.js"] \ No newline at end of file diff --git a/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera.meta b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera.meta new file mode 100644 index 0000000..3746127 --- /dev/null +++ b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a0b9705ba19a9445795cf43bed3717cb +folderAsset: yes +timeCreated: 1511757953 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/controller.html.bytes b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/controller.html.bytes new file mode 100644 index 0000000..d32fe8d --- /dev/null +++ b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/controller.html.bytes @@ -0,0 +1,105 @@ + + + + + + + + + + + + + happyfuntimes Controls + + + + + + +
+
+
+

status

+
+
Touch to Move
+
+
+
+
+ +
+
+
+
+
+
+
Switching Games...
+
+
+
+

+      
+
+
+ +
+
+
+ +
+
+ +
+
+
Set Name
+
Restart
+
Back
+
+
+ +
+
+
+ + + + + + + + diff --git a/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/controller.html.bytes.meta b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/controller.html.bytes.meta new file mode 100644 index 0000000..5aac0ad --- /dev/null +++ b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/controller.html.bytes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 03878c510f2214d8a8b938176a489468 +timeCreated: 1511757953 +licenseType: Free +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/css.meta b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/css.meta new file mode 100644 index 0000000..fd0e05e --- /dev/null +++ b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/css.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 96f1dbb42e7e24f8b8eb5083058023f2 +folderAsset: yes +timeCreated: 1511757953 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/css/controller.css.bytes b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/css/controller.css.bytes new file mode 100644 index 0000000..721a006 --- /dev/null +++ b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/css/controller.css.bytes @@ -0,0 +1,75 @@ +/* + * Copyright 2014, Gregg Tavares. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Gregg Tavares. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#gamearea { + width: 100%; + height: 100%; +} +#gamestatus { + position: absolute; + z-index: 4000; + border-radius: 5px; + background-color: rgba(0,0,0,0.5); + margin: 0.5em; + padding: 0.5em; + color: white; + font-size: medium; +} +#display { +} +#inputarea { + position: absolute; + z-index: 4100; + top: 0px; + left: 0px; + width: 100%; + height: 100%; +} +#picture { + text-align: center; + background: red; + position: absolute; + z-index: 4101; + font-size: 20pt; + top: 0px; + left: 0px; + width: 100%; + height: 100%; +} +#picture input[type=file] { + display: none; +} +#picture label { + display: block; + padding: 0.5em; + margin: 0.5em; + background: yellow; + border-radius: 0.5em; +} diff --git a/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/css/controller.css.bytes.meta b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/css/controller.css.bytes.meta new file mode 100644 index 0000000..33a06f9 --- /dev/null +++ b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/css/controller.css.bytes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9d865a2224850462f9a20e706f955c77 +timeCreated: 1511757953 +licenseType: Free +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/scripts.meta b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/scripts.meta new file mode 100644 index 0000000..2db736a --- /dev/null +++ b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/scripts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7b32ac2d6a5e34bb3afa76d6f7df095c +folderAsset: yes +timeCreated: 1511757953 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/scripts/controller.js.bytes b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/scripts/controller.js.bytes new file mode 100644 index 0000000..1c0e06b --- /dev/null +++ b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/scripts/controller.js.bytes @@ -0,0 +1,120 @@ +/* + * Copyright 2014, Gregg Tavares. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Gregg Tavares. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +"use strict"; + +// Start the main app logic. +var commonUI = sampleUI.commonUI; +var input = sampleUI.input; +var misc = sampleUI.misc; +var mobileHacks = sampleUI.mobileHacks; +var strings = sampleUI.strings; +var touch = sampleUI.touch; + +var globals = { + debug: false, + //orientation: "landscape-primary", +}; +misc.applyUrlSettings(globals); +mobileHacks.fixHeightHack(); +mobileHacks.disableContextMenu(); + +var score = 0; +var statusElem = document.getElementById("gamestatus"); +var inputElem = document.getElementById("inputarea"); +var colorElem = document.getElementById("display"); +var picFrameElem = document.getElementById("picture"); +var picElem = document.querySelector("#picture input[type=file]"); +var client = new hft.GameClient(); + +commonUI.setupStandardControllerUI(client, globals); +commonUI.askForNameOnce(); +commonUI.showMenu(true); + +function randInt(range) { + return Math.floor(Math.random() * range); +}; + +// Sends a move command to the game. +// +// This will generate a 'move' event in the corresponding +// NetPlayer object in the game. +function sendMoveCmd(position, target) { + client.sendCmd('move', { + x: position.x / target.clientWidth, + y: position.y / target.clientHeight, + }); +}; + +// Send a message to the game when the screen is touched +inputElem.addEventListener('pointermove', function(event) { + var position = input.getRelativeCoordinates(event.target, event); + sendMoveCmd(position, event.target); + event.preventDefault(); +}); + +// Send selected picture to game +picElem.addEventListener('change', function(event) { + if (this.files && this.files[0]) { + // NOTE: Older iOS could not handle camera images + // in web pages + picFrameElem.style.display = "none"; + // make image to load picture + var img = new Image(); + // call function when done loading + img.onload = function() { + // create a 256x256 canvas + var canvas = document.createElement("canvas"); + canvas.width = 256; + canvas.height = 256; + var ctx = canvas.getContext("2d"); + // scale the image using a css "cover" algo + var aspect = img.width / img.height; + var dstHeight = 256 + var dstWidth = dstHeight * aspect; + if (dstWidth < 256) { + dstWidth = 256; + dstHeight = dstWidth / aspect; + } + var dstX = (256 - dstWidth) / 2; + var dstY = (256 - dstHeight) / 2; + ctx.drawImage(img, dstX, dstY, dstWidth, dstHeight); + // send the image as a dataUrl to theg game + client.sendCmd('pic', { + dataUrl: canvas.toDataURL(), + }); + // tell the browser we're done + URL.revokeObjectURL(img.src); + }; + // load the image + img.src = URL.createObjectURL(this.files[0]); + } +}); + diff --git a/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/scripts/controller.js.bytes.meta b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/scripts/controller.js.bytes.meta new file mode 100644 index 0000000..d12d1ba --- /dev/null +++ b/Assets/HappyFunTimes/Resources/HappyFunTimesAutoGeneratedDoNotEdit/controllers/camera/scripts/controller.js.bytes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a3dd0e94954f740fa974bb38d8c9c579 +timeCreated: 1511757953 +licenseType: Free +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera.meta b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera.meta new file mode 100644 index 0000000..db5fce9 --- /dev/null +++ b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f506f563472a14485bb67505a8488a39 +folderAsset: yes +timeCreated: 1511757952 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/controller.html b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/controller.html new file mode 100644 index 0000000..d32fe8d --- /dev/null +++ b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/controller.html @@ -0,0 +1,105 @@ + + + + + + + + + + + + + happyfuntimes Controls + + + + + + +
+
+
+

status

+
+
Touch to Move
+
+
+
+
+ +
+
+
+
+
+
+
Switching Games...
+
+
+
+

+      
+
+
+ +
+
+
+ +
+
+ +
+
+
Set Name
+
Restart
+
Back
+
+
+ +
+
+
+ + + + + + + + diff --git a/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/controller.html.meta b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/controller.html.meta new file mode 100644 index 0000000..ca49765 --- /dev/null +++ b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/controller.html.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3574210fe753c429f85af827dae4d16c +timeCreated: 1463116308 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/css.meta b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/css.meta new file mode 100644 index 0000000..3c69232 --- /dev/null +++ b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/css.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8d8f0fe8757dc46269844a9fb5c58732 +folderAsset: yes +timeCreated: 1463116308 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/css/controller.css b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/css/controller.css new file mode 100644 index 0000000..721a006 --- /dev/null +++ b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/css/controller.css @@ -0,0 +1,75 @@ +/* + * Copyright 2014, Gregg Tavares. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Gregg Tavares. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#gamearea { + width: 100%; + height: 100%; +} +#gamestatus { + position: absolute; + z-index: 4000; + border-radius: 5px; + background-color: rgba(0,0,0,0.5); + margin: 0.5em; + padding: 0.5em; + color: white; + font-size: medium; +} +#display { +} +#inputarea { + position: absolute; + z-index: 4100; + top: 0px; + left: 0px; + width: 100%; + height: 100%; +} +#picture { + text-align: center; + background: red; + position: absolute; + z-index: 4101; + font-size: 20pt; + top: 0px; + left: 0px; + width: 100%; + height: 100%; +} +#picture input[type=file] { + display: none; +} +#picture label { + display: block; + padding: 0.5em; + margin: 0.5em; + background: yellow; + border-radius: 0.5em; +} diff --git a/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/css/controller.css.meta b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/css/controller.css.meta new file mode 100644 index 0000000..e07b451 --- /dev/null +++ b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/css/controller.css.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 20654fdecebed4cb29d663e982922b82 +timeCreated: 1428745724 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/scripts.meta b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/scripts.meta new file mode 100644 index 0000000..c3b0316 --- /dev/null +++ b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/scripts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 318e64c2bde9b44f48c19ef8ecc9e1ac +folderAsset: yes +timeCreated: 1463116308 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/scripts/controller.js b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/scripts/controller.js new file mode 100644 index 0000000..1c0e06b --- /dev/null +++ b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/scripts/controller.js @@ -0,0 +1,120 @@ +/* + * Copyright 2014, Gregg Tavares. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Gregg Tavares. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +"use strict"; + +// Start the main app logic. +var commonUI = sampleUI.commonUI; +var input = sampleUI.input; +var misc = sampleUI.misc; +var mobileHacks = sampleUI.mobileHacks; +var strings = sampleUI.strings; +var touch = sampleUI.touch; + +var globals = { + debug: false, + //orientation: "landscape-primary", +}; +misc.applyUrlSettings(globals); +mobileHacks.fixHeightHack(); +mobileHacks.disableContextMenu(); + +var score = 0; +var statusElem = document.getElementById("gamestatus"); +var inputElem = document.getElementById("inputarea"); +var colorElem = document.getElementById("display"); +var picFrameElem = document.getElementById("picture"); +var picElem = document.querySelector("#picture input[type=file]"); +var client = new hft.GameClient(); + +commonUI.setupStandardControllerUI(client, globals); +commonUI.askForNameOnce(); +commonUI.showMenu(true); + +function randInt(range) { + return Math.floor(Math.random() * range); +}; + +// Sends a move command to the game. +// +// This will generate a 'move' event in the corresponding +// NetPlayer object in the game. +function sendMoveCmd(position, target) { + client.sendCmd('move', { + x: position.x / target.clientWidth, + y: position.y / target.clientHeight, + }); +}; + +// Send a message to the game when the screen is touched +inputElem.addEventListener('pointermove', function(event) { + var position = input.getRelativeCoordinates(event.target, event); + sendMoveCmd(position, event.target); + event.preventDefault(); +}); + +// Send selected picture to game +picElem.addEventListener('change', function(event) { + if (this.files && this.files[0]) { + // NOTE: Older iOS could not handle camera images + // in web pages + picFrameElem.style.display = "none"; + // make image to load picture + var img = new Image(); + // call function when done loading + img.onload = function() { + // create a 256x256 canvas + var canvas = document.createElement("canvas"); + canvas.width = 256; + canvas.height = 256; + var ctx = canvas.getContext("2d"); + // scale the image using a css "cover" algo + var aspect = img.width / img.height; + var dstHeight = 256 + var dstWidth = dstHeight * aspect; + if (dstWidth < 256) { + dstWidth = 256; + dstHeight = dstWidth / aspect; + } + var dstX = (256 - dstWidth) / 2; + var dstY = (256 - dstHeight) / 2; + ctx.drawImage(img, dstX, dstY, dstWidth, dstHeight); + // send the image as a dataUrl to theg game + client.sendCmd('pic', { + dataUrl: canvas.toDataURL(), + }); + // tell the browser we're done + URL.revokeObjectURL(img.src); + }; + // load the image + img.src = URL.createObjectURL(this.files[0]); + } +}); + diff --git a/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/scripts/controller.js.meta b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/scripts/controller.js.meta new file mode 100644 index 0000000..2c1070f --- /dev/null +++ b/Assets/WebPlayerTemplates/HappyFunTimes/controllers/camera/scripts/controller.js.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f87bc9623f5d34cc889dbbea8ef60b6c +timeCreated: 1428745724 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: