Ejemplo n.º 1
0
    public int[,] genTilePos(int[,] oldMap, TerrainProbabilities _terrainInits)
    {
        int[,] newMap = new int[width, height];
        int       neighb;
        BoundsInt myB = new BoundsInt(-1, -1, 0, 3, 3, 1);


        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                neighb = 0;
                foreach (var b in myB.allPositionsWithin)
                {
                    if (b.x == 0 && b.y == 0)
                    {
                        continue;
                    }
                    if (x + b.x >= 0 && x + b.x < width && y + b.y >= 0 && y + b.y < height)
                    {
                        neighb += oldMap[x + b.x, y + b.y];
                    }
                    else
                    {
                        neighb++;
                    }
                }

                if (oldMap[x, y] == 1)
                {
                    if (neighb < _terrainInits.deathLimit)
                    {
                        newMap[x, y] = 0;
                    }

                    else
                    {
                        newMap[x, y] = 1;
                    }
                }

                if (oldMap[x, y] == 0)
                {
                    if (neighb > _terrainInits.birthLimit)
                    {
                        newMap[x, y] = 1;
                    }

                    else
                    {
                        newMap[x, y] = 0;
                    }
                }
            }
        }



        return(newMap);
    }
Ejemplo n.º 2
0
 public void initPos(TerrainProbabilities _terrainInits, int[,] _map)
 {
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             if (Random.Range(1, 101) < _terrainInits.iniChance)
             {
                 _map[x, y] = 1;
             }
             else
             {
                 _map[x, y] = 0;
             }
         }
     }
 }