public void InitializeLevel() { //TODO Test için konuldu kaldırılacak //currentLevel = 19; if (currentLevel > maxLevelNumber) { int rand = Random.Range(0, maxLevelNumber); if (rand == PlayerPrefs.GetInt("LastLevel")) { rand = Random.Range(0, maxLevelNumber); } PlayerPrefs.SetInt("LastLevel", rand); currentLevelObject = Instantiate(Resources.Load("Level" + rand), new Vector3(0, 0, 0), Quaternion.identity) as GameObject; } else { Debug.Log("Level : " + currentLevel); currentLevelObject = Instantiate(Resources.Load("Level" + currentLevel), new Vector3(0, 0, 0), Quaternion.identity) as GameObject; } InGamePanel.SetActive(true); bestScore = PlayerPrefs.GetInt("HighestScore"); currentColor = currentLevel; ChangeColor(currentColor); currentTargetScore = currentLevelObject.GetComponent <LevelObject>().targetScore; LevelSlider.maxValue = currentTargetScore; LevelText.text = (currentLevel + 1).ToString(); NextLevelText.text = (currentLevel + 2).ToString(); }
void Update() { Scoremater.GetComponent <Text>().text = "Score : " + Score.ToString(); if (Score >= 15) { medal(1); } if (Score >= 30) { medal(2); } if (Score >= 50) { medal(3); } if (GameOver) { if (PlayerPrefs.GetInt("HS") < Score) { PlayerPrefs.SetInt("HS", Score); } int hs = PlayerPrefs.GetInt("HS"); HighScore.text = "High Score\n" + hs.ToString(); ScoreFinal.text = "Score\n" + Score.ToString(); InGamePanel.SetActive(false); GameOverPanel.SetActive(true); } }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } if (PlayerPrefs.HasKey("LevelId")) { currentLevel = PlayerPrefs.GetInt("LevelId"); } else { PlayerPrefs.SetInt("LevelId", currentLevel); } if (PlayerPrefs.HasKey("HighestScore")) { bestScore = PlayerPrefs.GetInt("HighestScore"); } else { PlayerPrefs.SetInt("HighestScore", bestScore); } if (PlayerPrefs.GetInt("UseMenu").Equals(1) || !PlayerPrefs.HasKey("UseMenu")) { StartPanel.SetActive(true); PlayerPrefs.SetInt("UseMenu", 1); } else if (PlayerPrefs.GetInt("UseMenu").Equals(0)) { InGamePanel.SetActive(true); } if (!PlayerPrefs.HasKey("VIBRATION")) { PlayerPrefs.SetInt("VIBRATION", 1); VibrationButton.GetComponent <Image>().sprite = on; } else { if (PlayerPrefs.GetInt("VIBRATION") == 1) { VibrationButton.GetComponent <Image>().sprite = on; } else { VibrationButton.GetComponent <Image>().sprite = off; } } if (SoundManager.Instance == null) { Instantiate(soundManager); } BestScoreText.text = currentScore.ToString(); InitializeLevel(); }
public void OpenInGameUI() { //reset in game variables LevelCountText.text = (GameManager.instance.LevelId + 1).ToString(); //CoinCountText.text = GameManager.instance.Player.CollectedCoin.ToString(); InGamePanel.SetActive(true); }
//Funcoes Estado do Jogo public static void MenuStart() { Time.timeScale = 1f; MenuStartPanel.SetActive(true); GameOverPanel.SetActive(false); InGamePanel.SetActive(false); C2.SetActive(true); C1.SetActive(true); InstancioadorInimigos.SetActive(false); CarroPossMenuStart(C1, C2); BestScore = SaveScript.LoadSave(); }
void FinishPanel() { Destroy(Apartment); InGamePanel.SetActive(false); finpanel.SetActive(true); PlayerPrefs.SetInt("Currentlevel", PlayerPrefs.GetInt("Currentlevel") + 1); if (PlayerPrefs.GetInt("Lastlevel") < PlayerPrefs.GetInt("Currentlevel")) { PlayerPrefs.SetInt("Lastlevel", PlayerPrefs.GetInt("Currentlevel")); } Time.timeScale = 0; }
IEnumerator WaitAndGameWin() { Confetties.SetActive(true); cubeManager.PlaceFinalObject(); SoundManager.Instance.StopAllSounds(); SoundManager.Instance.playSound(SoundManager.GameSounds.Win); yield return(new WaitForSeconds(1)); if (PlayerPrefs.GetInt("VIBRATION") == 1) { TapticManager.Impact(ImpactFeedback.Light); } currentLevel++; if (Particle != null) { Particle.SetActive(true); } PlayerPrefs.SetInt("LevelId", currentLevel); cubeManager.CloseAllCubeScripts(); WinPanel.SetActive(true); InGamePanel.SetActive(false); }
public void GameLose() { if (currentBestScore > PlayerPrefs.GetInt("HighestScore")) { PlayerPrefs.SetInt("HighestScore", currentBestScore); } InGamePanel.SetActive(false); BestScoreText.text = currentBestScore.ToString(); currentBestScore = 0; highestScoreText.text = "Best : " + PlayerPrefs.GetInt("HighestScore"); SoundManager.Instance.StopAllSounds(); SoundManager.Instance.playSound(SoundManager.GameSounds.Lose); //NextLevelText.GetComponentInParent<Image>().color = grayColor; currentScore = 0; Debug.Log("Game Lose"); GameLosePanel.SetActive(true); isGameOver = true; isGameStarted = false; if (PlayerPrefs.GetInt("VIBRATION") == 1) { TapticManager.Impact(ImpactFeedback.Light); } }
public void LoadInGamePanel() { CloseAllPanels(); InGamePanel.SetActive(true); }
public static void SGameOver() { GameOverPanel.SetActive(true); InGamePanel.SetActive(false); }
public static void StartGame() { MenuStartPanel.SetActive(false); InGamePanel.SetActive(true); }
public void GameOver() { InGamePanel.SetActive(false); GameOverPanel.SetActive(true); Time.timeScale = 0; }