public void Player2Goal() { player2Data.playerGoals++; uiController.EnableGoalText(player2Data); currentPlayer = General.PlayerNumber.Player2; Goal(); }
public void SwitchCurrentPlayer() { foreach (Player pl in players) { if (pl.GetPlayerNumber() == currentPlayer) { pl.SetNotCurrentPlayer(); } else { pl.SetCurrentPlayer(); } } if (currentPlayer == General.PlayerNumber.Player1) { currentPlayer = General.PlayerNumber.Player2; } else { currentPlayer = General.PlayerNumber.Player1; } initPlayerTime = Time.time; }
public void NewGame() { uiController.DisableFinishGameText(); foreach (Player pl in players) { Destroy(pl.gameObject); } players.Clear(); p1Players.Clear(); p2Players.Clear(); gameTime = 120f; initTime = Time.time; StartPosition[] startPositions = GameObject.FindObjectsOfType <StartPosition>(); List <StartPosition> p1Normal = new List <StartPosition>(); List <StartPosition> p1Offensive = new List <StartPosition>(); List <StartPosition> p2Normal = new List <StartPosition>(); List <StartPosition> p2Offensive = new List <StartPosition>(); foreach (StartPosition stPos in startPositions) { if (stPos.player == General.PlayerNumber.Player1) { if (stPos.startType == StartPosition.StartType.Normal) { p1Normal.Add(stPos); } else { p1Offensive.Add(stPos); } } else { if (stPos.startType == StartPosition.StartType.Normal) { p2Normal.Add(stPos); } else { p2Offensive.Add(stPos); } } gameStarted = true; } for (int i = 0; i < p1Normal.Count; i++) { GameObject playerGB = Instantiate(playerPrefab, Vector3.zero, Quaternion.identity) as GameObject; Player pl = playerGB.GetComponent <Player>(); pl.SetPlayerData(player1Data); players.Add(pl); p1Players.Add(pl); if (p1Offensive.Count >= i + 1) { pl.SetStartPositions(p1Normal[i], p1Offensive[i]); } else { pl.SetStartPositions(p1Normal[i]); } } for (int i = 0; i < p2Normal.Count; i++) { GameObject playerGB = Instantiate(playerPrefab, Vector3.zero, Quaternion.identity) as GameObject; Player pl = playerGB.GetComponent <Player>(); pl.SetPlayerData(player2Data); players.Add(pl); p2Players.Add(pl); if (p2Offensive.Count >= i + 1) { pl.SetStartPositions(p2Normal[i], p2Offensive[i]); } else { pl.SetStartPositions(p2Normal[i]); } } currentPlayer = General.PlayerNumber.Player1; StartGame(); }