Ejemplo n.º 1
0
    public static CaseData[][] GenerateMap(int sizeX, int sizeY, int seed)
    {
        Random.seed = seed;

        CaseData[][] map = EmptyMap(sizeX, sizeY);

        // Begin

        var sectorGenerator = new SectorGenerator {
            Height       = sizeY - 2,
            Width        = 2,
            NumberByType =
            {
                { CaseData.Obstacle, 4 }
            }
        };

        sectorGenerator.GenerateSector(map, 2, 1);

        // Center

        sectorGenerator = new SectorGenerator {
            Height       = sizeY - 2,
            Width        = SectorWidth,
            NumberByType =
            {
                { CaseData.Obstacle, ObstaclesNumberBySector },
                { CaseData.Stone,    StonesNumberBySector    }
            }
        };

        for (int i = 0; i < sizeX / SectorWidth - 1; i++)
        {
            int redMinesNumber = Random.Range(MinesNumberBySector / 2 - MinesNumberBySector / 3,
                                              MinesNumberBySector / 2 + MinesNumberBySector / 3);

            sectorGenerator.NumberByType[CaseData.RedMines]   = redMinesNumber;
            sectorGenerator.NumberByType[CaseData.GreenMines] = MinesNumberBySector - redMinesNumber;
            sectorGenerator.GenerateSector(map, 4 + i * SectorWidth, 1);
        }

        // End

        sectorGenerator = new SectorGenerator {
            Height       = sizeY - 2,
            Width        = 1,
            NumberByType =
            {
                { CaseData.Obstacle, 2 }
            }
        };

        sectorGenerator.GenerateSector(map, 4 + (sizeX / SectorWidth - 1) * SectorWidth, 1);

        return(map);
    }
Ejemplo n.º 2
0
    public static CaseData[][] GenerateMap(int sizeX, int sizeY, int seed)
    {
        Random.seed = seed;

        CaseData[][] map = EmptyMap(sizeX, sizeY);

        // Begin

        var sectorGenerator = new SectorGenerator {
            Height = sizeY - 2,
            Width = 2,
            NumberByType =
                {
                    {CaseData.Obstacle, 4}
                }
        };

        sectorGenerator.GenerateSector(map, 2, 1);

        // Center

        sectorGenerator = new SectorGenerator {
            Height = sizeY - 2,
            Width = SectorWidth,
            NumberByType =
                {
                    {CaseData.Obstacle, ObstaclesNumberBySector},
                    {CaseData.Stone, StonesNumberBySector}
                }
        };

        for (int i = 0; i < sizeX / SectorWidth - 1; i++)
        {
            int redMinesNumber = Random.Range(MinesNumberBySector / 2 - MinesNumberBySector / 3,
                MinesNumberBySector / 2 + MinesNumberBySector / 3);

            sectorGenerator.NumberByType[CaseData.RedMines] = redMinesNumber;
            sectorGenerator.NumberByType[CaseData.GreenMines] = MinesNumberBySector - redMinesNumber;
            sectorGenerator.GenerateSector(map, 4 + i * SectorWidth, 1);
        }

        // End

        sectorGenerator = new SectorGenerator {
            Height = sizeY - 2,
            Width = 1,
            NumberByType =
                {
                    {CaseData.Obstacle, 2}
                }
        };

        sectorGenerator.GenerateSector(map, 4 + (sizeX / SectorWidth - 1) * SectorWidth, 1);

        return map;
    }
Ejemplo n.º 3
0
    private void NewSectorLoaded(AsyncOperation operation)
    {
        operation.completed -= NewSectorLoaded;

        // Generate the sector
        sectorGrid = SectorGenerator.GenerateSectorGrid(_sector);
        for (int i = 0; i < sectorGrid.GetLength(0); i++)
        {
            for (int j = 0; j < sectorGrid.GetLength(1); j++)
            {
                if (sectorGrid[i, j] >= 0)
                {
                    Vector3    pos = new Vector3(i * _sector.GridSize, 0f, j * _sector.GridSize) - new Vector3(_sector.TotalSize / 2f, 0f, _sector.TotalSize / 2f);
                    GameObject poi = Instantiate(_sector.POIList[sectorGrid[i, j]], pos, Quaternion.identity);
                    MessagePublisher.Instance.PublishMessage(new POICreatedMessage(this, poi));
                }
            }
        }
    }
Ejemplo n.º 4
0
 public static string Generate(string template, Faction protagonist, Faction antagonist, Faction wildcard) => string.Format(template, protagonist.Name, antagonist.Name, wildcard.Name, SectorGenerator.Generate());