Example #1
0
        private void PlayerTurnSignalListener(ITurnAction turnAction)
        {
            if (!(turnAction is MoveTurnAction))
            {
                throw new System.ArgumentException(
                          "Expecting only " + typeof(MoveTurnAction) + " as player turn action");
            }

            PositionHolder positionHolder;

            if (!field.TryGetPositionHolder(turnAction.TargetPosition, out positionHolder) ||
                positionHolder is Exit)
            {
                turnAction.Perform();
                turnAction.Complete += TurnActionComplete;
                return;
            }

            Character enemy = positionHolder as Character;

            if (enemy != null)
            {
                AttackTurnAction attackPerformer = attackPerformerFactory.Create(
                    field.Player, enemy);
                attackPerformer.Perform();
                attackPerformer.Complete += TurnActionComplete;

                return;
            }
        }
Example #2
0
        private void WaitForEnemyTurnSignal(Character enemy)
        {
            Character   player     = field.Player;
            ITurnAction turnAction =
                attackPossibility.IsPossible(enemy, player)
                                        ? attackTurnActionFactory.Create(enemy, player) as ITurnAction
                                        : moveTurnActionFactory.Create(
                    enemy, enemyMovePositionPicker.PickPosition(enemy));

            enemyTurnSignal.Fire(turnAction);
        }