Ejemplo n.º 1
0
        public void Execute(EnemyProperties enemy, AttackAction attack)
        {
            var tile            = gameState.GetActiveTile();
            var positions       = tile.GetPositions();
            var currentPosition = positions.First(p => p.HasUnit(enemy.gameObject));

            var targetsInRange = attack.FindTargetsInWeaponRange(enemy, currentPosition, positions);
            var target         = FindClosestTarget(currentPosition, attack.TargetPreference, targetsInRange);

            if (target == null)
            {
                EventManager.RaiseEvent(ObjectEventType.AttackApplied, attack);
            }
            else
            {
                EventManager.RaiseEvent(ObjectEventType.AttackSelected, attack);
                EventManager.RaiseEvent(GameObjectEventType.UnitSelected, target);
            }
        }
Ejemplo n.º 2
0
        private void FindAllPotentialTargets()
        {
            var tile            = GameStateManager.Instance.GetActiveTile();
            var currentPosition = tile.GetUnitPosition(attackerRecieved.gameObject);
            var positions       = tile.GetPositions();
            var allTargets      = attackRecieved.FindTargetsInWeaponRange(attackerRecieved, currentPosition, positions);

            if (allTargets.Contains(defenderCurrent))
            {
                var targetPosition = tile.GetUnitPosition(defenderCurrent.gameObject);
                var finalTargets   = attackRecieved.FindTargetsOnNode(attackerRecieved, targetPosition, defenderCurrent);

                foreach (var target in finalTargets)
                {
                    defensesToResolve.Add(target);
                    target.ShowTargetableBrillance();
                }
            }
            else
            {
                throw new System.Exception();
            }
        }