public void NewAutomata()
 {
     _automata.Destroy();
     if(Seed.text.ToLower() == "random")
         _automata = new CellularAutomata(int.Parse(Width.text), int.Parse(Height.text), new System.Random());
     else
         _automata = new CellularAutomata(int.Parse(Width.text), int.Parse(Height.text), new System.Random());
     _automata.Player = DungeonSpawner.Player;
 }
Beispiel #2
0
        void Awake()
        {
            _automata        = new CellularAutomata(100, 100, new System.Random());
            _hexAutomata     = new HexCellularAutomata(100, 100, new System.Random());
            _automata.Player = DungeonSpawner.Player;

            Height.text = "100";
            Width.text  = "100";
            Seed.text   = "random";
        }
Beispiel #3
0
 public void NewAutomata()
 {
     _automata.Destroy();
     if (Seed.text.ToLower() == "random")
     {
         _automata = new CellularAutomata(int.Parse(Width.text), int.Parse(Height.text), new System.Random());
     }
     else
     {
         _automata = new CellularAutomata(int.Parse(Width.text), int.Parse(Height.text), new System.Random());
     }
     _automata.Player = DungeonSpawner.Player;
 }
Beispiel #4
0
        private void SpawnGrassMultiple()
        {
            //Get a random number of water spots:
            int waterSpots = _rnd.Next(4, 15);

            Debug.Log("OnSpawnGrass: " + waterSpots);
            int sizeX;
            int sizeY;
            int posX;
            int posY;


            //Setup a random cellular automata for each spot:
            CellularAutomata[] water = new CellularAutomata[waterSpots];
            for (int i = 0; i < waterSpots; i++)
            {
                //Get a random size for the cellular automata:
                //sizeX = _rnd.Next(4, 11);
                sizeY    = _rnd.Next(20, 30);
                sizeX    = sizeY + 2;
                water[i] = new CellularAutomata(sizeX, sizeY, _rnd);
                water[i].RandomFillMap();
                water[i].PlaceWalls_1D5678_2D1(4);

                //Select a random position for the water in the actual grid:
                posX = _rnd.Next(0, _mapWidth - sizeX);
                posY = _rnd.Next(0, _mapHeight - sizeY);
                //Merge the water map and the current map:
                for (int x = 0; x < water[i]._mapWidth; x++)
                {
                    for (int y = 0; y < water[i]._mapHeight; y++)
                    {
                        if (water[i].Map[x + y * water[i]._mapHeight].BasicValue == 0)
                        {
                            if (_map[(posX + x) + (posY + y) * _mapHeight].BasicValue != 1 && _map[(posX + x) + (posY + y) * _mapHeight].BasicValue != 2)
                            {
                                _map[(posX + x) + (posY + y) * _mapHeight].BasicValue = 3;
                            }
                        }
                    }
                }
            }
        }
        void Awake()
        {
            _automata = new CellularAutomata(100, 100, new System.Random());
            _hexAutomata = new HexCellularAutomata(100, 100, new System.Random());
            _automata.Player = DungeonSpawner.Player;

            Height.text = "100";
            Width.text = "100";
            Seed.text = "random";
        }
 void Start()
 {
     //BuildDungeon(Random.Range(7, 20));
     _automata = new CellularAutomata(100, 100, new System.Random());
 }
 void Start()
 {
     //BuildDungeon(Random.Range(7, 20));
     _automata = new CellularAutomata(100, 100, new System.Random());
 }
        private void SpawnWaterMultiple()
        {
            //Get a random number of water spots:
            int waterSpots = _rnd.Next(4, 15);
            Debug.Log("OnSpawnWater: " + waterSpots);
            int sizeX;
            int sizeY;
            int posX;
            int posY;

            //Setup a random cellular automata for each spot:
            CellularAutomata[] water = new CellularAutomata[waterSpots];
            for (int i = 0; i < waterSpots; i++)
            {
                //Get a random size for the cellular automata:
                //sizeX = _rnd.Next(4, 11);
                sizeY = _rnd.Next(8, 15);
                sizeX = sizeY +_rnd.Next(0, 5);
                water[i] = new CellularAutomata(sizeX, sizeY, _rnd);
                water[i].RandomFillMap();
                water[i].PlaceWalls_1D5678_2D1(3);

                //Select a random position for the water in the actual grid:
                posX = _rnd.Next(0, _mapWidth - sizeX);
                posY = _rnd.Next(0, _mapHeight - sizeY);
                //Merge the water map and the current map:
                for (int x = 0; x < water[i]._mapWidth; x++)
                {
                    for (int y = 0; y < water[i]._mapHeight; y++)
                    {
                        if (water[i].Map[x + y * water[i]._mapHeight].BasicValue == 0)
                        {
                            _map[(posX + x) + (posY + y) * _mapHeight].BasicValue = 2;
                        }
                    }
                }
            }
        }