void ProceduralGeneration(ProcGenTypes procGen) { if (procGen == ProcGenTypes.DEFAULT) //Middle 4 squares open { for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { if (x > 2 && x < 5 && y > 2 && y < 5) { Tiles[x, y].lightValue = true; } else { Tiles[x, y].lightValue = false; } } } } else if (procGen == ProcGenTypes.RANDOM) { for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { if (Random.Range(0f, 1f) <= 0.25f) { Tiles[x, y].lightValue = true; } } } } else if (procGen == ProcGenTypes.PERLIN) { float scale = 2f; float xOrg = 20f * Random.Range(-10f, 10f); float yOrg = 20f * Random.Range(-10f, 10f); for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { float xCoord = ((xOrg + x) / Width) * scale; float yCoord = ((yOrg + y) / Height) * scale; float height = Mathf.PerlinNoise(xCoord, yCoord) * 10f; if (height >= 4) { Tiles[x, y].lightValue = true; } } } } }
public GameState(int width, int height, ProcGenTypes procGen, int startingEnergy) { Moves = new List <Move>(); Width = width; Height = height; Tiles = new Tile[Width, Height]; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { Tiles[x, y].unit.energy = startingEnergy; Tiles[x, y].unit.team = Teams.NONE; Tiles[x, y].possibleMove = Teams.NONE; Tiles[x, y].x = x; Tiles[x, y].y = y; } } ProceduralGeneration(procGen); PlacePieces(); }