From a9a86b3252f910886cf013241301168ba9baf15c Mon Sep 17 00:00:00 2001 From: JoshuaReason Date: Thu, 2 May 2019 15:52:11 +1000 Subject: [PATCH] Started working on equality for blocks fixed jump waiting --- Assets/Data/Logic Blocks/U-Turn.asset | 3 +++ Assets/Data/Logic Blocks/U-Turn.asset.meta | 8 ++++++++ Assets/Scripts/Logic/BlockReader.cs | 2 +- Assets/Scripts/Logic/Blocks/LogicBlock.cs | 21 +++++++++++++++++---- Assets/Scripts/Logic/Blocks/Move.cs | 13 +++++++++++++ Assets/Scripts/Managers/GameManager.cs | 8 +++++--- 6 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 Assets/Data/Logic Blocks/U-Turn.asset create mode 100644 Assets/Data/Logic Blocks/U-Turn.asset.meta diff --git a/Assets/Data/Logic Blocks/U-Turn.asset b/Assets/Data/Logic Blocks/U-Turn.asset new file mode 100644 index 0000000..42749a7 --- /dev/null +++ b/Assets/Data/Logic Blocks/U-Turn.asset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20daf275a96f6c1909034cff9a3cc39f2636f25983e408ed050d69d8d18a37c8 +size 537 diff --git a/Assets/Data/Logic Blocks/U-Turn.asset.meta b/Assets/Data/Logic Blocks/U-Turn.asset.meta new file mode 100644 index 0000000..cdedf00 --- /dev/null +++ b/Assets/Data/Logic Blocks/U-Turn.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b5887451436a375419e538ef3706ecf9 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Logic/BlockReader.cs b/Assets/Scripts/Logic/BlockReader.cs index 867cd97..7e8bf75 100644 --- a/Assets/Scripts/Logic/BlockReader.cs +++ b/Assets/Scripts/Logic/BlockReader.cs @@ -72,7 +72,7 @@ public class BlockReader } //Should other readers wait for this one - return (currentBlock.isFinished() || !currentBlock.WaitUntilFinished); + return (currentBlock.isFinished() || currentBlock.WaitUntilFinished); } /// diff --git a/Assets/Scripts/Logic/Blocks/LogicBlock.cs b/Assets/Scripts/Logic/Blocks/LogicBlock.cs index 190f4ae..c68b0a7 100644 --- a/Assets/Scripts/Logic/Blocks/LogicBlock.cs +++ b/Assets/Scripts/Logic/Blocks/LogicBlock.cs @@ -31,7 +31,7 @@ public abstract class LogicBlock : ScriptableObject #endregion Inspector Fields #region ReadOnly Variables - public string DisplayName { get {return (string.IsNullOrEmpty(_DisplayName)) ? name : _DisplayName; } } + public string DisplayName { get { return (string.IsNullOrEmpty(_DisplayName)) ? name : _DisplayName; } } #endregion #region private variables @@ -80,7 +80,7 @@ public abstract class LogicBlock : ScriptableObject /// transform function will be based off /// layers to ignore /// block which character will finish on after performing this function - public abstract Block GetEndBlock(Block startBlock,Transform transform, LayerMask layerMask); + public abstract Block GetEndBlock(Block startBlock, Transform transform, LayerMask layerMask); /// /// Resets the block to be ready to used again @@ -134,6 +134,19 @@ public abstract class LogicBlock : ScriptableObject #endregion Serialisation Functions + public override bool Equals(object other) + { + if (Object.ReferenceEquals(null, other)) + return false; + + if (Object.ReferenceEquals(other.GetType(), other)) + return false; + + LogicBlock otherLogic = other as LogicBlock; + return !Object.ReferenceEquals(null, otherLogic) + && int.Equals(RepeatCount, otherLogic.RepeatCount); + } + public virtual void OnDoubleClick() { @@ -165,8 +178,8 @@ public class BlockToken public LogicBlock ToLogicBlock() { - - LogicBlock retVal = (LogicBlock) ScriptableObject.CreateInstance(blockType); + + LogicBlock retVal = (LogicBlock)ScriptableObject.CreateInstance(blockType); Debug.Log("type: " + retVal.GetType()); retVal.CopyToken(this); diff --git a/Assets/Scripts/Logic/Blocks/Move.cs b/Assets/Scripts/Logic/Blocks/Move.cs index 496b7a2..7336aa5 100644 --- a/Assets/Scripts/Logic/Blocks/Move.cs +++ b/Assets/Scripts/Logic/Blocks/Move.cs @@ -69,6 +69,19 @@ public class Move : LogicBlock return retVal; } + public override bool Equals(object other) + { + if (Object.ReferenceEquals(null, other)) + return false; + + if (Object.ReferenceEquals(other.GetType(), other)) + return false; + + Move otherMove = other as Move; + + return base.Equals(other)&& Direction.Equals(direction, otherMove.direction); + } + #endregion Class Functions } diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index cc69ee7..480581a 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -124,10 +124,12 @@ public class GameManager : MonoBehaviour gamemode.RoundEnd(playerArray.ToArray()); foreach (PlayerData player in playerArray) + { player.blockReader.Reset(); - - ClientList.ForEach(p => p.SendInventory()); - ClientList.ForEach(p => p.ChangeScene("ClientScene")); + player.waiting = false; + player.client.SendInventory(); + player.client.ChangeScene("ClientScene"); + } Debug.Log("Finished Moving"); StartRound(); }