From a53fef82d44dfc27cdbeaf45788cfa544f75102a Mon Sep 17 00:00:00 2001 From: Dmitri Kolytchev Date: Sun, 31 Jan 2016 09:41:29 -0500 Subject: [PATCH] tweaking the board to a manageable size --- Assets/scenes/CagedRoom.unity | 4 +- Assets/scenes/GameplayScene.unity | 257 +++++++++++++++- Assets/scripts/GameState.cs | 50 ++-- Assets/scripts/LevelManager.cs | 415 +++++++++++++------------- Assets/scripts/RuneBehaviour.cs | 174 +++++------ ProjectSettings/ProjectSettings.asset | 72 +---- 6 files changed, 577 insertions(+), 395 deletions(-) diff --git a/Assets/scenes/CagedRoom.unity b/Assets/scenes/CagedRoom.unity index 07d51f7..d6869f1 100644 --- a/Assets/scenes/CagedRoom.unity +++ b/Assets/scenes/CagedRoom.unity @@ -255,7 +255,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 377027947} m_LocalRotation: {x: .707106709, y: -1.42108547e-14, z: -1.42108547e-14, w: .707106829} - m_LocalPosition: {x: -3.54999995, y: 14.7600002, z: -32.4900017} + m_LocalPosition: {x: 3.53999996, y: 31.0900002, z: -37.0800018} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -502,7 +502,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1903459893} m_LocalRotation: {x: .612653315, y: .0739248246, z: .0576999038, w: .784768701} - m_LocalPosition: {x: 4.05999994, y: 8.14000034, z: -31.3700008} + m_LocalPosition: {x: -1.55999994, y: 8.14000034, z: -38.8199997} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} diff --git a/Assets/scenes/GameplayScene.unity b/Assets/scenes/GameplayScene.unity index 36a3d11..403a9b6 100644 --- a/Assets/scenes/GameplayScene.unity +++ b/Assets/scenes/GameplayScene.unity @@ -65,7 +65,6 @@ LightmapSettings: m_TextureCompression: 1 m_FinalGather: 0 m_FinalGatherRayCount: 1024 - m_ReflectionCompression: 2 m_LightmapSnapshot: {fileID: 0} m_RuntimeCPUUsage: 25 --- !u!196 &4 @@ -85,6 +84,9 @@ NavMeshSettings: cellSize: .166666672 manualCellSize: 0 m_NavMeshData: {fileID: 0} +--- !u!127 &5 +LevelGameManager: + m_ObjectHideFlags: 0 --- !u!1 &16934334 GameObject: m_ObjectHideFlags: 0 @@ -459,7 +461,6 @@ Camera: m_RenderingPath: -1 m_TargetTexture: {fileID: 0} m_TargetDisplay: 0 - m_TargetEye: 3 m_HDR: 0 m_OcclusionCulling: 1 m_StereoConvergence: 10 @@ -593,7 +594,9 @@ MonoBehaviour: m_EditorClassIdentifier: xScale: 2.79999995 yScale: 2.79999995 - dimension: .720000029 + colSpacing: 0 + rowSpacing: 0 + dimension: 1 hexagon: {fileID: 118646, guid: 950731e814d3ade4c91c128681c35ce2, type: 2} PlayerColors: - {r: .448275924, g: 1, b: 0, a: 1} @@ -606,7 +609,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1173224166} m_LocalRotation: {x: .707106829, y: 0, z: 0, w: .707106709} - m_LocalPosition: {x: -22.5, y: -0, z: -2.74000001} + m_LocalPosition: {x: -23, y: -0, z: 10} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -1114,7 +1117,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1374790521} m_LocalRotation: {x: 0, y: .707106829, z: 0, w: .707106709} - m_LocalPosition: {x: 4.65999985, y: 1.46200013, z: 3.53900003} + m_LocalPosition: {x: 4.65999985, y: 1.46200013, z: 2.70000005} m_LocalScale: {x: .200000003, y: 6, z: 18} m_Children: [] m_Father: {fileID: 1944057160} @@ -2197,6 +2200,226 @@ Prefab: propertyPath: m_Layer value: 8 objectReference: {fileID: 0} + - target: {fileID: 5995724, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 2.36985193e-06 + objectReference: {fileID: 0} + - target: {fileID: 5995724, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.y + value: -1.24000549 + objectReference: {fileID: 0} + - target: {fileID: 5995724, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 2.03197669e-06 + objectReference: {fileID: 0} + - target: {fileID: 5995028, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 1.09475582e-06 + objectReference: {fileID: 0} + - target: {fileID: 5995028, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 7.16499997e-08 + objectReference: {fileID: 0} + - target: {fileID: 5991708, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 1.99487522e-06 + objectReference: {fileID: 0} + - target: {fileID: 5991708, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 8.34955642e-07 + objectReference: {fileID: 0} + - target: {fileID: 5990032, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 2.73828027e-06 + objectReference: {fileID: 0} + - target: {fileID: 5990032, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: -9.16678573e-08 + objectReference: {fileID: 0} + - target: {fileID: 5989208, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: -1.96249289e-07 + objectReference: {fileID: 0} + - target: {fileID: 5989208, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.y + value: 1.57999945 + objectReference: {fileID: 0} + - target: {fileID: 5989208, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: -.141496658 + objectReference: {fileID: 0} + - target: {fileID: 5987272, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 9.10650044e-07 + objectReference: {fileID: 0} + - target: {fileID: 5987272, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: -9.16689942e-08 + objectReference: {fileID: 0} + - target: {fileID: 5984972, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: -5.58595502e-07 + objectReference: {fileID: 0} + - target: {fileID: 5984972, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: -2.05027413e-06 + objectReference: {fileID: 0} + - target: {fileID: 5975630, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 1.67725545e-06 + objectReference: {fileID: 0} + - target: {fileID: 5975630, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.y + value: -1.38999176 + objectReference: {fileID: 0} + - target: {fileID: 5975630, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: -5.60157389e-07 + objectReference: {fileID: 0} + - target: {fileID: 5975472, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 4.09336371e-06 + objectReference: {fileID: 0} + - target: {fileID: 5975472, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.y + value: -1.38998413 + objectReference: {fileID: 0} + - target: {fileID: 5975472, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 4.13718499e-06 + objectReference: {fileID: 0} + - target: {fileID: 5968422, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 9.22213985e-07 + objectReference: {fileID: 0} + - target: {fileID: 5968110, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 1.61266485e-06 + objectReference: {fileID: 0} + - target: {fileID: 5968110, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: -7.45058105e-06 + objectReference: {fileID: 0} + - target: {fileID: 5966534, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 1.38189193e-06 + objectReference: {fileID: 0} + - target: {fileID: 5966534, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.y + value: -1.3599968 + objectReference: {fileID: 0} + - target: {fileID: 5966534, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 8.19955676e-06 + objectReference: {fileID: 0} + - target: {fileID: 5959588, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 2.18657283e-06 + objectReference: {fileID: 0} + - target: {fileID: 5959588, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.y + value: -1.27000427 + objectReference: {fileID: 0} + - target: {fileID: 5959588, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 3.38662858e-06 + objectReference: {fileID: 0} + - target: {fileID: 5956290, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: -.000424422324 + objectReference: {fileID: 0} + - target: {fileID: 5956290, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.y + value: 1.57999897 + objectReference: {fileID: 0} + - target: {fileID: 5956290, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: -.114237666 + objectReference: {fileID: 0} + - target: {fileID: 5950970, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 3.69365398e-06 + objectReference: {fileID: 0} + - target: {fileID: 5950970, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 1.50880339e-06 + objectReference: {fileID: 0} + - target: {fileID: 5950628, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 2.12233613e-06 + objectReference: {fileID: 0} + - target: {fileID: 5950628, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 1.14638922e-07 + objectReference: {fileID: 0} + - target: {fileID: 5949202, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 2.3415808e-07 + objectReference: {fileID: 0} + - target: {fileID: 5949202, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 2.79338474e-06 + objectReference: {fileID: 0} + - target: {fileID: 5948580, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 9.07083461e-07 + objectReference: {fileID: 0} + - target: {fileID: 5948580, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: -1.60923082e-06 + objectReference: {fileID: 0} + - target: {fileID: 5946966, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: -7.42570876e-08 + objectReference: {fileID: 0} + - target: {fileID: 5946966, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 1.54151564e-07 + objectReference: {fileID: 0} + - target: {fileID: 5933246, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 4.459867e-07 + objectReference: {fileID: 0} + - target: {fileID: 5933246, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 2.292619e-06 + objectReference: {fileID: 0} + - target: {fileID: 5932448, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 3.00177248e-07 + objectReference: {fileID: 0} + - target: {fileID: 5932448, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: -4.25080088e-06 + objectReference: {fileID: 0} + - target: {fileID: 5930116, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: 5.66325127e-07 + objectReference: {fileID: 0} + - target: {fileID: 5930116, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 7.15386544e-14 + objectReference: {fileID: 0} + - target: {fileID: 5928330, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: .00855574757 + objectReference: {fileID: 0} + - target: {fileID: 5928330, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.y + value: 1.57999897 + objectReference: {fileID: 0} + - target: {fileID: 5928330, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: -.22732614 + objectReference: {fileID: 0} + - target: {fileID: 5927204, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.x + value: -2.07060964e-07 + objectReference: {fileID: 0} + - target: {fileID: 5927204, guid: 435740a68d38e76438007304b084ccf7, type: 2} + propertyPath: m_ConnectedAnchor.z + value: 2.86692966e-06 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 435740a68d38e76438007304b084ccf7, type: 2} m_IsPrefabParent: 0 @@ -2311,6 +2534,30 @@ Prefab: propertyPath: m_IsActive value: 0 objectReference: {fileID: 0} + - target: {fileID: 10828902, guid: 09a2e2e70f49c4330831bd4f733bbdb4, type: 2} + propertyPath: m_Range + value: 238.649155 + objectReference: {fileID: 0} + - target: {fileID: 10872598, guid: 09a2e2e70f49c4330831bd4f733bbdb4, type: 2} + propertyPath: m_Range + value: 280.692017 + objectReference: {fileID: 0} + - target: {fileID: 10833872, guid: 09a2e2e70f49c4330831bd4f733bbdb4, type: 2} + propertyPath: m_Range + value: 252.96521 + objectReference: {fileID: 0} + - target: {fileID: 169668, guid: 09a2e2e70f49c4330831bd4f733bbdb4, type: 2} + propertyPath: m_Name + value: Spotlight_red (left) + objectReference: {fileID: 0} + - target: {fileID: 149990, guid: 09a2e2e70f49c4330831bd4f733bbdb4, type: 2} + propertyPath: m_Name + value: Spotlight _yellow (top) + objectReference: {fileID: 0} + - target: {fileID: 190240, guid: 09a2e2e70f49c4330831bd4f733bbdb4, type: 2} + propertyPath: m_Name + value: Spotlight_blue (right) + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 09a2e2e70f49c4330831bd4f733bbdb4, type: 2} m_IsPrefabParent: 0 diff --git a/Assets/scripts/GameState.cs b/Assets/scripts/GameState.cs index 439859f..e308cf7 100644 --- a/Assets/scripts/GameState.cs +++ b/Assets/scripts/GameState.cs @@ -1,25 +1,25 @@ -using UnityEngine; -using System.Collections; - -public class GameState { - - private static GameState instance = new GameState(); - public static GameState Instance { get { return instance; } } - - public LevelManager currentLevel = null; - - public int numPlayers = 3; - public int wordLength = 5; - public int numRows = 50; - public int numColumns = 30; - public Player[] players; - - private GameState() - { - players = new Player[numPlayers]; - for (int i = 0; i < numPlayers; i++) - { - players[i] = new Player(i+1); - } - } -} +using UnityEngine; +using System.Collections; + +public class GameState { + + private static GameState instance = new GameState(); + public static GameState Instance { get { return instance; } } + + public LevelManager currentLevel = null; + + public int numPlayers = 3; + public int wordLength = 5; + public int numRows = 12; + public int numColumns = 8; + public Player[] players; + + private GameState() + { + players = new Player[numPlayers]; + for (int i = 0; i < numPlayers; i++) + { + players[i] = new Player(i+1); + } + } +} diff --git a/Assets/scripts/LevelManager.cs b/Assets/scripts/LevelManager.cs index b1b1a62..479342a 100644 --- a/Assets/scripts/LevelManager.cs +++ b/Assets/scripts/LevelManager.cs @@ -1,206 +1,209 @@ -using UnityEngine; -using System.Collections.Generic; -using System.Linq; -using System.Collections; -using InputHandler; - -public class LevelManager : MonoBehaviour { - - public float xScale = 1f; - public float yScale = 0.8f; - public float dimension = 0.6f; - public GameObject hexagon; - public Color[] PlayerColors; - private float ratio = Mathf.Sqrt(1 - 0.5f * 0.5f); - private GameState state; - private List runes = new List(); - - - private SelectorWithBolts Selector; - private GameObject PhysicsContainer; - - // Use this for initialization - void Start() - { - state = GameState.Instance; - state.currentLevel = this; - int numColumns = state.numColumns; - int numRows = state.numRows; - - int[] runeNums = new int[numColumns * numRows]; - for (int i = 0; i < numRows * numColumns; i++) - { - runeNums[i] = i % 26; - } - - System.Random rnd = new System.Random(); - var randomNums = runeNums.OrderBy(r => rnd.Next()) - .ToArray(); - - GameObject hex; - RuneBehaviour rune; - int index = 0; - - float xOffset = numColumns * 1.5f * dimension / 2f; - float yOffset = numRows * 1f * ratio * dimension / 2f; - - for (int row = 0; row < numRows; row++) - { - for (int col = 0; col < numColumns; col++) - { - hex = GameObject.Instantiate(hexagon) as GameObject; - hex.transform.parent = transform; - hex.transform.localScale = new Vector3(xScale, yScale, 1f); - - hex.transform.localPosition = new Vector3( - (3f * dimension * col + 1.5f * dimension * (row % 2)) * xScale - xOffset, - (row * ratio * dimension) * yScale - yOffset, 0f); - - hex.transform.localRotation = Quaternion.identity; - - rune = hex.GetComponent(); - rune.SetSymbol(randomNums[index++]); - runes.Add(rune); - } - } - - int numLetters = state.wordLength; - foreach (Player player in state.players) - { - player.SetWord(WordGen.GetWord(numLetters)); - } - - Selector = GameObject.FindObjectOfType(); - PhysicsContainer = GameObject.Find("PhysicsContainer"); - } - - public void PressTile(int letterNum, RuneBehaviour tile) - { - foreach (Player player in state.players) - { - if (player.hasNextLetter(letterNum)) - { - tile.symbol.color = PlayerColors[player.num - 1]; - StartCoroutine(MoveSelectorToTile(tile)); - - //Do something - if (player.hasWon()) - { - Debug.Log("Player won!"); - //Yeah maybe don't quit at this point... - Application.Quit(); - } - } - } - } - - private IEnumerator MoveSelectorToTile(RuneBehaviour tile) - { - for (int i = 0; i < 3; i++) - { - InputManager.Instance.PushActiveContext("CinematicEvent", i); - } - - // We dontt want the color to lerp back to white while we are moving to the rune - tile.GetComponent().enabled = false; - - tile.GetComponent().enabled = false; - tile.GetComponent().sortingOrder = 100; - tile.symbol.sortingOrder = 101; - - EnableKinematics(true); - - Transform trans = PhysicsContainer.GetComponent(); - - Vector3 startPos = trans.position; - Vector3 endPos = startPos + tile.GetComponent().position - Selector.GetComponent().position; ; - endPos.y = startPos.y; - - float ratio = 0f; - - while (ratio < 1f) - { - ratio += Time.deltaTime / 0.25f; - - trans.position = Vector3.Lerp(startPos, endPos, ratio); - - yield return null; - } - - StartCoroutine(LiftTileInTheAir(tile)); - } - - private IEnumerator LiftTileInTheAir(RuneBehaviour tile) - { - float ratio = 0f; - - Transform trans = tile.GetComponent(); - Transform cameraTrans = Camera.main.GetComponent(); - - Vector3 startPos = trans.position; - - - Quaternion startRot = trans.rotation; - - - while (ratio < 1f) - { - // The camera might move, so we recalculate the end position every frame - Vector3 endPos = cameraTrans.position + cameraTrans.forward * 10f;//trans.position + new Vector3(0f, 5f, 0f); - Quaternion endRot = Quaternion.LookRotation(cameraTrans.forward); - - ratio += Time.deltaTime / 2f; - - trans.position = Vector3.Lerp(startPos, endPos, ratio); - trans.rotation = Quaternion.Slerp(startRot, endRot, ratio); - - yield return null; - } - - yield return new WaitForSeconds(0.5f); - - StartCoroutine(SendTileToUI(tile)); - } - - private IEnumerator SendTileToUI(RuneBehaviour tile) - { - Transform trans = tile.GetComponent(); - - Vector3 startPos = trans.position; - - Vector3 startScale = trans.localScale; - Vector3 endScale = Vector3.one * 0.03f; - - float ratio = 0f; - while (ratio < 1f) - { - ratio += Time.deltaTime / 0.5f; - - Vector3 endPos = Camera.main.ViewportToWorldPoint(new Vector3(0.9f, 0.9f, Camera.main.nearClipPlane + 0.1f)); - - trans.position = Vector3.Lerp(startPos, endPos, ratio); - trans.localScale = Vector3.Lerp(startScale, endScale, ratio); - - yield return null; - } - - // At the end of it all, we re-enabled the controls - for (int i = 0; i < 3; i++) - { - InputManager.Instance.PushActiveContext("Normal", i); - } - - EnableKinematics(false); - Destroy(tile.gameObject); - } - - private void EnableKinematics(bool state) - { - Rigidbody[] rbs = PhysicsContainer.GetComponentsInChildren(); - - foreach (Rigidbody rb in rbs) - { - rb.isKinematic = state; - } - } -} +using UnityEngine; +using System.Collections.Generic; +using System.Linq; +using System.Collections; +using InputHandler; + +public class LevelManager : MonoBehaviour { + + public float xScale = 1f; + public float yScale = 0.8f; + public float colSpacing = 0f; + public float rowSpacing = 0f; + + public float dimension = 0.6f; + public GameObject hexagon; + public Color[] PlayerColors; + private float ratio = Mathf.Sqrt(1 - 0.5f * 0.5f); + private GameState state; + private List runes = new List(); + + + private SelectorWithBolts Selector; + private GameObject PhysicsContainer; + + // Use this for initialization + void Start() + { + state = GameState.Instance; + state.currentLevel = this; + int numColumns = state.numColumns; + int numRows = state.numRows; + + int[] runeNums = new int[numColumns * numRows]; + for (int i = 0; i < numRows * numColumns; i++) + { + runeNums[i] = i % 26; + } + + System.Random rnd = new System.Random(); + var randomNums = runeNums.OrderBy(r => rnd.Next()) + .ToArray(); + + GameObject hex; + RuneBehaviour rune; + int index = 0; + + float xOffset = numColumns * 1.5f * dimension / 2f; + float yOffset = numRows * 1f * ratio * dimension / 2f; + + for (int row = 0; row < numRows; row++) + { + for (int col = 0; col < numColumns; col++) + { + hex = GameObject.Instantiate(hexagon) as GameObject; + hex.transform.parent = transform; + hex.transform.localScale = new Vector3(xScale, yScale, 1f); + + hex.transform.localPosition = new Vector3( + ((3f+colSpacing) * dimension * col + 1.5f * dimension * (row % 2)) * xScale - xOffset, + (row * (ratio * dimension + rowSpacing)) * yScale - yOffset, 0f); + + hex.transform.localRotation = Quaternion.identity; + + rune = hex.GetComponent(); + rune.SetSymbol(randomNums[index++]); + runes.Add(rune); + } + } + + int numLetters = state.wordLength; + foreach (Player player in state.players) + { + player.SetWord(WordGen.GetWord(numLetters)); + } + + Selector = GameObject.FindObjectOfType(); + PhysicsContainer = GameObject.Find("PhysicsContainer"); + } + + public void PressTile(int letterNum, RuneBehaviour tile) + { + foreach (Player player in state.players) + { + if (player.hasNextLetter(letterNum)) + { + tile.symbol.color = PlayerColors[player.num - 1]; + StartCoroutine(MoveSelectorToTile(tile)); + + //Do something + if (player.hasWon()) + { + Debug.Log("Player won!"); + //Yeah maybe don't quit at this point... + Application.Quit(); + } + } + } + } + + private IEnumerator MoveSelectorToTile(RuneBehaviour tile) + { + for (int i = 0; i < 3; i++) + { + InputManager.Instance.PushActiveContext("CinematicEvent", i); + } + + // We dontt want the color to lerp back to white while we are moving to the rune + tile.GetComponent().enabled = false; + + tile.GetComponent().enabled = false; + tile.GetComponent().sortingOrder = 100; + tile.symbol.sortingOrder = 101; + + EnableKinematics(true); + + Transform trans = PhysicsContainer.GetComponent(); + + Vector3 startPos = trans.position; + Vector3 endPos = startPos + tile.GetComponent().position - Selector.GetComponent().position; ; + endPos.y = startPos.y; + + float ratio = 0f; + + while (ratio < 1f) + { + ratio += Time.deltaTime / 0.25f; + + trans.position = Vector3.Lerp(startPos, endPos, ratio); + + yield return null; + } + + StartCoroutine(LiftTileInTheAir(tile)); + } + + private IEnumerator LiftTileInTheAir(RuneBehaviour tile) + { + float ratio = 0f; + + Transform trans = tile.GetComponent(); + Transform cameraTrans = Camera.main.GetComponent(); + + Vector3 startPos = trans.position; + + + Quaternion startRot = trans.rotation; + + + while (ratio < 1f) + { + // The camera might move, so we recalculate the end position every frame + Vector3 endPos = cameraTrans.position + cameraTrans.forward * 10f;//trans.position + new Vector3(0f, 5f, 0f); + Quaternion endRot = Quaternion.LookRotation(cameraTrans.forward); + + ratio += Time.deltaTime / 2f; + + trans.position = Vector3.Lerp(startPos, endPos, ratio); + trans.rotation = Quaternion.Slerp(startRot, endRot, ratio); + + yield return null; + } + + yield return new WaitForSeconds(0.5f); + + StartCoroutine(SendTileToUI(tile)); + } + + private IEnumerator SendTileToUI(RuneBehaviour tile) + { + Transform trans = tile.GetComponent(); + + Vector3 startPos = trans.position; + + Vector3 startScale = trans.localScale; + Vector3 endScale = Vector3.one * 0.03f; + + float ratio = 0f; + while (ratio < 1f) + { + ratio += Time.deltaTime / 0.5f; + + Vector3 endPos = Camera.main.ViewportToWorldPoint(new Vector3(0.9f, 0.9f, Camera.main.nearClipPlane + 0.1f)); + + trans.position = Vector3.Lerp(startPos, endPos, ratio); + trans.localScale = Vector3.Lerp(startScale, endScale, ratio); + + yield return null; + } + + // At the end of it all, we re-enabled the controls + for (int i = 0; i < 3; i++) + { + InputManager.Instance.PushActiveContext("Normal", i); + } + + EnableKinematics(false); + Destroy(tile.gameObject); + } + + private void EnableKinematics(bool state) + { + Rigidbody[] rbs = PhysicsContainer.GetComponentsInChildren(); + + foreach (Rigidbody rb in rbs) + { + rb.isKinematic = state; + } + } +} diff --git a/Assets/scripts/RuneBehaviour.cs b/Assets/scripts/RuneBehaviour.cs index 255fe12..7fd6c52 100644 --- a/Assets/scripts/RuneBehaviour.cs +++ b/Assets/scripts/RuneBehaviour.cs @@ -1,87 +1,87 @@ -using UnityEngine; -using System.Collections; - -public class RuneBehaviour : MonoBehaviour { - - public static float range; - public SpriteRenderer symbol; - public int letterNum; - private float elapsedTime = 0f; - public const float LightTime = 1.5f; - public Color DefaultColor; - - private Color targetColor; - private float sign = 0f; - - private Character currentCharacter; - - void Update () - { - if (sign == 0f) return; - - elapsedTime += Time.deltaTime * sign; - - float ratio = elapsedTime / LightTime; - - symbol.color = Color.Lerp(DefaultColor, targetColor, ratio); - - if (ratio < 0f || ratio > 1f) - { - sign = 0f; - } - } - - void Start() - { - float col = 80f/255f; // Random.value; - GetComponent().material.color = new Color(col, col, col); - } - - void OnTriggerEnter(Collider col) - { - if (col.gameObject.tag == "Player" && currentCharacter == null) - { - currentCharacter = col.gameObject.GetComponent(); - - if (currentCharacter) - { - symbol.color = currentCharacter.TrailColor; - } - } - else if (col.gameObject.tag == "Ouija") - { - GameState.Instance.currentLevel.PressTile(letterNum, this); - } - } - - void OnTriggerExit(Collider col) - { - if (col.gameObject.tag == "Player" && currentCharacter != null && currentCharacter.gameObject == col.gameObject) - { - currentCharacter = null; - - StartCoroutine(FadeColorOut()); - } - } - - private IEnumerator FadeColorOut() - { - Color startColor = symbol.color; - - float ratio = 0f; - - while (ratio < 1f) - { - ratio += Time.deltaTime / LightTime; - symbol.color = Color.Lerp(startColor, DefaultColor, ratio); - - yield return null; - } - } - - public void SetSymbol(int letterNum) - { - this.letterNum = letterNum; - symbol.sprite = Resources.Load("runic_" + (char)('a' + letterNum)); - } -} +using UnityEngine; +using System.Collections; + +public class RuneBehaviour : MonoBehaviour { + + public static float range; + public SpriteRenderer symbol; + public int letterNum; + private float elapsedTime = 0f; + public const float LightTime = 1.5f; + public Color DefaultColor; + + private Color targetColor; + private float sign = 0f; + + private Character currentCharacter; + + void Update () + { + if (sign == 0f) return; + + elapsedTime += Time.deltaTime * sign; + + float ratio = elapsedTime / LightTime; + + symbol.color = Color.Lerp(DefaultColor, targetColor, ratio); + + if (ratio < 0f || ratio > 1f) + { + sign = 0f; + } + } + + void Start() + { + float col = 80f/255f; // Random.value; + GetComponent().material.color = new Color(col, col, col); + } + + void OnTriggerEnter(Collider col) + { + if (col.gameObject.tag == "Player" && currentCharacter == null) + { + currentCharacter = col.gameObject.GetComponent(); + + if (currentCharacter) + { + symbol.color = currentCharacter.TrailColor; + } + } + else if (col.gameObject.tag == "Ouija") + { + GameState.Instance.currentLevel.PressTile(letterNum, this); + } + } + + void OnTriggerExit(Collider col) + { + if (col.gameObject.tag == "Player" && currentCharacter != null && currentCharacter.gameObject == col.gameObject) + { + currentCharacter = null; + + StartCoroutine(FadeColorOut()); + } + } + + private IEnumerator FadeColorOut() + { + Color startColor = symbol.color; + + float ratio = 0f; + + while (ratio < 1f) + { + ratio += Time.deltaTime / LightTime; + symbol.color = Color.Lerp(startColor, DefaultColor, ratio); + + yield return null; + } + } + + public void SetSymbol(int letterNum) + { + this.letterNum = letterNum; + symbol.sprite = Resources.Load("runic_" + (char)('a' + letterNum)); + } +} diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index c8b6db5..b8902bf 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -8,7 +8,6 @@ PlayerSettings: defaultScreenOrientation: 4 targetDevice: 2 targetResolution: 0 - useOnDemandResources: 0 accelerometerFrequency: 60 companyName: DefaultCompany productName: GameJamProject @@ -29,7 +28,6 @@ PlayerSettings: androidShowActivityIndicatorOnLoading: -1 iosAppInBackgroundBehavior: 0 displayResolutionDialog: 1 - iosAllowHTTPDownload: 1 allowedAutorotateToPortrait: 1 allowedAutorotateToPortraitUpsideDown: 1 allowedAutorotateToLandscapeRight: 1 @@ -62,23 +60,11 @@ PlayerSettings: xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 - n3dsDisableStereoscopicView: 0 - n3dsEnableSharedListOpt: 1 - n3dsEnableVSync: 0 xboxOneResolution: 0 ps3SplashScreen: {fileID: 0} videoMemoryForVertexBuffers: 0 psp2PowerMode: 0 psp2AcquireBGM: 1 - wiiUTVResolution: 0 - wiiUGamePadMSAA: 1 - wiiUSupportsNunchuk: 0 - wiiUSupportsClassicController: 0 - wiiUSupportsBalanceBoard: 0 - wiiUSupportsMotionPlus: 0 - wiiUSupportsProController: 0 - wiiUAllowScreenCapture: 1 - wiiUControllerCount: 0 m_SupportedAspectRatios: 4:3: 1 5:4: 1 @@ -91,26 +77,20 @@ PlayerSettings: metroEnableIndependentInputSource: 0 metroEnableLowLatencyPresentationAPI: 0 xboxOneDisableKinectGpuReservation: 0 - virtualRealitySupported: 0 productGUID: dbca7936984e94248bf9f90833bc0c3a AndroidBundleVersionCode: 1 AndroidMinSdkVersion: 9 AndroidPreferredInstallLocation: 1 aotOptions: apiCompatibilityLevel: 2 - stripEngineCode: 1 iPhoneStrippingLevel: 0 iPhoneScriptCallOptimization: 0 - iPhoneBuildNumber: 0 ForceInternetPermission: 0 ForceSDCardPermission: 0 CreateWallpaper: 0 APKExpansionFiles: 0 preloadShaders: 0 StripUnusedMeshComponents: 0 - VertexChannelCompressionMask: - serializedVersion: 2 - m_Bits: 238 iPhoneSdkVersion: 988 iPhoneTargetOSVersion: 22 uIPrerenderedIcon: 0 @@ -137,15 +117,6 @@ PlayerSettings: iOSLaunchScreenFillPct: 100 iOSLaunchScreenSize: 100 iOSLaunchScreenCustomXibPath: - iOSLaunchScreeniPadType: 0 - iOSLaunchScreeniPadImage: {fileID: 0} - iOSLaunchScreeniPadBackgroundColor: - serializedVersion: 2 - rgba: 0 - iOSLaunchScreeniPadFillPct: 100 - iOSLaunchScreeniPadSize: 100 - iOSLaunchScreeniPadCustomXibPath: - iOSDeviceRequirements: [] AndroidTargetDevice: 0 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} @@ -165,23 +136,6 @@ PlayerSettings: m_BuildTargetGraphicsAPIs: [] webPlayerTemplate: APPLICATION:Default m_TemplateCustomTags: {} - wiiUTitleID: 0005000011000000 - wiiUGroupID: 00010000 - wiiUCommonSaveSize: 4096 - wiiUAccountSaveSize: 2048 - wiiUOlvAccessKey: 0 - wiiUTinCode: 0 - wiiUJoinGameId: 0 - wiiUJoinGameModeMask: 0000000000000000 - wiiUCommonBossSize: 0 - wiiUAccountBossSize: 0 - wiiUAddOnUniqueIDs: [] - wiiUMainThreadStackSize: 3072 - wiiULoaderThreadStackSize: 1024 - wiiUSystemHeapSize: 128 - wiiUTVStartupScreen: {fileID: 0} - wiiUGamePadStartupScreen: {fileID: 0} - wiiUProfilerLibPath: actionOnDotNetUnhandledException: 1 enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 @@ -232,20 +186,15 @@ PlayerSettings: ps4BackgroundImagePath: ps4StartupImagePath: ps4SaveDataImagePath: - ps4SdkOverride: ps4BGMPath: ps4ShareFilePath: - ps4ShareOverlayImagePath: - ps4PrivacyGuardImagePath: ps4NPtitleDatPath: ps4RemotePlayKeyAssignment: -1 - ps4RemotePlayKeyMappingDir: ps4EnterButtonAssignment: 1 ps4ApplicationParam1: 0 ps4ApplicationParam2: 0 ps4ApplicationParam3: 0 ps4ApplicationParam4: 0 - ps4DownloadDataSize: 0 ps4GarlicHeapSize: 2048 ps4Passcode: 3mJ7tLHOsT9jNvqC8LNjpnotcWDQLy4O ps4pnSessions: 1 @@ -253,14 +202,6 @@ PlayerSettings: ps4pnFriends: 1 ps4pnGameCustomData: 1 playerPrefsSupport: 0 - ps4ReprojectionSupport: 0 - ps4UseAudio3dBackend: 0 - ps4Audio3dVirtualSpeakerCount: 14 - ps4attribUserManagement: 0 - ps4attribMoveSupport: 0 - ps4attrib3DSupport: 0 - ps4attribShareSupport: 0 - ps4IncludedModules: [] monoEnv: psp2Splashimage: {fileID: 0} psp2NPTrophyPackPath: @@ -309,6 +250,7 @@ PlayerSettings: psp2InfoBarOnStartup: 0 psp2InfoBarColor: 0 psmSplashimage: {fileID: 0} + virtualRealitySupported: 0 spritePackerPolicy: scriptingDefineSymbols: {} metroPackageName: GameJamProject @@ -400,17 +342,6 @@ PlayerSettings: tizenSigningProfileName: tizenGPSPermissions: 0 tizenMicrophonePermissions: 0 - n3dsUseExtSaveData: 0 - n3dsCompressStaticMem: 1 - n3dsExtSaveDataNumber: 0x12345 - n3dsStackSize: 131072 - n3dsTargetPlatform: 2 - n3dsRegion: 7 - n3dsMediaSize: 0 - n3dsLogoStyle: 3 - n3dsTitle: GameName - n3dsProductCode: - n3dsApplicationId: 0xFF3FF stvDeviceAddress: stvProductDescription: stvProductAuthor: @@ -476,6 +407,7 @@ PlayerSettings: additionalIl2CppArgs::additionalIl2CppArgs: firstStreamedSceneWithResources: 0 cloudProjectId: + projectId: projectName: organizationId: cloudEnabled: 0