Exemple #1
0
        public Map(StartRaw startingData)
        {
            this.Raw  = startingData;
            this.Size = startingData.MapSize;

            placementGridOriginal = new MapArray <byte>(startingData.PlacementGrid.Data.ToByteArray(), this.Size);
            placementGrid         = new MapArray <byte>(placementGridOriginal);
            pathingGrid           = new MapArray <byte>(startingData.PathingGrid.Data.ToByteArray(), this.Size);
            heightGrid            = new MapArray <byte>(startingData.TerrainHeight.Data.ToByteArray(), this.Size);
            creepGrid             = new MapArray <byte>(startingData.TerrainHeight.Data.ToByteArray(), this.Size);

            this.structuresAndDeposits     = new MapArray <Unit>(this.Size);
            this.structuresAndDepositsList = new List <Unit>();

            GeneratePadding(startingData);

            this.structurePadding = new MapArray <bool>(this.Size);
            this.resourcePadding  = new MapArray <bool>(this.Size);

            // Not gonna work for anything but 1-on-1 games, but it seems like
            // it doesn't give this player's location, just the enemy's.
            var enemyStart = startingData.StartLocations.Single();

            this.enemyStartLocation = new Location {
                X = (int)enemyStart.X, Y = (int)enemyStart.Y
            };
        }
Exemple #2
0
        private void GenerateColonies(StartRaw startRaw)
        {
            Colonies = MapAnalyser.GetColonies(MineralFields.Values.Cast <IUnit>().ToList(), VespeneGeysers.Values.Cast <IUnit>().ToList(), startRaw.StartLocations);
            // Find Primary Colony
            var mainBase = StructuresSelf.First();
            var primary  = (IntelColony)mainBase.Value.Pos.ConvertTo2D().GetClosest(Colonies);

            primary.Workers    = WorkersSelf.Select(kvp => (IUnit)kvp.Value).ToList();
            primary.Structures = new List <IUnit> {
                mainBase.Value
            };
            PrimaryColony = primary;
        }
Exemple #3
0
        private void GeneratePadding(StartRaw startingData)
        {
            this.padding = new MapArray <bool>(this.Size);

            for (var x = 0; x < Size.X; x++)
            {
                for (var y = 0; y < Size.Y; y++)
                {
                    if (placementGrid[x, y] == 0)
                    {
                        SetAdjacentSpaces(this.padding, x, y);
                    }
                }
            }
        }
Exemple #4
0
        public MapData(StartRaw startingData)
        {
            this.Raw  = startingData;
            this.Size = startingData.MapSize;

            pathingGrid   = new MapArray <byte>(startingData.PathingGrid.Data.ToByteArray(), this.Size);
            placementGrid = new MapArray <byte>(startingData.PlacementGrid.Data.ToByteArray(), this.Size);
            heightGrid    = new MapArray <byte>(startingData.TerrainHeight.Data.ToByteArray(), this.Size);

            this.structuresAndDeposits = new MapArray <Unit>(this.Size);

            GeneratePadding(startingData);

            this.areas    = GetAreas();
            this.deposits = new List <Deposit>();

            this.structurePadding = new MapArray <bool>(this.Size);
        }