Ejemplo n.º 1
0
        public override ILandObject Clone(LandTransition wallLandTransition)
        {
            if (wallLandTransition != LandTransition.NONE)
            {
                GrassElementLandObject grassLandObject = new GrassElementLandObject(this.Position.X, this.Position.Y, this.Altitude, this.LandGrassType, this.ElementIndex);

                return(grassLandObject);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public override int GenerateLandLayer(WorldGenerator worldGenerator, ILandChunk landChunk, IntRect area, int seed, int minAltitude, int maxAltitude)
        {
            ALandLayerGenerator grassLandLayerGenerator = worldGenerator.Generators["grass"];

            ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"];

            ALandLayerGenerator cliffLandLayerGenerator = worldGenerator.Generators["cliff"];

            ALandLayerGenerator elementLandLayerGenerator = worldGenerator.Generators["element"];

            bool isThereGrassElement = false;

            Random random = new Random(seed);

            for (int i = 0; i < area.Height; i++)
            {
                for (int j = 0; j < area.Width; j++)
                {
                    int altitude = altitudeLandLayerGenerator.GetComputedPowerAt(j, i);

                    int altitudeOffset = cliffLandLayerGenerator.GetComputedPowerAt(j, i);

                    int elementIndex = random.Next(0, 12);

                    int power = this.GetElementPower(elementLandLayerGenerator.GetComputedPowerAt(j, i));

                    GrassType grassType = (GrassType)grassLandLayerGenerator.GetComputedPowerAt(j, i);

                    if (power >= 2 && random.Next(0, 3) > 0 && altitudeOffset == 0 && grassType != GrassType.NONE)
                    {
                        GrassElementLandObject grassElement = new GrassElementLandObject(area.Left + j, area.Top + i, altitude, grassType, elementIndex);

                        LandCase landCase = landChunk.GetLandCase(i, j, altitude);

                        landCase.LandOverGround = grassElement;

                        isThereGrassElement = true;
                    }
                }
            }

            if (isThereGrassElement)
            {
                landChunk.AddTypeInChunk(typeof(GrassElementLandObject));
            }

            return(random.Next());
        }
Ejemplo n.º 3
0
        public override ILandObject Clone()
        {
            GrassElementLandObject grassLandObject = new GrassElementLandObject(this.Position.X, this.Position.Y, this.Altitude, this.LandGrassType, this.ElementIndex);

            return(grassLandObject);
        }