void OnControllerColliderHit(ControllerColliderHit hit) { GameObject go = GameObject.FindGameObjectWithTag("Player"); MainPjMovement target = go.GetComponent("MainPjMovement") as MainPjMovement; if (target.getHP() != target.getMAXHP()) { if (hit.gameObject.tag == "BigHealPotion") { PJAudio.DrinkPotion(); target.increaseHeal(200); Destroy(hit.gameObject); } if (hit.gameObject.tag == "LittleHealPotion") { PJAudio.DrinkPotion(); target.increaseHeal(100); Destroy(hit.gameObject); } } if (target.getMP() != target.getMAXMP()) { if (hit.gameObject.tag == "BigManaPotion") { target.increaseMana(200); Destroy(hit.gameObject); } if (hit.gameObject.tag == "BigManaPotion") { target.increaseMana(100); Destroy(hit.gameObject); } } if (hit.gameObject.tag == "Shield") { target.setShield(true); Destroy(hit.gameObject); } }
// Update is called once per frame void Update() { if (this.time > 0) { this.time -= Time.deltaTime; } else { this.time = 1.0f; if (pj.isAlive()) { pj.increaseHeal(pj.getRegenHP()); pj.increaseMana(pj.getRegenMP()); } } }