Browse Source

Fix characters dying and order based on x at start of game

master
ClairePeta 5 years ago
parent
commit
35f4b9dcb8
4 changed files with 15 additions and 63 deletions
  1. +2
    -2
      Assets/Scenes/Menus/MainMenu Server.unity
  2. +2
    -2
      Assets/Scripts/Character.cs
  3. +0
    -57
      Assets/Scripts/GameMode/ColorGameMode/RacetrackGameMode.cs
  4. +11
    -2
      Assets/Scripts/Managers/GameManager.cs

+ 2
- 2
Assets/Scenes/Menus/MainMenu Server.unity View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:81882783cf5a376883ed9ca4f106b45f430a5c9af5cefe8480283c39fe2b3c41
size 145896
oid sha256:be1fecc5293999a37beabc3563e41990e6d8d9f9dadd8ba50c057c8342875a49
size 145925

+ 2
- 2
Assets/Scripts/Character.cs View File

@ -20,7 +20,7 @@ public class Character : MonoBehaviour
public bool stuck = false; //Am I still stuck? public bool stuck = false; //Am I still stuck?
public bool justMoved = false; //Was the logic block I just executed a move command? public bool justMoved = false; //Was the logic block I just executed a move command?
public bool inPit = false; public bool inPit = false;
Vector3 death = new Vector3(9999, 0, 0);
Vector3 death = new Vector3(-50, 0, 0);
#region Inspector Fields #region Inspector Fields
[SerializeField] [SerializeField]
@ -77,7 +77,7 @@ public class Character : MonoBehaviour
} }
private void Update() private void Update()
{ {
if(lives < 1)
if(ClientLink.Lives < 1)
{ {
this.transform.position = death; this.transform.position = death;
} }

+ 0
- 57
Assets/Scripts/GameMode/ColorGameMode/RacetrackGameMode.cs View File

@ -330,57 +330,6 @@ public class RacetrackGameMode : GameMode
protected override void OnPlayerMoved(Character character, ClientData client, Block currentBlock) protected override void OnPlayerMoved(Character character, ClientData client, Block currentBlock)
{ {
handleFalling(character, client, currentBlock, character.justMoved); handleFalling(character, client, currentBlock, character.justMoved);
/*Debug.Log("Moved to square at " + currentBlock.transform.position.x + ", "
+ currentBlock.transform.position.y + ", "
+ currentBlock.transform.position.z);
//If a character has fallen in the water or into a pit, we mark that fact, and they lose the rest of their turn
character.inWater = currentBlock.isWater;
character.respawnNeeded = currentBlock.isPit;
if (character.inWater == true || character.respawnNeeded == true)
{
character.stuck = true;
}
Debug.Log("inWater = " + character.inWater + ", respawnNeeded = " + character.respawnNeeded + ", stuck = " + character.stuck);*/
//Commented out because we don't do this in the racetrack mode
/*ClientData OwnedClient;
Material overlay = null;
if (isOwned(currentBlock, out OwnedClient))
{
if (OwnedClient == client)
return;
BlocksOwned[OwnedClient].Remove(currentBlock);
foreach (Material mat in currentBlock.GetComponent<Renderer>().materials)
{
if (mat.name == OverlayMaterial.name + " (Instance)")
overlay = mat;
}
}
if (overlay == null)
{
overlay = new Material(OverlayMaterial);
List<Material> mats = new List<Material>(currentBlock.GetComponent<Renderer>().materials);
mats.Add(overlay);
currentBlock.GetComponent<Renderer>().materials = mats.ToArray();
}
overlay.SetColor("_NewColor", client.Color);
if (!BlocksOwned.ContainsKey(client))
BlocksOwned.Add(client, new List<Block>());
BlocksOwned[client].Add(currentBlock);
if (overlay != null)
currentBlock.StartCoroutine(AnimateBlock(overlay, 0.25f));*/
} }
protected override void OnRoundStart(PlayerData[] allPlayers) protected override void OnRoundStart(PlayerData[] allPlayers)
@ -397,11 +346,6 @@ public class RacetrackGameMode : GameMode
* It's not needed from move to move, so we clear it * It's not needed from move to move, so we clear it
*/ */
player.character.justMoved = false; player.character.justMoved = false;
/* if (BlocksOwned.ContainsKey(player.client))
player.client.SceneScore = BlocksOwned[player.client].Count;
else
player.client.SceneScore = 0;*/
} }
} }
@ -438,7 +382,6 @@ public class RacetrackGameMode : GameMode
{ {
character.stuck = true; character.stuck = true;
} }
//Debug.Log("inWater = " + character.inWater + ", respawnNeeded = " + character.respawnNeeded + ", stuck = " + character.stuck);
} }
protected override void OnPlayerKilled(Character character, ClientData client) protected override void OnPlayerKilled(Character character, ClientData client)

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

@ -83,6 +83,15 @@ public class GameManager : MonoBehaviour
playerDataAsArray.ForEach(p => p.client.SendLives()); playerDataAsArray.ForEach(p => p.client.SendLives());
gameMode.GameStart(playerDataAsArray); gameMode.GameStart(playerDataAsArray);
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;
foreach (PlayerData data in filteredPlayers.Values)
{
data.character.runOrder = order;
order++;
}
//Loop until the GameMode lets us know the game is over //Loop until the GameMode lets us know the game is over
while (!gameMode.isGameOver(playerDataAsArray)) while (!gameMode.isGameOver(playerDataAsArray))
{ {
@ -190,9 +199,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);
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++;

Loading…
Cancel
Save