public void poisonAttack(Battle_npc target) { int roll = Random.Range(0, 100); if (roll > 10) { target.stats.STATUS = "PSN"; Debug.Log("Snake poisons " + target.stats.NAME); } }
public void takeDamage(Battle_npc target) //<--put the target in the () { TMP_Text damageCounter = Instantiate(damagePrefab); damageCounter.transform.SetParent(canvas); damageCounter.text = this.stats.PWR.ToString(); Vector3 newPos = Camera.main.WorldToScreenPoint(target.transform.position); damageCounter.transform.position = newPos; }
public void takePoisonDamage(Battle_npc target) //<--put the target in the () { TMP_Text poisonCounter = Instantiate(poisonPrefab); poisonCounter.color = new Color(0, 0.75f, 0, 1); poisonCounter.transform.SetParent(canvas); poisonCounter.text = ailments.poisonDamage.ToString(); Vector3 newPos = Camera.main.WorldToScreenPoint(target.transform.position); poisonCounter.transform.position = newPos; }
protected void Update() { if (stats == null) { return; } //Turns stats.TIMER -= Time.deltaTime; if (stats.TIMER <= 0) { //Hero Attacks if (this.gameObject.tag == "Player") { if (this.stats.STATUS == "NA") { onAttackHero(); } if (this.stats.STATUS == "PSN") { onAttackHero(); ailments.isPoisoned(this); } } //Enemy Attacks if (this.gameObject.tag == "Enemy") { //if ( this.stats.HP > this.stats.MaxHP * 0.75f ) { //onAttackEnemy(); //} //else { Battle_npc target = onAttackEnemy(); ailments.poisonAttack(target); if (target.stats.STATUS == "PSN") { Debug.Log(target.stats.NAME + " is poisoned"); } if (target.stats.STATUS == "NA") { Debug.Log(target.stats.NAME + " did not get poisoned"); } //} } stats.TIMER = stats.SPD; } //Timer Bar timerbar.SetSize((stats.TIMER / stats.SPD)); //Damage and Death if (stats.HP <= 0) { this.isDead = true; Death(); } if (heroes[0].isDead == true && heroes[1].isDead == true && heroes[2].isDead == true) { SceneManager.LoadScene("LoseBattle"); } if (enemy.isDead == true) { Victory(); } }
public void isPoisoned(Battle_npc hero) { Debug.Log("I'm poisoned!"); hero.stats.HP -= poisonDamage; hero.takePoisonDamage(hero); }