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 2b4e642..6750d7e 100644 --- a/Assets/Scripts/BlockInput.cs +++ b/Assets/Scripts/BlockInput.cs @@ -20,7 +20,8 @@ public class BlockInput : MonoBehaviour [ContextMenu("Read Next")] public void ReadNext() { - blockReader.Read(character, waitTime); + float TotalAnimationTime; + blockReader.Read(character, waitTime,out TotalAnimationTime); } public void ReadAll() 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/Logic/BlockReader.cs b/Assets/Scripts/Logic/BlockReader.cs index 8dd5dca..157426a 100644 --- a/Assets/Scripts/Logic/BlockReader.cs +++ b/Assets/Scripts/Logic/BlockReader.cs @@ -56,28 +56,32 @@ 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 animationTime) + public bool Read(Character character,float speedMultiplier, out float TotalAnimationTime) { - //return that this is done if no more blocks left in chain + //return that this is done if no more blocks left in chain if (LogicChain.Count <= currentBlockIndex) + { + TotalAnimationTime = 0; return true; + } //get current Block LogicBlock currentBlock = LogicChain[currentBlockIndex]; //apply blocks to character - currentBlock.Run(character, animationTime); + bool runAgainNot = currentBlock.Run(character, speedMultiplier,out TotalAnimationTime); //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) - if (currentBlock.isFinished()) + bool isFinished = currentBlock.isFinished(); + if (isFinished) { currentBlock.Reset(); currentBlockIndex++; } //Should other readers wait for this one - return (currentBlock.isFinished() || currentBlock.WaitUntilFinished); + return (runAgainNot || !currentBlock.WaitUntilFinished); } /// diff --git a/Assets/Scripts/Logic/Blocks/CombinedBlock.cs b/Assets/Scripts/Logic/Blocks/CombinedBlock.cs index bcbeaed..ad25590 100644 --- a/Assets/Scripts/Logic/Blocks/CombinedBlock.cs +++ b/Assets/Scripts/Logic/Blocks/CombinedBlock.cs @@ -16,15 +16,21 @@ public class CombinedBlock : LogicBlock public BlockReader blockReader = new BlockReader(); #endregion Inspector Variables + #region ReadOnly Variables + public override bool WaitUntilFinished { get { if (blockReader != null && blockReader.CurrentBlock != null) return (blockReader.CurrentBlock.WaitUntilFinished || base.WaitUntilFinished); else return base.WaitUntilFinished; } } + #endregion + #region Private Variables - + #endregion Private Variables - public override bool Run(Character player, float animationTime) + public override bool Run(Character player, float animationTime, out float TotalAnimationTime) { BlockLogic(player,animationTime); + blockReader.Read(player, animationTime / SpeedMultiplier, out TotalAnimationTime); + if (blockReader.Finished) { blockReader.Reset(); @@ -36,7 +42,7 @@ public class CombinedBlock : LogicBlock protected override void BlockLogic(Character player, float animationTime) { - blockReader.Read(player,animationTime); + } diff --git a/Assets/Scripts/Logic/Blocks/EditableBlock.cs b/Assets/Scripts/Logic/Blocks/EditableBlock.cs index dca4a9c..d115cd6 100644 --- a/Assets/Scripts/Logic/Blocks/EditableBlock.cs +++ b/Assets/Scripts/Logic/Blocks/EditableBlock.cs @@ -27,4 +27,5 @@ public class EditableBlock : CombinedBlock } + } diff --git a/Assets/Scripts/Logic/Blocks/LogicBlock.cs b/Assets/Scripts/Logic/Blocks/LogicBlock.cs index 8b78e6f..392ff85 100644 --- a/Assets/Scripts/Logic/Blocks/LogicBlock.cs +++ b/Assets/Scripts/Logic/Blocks/LogicBlock.cs @@ -22,12 +22,16 @@ public abstract class LogicBlock : ScriptableObject [SerializeField] [Header("Base Settings")] [Tooltip("Wait until this block is resolved before moving to next")] - public bool WaitUntilFinished = false; + protected bool _WaitUntilFinished = false; [SerializeField] [Tooltip("Amount of times to run this Block before moving to next")] protected int RepeatAmount = 1; + [SerializeField] + [Tooltip("Speed this block will be played back at. (Default = 1)")] + protected float SpeedMultiplier = 1; + #endregion Inspector Fields #region ReadOnly Variables @@ -35,6 +39,8 @@ public abstract class LogicBlock : ScriptableObject [HideInInspector] public bool hasBeenRemoved = false; + + public virtual bool WaitUntilFinished { get { return _WaitUntilFinished; } } #endregion #region private variables @@ -52,10 +58,11 @@ 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 animationTime) + public virtual bool Run(Character player, float animationSpeed, out float TotalAnimationTime) { RepeatCount++; - BlockLogic(player, animationTime); + TotalAnimationTime = animationSpeed / SpeedMultiplier; + BlockLogic(player, TotalAnimationTime); if(GlobalVariables.playerMoves == true){ player.DisplayBlock(this); @@ -106,7 +113,6 @@ public abstract class LogicBlock : ScriptableObject return (RepeatCount == RepeatAmount); } - #region Serialisation Functions /// /// Copies data from BlockToken to this Block @@ -116,9 +122,10 @@ public abstract class LogicBlock : ScriptableObject { Color = token.Color; _DisplayName = token._DisplayName; - WaitUntilFinished = token.WaitUntilFinished; + _WaitUntilFinished = token.WaitUntilFinished; RepeatAmount = token.RepeatAmount; name = token.ObjectName; + SpeedMultiplier = token.SpeedMultiplier; } /// @@ -135,6 +142,7 @@ public abstract class LogicBlock : ScriptableObject token.WaitUntilFinished = WaitUntilFinished; token.RepeatAmount = RepeatAmount; token.ObjectName = name; + token.SpeedMultiplier = SpeedMultiplier; return token; } @@ -187,6 +195,8 @@ public class BlockToken public int RepeatAmount; + public float SpeedMultiplier; + public BlockToken(LogicBlock block) { blockType = block.GetType(); 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 88c03f7..c6f98d5 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -105,31 +105,46 @@ public class GameManager : MonoBehaviour { playerArray.ForEach(p => p.recievedList = false); + //while (playerArray.Any(p => !p.blockReader.Finished)) + //{ + // foreach (PlayerData player in playerArray) + // { + // if (!player.waiting) + // { + // if (player.blockReader.CurrentBlock != null && !player.blockReader.CurrentBlock.hasBeenRemoved) + // { + // //Debug.Log("used Block: " + player.blockReader.CurrentBlock.name); + // player.client.Inventory.Remove(player.blockReader.CurrentBlock); + // player.blockReader.CurrentBlock.hasBeenRemoved = true; + // } + // player.waiting = player.blockReader.Read(player.character, AnimationTime); + // } + // } + // + // yield return new WaitForSeconds(AnimationTime); + // + // + // + // if (playerArray.All(p => p.waiting)) + // { + // playerArray.ForEach(p => p.waiting = false); + // Debug.Log("Finished one move"); + // } + //} + + Debug.Log("Doing Round Routine"); + while (playerArray.Any(p => !p.blockReader.Finished)) { + Debug.Log("One Move"); foreach (PlayerData player in playerArray) - { - if (!player.waiting) - { - if (player.blockReader.CurrentBlock != null && !player.blockReader.CurrentBlock.hasBeenRemoved) - { - //Debug.Log("used Block: " + player.blockReader.CurrentBlock.name); - player.client.Inventory.Remove(player.blockReader.CurrentBlock); - player.blockReader.CurrentBlock.hasBeenRemoved = true; - } - player.waiting = player.blockReader.Read(player.character, AnimationTime); - } - } + StartCoroutine(RunOnce(player)); - yield return new WaitForSeconds(AnimationTime); + //wait until all players have finished + yield return new WaitUntil(() => playerArray.All(p => p.waiting)); gamemode.FinishedMove(playerArray.ToArray()); - if (playerArray.All(p => p.waiting)) - { - playerArray.ForEach(p => p.waiting = false); - Debug.Log("Finished one move"); - } } if (gamemode.isGameOver(playerArray.ToArray())) @@ -175,6 +190,34 @@ public class GameManager : MonoBehaviour { server.server.RegisterHandler(LogicProtocols.SendLogicList, RecieveLogicList); } + + private IEnumerator RunOnce(PlayerData data) + { + + + data.waiting = false; + bool blockFinished = false; + float waitTime; + while (!blockFinished && !data.blockReader.Finished) + { + Debug.Log(data.client + "Moving once"); + + if (data.blockReader.CurrentBlock != null && !data.blockReader.CurrentBlock.hasBeenRemoved) + { + data.client.Inventory.Remove(data.blockReader.CurrentBlock); + data.blockReader.CurrentBlock.hasBeenRemoved = true; + } + + blockFinished = data.blockReader.Read(data.character, AnimationTime,out waitTime); + + Debug.Log("Waiting: " + waitTime); + yield return new WaitForSeconds(waitTime); + } + + data.waiting = true; + } + + } public class PlayerData