public void killPlayer() { rouletteminScript currentPlayerScript = currentPlayers[0].GetComponent <rouletteminScript>(); currentPlayerScript.dead = true; checkWin(); }
public void checkButtons() { rouletteminScript currentPlayerScript = currentPlayers[0].GetComponent <rouletteminScript>(); passText.text = "x" + currentPlayerScript.passLeft; peekText.text = "x" + currentPlayerScript.peekLeft; spinText.text = "x" + currentPlayerScript.spinLeft; if (currentPlayerScript.passLeft > 0) { passButton.interactable = true; } else { passButton.interactable = false; } if (currentPlayerScript.peekLeft > 0) { peekButton.interactable = true; } else { peekButton.interactable = false; } if (currentPlayerScript.spinLeft > 0) { spinButton.interactable = true; } else { spinButton.interactable = false; } }
void initializePlayers() { int currentPlayer = 1; //do bottom half for (int i = Mathf.CeilToInt(spawnPoints.Count / 2); i <= Mathf.CeilToInt(spawnPoints.Count / 2) && i >= 0; i--) { GameObject playuh = Instantiate(playerObject); players.Add(playuh); rouletteminScript playerScript = playuh.GetComponent <rouletteminScript>(); playerScript.placeInLine = spawnPoints[i]; playerScript.myNum = currentPlayer; currentPlayer++; } //do top half for (int i = spawnPoints.Count - 1; i > Mathf.CeilToInt(spawnPoints.Count / 2); i--) { GameObject playuh = Instantiate(playerObject); players.Add(playuh); rouletteminScript playerScript = playuh.GetComponent <rouletteminScript>(); playerScript.placeInLine = spawnPoints[i]; playerScript.myNum = currentPlayer; currentPlayer++; } currentPlayers = players; }
public void takeAPeek() { rouletteminScript currentPlayerScript = playerLogic.currentPlayers[0].GetComponent <rouletteminScript>(); currentPlayerScript.peekLeft--; SyncUIBullets(); UIAnim.SetBool("Peek Up", true); Invoke("UIBackDown", 3); giveReadout(); playerLogic.checkButtons(); }
public void moveLine() { if (placesInLineForShuffle.Count > 0) { placesInLineForShuffle.Clear(); } //take current positions foreach (GameObject player in players) { rouletteminScript currentPlayer = player.GetComponent <rouletteminScript>(); placesInLineForShuffle.Add(currentPlayer.placeInLine); } //shuffle positions tempArray = placesInLineForShuffle.ToArray(); GameObject tempPlace = tempArray[tempArray.Length - 1]; for (int i = tempArray.Length - 2; i >= 0; i--) { tempArray[i + 1] = tempArray[i]; } tempArray[0] = tempPlace; //set positions back int index = 0; foreach (GameObject player in players) { rouletteminScript currentPlayer = player.GetComponent <rouletteminScript>(); currentPlayer.placeInLine = tempArray[index]; index++; } //shuffle player list to keep sync tempArray = new GameObject[players.Count]; tempArray = currentPlayers.ToArray(); //DO THIS BACKWARDS /* * GameObject tempPlayer = tempArray[tempArray.Length - 1]; * for (int i = tempArray.Length - 2; i >= 0; i--) * { * tempArray[i + 1] = tempArray[i]; * } * tempArray[0] = tempPlayer; */ GameObject tempPlayer = tempArray[0]; for (int i = 1; i < tempArray.Length; i++) { tempArray[i - 1] = tempArray[i]; } tempArray[tempArray.Length - 1] = tempPlayer; currentPlayers = tempArray.ToList(); setCurrentPlayer(); }
public void setCurrentPlayer() { rouletteminScript currentPlayer = currentPlayers[0].GetComponent <rouletteminScript>(); if (currentPlayer.dead == true) { moveLine(); } else { playerText.text = "PLAYER\n" + currentPlayer.myNum; } checkButtons(); }
void checkWin() { int alivePlayers = 0; foreach (GameObject player in players) { rouletteminScript playerScript = player.GetComponent <rouletteminScript>(); if (playerScript.dead == false) { alivePlayers++; lastAlivePlayer = playerScript; } } if (alivePlayers == 1) { winText.text = "PLAYER " + lastAlivePlayer.myNum + " WINS!!"; winText.gameObject.SetActive(true); Invoke("returnToMainMenu", 3); } }
public void spin(int num, bool minusFromPlayer) { if (minusFromPlayer == true) { rouletteminScript currentPlayerScript = playerLogic.currentPlayers[0].GetComponent <rouletteminScript>(); currentPlayerScript.spinLeft--; } for (int times2Do = 0; times2Do < num; times2Do++) { tempArray = spunChamber; int tempChamber = tempArray[5]; for (int i = 4; i >= 0; i--) { tempArray[i + 1] = tempArray[i]; } tempArray[0] = tempChamber; spunChamber = tempArray; } gunAnim.SetTrigger("spin"); SyncUIBullets(); giveReadout(); playerLogic.checkButtons(); }
public void extraPassStuff() { rouletteminScript currentPlayerScript = currentPlayers[0].GetComponent <rouletteminScript>(); currentPlayerScript.passLeft--; }