コード例 #1
0
        public void BuildPlates()
        {
            this.Plates = new TectonicPlate[this.PlateCount];

            this.HexplanetTiles = new Dictionary <int, Tile>();

            List <Tile> tiles = this.HexPlanet.GetTiles();

            for (int i = 0; i < this.Plates.Length; i++)
            {
                int  randomIndex = Random.Range(0, tiles.Count);
                Tile randomTile  = tiles[randomIndex];

                GameObject go = new GameObject("Plate" + i);
                go.transform.position = randomTile.center;
                go.transform.rotation = randomTile.transform.rotation;
                go.transform.SetParent(this.HexPlanet.transform);
                this.Plates[i] = go.AddComponent <TectonicPlate>();

                bool isWater = TerrainGenerator.EvalPercentChance(this.ChanceOfWaterPlate);

                float            extrusion = isWater ? (this.SeaLevel / 2.0f) : Random.Range(this.GetMinLandExtude(), this.MaxPlateExtrusion);
                TerrainElevation elevation = this.GetElevation(extrusion);
                Color            color     = (elevation != null) ? elevation.TerrainColor : Color.black;
                this.Plates[i].PlateSetup(this.HexPlanet, tiles[randomIndex], isWater, extrusion * this.ExtrusionMultiplier, color, this.HexplanetTiles);
            }

            int maxLoop = 100;

            for (int i = 0; i < maxLoop; i++)
            {
                bool addedAny = false;
                for (int j = 0; j < this.Plates.Length; j++)
                {
                    bool added = this.Plates[j].Fill(this.HexplanetTiles, this.ChanceOfFillRequeue);
                    if (added)
                    {
                        addedAny = true;
                    }
                }

                if (!addedAny)
                {
                    Debug.Log("Stopped adding at i=" + i);
                    break;
                }
            }

            for (int j = 0; j < this.Plates.Length; j++)
            {
                this.Plates[j].SetupTileInfo();
            }

            Debug.Log("Stopped HexplanetUsedTiles " + this.HexplanetTiles.Count + " / " + tiles.Count);
        }
コード例 #2
0
ファイル: TerrainGenerator.cs プロジェクト: dstovell/Orbital
 public TerrainElevation GetElevation(float extrusion)
 {
     for (int i = 0; i < this.Elevations.Length; i++)
     {
         TerrainElevation e = this.Elevations[i];
         if (e.IsExtrusionMatch(extrusion))
         {
             return(e);
         }
     }
     return(null);
 }
コード例 #3
0
 public void AssignTerrainTypes()
 {
     for (int i = 0; i < this.Plates.Length; i++)
     {
         TectonicPlate plate = this.Plates[i];
         for (int j = 0; j < plate.Tiles.Count; j++)
         {
             Tile             t         = plate.Tiles[j];
             TerrainElevation elevation = this.GetElevation(t.amountExtruded);
             Color            color     = (elevation != null) ? elevation.TerrainColor : Color.black;
             t.setColor(color);
         }
     }
 }