예제 #1
0
        private void PrepareTiles()
        {
            int   xDim                = Constants.mapWidth / 2;
            int   yDim                = Constants.mapHeight / 2;
            int   enemyBaseX          = xDim - Constants.xMargin;
            int   enemyBaseY          = yDim - Constants.yMargin;
            float creepSpreadModifier = Mathf.Pow((Constants.mapWidth / 5f), 2f);

            foreach (IHexGridCell tile in HexTiling.AllCells)
            {
                Point <int>       gridPoint        = tile.Position.GridPoint;
                bool              activeCreep      = (Mathf.Pow(gridPoint.X - enemyBaseX, 2f) / creepSpreadModifier) + (Mathf.Pow(gridPoint.Y - enemyBaseY, 2f) / creepSpreadModifier) - Random.Range(0, 0.2f) < 1;
                ITerrainComponent terrainComponent = GetTileTerrain(tile);
                tile.AddComponent(terrainComponent);
                if (!(terrainComponent is RiverTerrainComponent))
                {
                    tile.AddComponent(new CreepComponent(activeCreep));
                }
            }

            IDictionary <IHexGridCell, bool> baseTerrains = new Dictionary <IHexGridCell, bool>();

            CreateBase(-xDim + Constants.xMargin, -yDim + Constants.yMargin, true, baseTerrains);
            CreateBase(enemyBaseX, enemyBaseY, false, baseTerrains);

            foreach (KeyValuePair <IHexGridCell, bool> tileTerrains in baseTerrains)
            {
                tileTerrains.Key.RemoveComponent <ITerrainComponent>();
                ITerrainComponent newTerrain = (tileTerrains.Value) ? (new PlayerTerritoryTerrainComponent() as ITerrainComponent)
                    : new EnemyTerritoryTerrainComponent();
                newTerrain.Height     = GetTileHeight(tileTerrains.Key);
                newTerrain.WaterLevel = GetTileWaterLevel(tileTerrains.Key);
                tileTerrains.Key.AddComponent(newTerrain);
            }

            foreach (ITown town in Town.GetAllTowns())
            {
                if (town.ID == 0)
                {
                    continue;
                }
                HexTiling[town.X, town.Y].AddComponent(new TownComponent(town, townCanvasController));
            }
        }
예제 #2
0
 public void Remove(ITerrainComponent tc)
 {
     components.Remove(tc);
 }
예제 #3
0
 public void Add(ITerrainComponent tc)
 {
     components.Add(tc);
 }