示例#1
0
    public void BiomeGenerate()
    {
        GetHighestPositon();
        int highestPositon = elevationList.IndexOf(maxPosition);

        grid.cells[highestPositon].visible = true;
        sttg.SetTileToCell(sttg.collection.spriteCollection[1], grid.CellGetPosition(highestPositon), grid.cells[highestPositon]);


        for (int i = 0; i < elevationList.Count; i++)
        {
            if (elevationList[i] < waterLevel)
            {
                //海拔低于海平面且单元格信息为null
                // water
                grid.cells[i].visible = false;
                sttg.SetTileToCell(sttg.collection.spriteCollection[4], grid.CellGetPosition(i), grid.cells[i]);
            }
            else if (elevationList[i] > waterLevel && grid.cells[i].info == null)
            {
                //海拔高于海平面且单元格信息为null
                if (GenerateRandom.floatRandom(0.6f, Random.Range(0, 1f)))
                {
                    grid.cells[i].visible = true;
                    sttg.SetTileToCell(sttg.collection.spriteCollection[6], grid.CellGetPosition(i), grid.cells[i]);
                }

                else
                {
                    grid.cells[i].visible = true;
                    sttg.SetTileToCell(sttg.collection.spriteCollection[0], grid.CellGetPosition(i), grid.cells[i]);
                }
            }
            else if (elevationList[i] > waterLevel && grid.cells[i].info != null)
            {
                Debug.Log("Is City");
                //海报高于海平面且单元格信息不为null
            }
            else if (elevationList[i] == waterLevel)
            {
                grid.cells[i].visible = true;
                sttg.SetTileToCell(sttg.collection.spriteCollection[0], grid.CellGetPosition(i), grid.cells[i]);
            }
        }
    }