// Start is called before the first frame update public void Start() { this.Init(); this.currentHealth = this.GetMaxHealth(); this.sfxManager = FindObjectOfType <SFXManager>(); if (this.uiManager == null) { this.uiManager = FindObjectOfType <UIManager>(); } if (this.sceneManager == null) { this.sceneManager = FindObjectOfType <RPGWorldCapstone.SceneManager>(); } }
// Update is called once per frame public void Update() { if (this.sceneManager == null) { this.sceneManager = FindObjectOfType <RPGWorldCapstone.SceneManager>(); } if (this.currentHealth <= 0 && this.gameObject.tag != "Player") { gameObject.SetActive(false); } if (this.gameObject.tag == "Player") { this.TryToLevelUp(); } if (this.flashAfterTakingDamage) { if (this.flashAfterTakingDamageCounter > this.flashAfterTakingDamageLength * .66f) { this.spriteRenderer.color = new Color(this.spriteRenderer.color.r, this.spriteRenderer.color.g, this.spriteRenderer.color.b, 0f); } else if (this.flashAfterTakingDamageCounter > this.flashAfterTakingDamageLength * .33f) { this.spriteRenderer.color = new Color(this.spriteRenderer.color.r, this.spriteRenderer.color.g, this.spriteRenderer.color.b, 1f); } else if (this.flashAfterTakingDamageCounter > 0) { this.spriteRenderer.color = new Color(this.spriteRenderer.color.r, this.spriteRenderer.color.g, this.spriteRenderer.color.b, 0f); } else { this.spriteRenderer.color = new Color(this.spriteRenderer.color.r, this.spriteRenderer.color.g, this.spriteRenderer.color.b, 1f); this.flashAfterTakingDamage = false; } this.flashAfterTakingDamageCounter -= Time.deltaTime; } }