public override void Attack(Actor a, ParticleSystem blood) { Vector2 start = bulletStart.position; Vector2 end = start + a.Forward() * 15; RaycastHit2D hit; if (hit = Physics2D.Raycast(start, a.Forward(), range)) { end = new Vector2(hit.point.x, hit.point.y); Damage d = new Damage(a, hit.collider.gameObject, hit.point, damage); if (d.onActor()) { Bullet(start, end, blood); } else { Bullet(start, end, spark); } d.Apply(); } else { Bullet(start, end, null); } }
public void TakeDamage() { var barrelCharacter = new CharacterBuilder() .Attributes(new AttributesBuilder() .Health(50) .Defense(0) .Build()) .Build(); var fuckingBarrel = new BaseCombatant(barrelCharacter, ArmyType.Other); var damage = new Damage(100); damage.Apply(fuckingBarrel); Assert.AreEqual(0, fuckingBarrel.Health); Assert.IsFalse(fuckingBarrel.IsAlive); }
private void SendDamage() { if (damageRange > 0 && Damage != null) { Damage.Sender = sender; // 如果伤害有阵营等附加信息,在 Sender 中携带。 int victimNum = GetVictimsByLayer(colliders); for (int i = 0; i < victimNum; i++) { Damage.Apply(colliders[i].gameObject, colliders[i].transform.position - xform.position); } } if (onComplete != null) { onComplete(); } }
public override void Use(ICombatant combatant) { var heal = new Damage(-10); heal.Apply(combatant); }