public override List <EncounterAction> _DecideNextAction(EncounterState state, Entity parent) { var unit = state.GetUnit(parent.GetComponent <UnitComponent>().UnitId); var unitComponent = parent.GetComponent <UnitComponent>(); if (unit.StandingOrder == UnitOrder.REFORM) { if (state.CurrentTurn < EncounterStateBuilder.ADVANCE_AT_TURN) { if (state.EncounterRand.Next(750) == 0) { parent.GetComponent <PositionComponent>().PlaySpeechBubble(Quips[state.EncounterRand.Next(Quips.Length)]); } } return(AIUtils.ActionsForUnitReform(state, parent, unitComponent.FormationNumber, unit)); } else if (unit.StandingOrder == UnitOrder.ADVANCE) { return(AIUtils.ActionsForUnitAdvanceInLine(state, parent, unit)); } else if (unit.StandingOrder == UnitOrder.ROUT) { return(AIUtils.ActionsForUnitRetreat(state, parent, unit)); } else { throw new NotImplementedException(); } }
public override List <EncounterAction> _DecideNextAction(EncounterState state, Entity parent) { var unit = state.GetUnit(parent.GetComponent <UnitComponent>().UnitId); var unitComponent = parent.GetComponent <UnitComponent>(); if (unit.StandingOrder == UnitOrder.REFORM) { return(AIUtils.ActionsForUnitReform(state, parent, unitComponent.FormationNumber, unit)); } else if (unit.StandingOrder == UnitOrder.ADVANCE) { return(AIUtils.ActionsForUnitAdvanceInLine(state, parent, unit)); } else if (unit.StandingOrder == UnitOrder.ROUT) { return(AIUtils.ActionsForUnitRetreat(state, parent, unit)); } else { throw new NotImplementedException(); } }
public List <EncounterAction> DecideNextActionForInput(EncounterState state, Entity parent, string actionMapping) { var unit = state.GetUnit(parent.GetComponent <UnitComponent>().UnitId); var unitComponent = parent.GetComponent <UnitComponent>(); if (actionMapping == InputHandler.ActionMapping.LEAVE_FORMATION) { parent.GetComponent <PlayerComponent>().LeaveFormation(state, parent); return(null); } if (unit.StandingOrder == UnitOrder.REFORM) { if (actionMapping == AUTOPILOT) { return(AIUtils.ActionsForUnitReform(state, parent, unitComponent.FormationNumber, unit)); } else { return(null); } } else if (unit.StandingOrder == UnitOrder.ADVANCE) { if (this.AllowedActions(state, parent, unit.StandingOrder).Contains(actionMapping)) { if (actionMapping == InputHandler.ActionMapping.ROTATE) { parent.GetComponent <AIRotationComponent>().PlayerSetRotation(true); parent.GetComponent <PlayerComponent>().AddPrestige(-2, state, "You cry out [b]'Rotation!'[/b]' and pull back through your lines. [b]You lose 2 prestige.[/b]", PrestigeSource.ROTATING); return(null); } else if (actionMapping == InputHandler.ActionMapping.WAIT) { return(new List <EncounterAction>() { new WaitAction(parent.EntityId) }); } else { return(HandleMoveCommand(state, actionMapping)); } } else if (actionMapping == AUTOPILOT) { var playerComponent = state.Player.GetComponent <PlayerComponent>(); var actions = AIUtils.ActionsForUnitAdvanceInLine(state, parent, unit); // Termination for startoflevel if (playerComponent.StartOfLevel) { var anyHostilesAdjacent = AIUtils.AdjacentHostiles(state, FactionName.PLAYER, parent.GetComponent <PositionComponent>().EncounterPosition).Count > 0; if (anyHostilesAdjacent) { state.Player.GetComponent <PlayerComponent>().StartOfLevel = false; return(null); } foreach (var action in actions) { if (action.ActionType == ActionType.MOVE) { if (AIUtils.AdjacentHostiles(state, FactionName.PLAYER, ((MoveAction)action).TargetPosition).Count > 0) { state.Player.GetComponent <PlayerComponent>().StartOfLevel = false; return(null); } } } } return(actions); } else { return(null); } } else if (unit.StandingOrder == UnitOrder.ROUT) { return(null); } else { throw new NotImplementedException(); } }