Browse Source

Two people cant choose the same animal, even if one is selected before another peson connects. Life is now lost/deducted once at the end of the round instead of one per move (causing multiple lifes lost if in the pit) when lives reach zero players die

Josh_Dev_branch
ClairePeta 5 years ago
parent
commit
fbbdc46b5c
7 changed files with 42 additions and 10 deletions
  1. +8
    -1
      Assets/Scripts/Character.cs
  2. +4
    -4
      Assets/Scripts/GameMode/ColorGameMode/ColorGameMode.cs
  3. +4
    -3
      Assets/Scripts/GameMode/ColorGameMode/RacetrackGameMode.cs
  4. +8
    -0
      Assets/Scripts/GameMode/GameMode.cs
  5. +6
    -0
      Assets/Scripts/Managers/GameManager.cs
  6. +1
    -0
      Assets/Scripts/Networking/Client/ClientLoginManager.cs
  7. +11
    -2
      Assets/Scripts/UI/Client/LoginUIManager.cs

+ 8
- 1
Assets/Scripts/Character.cs View File

@ -69,7 +69,14 @@ public class Character : MonoBehaviour
characterAnimator = GetComponentInChildren<Animator>();
}
private void Update()
{
if(lives < 1)
{
this.enabled = false;
gameObject.SetActive(false);
}
}
#endregion Unity Functions

+ 4
- 4
Assets/Scripts/GameMode/ColorGameMode/ColorGameMode.cs View File

@ -170,15 +170,15 @@ public class ColorGameMode : GameMode
{
character.stuck = true;
}
Debug.Log("inWater = " + character.inWater + ", inPit = " + character.inPit + ", stuck = " + character.stuck);
}
protected override void OnPlayerKilled(Character character, ClientData client)
{
if (character.inPit)
{
character.lives -= 1;
character.ClientLink.Lives = character.lives;
}
Debug.Log("inWater = " + character.inWater + ", inPit = " + character.inPit + ", stuck = " + character.stuck);
}
private IEnumerator AnimateBlock(Material mat, float time)

+ 4
- 3
Assets/Scripts/GameMode/ColorGameMode/RacetrackGameMode.cs View File

@ -187,15 +187,16 @@ public class RacetrackGameMode : GameMode
{
character.stuck = true;
}
Debug.Log("inWater = " + character.inWater + ", inPit = " + character.inPit + ", stuck = " + character.stuck);
}
protected override void OnPlayerKilled(Character character, ClientData client)
{
if (character.inPit)
{
character.lives -= 1;
character.ClientLink.Lives = character.lives;
}
Debug.Log("inWater = " + character.inWater + ", inPit = " + character.inPit + ", stuck = " + character.stuck);
}
private IEnumerator AnimateBlock(Material mat, float time)

+ 8
- 0
Assets/Scripts/GameMode/GameMode.cs View File

@ -67,6 +67,9 @@ public abstract class GameMode : ScriptableObject
/// <param name="currentBlock">Block which the character finished on</param>
protected virtual void OnPlayerMoved(Character character, ClientData client, Block currentBlock) { }
protected virtual void OnPlayerKilled(Character character, ClientData client) { }
/// <summary>
/// Called once after every player has finished one move
/// </summary>
@ -150,6 +153,11 @@ public abstract class GameMode : ScriptableObject
OnPlayerMoved(player.character, player.client, player.character.CurrentBlock);
}
public void PlayerKilled(PlayerData player)
{
OnPlayerKilled(player.character, player.client);
}
public void AllPlayersMoved(PlayerData[] allPlayers)
{
OnAllPlayersMoved(allPlayers);

+ 6
- 0
Assets/Scripts/Managers/GameManager.cs View File

@ -126,6 +126,12 @@ public class GameManager : MonoBehaviour
//Let Gamemode know all players have moved
gameMode.AllPlayersMoved(playerDataAsArray.ToArray());
//decrease lives here!!
foreach(PlayerData player in playerDataAsArray)
{
gameMode.PlayerKilled(player);
}
playerDataAsArray.ForEach(p => p.client.SendLives()); //Update the players score
//if Game is over break out of loop

+ 1
- 0
Assets/Scripts/Networking/Client/ClientLoginManager.cs View File

@ -47,6 +47,7 @@ namespace Networking.Client
[Tooltip("Send prefilled Player settings after connecting")]
private bool IdentifyOnConnect = false;
ConnectedClients clients;
#endregion Inspector Fields
#region Events

+ 11
- 2
Assets/Scripts/UI/Client/LoginUIManager.cs View File

@ -8,7 +8,7 @@ public class LoginUIManager : MonoBehaviour
{
public int conn;
public int maxPlayers = 2;
ConnectedClients clients;
public ConnectedClients clients;
[Header("References")]
[SerializeField]
private ClientLoginManager clientManager;
@ -54,6 +54,15 @@ public class LoginUIManager : MonoBehaviour
private void Update()
{
conn = GetComponent<animalSelection>().count;
clients = GetComponent<animalSelection>().Clients;
foreach (ClientData cli in clients.AllClients)
{
if (playerAnimal == cli.characterAnimal)
{
playerAnimal = null;
animalSelected = false;
}
}
}
private void OnEnable()
{
@ -78,7 +87,6 @@ public class LoginUIManager : MonoBehaviour
OnLoginFail();
}
#endregion Unity Functions
@ -151,6 +159,7 @@ public class LoginUIManager : MonoBehaviour
{
if (colorSelected == true && animalSelected == true && playerName != "")
{
clientManager.SendPlayerDetails(playerName, playerColor, playerAnimal);
PlayerPrefs.SetString("LastUsedName", playerName);
}

Loading…
Cancel
Save