示例#1
0
        //static int min = int.MaxValue;
        //static int max = int.MinValue;

        public void UpdateMap()
        {
            int initTile = LogicTile.SetTerrain(0, TerrainType.Grass);

            initTile = LogicTile.SetAltitude(initTile, LogicTile.MAX_ALTITUDE / 2);
            map.Clear(initTile);

            GenerateMap();



            //AltitudeAbsNoise(map, 5, seed, 100);
            //AltitudeNoise(map, 5, seed, 40);
            //AltitudeNoise(map, 6, seed, 20);


            //Noise(map, seed);

            /*
             * int gridSize = 8;
             * int gridRowCount = 5;
             * LogicHex center = new LogicHex(map.width/2,map.height/2);
             * LogicHex start = center.Sub(new LogicHex(gridSize * gridRowCount / 2, gridSize * gridRowCount / 2));
             *
             * List<LogicHex> nodes = CreateGrid(gridSize, gridRowCount);
             * OffsetNodes(nodes, start);
             * RandomOffsetNodes(nodes, 7, seed);
             *
             * PlotNodes(map, nodes, 3, TerrainType.Sand);
             */
            //int min, max;
            //GetAltitudeRange(map, out min, out max);

            /*
             * if (min < LogicWorld.min)
             *  LogicWorld.min = min;
             *
             * if (max > LogicWorld.max)
             *  LogicWorld.max = max;
             *
             * Debugger.Log("Altitude range 1 [" + LogicWorld.min + " - " + LogicWorld.max + "]");
             * Debugger.Log("Altitude range 2 [" + LogicPerlinNoise.minNoise + " - " + LogicPerlinNoise.maxNoise + "]");
             */
            /*for(int i = -LogicPerlinNoise.SCALE; i < LogicPerlinNoise.SCALE; ++i)
             * {
             *  int altitude = LogicPerlinNoise.ScaleNoise(i,LogicTile.MAX_ALTITUDE);
             *
             *  if (altitude < min)
             *      min = altitude;
             *
             *  if (altitude > max)
             *      max = altitude;
             *
             * }*/

            //Debugger.Log("Altitude range 3 [" + min + " - " + max + "]");
        }
示例#2
0
        public static void AltitudeAbsNoise(LogicHexMap map, int octave, int seed, int percent)
        {
            for (int r = 0; r < map.height; ++r)
            {
                for (int q = 0; q < map.width; ++q)
                {
                    int         tile     = map.Get(q, r);
                    int         altitude = LogicTile.GetAltitude(tile);
                    LogicPoint3 pos      = HexToLogicPos(new LogicHex(q, r), altitude * ALTITUDE_SCALE);


                    int noise = LogicPerlinNoise.Noise((pos.x << octave) + seed, (pos.z << octave) + seed, seed << 2, LogicTween.SCALE);


                    int  distanceToMiddle = (noise - LogicTween.SCALE_HALF);
                    bool flip             = false;
                    if (distanceToMiddle < 0)
                    {
                        distanceToMiddle = -distanceToMiddle;
                        flip             = true;
                    }
                    distanceToMiddle = LogicTween.QuadIn(distanceToMiddle * 2) / 2;
                    if (flip)
                    {
                        distanceToMiddle = -distanceToMiddle;
                    }

                    noise = LogicTween.SCALE_HALF + distanceToMiddle;
                    noise = noise / (LogicTween.SCALE / LogicTile.MAX_ALTITUDE);



                    /*int noise = LogicPerlinNoise.Noise((pos.x << octave) + seed, (pos.z << octave) + seed, seed << 2, LogicTile.MAX_ALTITUDE*2);
                     * noise -= LogicTile.MAX_ALTITUDE;
                     * if (noise < 0)
                     *  noise = -noise;
                     *
                     *
                     * LogicTween.QuadIn();
                     */

                    //noise = LogicPerlinNoise.ScaleNoise(noise, LogicTile.MAX_ALTITUDE);

                    altitude = Lerp(altitude, noise, percent);
                    tile     = LogicTile.SetAltitude(tile, altitude);



                    map.Set(q, r, tile);
                }
            }
        }
示例#3
0
        public static void AltitudeFlip(LogicHexMap map, int cutoff)
        {
            for (int r = 0; r < map.height; ++r)
            {
                for (int q = 0; q < map.width; ++q)
                {
                    int tile     = map.Get(q, r);
                    int altitude = LogicTile.GetAltitude(tile);



                    tile = LogicTile.SetAltitude(tile, altitude);
                    map.Set(q, r, tile);
                }
            }
        }
示例#4
0
        public static void AltitudeNoise(LogicHexMap map, int octave, int seed, int percent)
        {
            for (int r = 0; r < map.height; ++r)
            {
                for (int q = 0; q < map.width; ++q)
                {
                    int         tile     = map.Get(q, r);
                    int         altitude = LogicTile.GetAltitude(tile);
                    LogicPoint3 pos      = HexToLogicPos(new LogicHex(q, r), altitude * ALTITUDE_SCALE);

                    int noise = LogicPerlinNoise.Noise((pos.x << octave) + seed, (pos.z << octave) + seed, seed << 2, LogicTile.MAX_ALTITUDE);

                    altitude = Lerp(altitude, noise, percent);
                    tile     = LogicTile.SetAltitude(tile, altitude);

                    map.Set(q, r, tile);
                }
            }
        }
示例#5
0
        public LogicIntArray2 CreateRoom(int width, int height, int tileHeight)
        {
            int tile = 0;

            tile = LogicTile.SetTerrain(tile, TerrainType.Dirt);
            tile = LogicTile.SetRoom(tile, 1);
            tile = LogicTile.SetAltitude(tile, tileHeight);

            LogicIntArray2 room = new LogicIntArray2(width, height, tile);

            /*
             * for (int y = 0; y < width; ++y)
             * {
             *  for (int x = 0; x < width; ++x)
             *  {
             *      room.Set(x,y,tile);
             *  }
             * }*/

            return(room);
        }
示例#6
0
        public int GetLogicTile()
        {
            int tile = LogicTile.SetAltitude(0, altitude / TILE_ALTITUDE_SCALE);

            return(LogicTile.SetTerrain(tile, terrain));
        }