示例#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);
 }