Beispiel #1
0
        public Cell GetNeighbor(Direction direction, CellGrid cellGrid)
        {
            var world = CallContext <World> .GetData("GameWorld");

            var neighbor = world.HexLibrary.GetNeighbor(new HexOffsetCoordinates(Column, Row), direction);

            var cell = cellGrid.GetCell(neighbor.Col, neighbor.Row);

            return(cell);
        }
Beispiel #2
0
        public Settlement(string name, int raceId, PointI location, byte settlementSize, CellGrid cellGrid, int[] buildingIds)
        {
            _gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache");

            _id = location.Y * Constants.WORLD_MAP_COLUMNS + location.X;

            Name               = name;
            Race               = _gameConfigCache.GetRaceConfigById(raceId);
            Location           = location;
            _populationGrowth  = 0;
            _currentlyBuilding = new CurrentlyBuilding(-1, -1, -1, 0);
            _buildingsBuilt    = new List <int>();
            foreach (var buildingId in buildingIds)
            {
                _buildingsBuilt.Add(buildingId);
            }
            Citizens = new SettlementCitizens(this, settlementSize, _buildingsBuilt);

            // control
            _catchmentCells = cellGrid.GetCatchment(location.X, location.Y, 2);
            foreach (var item in _catchmentCells)
            {
                var cell = cellGrid.GetCell(item.Column, item.Row);
                cellGrid.SetCell(cell, cell.SeenState, 1);
            }
            _catchmentCells = cellGrid.GetCatchment(location.X, location.Y, 2);
            cellGrid.CellFactionChange(_catchmentCells);

            // sight
            _seenCells = cellGrid.GetCatchment(location.X, location.Y, 3);
            foreach (var item in _seenCells)
            {
                var cell = cellGrid.GetCell(item.Column, item.Row);
                cellGrid.SetCell(cell, SeenState.CurrentlySeen);
            }
        }
Beispiel #3
0
        public List <Cell> GetNeighbors(CellGrid cellGrid)
        {
            var world = CallContext <World> .GetData("GameWorld");

            var neighbors = world.HexLibrary.GetSingleRing(new HexOffsetCoordinates(Column, Row), 1);

            var returnCells = new List <Cell>();

            foreach (var neighbor in neighbors)
            {
                var cell = cellGrid.GetCell(neighbor.Col, neighbor.Row);

                if (cell != Empty)
                {
                    returnCells.Add(cell);
                }
            }

            return(returnCells);
        }