diff --git a/Assets/Data/Inventory/BaseInventory.asset b/Assets/Data/Inventory/BaseInventory.asset index 82c2966..9ff8253 100644 --- a/Assets/Data/Inventory/BaseInventory.asset +++ b/Assets/Data/Inventory/BaseInventory.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9310fa0d8f14f0a8df3edf310504907081a4a345138aaa3ce16831b6f0a5c70a -size 1090 +oid sha256:dc2df0d3b6567d4e6c80879edaa512a1b93ac778c0c4755d946260db33a5553a +size 1312 diff --git a/Assets/Data/Logic Blocks/Horse_Left.asset b/Assets/Data/Logic Blocks/Horse_Left.asset index bb2cfac..24bcec6 100644 --- a/Assets/Data/Logic Blocks/Horse_Left.asset +++ b/Assets/Data/Logic Blocks/Horse_Left.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ccb2e2bcc61f067df1b019e2c9c4c0887bf628056a41bdf1ed5241f2569f35ae -size 943 +oid sha256:c689e7823398372bb409980d735f9ce532db12ffa527ff0b996e907cc0390745 +size 868 diff --git a/Assets/Data/Logic Blocks/Horse_Right.asset b/Assets/Data/Logic Blocks/Horse_Right.asset index 82b5c95..996704a 100644 --- a/Assets/Data/Logic Blocks/Horse_Right.asset +++ b/Assets/Data/Logic Blocks/Horse_Right.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a8c8f259d738148b0d20f7ec320d76c998d1d9c4e7a1ea79f118fbb53ebe7d36 -size 944 +oid sha256:fd3e7a21a3b9ea59742941d1f65dec34c56480c36ac7742d03ce15768b696311 +size 869 diff --git a/Assets/Scenes/Client Scenes/ClientScene.unity b/Assets/Scenes/Client Scenes/ClientScene.unity index b18f212..20aecef 100644 --- a/Assets/Scenes/Client Scenes/ClientScene.unity +++ b/Assets/Scenes/Client Scenes/ClientScene.unity @@ -685,7 +685,7 @@ PrefabInstance: - target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: m_AnchoredPosition.y - value: 0.00004012345 + value: 0.000022883927 objectReference: {fileID: 0} - target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} @@ -832,6 +832,11 @@ PrefabInstance: propertyPath: TimeText value: objectReference: {fileID: 1363815578} + - target: {fileID: 1240851277759925011, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: ScoreText + value: + objectReference: {fileID: 5195354181466942482} - target: {fileID: 5195354183134146528, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: inventory @@ -1122,6 +1127,18 @@ PrefabInstance: - {fileID: 5195354182462625307, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} - {fileID: 5195354183157824118, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} +--- !u!114 &5195354181466942482 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 2665231841929910945, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + m_PrefabInstance: {fileID: 5195354181466942481} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!114 &5195354181466942483 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 1240851277759925011, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, diff --git a/Assets/Scenes/TuteLevelTwo.unity b/Assets/Scenes/TuteLevelTwo.unity index b3a9209..79ff078 100644 --- a/Assets/Scenes/TuteLevelTwo.unity +++ b/Assets/Scenes/TuteLevelTwo.unity @@ -506,7 +506,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1704581577, guid: 47297317c21fe8a4c91caa79d00cc9a6, type: 3} propertyPath: m_AnchoredPosition.y - value: 0.000017690185 + value: -0.0000044650105 objectReference: {fileID: 0} - target: {fileID: 1704581577, guid: 47297317c21fe8a4c91caa79d00cc9a6, type: 3} propertyPath: m_AnchoredPosition.x diff --git a/Assets/Scripts/GameMode/GameMode.cs b/Assets/Scripts/GameMode/GameMode.cs index 710092b..bbd1ab7 100644 --- a/Assets/Scripts/GameMode/GameMode.cs +++ b/Assets/Scripts/GameMode/GameMode.cs @@ -81,13 +81,15 @@ public abstract class GameMode : ScriptableObject public void FinishedMove(PlayerData[] allPlayers) { - foreach (PlayerData player in allPlayers) - OnPlayerFinishedMove(player.character, player.client, player.character.CurrentBlock); - OnAllPlayersFinishedMove(allPlayers); AllPlayersMovedEvent?.Invoke(); } + public void OnePlayerMoved(PlayerData player) + { + OnPlayerFinishedMove(player.character, player.client, player.character.CurrentBlock); + } + public void RoundEnd(PlayerData[] allPlayers) { OnRoundEnd(allPlayers); diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index 86446d5..76e58fd 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -96,8 +96,8 @@ public class GameManager : MonoBehaviour { gamemode.RoundStart(playerArray.ToArray()); LogicProtocols.FloatMsg RoundTime = new LogicProtocols.FloatMsg( gamemode.GetRoundTime()); - bspawn.getPlayerScores(); - bspawn.getPlayerLocations(); + //bspawn.getPlayerScores(); + //bspawn.getPlayerLocations(); playerArray.ForEach(p => p.client.conn.Send(LogicProtocols.SendRoundTime, RoundTime)); } @@ -105,33 +105,6 @@ 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)) @@ -144,6 +117,8 @@ public class GameManager : MonoBehaviour yield return new WaitUntil(() => playerArray.All(p => p.waiting)); gamemode.FinishedMove(playerArray.ToArray()); + playerArray.ForEach(p => p.client.SendScore()); + } if (gamemode.isGameOver(playerArray.ToArray())) @@ -208,6 +183,7 @@ public class GameManager : MonoBehaviour Debug.Log("Waiting: " + waitTime); yield return new WaitForSeconds(waitTime); + gamemode.OnePlayerMoved(data); } data.waiting = true; } diff --git a/Assets/Scripts/Networking/Client/ClientObject.cs b/Assets/Scripts/Networking/Client/ClientObject.cs index 1147044..cf2afe7 100644 --- a/Assets/Scripts/Networking/Client/ClientObject.cs +++ b/Assets/Scripts/Networking/Client/ClientObject.cs @@ -74,6 +74,7 @@ namespace Networking.Client client.RegisterHandler(LoginProtocols.SceneChange, RecieveSceneChange); client.RegisterHandler(MsgType.Disconnect, OnDisconnect); client.RegisterHandler(LogicProtocols.SendRoundTime, UpdateTime); + client.RegisterHandler(LogicProtocols.SendScore, UpdateScore); } public void Stop() @@ -118,13 +119,21 @@ namespace Networking.Client public void UpdateTime(NetworkMessage msg) { - Debug.Log("Recieveing time from server"); LogicProtocols.FloatMsg floatMsg; if (!msg.TryRead(out floatMsg)) return; RoundTime = floatMsg.Float; } + + public void UpdateScore(NetworkMessage msg) + { + LogicProtocols.FloatMsg floatMsg; + if (!msg.TryRead(out floatMsg)) + return; + + RoundScore = floatMsg.Float; + } } } diff --git a/Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs b/Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs index a378c69..20aebe3 100644 --- a/Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs +++ b/Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs @@ -12,6 +12,7 @@ namespace Networking public const short SendInventory = 201; public const short SendRoundTime = 202; public const short SendNotification = 203; + public const short SendScore = 204; public class LogicMsg : MessageBase diff --git a/Assets/Scripts/Networking/Server/ClientList.cs b/Assets/Scripts/Networking/Server/ClientList.cs index 613bbcb..c1be9fe 100644 --- a/Assets/Scripts/Networking/Server/ClientList.cs +++ b/Assets/Scripts/Networking/Server/ClientList.cs @@ -199,6 +199,11 @@ namespace Networking.Server conn.SendByChannel(LogicProtocols.SendInventory, new LogicProtocols.InventoryMsg(Inventory), TransportConfigure.ReliableFragmented); } + public void SendScore() + { + conn.Send(LogicProtocols.SendScore, new LogicProtocols.FloatMsg(SceneScore)); + } + public void ChangeScene(string scene, bool Additive = false) { conn.Send(LoginProtocols.SceneChange, new LoginProtocols.SceneMsg(scene,Additive)); diff --git a/Assets/Scripts/UI/InventoryCatch.cs b/Assets/Scripts/UI/InventoryCatch.cs index 23eaa73..4cf4489 100644 --- a/Assets/Scripts/UI/InventoryCatch.cs +++ b/Assets/Scripts/UI/InventoryCatch.cs @@ -8,25 +8,26 @@ public class InventoryCatch : LogicElementHolder [SerializeField] private InventoryUI InventoryUI; + public override void OnAdd(LogicElementUI element) { foreach (LogicBlock block in element.logicElement.GetAllBlocks()) { - + BagItem item = InventoryUI.content.FirstOrDefault(p => p.canHold(block)); - + if (item != default) item.OnAdd(element); - + Destroy(element.gameObject); } } - + public override void OnDoubleClick(LogicElementUI element) { //DoNothing } - + public override void OnRemove(LogicElementUI element) { //DoNothing diff --git a/Assets/Scripts/UI/NetworkedUIManager.cs b/Assets/Scripts/UI/NetworkedUIManager.cs index 22ed66e..22bfc49 100644 --- a/Assets/Scripts/UI/NetworkedUIManager.cs +++ b/Assets/Scripts/UI/NetworkedUIManager.cs @@ -13,6 +13,8 @@ public class NetworkedUIManager : PlayerUIManager private TMPro.TextMeshProUGUI TimeText; [SerializeField] private RectTransform Title; + [SerializeField] + private TMPro.TextMeshProUGUI ScoreText; [Header("Debug")] [SerializeField] @@ -29,9 +31,11 @@ public class NetworkedUIManager : PlayerUIManager TrayUI.SetBlockReader(reader); StartTime = Time.time; ShowPosition.y -= Title.rect.height; + ScoreText.text = "Score: " + Client.RoundScore; OnClick_Show(); } + private void Update() {