static bool IsFacing(GameActor a, GameActor b) { // actor with no direction faces everyone. Making this choice because a) directionality is // something we added later, and this keeps things backwards-compatible (and makes old tests pass), // and b) you can rationalize it to make sense in a game world, somehow if (a.dir == PointUtil.zero) { return(true); } var deltaPos = b.pos.x - a.pos.x; if (deltaPos > 0) { return(a.dir == PointUtil.right); } return(a.dir == PointUtil.left); }
public void Attack(GameActor other) { if (other == null) { throw new ArgumentNullException(nameof(other), "other actor is null"); } if (Weapon != null) { if (!IsFacing(this, other)) { dir = Flip(dir); } GameEvents.Instance.AttackStart_Fire(this, other); float critMultiplier = 1; if (!IsFacing(other, this)) { critMultiplier = Weapon.critMultiplier; GameEvents.Instance.AttackWillCrit_Fire(this, other); } other.TakeDamage(Weapon.damage * critMultiplier); GameEvents.Instance.AttackEnd_Fire(this, other); } }
public void AttackStart_Fire(GameActor attacker, GameActor victim) { AttackStart(attacker, victim); }
public void AttackWillCrit_Fire(GameActor attacker, GameActor victim) { AttackWillCrit(attacker, victim); }
public void ActorTargetedChange_Fire(GameActor a) { ActorTargetedChange(a); }
public void ActorPositionChange_Fire(GameActor a, Point <int> old) { ActorPositionChange(a, old); }
public void ActorActionsStart_Fire(Game g, GameActor a) { ActorActionsStart(g, a); }
public void ActorActionsEnd_Fire(Game g, GameActor a) { ActorActionsEnd(g, a); }
public void ActorRemoved_Fire(Game g, GameActor a) { ActorRemoved(g, a); }
public void ActorAdded_Fire(Game g, GameActor a) { ActorAdded(g, a); }
public void Death_Fire(GameActor a) { Death(a); }
public void ActorHealthChange_Fire(GameActor a, float oldHealth, float newHealth) { ActorHealthChange(a, oldHealth, newHealth); }
public void AttackEnd_Fire(GameActor attacker, GameActor victim) { AttackEnd(attacker, victim); }