Browse Source

Fix lives lost, and small code cleaning

master
Claire Peta 5 years ago
parent
commit
d09abf7567
3 changed files with 5 additions and 12 deletions
  1. +1
    -3
      Assets/Scripts/LevelBlocks/ActiveBlock.cs
  2. +4
    -2
      Assets/Scripts/Managers/GameManager.cs
  3. +0
    -7
      Assets/Scripts/blockSpawn.cs

+ 1
- 3
Assets/Scripts/LevelBlocks/ActiveBlock.cs View File

@ -4,7 +4,6 @@ using UnityEngine;
public abstract class ActiveBlock : Block public abstract class ActiveBlock : Block
{ {
#region Read-Only Variables #region Read-Only Variables
public bool isFinished { get; protected set; } public bool isFinished { get; protected set; }
#endregion Read-Only Variables #endregion Read-Only Variables
@ -46,6 +45,5 @@ public abstract class ActiveBlock : Block
public abstract int GetInitative(); public abstract int GetInitative();
#endregion Class Functions #endregion Class Functions
} }

+ 4
- 2
Assets/Scripts/Managers/GameManager.cs View File

@ -177,12 +177,13 @@ public class GameManager : MonoBehaviour
gameMode.PlayerKilled(player); gameMode.PlayerKilled(player);
} }
playerDataAsArray.ForEach(p => p.client.SendLives()); //Update the players score
//Let GameMode know that Round is Over //Let GameMode know that Round is Over
yield return StartCoroutine(EnvironmentEnd()); yield return StartCoroutine(EnvironmentEnd());
gameMode.RoundEnd(playerDataAsArray.ToArray()); gameMode.RoundEnd(playerDataAsArray.ToArray());
playerDataAsArray.ForEach(p => p.client.SendLives()); //Update the players score
//check is anyone has 0 lives remaining //check is anyone has 0 lives remaining
//remove them from the array //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); playerData = playerData.OrderBy(unit => unit.Value.character.CurrentBlock.transform.position.x).ToDictionary(unit => unit.Key, unit => unit.Value);
Dictionary<int,PlayerData> filteredPlayers = playerData.Where(p => !p.Value.isDead).ToDictionary(unit => unit.Key, unit => unit.Value);
int order = 1; int order = 1;
foreach (PlayerData data in playerDataAsArray)
foreach (PlayerData data in filteredPlayers.Values)
{ {
data.character.runOrder = order; data.character.runOrder = order;
order++; order++;

+ 0
- 7
Assets/Scripts/blockSpawn.cs View File

@ -55,7 +55,6 @@ public class blockSpawn : MonoBehaviour
possibleSpawnLocations.Add(point); possibleSpawnLocations.Add(point);
} }
} }
int triesCount = 0; int triesCount = 0;
if(possibleSpawnLocations.Count > 0) if(possibleSpawnLocations.Count > 0)
{ {
@ -92,12 +91,10 @@ public class blockSpawn : MonoBehaviour
if (duplicate == false) if (duplicate == false)
{ {
spawnBlock(spawnposition); spawnBlock(spawnposition);
//Debug.Log("spawned at" + spawnposition);
return true; return true;
} }
else else
{ {
//Debug.Log("Fail to spawn at " + spawnposition);
return false; return false;
} }
} }
@ -140,10 +137,6 @@ public class blockSpawn : MonoBehaviour
{ {
listtoUse = StrongLogicList; 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); int number = Random.Range(0, listtoUse.Length-1);
block.GetComponent<LogicCollectable_Multiplayer>().Collectable.element = listtoUse[number].element; block.GetComponent<LogicCollectable_Multiplayer>().Collectable.element = listtoUse[number].element;

Loading…
Cancel
Save