override public TurnStepAction FindAction(Avatar currentAvatar, AvatarTurnState avatarTurnState, QuestAnalyzer mapAnalyzer, ChanceProvider chanceProvider)
		{
			List<AbstractTileAction> actionsForCurrentLocation = mapAnalyzer.GetActionsAtObserverLocation(currentAvatar);
			if (actionsForCurrentLocation.Count <= 0)
			{ return null; }

			AbstractTileAction tileAction = actionsForCurrentLocation[0];
			TurnStepAction action = new ActionableTurnStepAction(tileAction, currentAvatar);

			return action;
		}
		override public TurnStepAction FindAction(Avatar currentAvatar, AvatarTurnState avatarTurnState, QuestAnalyzer mapAnalyzer, ChanceProvider chanceProvider)
		{
			List<LocationOfInterest> interestingDestinations = mapAnalyzer.GetInterestingLocationsCheating(currentAvatar);
			if (interestingDestinations.Count <= 0)
			{ return null; }

			interestingDestinations = interestingDestinations.OrderBy(item => item.StepsToLocation).ToList();

			MovementTurnStepAction action = new MovementTurnStepAction(currentAvatar, interestingDestinations[0].StepsToLocation);
			return action;
		}
		override public TurnStepAction FindAction(Avatar currentAvatar, AvatarTurnState avatarTurnState, QuestAnalyzer mapAnalyzer, ChanceProvider chanceProvider)
		{
			PointList unwalkedTiles = mapAnalyzer.GetAdjacentUnvisitedLocations(currentAvatar);
			if (unwalkedTiles.Count <= 0)
			{ return null; }

			// Just pick the first tile, and see if that opens up any other actions...
			PointList path = new PointList() { unwalkedTiles[0] };

			MovementTurnStepAction action = new MovementTurnStepAction(currentAvatar, path);
			return action;
		}
示例#4
0
		virtual public TurnStepAction DoTakeTurnStep(QuestAnalyzer mapAnalyzer, ChanceProvider chanceProvider)
		{
			if (!IsHeroAlive) // Can't play if dead.
			{
				if (_sentDeathMessage)
				{ return null; }
				else
				{
					_sentDeathMessage = true;
					return new DeadTurnStepAction(this);
				}
			}
			if (TurnState.MovementPointsLeft <= 0 && TurnState.HasTakenAction) // We can continue our turn as long as we have movement points left, and have not taken our action
			{ return null; }

			// Determine the action to perform
			TurnStepAction action = null;
			for (int i = 0; i < _avatarClass.ActionStrategies.Count && action == null; i++)
			{
				AbstractActionStrategy strategy = _avatarClass.ActionStrategies[i];
				if (_focusAction == null || strategy.CanBreakFocus)
				{
					action = strategy.FindAction(this, TurnState, mapAnalyzer, chanceProvider);
					
					if (action != null && !MayTakeAction(action, TurnState))
					{ action = null; }

					if (action != null)
					{ _focusAction = null; }
				}
			}

			if (_focusAction != null && _focusAction.AcceptsAvatarFocus && _focusAction.HasMoreTurns) // If our focus action still has stuff to do, let it keep focus
			{
				if (MayTakeAction(_focusAction, TurnState))
				{ action = _focusAction; }
			}

			if (action == null) // If we can't figure anything else out, then end the turn.
			{
				action = new ConfusedTurnStepAction(this); // In the real game, this should never happen.  Avatars should always find *something* to do.
				TurnState.HasTakenAction = true;
				TurnState.MovementPointsLeft = 0;
			}

			if (action.AcceptsAvatarFocus && action.HasMoreTurns) // If the action is multi-step, focus on it until something interrupts us
			{ _focusAction = action; }

			return action;
		}
		private void BeginTurnCycle()
		{
			_storyTeller.StoryComplete -= OnQuestIntroductionStoryComplete;

			_turnTakers.Clear();
			foreach (Hero hero in _quest.Heroes)
			{ _turnTakers.Add(hero); }
			foreach (Monster monster in _quest.Monsters)
			{ _turnTakers.Add(monster); }

			// Make the first person in the list the current player
			_currentTurnTakerIndex = 0;
			_currentTurnTaker = _turnTakers[_currentTurnTakerIndex];
			_currentTurnTaker.StartTurn();

			_questAnalyzer = new QuestAnalyzer(_quest);
			PerformNextTurnCycle(); // Immediately take one turn
		}
		public virtual TurnStepAction FindAction(Avatar currentAvatar, AvatarTurnState avatarTurnState, QuestAnalyzer mapAnalyzer, ChanceProvider chanceProvider)
		{ return null; } // Override in subclasses
		override public TurnStepAction FindAction(Avatar currentAvatar, AvatarTurnState avatarTurnState, QuestAnalyzer mapAnalyzer, ChanceProvider chanceProvider)
		{
			List<Avatar> enemies = mapAnalyzer.GetAdjacentEnemies(currentAvatar, currentAvatar.CanAttackAdjacent);

			return null;
		}