Exemple #1
0
    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());
    }
Exemple #2
0
    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));
        }
    }
Exemple #3
0
    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));
    }
Exemple #4
0
    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);
        }
    }
Exemple #5
0
 public static bool HasEntityWhere(this ScenarioState state, Predicate <EntityData> predicate)
 {
     return(state.GetAllEntities().Any(e => predicate(e)));
 }
Exemple #6
0
 public static List <EntityData> GetAllEntitiesWhere(this ScenarioState state, Predicate <EntityData> predicate)
 {
     return(state.GetAllEntities().FindAll(e => predicate(e)).ToList());
 }
Exemple #7
0
 public static EntityData GetEntityWhere(this ScenarioState state, Predicate <EntityData> predicate)
 {
     return(state.GetAllEntities().Find(e => predicate(e)));
 }