Ejemplo n.º 1
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);
         }
     }
 }
Ejemplo n.º 2
0
        private void ExtrudeTile(float amount, Tile t, TectonicPlate parentPlate = null)
        {
            float clampedAmount = Mathf.Clamp(amount, 0.0f, 1.0f);

            if (parentPlate)
            {
                clampedAmount = parentPlate.isWater ? Mathf.Clamp(amount, 0.0f, this.GetMaxWaterExtude()) : Mathf.Clamp(amount, this.GetMinLandExtude(), 1.0f);
            }

            if (clampedAmount > 0.0f)
            {
                t.ExtrudeAbsolute(clampedAmount);
            }
        }
Ejemplo n.º 3
0
        public bool IsShorelineTile(Tile t, float seaLevel = 0.0f)
        {
            if (!this.isWater || !this.EdgeTiles.Contains(t))
            {
                return(false);
            }

            for (int j = 0; j < t.neighborTiles.Count; j++)
            {
                Tile n = t.neighborTiles[j];
                if ((seaLevel > 0.0f) && (n.amountExtruded > seaLevel))
                {
                    return(true);
                }

                TectonicPlate otherPlate = TectonicPlate.GetTilePlate(n);
                if ((otherPlate != null) && !otherPlate.isWater)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 4
0
        public void AdjustTerrainHeights()
        {
            for (int i = 0; i < this.Plates.Length; i++)
            {
                TectonicPlate plate     = this.Plates[i];
                float         extrusion = plate.extrusion;
                bool          isWater   = plate.isWater;
                for (int j = 0; j < plate.PressureEdgeTiles.Count; j++)
                {
                    Tile  tile          = plate.PressureEdgeTiles[j];
                    float tileExtrusion = extrusion;

                    for (int k = 0; k < tile.neighborTiles.Count; k++)
                    {
                        Tile          otherTile  = tile.neighborTiles[k];
                        TectonicPlate otherPlate = TectonicPlate.GetTilePlate(otherTile);

                        if ((otherTile != null) && (otherPlate != null))
                        {
                            bool  isOtherWater        = otherPlate.isWater;
                            bool  isOtherPressureTile = otherPlate.IsPressureEdgeTile(otherTile);
                            float otherExtrusion      = otherPlate.extrusion;

                            if (isWater)
                            {
                                if (isOtherWater)
                                {
                                    if (isOtherPressureTile)
                                    {
                                        float chanceOfOceanFaultIsland = 0.2f;
                                        if (TerrainGenerator.EvalPercentChance(chanceOfOceanFaultIsland))
                                        {
                                            tileExtrusion = this.GetMinLandExtude();                                             //Mathf.Max(this.SeaLevel + tileExtrusion, this.GetMinLandExtude());
                                        }
                                    }
                                }
                                else
                                {
                                }
                            }
                            else
                            {
                            }
                        }
                    }

                    this.ExtrudeTile(tileExtrusion, tile);
                }


                if (isWater)
                {
                    for (int j = 0; j < plate.EdgeTiles.Count; j++)
                    {
                        Tile edgeTile = plate.EdgeTiles[j];
                        if (plate.IsShorelineTile(edgeTile, this.SeaLevel))
                        {
                            this.ExtrudeTile(this.GetMaxWaterExtude(), edgeTile, plate);
                        }
                    }
                }
            }
        }