Example #1
0
        private static Terrain.TerrainType[,] GenerateArray(int width, int height)
        {
            var types = new Terrain.TerrainType[height, width];

            for (var x = 0; x < width; ++x)
                for (var y = height - 20; y < height - 10; ++y)
                    types[y, x] = Terrain.TerrainType.Water;

            for (var x = 0; x < width; ++x)
                for (var y = 0; y < height - 10; ++y)
                    if (weightedNoise(2f, height,x,y) > 0)
                        types[y, x] = Terrain.TerrainType.Earth;
                    else if (weightedNoise(2f, height, x, y) > -0.1)
                        types[y, x] = Terrain.TerrainType.Sand;
                    else if (weightedNoise(2f, height, x, y) > -0.2)
                        types[y, x] = Terrain.TerrainType.Water;

            for (var x = 0; x < width; ++x)
                for (var y = height - 10; y < height; ++y)
                    types[y,x] = Terrain.TerrainType.Stone;

            for (var i = 0; i < 4; ++i)
                while (true)
                {
                    var x = Rng.Next(width);
                    var y = Rng.Next(height);
                    if (types[y, x] != Terrain.TerrainType.Air)
                        continue;
                    types[y, x] = Terrain.TerrainType.VegetationSeed;
                    break;
                }

            return types;
        }
Example #2
0
        private static Terrain.TerrainType[,] GenerateArray(int width, int height)
        {
            var types = new Terrain.TerrainType[height, width];

            for (var x = 0; x < width; ++x)
            {
                for (var y = height - 20; y < height - 10; ++y)
                {
                    types[y, x] = Terrain.TerrainType.Water;
                }
            }


            for (var x = 0; x < width; ++x)
            {
                for (var y = 0; y < height - 10; ++y)
                {
                    if (weightedNoise(2f, height, x, y) > 0)
                    {
                        types[y, x] = Terrain.TerrainType.Earth;
                    }
                    else if (weightedNoise(2f, height, x, y) > -0.1)
                    {
                        types[y, x] = Terrain.TerrainType.Sand;
                    }
                    else if (weightedNoise(2f, height, x, y) > -0.2)
                    {
                        types[y, x] = Terrain.TerrainType.Water;
                    }
                }
            }

            for (var x = 0; x < width; ++x)
            {
                for (var y = height - 10; y < height; ++y)
                {
                    types[y, x] = Terrain.TerrainType.Stone;
                }
            }

            for (var i = 0; i < 4; ++i)
            {
                while (true)
                {
                    var x = Rng.Next(width);
                    var y = Rng.Next(height);
                    if (types[y, x] != Terrain.TerrainType.Air)
                    {
                        continue;
                    }
                    types[y, x] = Terrain.TerrainType.VegetationSeed;
                    break;
                }
            }

            return(types);
        }
Example #3
0
        int CalculateDefenseBonus(Terrain.TerrainType type, bool containsHIlls)
        {
            Configuration file  = FileManager.LoadConfig("configs/terrain/terrainBonusses");
            int           bonus = file.GetProperty <int>(type.ToString().ToLower() + ".defense");

            if (hills)
            {
                bonus += file.GetProperty <int>("hills.defense");
            }
            return(bonus);
        }
Example #4
0
        public static Tile LoadFromFile(BinaryReader reader, int xPos, int yPos)
        {
            byte data  = reader.ReadByte();
            bool hills = (data & 0x80) == 0x80;

            Terrain.TerrainType type = (Terrain.TerrainType)(data & (0x80 ^ 0xFF));

            Tile retVal = new Tile(Terrain.FromTerrainID((byte)type), xPos, yPos);

            retVal.hills = hills;
            return(retVal);
        }