public void Win() { canvas.enabled = true; gameOver = true; StockSave ss = FindObjectOfType <StockSave>(); int bestPlayer = 1; int actualBestScore = 0; PlayerManager pm = FindObjectOfType <PlayerManager>(); foreach (KeyValuePair <int, int> kvp in ss.playerScore) { if (kvp.Value > actualBestScore) { bestPlayer = kvp.Key; actualBestScore = kvp.Value; } GameObject.Find("PV" + kvp.Key).GetComponent <VictoryUI>().updateUI(kvp.Value, pm.playerList[kvp.Key]); } GameObject.Find("PV" + bestPlayer).GetComponent <VictoryUI>().Crown(); for (int i = 0; i < 4 - pm.playerList.Count; i++) { GameObject.Find("PV" + (4 - i).ToString()).gameObject.SetActive(false); } }
private IEnumerator SaveApples(StockSave stock, int playerIndex) { while (true) { SaveApple(stock, playerIndex); yield return(new WaitForSeconds(stockDelay)); } }
public void OnStockCollision(StockSave stock, int playerIndex) { if (_apples.Count > 0) { saveApplesCoroutine = StartCoroutine(SaveApples(stock, playerIndex)); _stockingApples = true; } }
public void SaveApple(StockSave stock, int playerIndex) { GameObject savedApple = _apples.Pop(); if (_apples.Count == 0) { if (saveApplesCoroutine != null) { StopCoroutine(saveApplesCoroutine); } _stockingApples = false; } stock.AddApple(savedApple, playerIndex); }