public void DrawUpcomingStates(ScenarioState currentState, List <ProjectedGameState> upcomingStates) { Clear(); drawingSelectedEntity = true; EntityData lastActiveEntity = null; for (int i = 0; i < upcomingStates.Count; i++) { ProjectedGameState projectedState = upcomingStates[i]; if (projectedState.IsDummyState) { continue; } ProjectedGameState nextState = i == upcomingStates.Count - 1 ? null : upcomingStates[i + 1]; DrawState(projectedState, nextState, lastActiveEntity); lastActiveEntity = projectedState.activeEntity; } DrawItemDurations(currentState.items); DrawEntityHealths(currentState.GetAllEntities()); }
static ProjectedGameState GetNextGameStateFromAction(ScenarioState lastState, EntityData entity, Action action) { ScenarioState newState = lastState.DeepCopy(); newState.lastGameState = lastState; EntityData entityCopy = newState.GetAllEntities().Find(e => entity.ID == e.ID); // TODO: This is pretty bare-bones right now because it isn't clear how other card categories will be // implemented--need to get it more set up once the basic structure of the state list is running. switch (action.card.category) { case CardCategory.Movement: return(GetNextGameStateFromMove(newState, entityCopy, action.direction)); case CardCategory.Attack: return(GetNextStateFromAction_Attack(newState, entityCopy, action)); case CardCategory.Self: return(GetNextStateFromAction_Self(newState, entityCopy, action)); default: return(GetNextGameStateFromMove(newState, entityCopy, action.direction)); } }
static ProjectedGameState GetNextGameStateFromMove(ScenarioState lastState, EntityData entity, Direction move) { ScenarioState newState = lastState.DeepCopy(); newState.lastGameState = lastState; EntityData entityCopy = newState.GetAllEntities().Find(e => entity.ID == e.ID); Tile currentEntityTile = BoardController.CurrentBoard.GetTileAtPosition(entityCopy.Position); Action stateAction = new Action(GenericMovementCard, entity, move, 1); // If entity can't move that direction, return state as-is. if (!currentEntityTile.ConnectsToNeighbor(move)) { return(new ProjectedGameState(entityCopy, newState, stateAction)); } Tile nextTile = currentEntityTile.GetDirectionalNeighbor(move); // If tile is empty, move entity there and return. if (!newState.IsTileOccupied(nextTile)) { entityCopy.SetPosition(nextTile.Position, newState); return(new ProjectedGameState(entityCopy, newState, stateAction)); } EntityData tileOccupant = newState.GetTileOccupant(nextTile.Position); ResolveBump(entity, tileOccupant, move, newState); Bump bump = new Bump(entityCopy, tileOccupant); return(new ProjectedGameState(entityCopy, newState, stateAction, bump)); }
public static void CollectFinishMoveItems(this ScenarioState state) { List <EntityData> allEntities = state.GetAllEntities(); for (int i = 0; i < allEntities.Count; i++) { EntityData entity = allEntities[i]; ItemData itemAtEntityPosition = state.GetItemInPosition(entity.Position); if (itemAtEntityPosition == null) { continue; } state.CollectItem(itemAtEntityPosition, entity); } }
public static bool HasEntityWhere(this ScenarioState state, Predicate <EntityData> predicate) { return(state.GetAllEntities().Any(e => predicate(e))); }
public static List <EntityData> GetAllEntitiesWhere(this ScenarioState state, Predicate <EntityData> predicate) { return(state.GetAllEntities().FindAll(e => predicate(e)).ToList()); }
public static EntityData GetEntityWhere(this ScenarioState state, Predicate <EntityData> predicate) { return(state.GetAllEntities().Find(e => predicate(e))); }