|
@ -44,7 +44,7 @@ public class GameManager : MonoBehaviour |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Easy access to GameMode value in CurrentGameMode reference
|
|
|
/// Easy access to GameMode value in CurrentGameMode reference
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private GameMode gameMode {get { return CurrentGameMode.Value; } } |
|
|
|
|
|
|
|
|
private GameMode gameMode { get { return CurrentGameMode.Value; } } |
|
|
#endregion Read Only
|
|
|
#endregion Read Only
|
|
|
|
|
|
|
|
|
#region Unity Functions
|
|
|
#region Unity Functions
|
|
@ -117,6 +117,8 @@ public class GameManager : MonoBehaviour |
|
|
while (playerDataAsArray.Any(p => !p.blockReader.Finished)) |
|
|
while (playerDataAsArray.Any(p => !p.blockReader.Finished)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Loop through all players
|
|
|
//Loop through all players
|
|
|
foreach (PlayerData player in playerDataAsArray) |
|
|
foreach (PlayerData player in playerDataAsArray) |
|
|
{ |
|
|
{ |
|
@ -142,18 +144,18 @@ public class GameManager : MonoBehaviour |
|
|
//force them back to the waiting for players screen
|
|
|
//force them back to the waiting for players screen
|
|
|
foreach (PlayerData player in playerDataAsArray) |
|
|
foreach (PlayerData player in playerDataAsArray) |
|
|
{ |
|
|
{ |
|
|
if(player.client.Lives == 0) |
|
|
|
|
|
|
|
|
if (player.client.Lives == 0) |
|
|
{ |
|
|
{ |
|
|
Debug.Log("Remove: " + player.client.characterAnimal); |
|
|
Debug.Log("Remove: " + player.client.characterAnimal); |
|
|
removePlayer(player); |
|
|
removePlayer(player); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Reset some player Data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Reset some player Data
|
|
|
foreach (PlayerData player in playerDataAsArray) |
|
|
foreach (PlayerData player in playerDataAsArray) |
|
|
{ |
|
|
{ |
|
|
if(player.client.Lives > 0) |
|
|
|
|
|
|
|
|
if (player.client.Lives > 0) |
|
|
{ |
|
|
{ |
|
|
player.blockReader.Reset(); |
|
|
player.blockReader.Reset(); |
|
|
player.client.SendInventory(); |
|
|
player.client.SendInventory(); |
|
@ -166,7 +168,7 @@ public class GameManager : MonoBehaviour |
|
|
//send round length to players
|
|
|
//send round length to players
|
|
|
//#TODO make this only happen after first input
|
|
|
//#TODO make this only happen after first input
|
|
|
LogicProtocols.FloatMsg RoundTime = new LogicProtocols.FloatMsg(gameMode.GetRoundTime()); |
|
|
LogicProtocols.FloatMsg RoundTime = new LogicProtocols.FloatMsg(gameMode.GetRoundTime()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//playerDataAsArray.ForEach(p => p.client.conn.Send(LogicProtocols.SendRoundTime, RoundTime));
|
|
|
//playerDataAsArray.ForEach(p => p.client.conn.Send(LogicProtocols.SendRoundTime, RoundTime));
|
|
|
foreach (PlayerData player in playerDataAsArray) |
|
|
foreach (PlayerData player in playerDataAsArray) |
|
|
{ |
|
|
{ |
|
@ -180,7 +182,7 @@ public class GameManager : MonoBehaviour |
|
|
//ClientList.ForEach(p => p.ChangeScene("ClientScene"));
|
|
|
//ClientList.ForEach(p => p.ChangeScene("ClientScene"));
|
|
|
foreach (ClientData client in ClientList) |
|
|
foreach (ClientData client in ClientList) |
|
|
{ |
|
|
{ |
|
|
if(client.Lives > 0){client.ChangeScene("ClientScene");} |
|
|
|
|
|
|
|
|
if (client.Lives > 0) { client.ChangeScene("ClientScene"); } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Let gamemode know clients are input-ing
|
|
|
//Let gamemode know clients are input-ing
|
|
@ -193,7 +195,7 @@ public class GameManager : MonoBehaviour |
|
|
//playerDataAsArray.ForEach(p => p.recievedList = false); //reset all players list
|
|
|
//playerDataAsArray.ForEach(p => p.recievedList = false); //reset all players list
|
|
|
foreach (PlayerData player in playerDataAsArray) |
|
|
foreach (PlayerData player in playerDataAsArray) |
|
|
{ |
|
|
{ |
|
|
if (player.client.Lives > 0){player.recievedList = false;} |
|
|
|
|
|
|
|
|
if (player.client.Lives > 0) { player.recievedList = false; } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Let gamemode know all inputs have been recieved
|
|
|
//Let gamemode know all inputs have been recieved
|
|
@ -202,28 +204,21 @@ public class GameManager : MonoBehaviour |
|
|
|
|
|
|
|
|
private IEnumerator MoveRoutine(PlayerData data) |
|
|
private IEnumerator MoveRoutine(PlayerData data) |
|
|
{ |
|
|
{ |
|
|
bool blockFinished = false; |
|
|
|
|
|
float waitTime; |
|
|
|
|
|
|
|
|
|
|
|
//Loop until the current block indicates or the reader indicates it has finished
|
|
|
|
|
|
while (!blockFinished && !data.blockReader.Finished) |
|
|
|
|
|
|
|
|
//If the current block hasn't already been removed, remove it from the player inventory
|
|
|
|
|
|
//We need to check if it has already been removed so loops don't eat an entire stack
|
|
|
|
|
|
if (data.blockReader.CurrentBlock != null && !data.blockReader.CurrentBlock.hasBeenRemoved) |
|
|
{ |
|
|
{ |
|
|
|
|
|
data.client.Inventory.Remove(data.blockReader.CurrentBlock); |
|
|
|
|
|
data.blockReader.CurrentBlock.hasBeenRemoved = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//If the current block hasn't already been removed, remove it from the player inventory
|
|
|
|
|
|
//We need to check if it has already been removed so loops don't eat an entire stack
|
|
|
|
|
|
if (data.blockReader.CurrentBlock != null && !data.blockReader.CurrentBlock.hasBeenRemoved) |
|
|
|
|
|
{ |
|
|
|
|
|
data.client.Inventory.Remove(data.blockReader.CurrentBlock); |
|
|
|
|
|
data.blockReader.CurrentBlock.hasBeenRemoved = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Process the move
|
|
|
|
|
|
blockFinished = data.blockReader.Read(data.character, AnimationTime, out waitTime); |
|
|
|
|
|
|
|
|
//Process the move
|
|
|
|
|
|
//blockFinished = data.blockReader.Read(data.character, AnimationTime, out waitTime);
|
|
|
|
|
|
|
|
|
//Wait for the animation to finish
|
|
|
|
|
|
yield return new WaitForSeconds(waitTime); |
|
|
|
|
|
|
|
|
//Wait for the animation to finish
|
|
|
|
|
|
//yield return new WaitForSeconds(waitTime);
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
yield return StartCoroutine(data.blockReader.Read(data.character, AnimationTime)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void SpawnCharacters() |
|
|
private void SpawnCharacters() |
|
@ -256,7 +251,7 @@ public class GameManager : MonoBehaviour |
|
|
newChar.ClientLink = client; |
|
|
newChar.ClientLink = client; |
|
|
client.playerCharacter = newChar; |
|
|
client.playerCharacter = newChar; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
#endregion Class Functions
|
|
|
#endregion Class Functions
|
|
|
|
|
|
|
|
|
#region Networking Functions
|
|
|
#region Networking Functions
|
|
|