From d09abf756736d803b9c1ef7b30e09ced0273c96d Mon Sep 17 00:00:00 2001 From: Claire Peta Date: Thu, 17 Oct 2019 19:23:35 +1100 Subject: [PATCH] Fix lives lost, and small code cleaning --- Assets/Scripts/LevelBlocks/ActiveBlock.cs | 4 +--- Assets/Scripts/Managers/GameManager.cs | 6 ++++-- Assets/Scripts/blockSpawn.cs | 7 ------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/LevelBlocks/ActiveBlock.cs b/Assets/Scripts/LevelBlocks/ActiveBlock.cs index f3ed369..a57dcb5 100644 --- a/Assets/Scripts/LevelBlocks/ActiveBlock.cs +++ b/Assets/Scripts/LevelBlocks/ActiveBlock.cs @@ -4,7 +4,6 @@ using UnityEngine; public abstract class ActiveBlock : Block { - #region Read-Only Variables public bool isFinished { get; protected set; } #endregion Read-Only Variables @@ -46,6 +45,5 @@ public abstract class ActiveBlock : Block public abstract int GetInitative(); #endregion Class Functions - - } + diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index ff1c7e4..aedba90 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -177,12 +177,13 @@ public class GameManager : MonoBehaviour gameMode.PlayerKilled(player); } - playerDataAsArray.ForEach(p => p.client.SendLives()); //Update the players score + //Let GameMode know that Round is Over yield return StartCoroutine(EnvironmentEnd()); gameMode.RoundEnd(playerDataAsArray.ToArray()); + playerDataAsArray.ForEach(p => p.client.SendLives()); //Update the players score //check is anyone has 0 lives remaining //remove them from the array @@ -210,8 +211,9 @@ public class GameManager : MonoBehaviour } playerData = playerData.OrderBy(unit => unit.Value.character.CurrentBlock.transform.position.x).ToDictionary(unit => unit.Key, unit => unit.Value); + Dictionary filteredPlayers = playerData.Where(p => !p.Value.isDead).ToDictionary(unit => unit.Key, unit => unit.Value); int order = 1; - foreach (PlayerData data in playerDataAsArray) + foreach (PlayerData data in filteredPlayers.Values) { data.character.runOrder = order; order++; diff --git a/Assets/Scripts/blockSpawn.cs b/Assets/Scripts/blockSpawn.cs index d18ae2b..b706a2b 100644 --- a/Assets/Scripts/blockSpawn.cs +++ b/Assets/Scripts/blockSpawn.cs @@ -55,7 +55,6 @@ public class blockSpawn : MonoBehaviour possibleSpawnLocations.Add(point); } } - int triesCount = 0; if(possibleSpawnLocations.Count > 0) { @@ -92,12 +91,10 @@ public class blockSpawn : MonoBehaviour if (duplicate == false) { spawnBlock(spawnposition); - //Debug.Log("spawned at" + spawnposition); return true; } else { - //Debug.Log("Fail to spawn at " + spawnposition); return false; } } @@ -140,10 +137,6 @@ public class blockSpawn : MonoBehaviour { listtoUse = StrongLogicList; } - //max behind camera is -6/-7 - //max lives = 3 - // ~ anyone ahead of the average will have a minimum of 4(full lives) or 2(with 1 life left) - // ~ anyone behind the average will have a minimum of -3-4(full lives) or -5/-6 (with one life left) int number = Random.Range(0, listtoUse.Length-1); block.GetComponent().Collectable.element = listtoUse[number].element;