public void OnTriggerEnter2D(Collider2D collision) { if (!collision.CompareTag("Player")) { if (collision.CompareTag("enemy") || collision.CompareTag("enemy_rt") || collision.CompareTag("enemy_goomba") || collision.CompareTag("boss")) { IMonster monster = collision.gameObject.GetComponent <IMonster>(); monster.TakeDamage(); monster.TakeDamage(); monster.ObserveHP(); } } }
public virtual AttackResult Attack(IMonster target) { bool isHit = false; int damage = 0; // Let's do some placeholder logic for calculating damage. double dexDiff = (this.Dexterity - target.Dexterity) / 10.0; isHit = Game.Current.RNG.NextDouble() < (BaseToHitChance + dexDiff); if(isHit) { damage = BaseDamage + (this.Strength - target.Constitution); damage += Game.Current.RNG.Next(-2, 2); AttackResult result = new AttackResult(isHit, damage); target.TakeDamage(result); return result; } else { return AttackResult.Miss; } }
public static void HeroAttack(Hero hero, IMonster monster, Skill attack) { CombatDisplay(hero, monster); PlayerAttack(hero, attack); System.Threading.Thread.Sleep(1500); PlayerAttackDisplay(hero, monster); PlayerAttack(hero, attack); System.Threading.Thread.Sleep(1500); monster.TakeDamage(attack.Damage); CombatDisplay(hero, monster); }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.CompareTag("enemy") || coll.gameObject.CompareTag("enemy_rt") || coll.gameObject.CompareTag("enemy_goomba") || coll.gameObject.CompareTag("boss")) { Destroy(this.transform.parent.gameObject); IMonster bt = coll.gameObject.GetComponent <IMonster>(); bt.TakeDamage(); bt.ObserveHP(); Hit(coll.transform.position); } else if (coll.gameObject.CompareTag("rock")) { Destroy(this.transform.parent.gameObject); Hit(coll.transform.position); } }