Exemplo n.º 1
0
 public LocalStateController(IStateActionExecutor <FightState> stateActionExecutor, FightState state,
                             IFightInfoProvider fightInfoProvider, ILogger logger)
 {
     _stateActionExecutor = stateActionExecutor;
     _state             = state;
     _fightInfoProvider = fightInfoProvider;
     _logger            = logger;
 }
Exemplo n.º 2
0
        public static TileState GetTileState(this FightState state, int x, int y)
        {
            if (!ValidCoordinates(state, x, y))
            {
                Debug.LogError($"Trying to get non-valid coordinates [{x},{y}]");
            }

            return(state.tiles[x][y]);
        }
Exemplo n.º 3
0
        public static UnitState GetUnitState(this FightState state, int id)
        {
            var unit = state.units.FirstOrDefault(u => u.unitId == id);

            if (unit == null)
            {
                Debug.LogError($"There's no unit with id {id}");
            }

            return(unit);
        }
Exemplo n.º 4
0
        public static void CreateTileStates(this FightState state, int width, int height)
        {
            if (state.tiles == null)
            {
                state.tiles = new List <List <TileState> >();
            }

            for (int x = 0; x < width; x++)
            {
                state.tiles.Add(new List <TileState>());

                for (int y = 0; y < height; y++)
                {
                    state.tiles[x].Add(new TileState()
                    {
                        coordinates = new Coordinates(x, y)
                    });
                }
            }
        }
Exemplo n.º 5
0
        public static int CreateUnitState(this FightState state, UnitPrimitiveInfo info, TileState originTile, int teamId, EDirection direction)
        {
            if (state.units == null)
            {
                state.units = new List <UnitState>();
            }

            var unitState = new UnitState()
            {
                currentTile = originTile,
                teamId      = teamId,
                direction   = direction,
                info        = info,
                unitId      = state.totalUnitsCreated++,
                stats       = new BestiaryStatsSystem(BestiaryCustomComparers.Stats, info._baseStats) //TODO: make a serialization test for all state types
            };

            state.units.Add(unitState);

            return(unitState.unitId);
        }
Exemplo n.º 6
0
 private static bool ValidCoordinates(FightState state, int x, int y)
 {
     return(x >= 0 && y >= 0 && x < state.tiles.Count && y < state.tiles[x].Count);
 }