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