public void ShowWinner(int winner) { if (winner == 0) { DatabaseDataAcces.insertGamePlayed(player.id, opponent.id, 1, 0); int wonCount = DatabaseDataAcces.getNumberofWonInRow(player.id); int cntNotOpened = DatabaseDataAcces.getNumberOfNotOpenedBoxes(player.id); if (wonCount % 3 == 0 && cntNotOpened < 4) { long now = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds; DatabaseDataAcces.insertBox(player.id, now); } winnerText.text = "You won!"; } else { DatabaseDataAcces.insertGamePlayed(player.id, opponent.id, 2, 0); winnerText.text = "You lost!"; } winnerText.gameObject.SetActive(true); goToGarage.gameObject.SetActive(true); winnerBackground.gameObject.SetActive(true); }
// Start is called before the first frame update void Start() { oneStar = Resources.Load <Sprite>("one-star"); twoStars = Resources.Load <Sprite>("two-stars"); threeStars = Resources.Load <Sprite>("three-stars"); string nickname = PlayerPrefs.GetString("player"); player = DatabaseDataAcces.getPlayerWithNickname(nickname); int lastWon = DatabaseDataAcces.getNumberofWonInRow(player.id) % 3; nextBoxImage.fillAmount = (lastWon * 1f) / 3.0f; nextBoxText.text = lastWon + " / 3 Won"; LoadBoxes(); LoadCar(); }