//Deactivates the level up canvas and applies the chosen upgrades public void DeactivateStatCanvas() { LevelUpCanvas statScript = statCanvas.GetComponent <LevelUpCanvas>(); PlayerStats.Instance().HP = statScript.GetHP(); PlayerStats.Instance().Speed = statScript.GetSpeed(); PlayerStats.Instance().Power = statScript.GetPower(); PlayerStats.Instance().Jump = statScript.GetJump(); //If the player's health is full when upgrading health, if (isHealthFull()) { //Also increase current health maxHealth = PlayerStats.Instance().HP; currHealth = maxHealth; } else { maxHealth = PlayerStats.Instance().HP; } healthBar.maxValue = maxHealth; healthBar.value = currHealth; speed = PlayerStats.Instance().Speed; power = PlayerStats.Instance().Power; jumpSpeed = PlayerStats.Instance().Jump * 10; statCanvas.SetActive(false); Time.timeScale = 1; Paused(false); }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(this.gameObject); return; } }
//Activates the level up canvas and passes it the player's current stats private void ActivateStatCanvas() { Time.timeScale = 0; Paused(true); statCanvas.SetActive(true); LevelUpCanvas statScript = statCanvas.GetComponent <LevelUpCanvas>(); statScript.SetHP(PlayerStats.Instance().HP); statScript.SetSpeed(PlayerStats.Instance().Speed); statScript.SetPower(PlayerStats.Instance().Power); statScript.SetJump(PlayerStats.Instance().Jump); }