diff --git a/Assets/Plugins/IngameDebugConsole/Android.meta b/Assets/Plugins/IngameDebugConsole/Android.meta deleted file mode 100644 index 12049b6..0000000 --- a/Assets/Plugins/IngameDebugConsole/Android.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3d7d7a61a5341904eb3c65af025b1d86 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Prefabs.meta b/Assets/Plugins/IngameDebugConsole/Prefabs.meta deleted file mode 100644 index 6aa8bf2..0000000 --- a/Assets/Plugins/IngameDebugConsole/Prefabs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7dbc36665bc0d684db9a4447e27a7a4b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Scripts.meta b/Assets/Plugins/IngameDebugConsole/Scripts.meta deleted file mode 100644 index 72dcaac..0000000 --- a/Assets/Plugins/IngameDebugConsole/Scripts.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 860c08388401a6d4e858fe4910ea9337 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta b/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta deleted file mode 100644 index f3769b1..0000000 --- a/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f6caae32d463529478f2186f47c2e3fe -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/BlockInput.cs b/Assets/Scripts/BlockInput.cs index 6750d7e..a09a8f7 100644 --- a/Assets/Scripts/BlockInput.cs +++ b/Assets/Scripts/BlockInput.cs @@ -20,8 +20,7 @@ public class BlockInput : MonoBehaviour [ContextMenu("Read Next")] public void ReadNext() { - float TotalAnimationTime; - blockReader.Read(character, waitTime,out TotalAnimationTime); + StartCoroutine(blockReader.Read(character, waitTime)); } public void ReadAll() diff --git a/Assets/Scripts/Character.cs b/Assets/Scripts/Character.cs index 7156348..fba6a10 100644 --- a/Assets/Scripts/Character.cs +++ b/Assets/Scripts/Character.cs @@ -103,6 +103,7 @@ public class Character : MonoBehaviour public IEnumerator MoveToBlock(Block target, Animation animation, float time) { + float startTime = Time.time; Vector3 moveDirection = Vector3.ProjectOnPlane(target.position - _currentBlock.position, Vector3.up).normalized; _currentBlock.OnLeftByPlayer(this); @@ -113,10 +114,13 @@ public class Character : MonoBehaviour StartAnimation(animation, time); - yield return StartCoroutine(LerpToBlock(target.VisualPosition, time, yFunction)); + yield return StartCoroutine(LerpToBlock(target.VisualPosition, time * 0.8f, yFunction)); _currentBlock= target; yield return StartCoroutine (_currentBlock.OnWalkedOnByPlayer(this,moveDirection)); + + yield return new WaitForSeconds(time - (Time.time - startTime)); + StopAnimation(animation); } @@ -130,7 +134,7 @@ public class Character : MonoBehaviour StartAnimation(animation, time); - yield return StartCoroutine(LerpToRotation(_endDir, time, yFunction)); + yield return StartCoroutine(LerpToRotation(_endDir, time * 0.8f, yFunction)); StopAnimation(animation); } diff --git a/Assets/Models.meta b/Assets/Scripts/Components.meta similarity index 77% rename from Assets/Models.meta rename to Assets/Scripts/Components.meta index 5346456..5a95b09 100644 --- a/Assets/Models.meta +++ b/Assets/Scripts/Components.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 296bd90e667df1f4697823a0aa45acf0 +guid: 8d7394d70ec233849a60a26da5f23b75 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Scripts/KeyboardInput.cs b/Assets/Scripts/KeyboardInput.cs index 886aee4..0d12796 100644 --- a/Assets/Scripts/KeyboardInput.cs +++ b/Assets/Scripts/KeyboardInput.cs @@ -35,14 +35,14 @@ public class KeyboardInput : MonoBehaviour { float outTime; Move move = (Move)ScriptableObject.CreateInstance(typeof(Move)); - move.Run(character, characterSpeed, out outTime); + StartCoroutine(move.Run(character, characterSpeed)); Destroy(move); } if (Input.GetKeyDown(KeyCode.Space)) { float outTime; Jump jump = (Jump)ScriptableObject.CreateInstance(typeof(Jump)); - jump.Run(character, characterSpeed, out outTime); + StartCoroutine(jump.Run(character, characterSpeed)); Destroy(jump); } } diff --git a/Assets/Scripts/Logic/BlockReader.cs b/Assets/Scripts/Logic/BlockReader.cs index f04e89f..eb1744a 100644 --- a/Assets/Scripts/Logic/BlockReader.cs +++ b/Assets/Scripts/Logic/BlockReader.cs @@ -56,13 +56,12 @@ public class BlockReader /// /// Character to control /// Returns false if other readers should wait for this one to run again - public bool Read(Character character,float speedMultiplier, out float TotalAnimationTime) + public IEnumerator Read(Character character,float speedMultiplier) { //If the character has become stuck, they forfeit their remaining moves - we skip directly to their end of their chain if (character.stuck == true) { Debug.Log("Character is stuck! No moving!"); - TotalAnimationTime = 0; //return true; currentBlockIndex = LogicChain.Count; @@ -75,15 +74,14 @@ public class BlockReader //return that this is done if no more blocks left in chain if (LogicChain.Count <= currentBlockIndex) { - TotalAnimationTime = 0; - return true; + //return true; } //get current Block LogicBlock currentBlock = LogicChain[currentBlockIndex]; //apply blocks to character - bool runAgainNot = currentBlock.Run(character, speedMultiplier,out TotalAnimationTime); + yield return character.StartCoroutine(currentBlock.Run(character, speedMultiplier)); //if the block is finished reset it and move on to next one //(it might not be finished if it is a for loop or something) @@ -95,7 +93,7 @@ public class BlockReader } //Should other readers wait for this one - return (runAgainNot || !currentBlock.WaitUntilFinished); + //return (runAgainNot || !currentBlock.WaitUntilFinished); } /// diff --git a/Assets/Scripts/Logic/Blocks/CombinedBlock.cs b/Assets/Scripts/Logic/Blocks/CombinedBlock.cs index ad25590..c9ab437 100644 --- a/Assets/Scripts/Logic/Blocks/CombinedBlock.cs +++ b/Assets/Scripts/Logic/Blocks/CombinedBlock.cs @@ -25,24 +25,33 @@ public class CombinedBlock : LogicBlock #endregion Private Variables - public override bool Run(Character player, float animationTime, out float TotalAnimationTime) + public override IEnumerator Run(Character player, float animationTime) { BlockLogic(player,animationTime); - blockReader.Read(player, animationTime / SpeedMultiplier, out TotalAnimationTime); + if (WaitUntilFinished) + { + for (int i = 0; i < blockReader.Length; i++) + { + yield return player.StartCoroutine(blockReader.Read(player, animationTime / SpeedMultiplier)); + } + + } + else + { + yield return player.StartCoroutine(blockReader.Read(player, animationTime / SpeedMultiplier)); + } if (blockReader.Finished) { blockReader.Reset(); RepeatCount++; } - - return isFinished(); } - protected override void BlockLogic(Character player, float animationTime) + protected override IEnumerator BlockLogic(Character player, float animationTime) { - + yield break; } diff --git a/Assets/Scripts/Logic/Blocks/Jump.cs b/Assets/Scripts/Logic/Blocks/Jump.cs index 6e0dcf8..a08224a 100644 --- a/Assets/Scripts/Logic/Blocks/Jump.cs +++ b/Assets/Scripts/Logic/Blocks/Jump.cs @@ -28,13 +28,13 @@ public class Jump : LogicBlock /// Implementation of BlockLogic, moves the player forward /// /// Player to move - protected override void BlockLogic(Character player, float animationTime) + protected override IEnumerator BlockLogic(Character player, float animationTime) { //player.Jump(direction, animationTime); player.justMoved = true; Block endBlock = GetEndBlock(player.CurrentBlock, player.transform, ~player.Ignore); - player.StartCoroutine(player.MoveToBlock(endBlock, Character.Animation.Jump, animationTime)); + yield return player.StartCoroutine(player.MoveToBlock(endBlock, Character.Animation.Jump, animationTime)); } diff --git a/Assets/Scripts/Logic/Blocks/LogicBlock.cs b/Assets/Scripts/Logic/Blocks/LogicBlock.cs index 4000e74..8531216 100644 --- a/Assets/Scripts/Logic/Blocks/LogicBlock.cs +++ b/Assets/Scripts/Logic/Blocks/LogicBlock.cs @@ -58,17 +58,29 @@ public abstract class LogicBlock : ScriptableObject /// /// Player which will be affected by the block /// returns true if block is finished - public virtual bool Run(Character player, float animationSpeed, out float TotalAnimationTime) + public virtual IEnumerator Run(Character player, float animationSpeed) { - RepeatCount++; - TotalAnimationTime = animationSpeed / SpeedMultiplier; - BlockLogic(player, TotalAnimationTime); + + float TotalAnimationTime = animationSpeed / SpeedMultiplier; + if(GlobalVariables.playerMoves == true){ player.DisplayBlock(this); } - return isFinished(); + if (WaitUntilFinished) + { + for (int i = 0; i < RepeatAmount; i++) + { + RepeatCount++; + yield return player.StartCoroutine(BlockLogic(player, TotalAnimationTime)); + } + } + else + { + RepeatCount++; + yield return player.StartCoroutine(BlockLogic(player, TotalAnimationTime)); + } } /// @@ -85,7 +97,7 @@ public abstract class LogicBlock : ScriptableObject /// /// Player which will be affected by the block /// returns true if block is finished - protected abstract void BlockLogic(Character player, float animationTime); + protected abstract IEnumerator BlockLogic(Character player, float animationTime); /// /// Returns the block that the character will endUp on after they use this logic element diff --git a/Assets/Scripts/Logic/Blocks/Move.cs b/Assets/Scripts/Logic/Blocks/Move.cs index ded9178..7607129 100644 --- a/Assets/Scripts/Logic/Blocks/Move.cs +++ b/Assets/Scripts/Logic/Blocks/Move.cs @@ -19,15 +19,13 @@ public class Move : LogicBlock /// Implementation of BlockLogic, moves the player forward /// /// Player to move - protected override void BlockLogic(Character player, float animationTime) + protected override IEnumerator BlockLogic(Character player, float animationTime) { player.justMoved = true; //player.Move(direction, animationTime); Block endBlock = GetEndBlock(player.CurrentBlock, player.transform, ~player.Ignore); - Debug.Log("CurrentBlock: " + player.CurrentBlock.position + "\nEndBlock: " + endBlock.position); - - player.StartCoroutine(player.MoveToBlock(endBlock, Character.Animation.Walk, animationTime)); + yield return player.StartCoroutine(player.MoveToBlock(endBlock, Character.Animation.Walk, animationTime)); } /// diff --git a/Assets/Scripts/Logic/Blocks/Rotate.cs b/Assets/Scripts/Logic/Blocks/Rotate.cs index 9bc5471..14a719b 100644 --- a/Assets/Scripts/Logic/Blocks/Rotate.cs +++ b/Assets/Scripts/Logic/Blocks/Rotate.cs @@ -23,11 +23,11 @@ public class Rotate : LogicBlock /// Rotates the player in the direction specified by this block /// /// Player to rotate - protected override void BlockLogic(Character player, float animationTime) + protected override IEnumerator BlockLogic(Character player, float animationTime) { //player.Rotate(direction, animationTime); - player.StartCoroutine(player.RotateToDirection(direction, Character.Animation.Jump, animationTime, true)); + yield return player.StartCoroutine(player.RotateToDirection(direction, Character.Animation.Jump, animationTime, true)); } /// diff --git a/Assets/Scripts/Logic/Blocks/RotateHalf.cs b/Assets/Scripts/Logic/Blocks/RotateHalf.cs index d5815f8..fc51591 100644 --- a/Assets/Scripts/Logic/Blocks/RotateHalf.cs +++ b/Assets/Scripts/Logic/Blocks/RotateHalf.cs @@ -23,9 +23,10 @@ public class RotateHalf : LogicBlock /// Rotates the player in the direction specified by this block /// /// Player to rotate - protected override void BlockLogic(Character player, float animationTime) + protected override IEnumerator BlockLogic(Character player, float animationTime) { player.RotateHalf(direction, animationTime); + yield break; } /// diff --git a/Assets/Scripts/LogicBlocks.meta b/Assets/Scripts/LogicBlocks.meta deleted file mode 100644 index 98af9d1..0000000 --- a/Assets/Scripts/LogicBlocks.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8936b441d7647f74884c94f97bfb8931 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index 63d5008..2803481 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -44,7 +44,7 @@ public class GameManager : MonoBehaviour /// /// Easy access to GameMode value in CurrentGameMode reference /// - private GameMode gameMode {get { return CurrentGameMode.Value; } } + private GameMode gameMode { get { return CurrentGameMode.Value; } } #endregion Read Only #region Unity Functions @@ -117,6 +117,8 @@ public class GameManager : MonoBehaviour while (playerDataAsArray.Any(p => !p.blockReader.Finished)) { + + //Loop through all players foreach (PlayerData player in playerDataAsArray) { @@ -142,18 +144,18 @@ public class GameManager : MonoBehaviour //force them back to the waiting for players screen foreach (PlayerData player in playerDataAsArray) { - if(player.client.Lives == 0) + if (player.client.Lives == 0) { Debug.Log("Remove: " + player.client.characterAnimal); removePlayer(player); } } - - //Reset some player Data + + //Reset some player Data foreach (PlayerData player in playerDataAsArray) { - if(player.client.Lives > 0) + if (player.client.Lives > 0) { player.blockReader.Reset(); player.client.SendInventory(); @@ -166,7 +168,7 @@ public class GameManager : MonoBehaviour //send round length to players //#TODO make this only happen after first input LogicProtocols.FloatMsg RoundTime = new LogicProtocols.FloatMsg(gameMode.GetRoundTime()); - + //playerDataAsArray.ForEach(p => p.client.conn.Send(LogicProtocols.SendRoundTime, RoundTime)); foreach (PlayerData player in playerDataAsArray) { @@ -180,7 +182,7 @@ public class GameManager : MonoBehaviour //ClientList.ForEach(p => p.ChangeScene("ClientScene")); foreach (ClientData client in ClientList) { - if(client.Lives > 0){client.ChangeScene("ClientScene");} + if (client.Lives > 0) { client.ChangeScene("ClientScene"); } } //Let gamemode know clients are input-ing @@ -193,7 +195,7 @@ public class GameManager : MonoBehaviour //playerDataAsArray.ForEach(p => p.recievedList = false); //reset all players list foreach (PlayerData player in playerDataAsArray) { - if (player.client.Lives > 0){player.recievedList = false;} + if (player.client.Lives > 0) { player.recievedList = false; } } //Let gamemode know all inputs have been recieved @@ -202,28 +204,21 @@ public class GameManager : MonoBehaviour private IEnumerator MoveRoutine(PlayerData data) { - bool blockFinished = false; - float waitTime; - - //Loop until the current block indicates or the reader indicates it has finished - while (!blockFinished && !data.blockReader.Finished) + //If the current block hasn't already been removed, remove it from the player inventory + //We need to check if it has already been removed so loops don't eat an entire stack + if (data.blockReader.CurrentBlock != null && !data.blockReader.CurrentBlock.hasBeenRemoved) { + data.client.Inventory.Remove(data.blockReader.CurrentBlock); + data.blockReader.CurrentBlock.hasBeenRemoved = true; + } - //If the current block hasn't already been removed, remove it from the player inventory - //We need to check if it has already been removed so loops don't eat an entire stack - if (data.blockReader.CurrentBlock != null && !data.blockReader.CurrentBlock.hasBeenRemoved) - { - data.client.Inventory.Remove(data.blockReader.CurrentBlock); - data.blockReader.CurrentBlock.hasBeenRemoved = true; - } - - //Process the move - blockFinished = data.blockReader.Read(data.character, AnimationTime, out waitTime); + //Process the move + //blockFinished = data.blockReader.Read(data.character, AnimationTime, out waitTime); - //Wait for the animation to finish - yield return new WaitForSeconds(waitTime); + //Wait for the animation to finish + //yield return new WaitForSeconds(waitTime); - } + yield return StartCoroutine(data.blockReader.Read(data.character, AnimationTime)); } private void SpawnCharacters() @@ -256,7 +251,7 @@ public class GameManager : MonoBehaviour newChar.ClientLink = client; client.playerCharacter = newChar; } - } + } #endregion Class Functions #region Networking Functions