Exemple #1
0
        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);
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
 public void AttackStart_Fire(GameActor attacker, GameActor victim)
 {
     AttackStart(attacker, victim);
 }
Exemple #4
0
 public void AttackWillCrit_Fire(GameActor attacker, GameActor victim)
 {
     AttackWillCrit(attacker, victim);
 }
Exemple #5
0
 public void ActorTargetedChange_Fire(GameActor a)
 {
     ActorTargetedChange(a);
 }
Exemple #6
0
 public void ActorPositionChange_Fire(GameActor a, Point <int> old)
 {
     ActorPositionChange(a, old);
 }
Exemple #7
0
 public void ActorActionsStart_Fire(Game g, GameActor a)
 {
     ActorActionsStart(g, a);
 }
Exemple #8
0
 public void ActorActionsEnd_Fire(Game g, GameActor a)
 {
     ActorActionsEnd(g, a);
 }
Exemple #9
0
 public void ActorRemoved_Fire(Game g, GameActor a)
 {
     ActorRemoved(g, a);
 }
Exemple #10
0
 public void ActorAdded_Fire(Game g, GameActor a)
 {
     ActorAdded(g, a);
 }
Exemple #11
0
 public void Death_Fire(GameActor a)
 {
     Death(a);
 }
Exemple #12
0
 public void ActorHealthChange_Fire(GameActor a, float oldHealth, float newHealth)
 {
     ActorHealthChange(a, oldHealth, newHealth);
 }
Exemple #13
0
 public void AttackEnd_Fire(GameActor attacker, GameActor victim)
 {
     AttackEnd(attacker, victim);
 }