/// <summary>
        /// Called to start an AI's turn.
        /// <para>Throws an exception if the AI returns a null ActionBase.</para>
        /// </summary>
        private void StartAITurn()
        {
            var aiDecision = _combatAI.GetAIDecision(CombatStateHandler.CurrentRoundOrder[0],
                                                     CombatStateHandler.EnemyCharacters,
                                                     CombatStateHandler.PlayerCharacters);

            if (aiDecision.ActionChoice == null)
            {
                throw new Exception("AI action choice cannot be null.");
            }

            // Invoke AIChoseTarget event once the AI has come to a decision.
            if (AIChoseTarget != null)
            {
                var eventArgs = new AIChoseTargetEventArgs()
                {
                    AICharacter     = CombatStateHandler.CurrentRoundOrder[0],
                    CenterOfTarget  = aiDecision.TargetPosition,
                    TargetPositions = AITargets.GetModifiedSelection(aiDecision.ActionChoice, aiDecision.TargetPosition)
                };
                AIChoseTarget(this, eventArgs);
            }

            StartAIAction(aiDecision.ActionChoice, aiDecision.TargetPosition);

            // todo: Create class to handle consumables
            if (aiDecision.ConsumableUsed != null)
            {
                _consumablesHandler.UseConsumable(aiDecision.ConsumableUsed,
                                                  CombatStateHandler.CurrentRoundOrder[0]);
            }
        }
Example #2
0
        /// <summary>
        /// Called whenever an AI has chosen an action and it's target. Refreshes the UI to visualize
        /// the selection.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnAIChoseTarget(object sender, AIChoseTargetEventArgs args)
        {
            int msWait = 1000;
            int frames = 2;

            _defaultsHandler.CurrentTargetPositions = args.TargetPositions;
            _defaultsHandler.IsInFormationPanel     = true;
            _uiContainer.PrintUI(frames, msWait);
        }