void CheckIfGameDone() { if (!gameEnded) //If game not ended { //Update teams tm.UpdateTeams(); //Check if game ended gameEnded = tm.IsThereOneTeamLeft(); if (gameEnded) //If game ended { CommonCommands.NextGame(tm.GetTeamFirstPlace(), tm.GetTeamSecondPlace()); //Start next game } } }
public void CheckNoBounce() { if ((playerListLeft.Count + playerListRight.Count == 2) && twoLeft) { if (canEnd && ableToRemove) { Time.timeScale = 1; timeScale = 1f; if (rb.position.x <= leftEnd) { CommonCommands.NextGame(playerListLeft, playerListRight); } else if (rb.position.x >= rightEnd) { CommonCommands.NextGame(playerListRight, playerListLeft); } canEnd = false; } } else if (canEnd && canRemove && !twoLeft && ableToRemove) { //Debug.Log("REMOVE!!!!"); canRemove = false; timerTextOut = 4f; if (rb.position.x <= leftEnd) { playerOut.text = "Player " + playerListLeft[playerListLeft.Count - 1] + " out! "; playerListLeft.RemoveAt(playerListLeft.Count - 1); } else if (rb.position.x >= rightEnd) { playerOut.text = "Player " + playerListRight[playerListRight.Count - 1] + " out! "; playerListRight.RemoveAt(playerListRight.Count - 1); } resetGame = true; justRemoved = true; ableToRemove = false; } }
//Sends the winner to "CommonCommands" or removes players from the list if there are more than 2 players left public void EndGame(List <int> firstList, List <int> secondList, int bounces, int howMany) { if ((bounces >= howMany)) { if ((playerListLeft.Count + playerListRight.Count) <= 2 && canEnd && twoLeft && ableToRemove) { Time.timeScale = 1; timeScale = 1f; if (left) { if (ballCollision.nrOfBouncesGood > 1) { CommonCommands.NextGame(firstList, secondList); } else if (ballCollision.nrOfBouncesBad > 0) { CommonCommands.NextGame(firstList, secondList); } } else if (!left) { if (ballCollision.nrOfBouncesGood > 1) { CommonCommands.NextGame(secondList, firstList); } else if (ballCollision.nrOfBouncesBad > 0) { CommonCommands.NextGame(secondList, firstList); } } canEnd = false; } else if (canEnd && canRemove && !twoLeft && ableToRemove) { canRemove = false; if (left) { timerTextOut = 4f; if (howMany == 1) { playerOut.text = "Player " + playerListLeft[playerListLeft.Count - 1] + " out! "; playerListLeft.RemoveAt(playerListLeft.Count - 1); } else if (howMany == 2) { playerOut.text = "Player " + playerListLeft[0] + " out! "; playerListLeft.RemoveAt(0); } } else if (!left) { timerTextOut = 4f; if (howMany == 1) { playerOut.text = "Player " + playerListRight[playerListRight.Count - 1] + " out! "; playerListRight.RemoveAt(playerListRight.Count - 1); } else if (howMany == 2) { playerOut.text = "Player " + playerListRight[0] + " out! "; playerListRight.RemoveAt(0); } } justRemoved = true; resetGame = true; ableToRemove = false; } if (howMany == 2) { ballCollision.nrOfBouncesGood = 0; } else if (howMany == 1) { ballCollision.nrOfBouncesBad = 0; } } }