示例#1
0
    public WindMap(int xSize, int ySize, TerrainMap terrainmap, TemperatureMap temperaturemap, int month)
    {
        this.vectormap = new Map <Vector2>(xSize, ySize);
        this.grid      = new Wind[xSize, ySize];
        this.xSize     = xSize;
        this.ySize     = ySize;
        this.month     = month;
        TradeWindGenerator     twg              = new TradeWindGenerator(xSize, ySize);
        RecursiveWindGenerator rwg              = new RecursiveWindGenerator(temperaturemap);
        Map <Vector2>          tradeWindMap     = twg.generateTradeWindMap(terrainmap, month);
        Map <Vector2>          recursiveWindMap = rwg.generateRecursiveWind();

        //blend
        float tw;

        IFunction combination = new ParabolaFunction(4, -10f, 4.15f);

        for (int x = 0; x < xSize; x++)
        {
            for (int y = 0; y < ySize; y++)
            {
                tw = combination.calculate(terrainmap.grid[x, y].height);
                tw = Mathf.Min(tw, 1);
                tw = Mathf.Max(tw, 0);
                vectormap.setAt(x, y, recursiveWindMap.grid[x, y] * (1.2f) * (1 - tw) + tradeWindMap.grid[x, y] * tw);
            }
        }
        smoothConvert(8, terrainmap);
    }
示例#2
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            /*physical = mapObject.GetComponent<PhysicalMap>();
             * physical.init(xSize, ySize);
             * HeightMapGenerator hgen = new HeightMapGenerator();
             * Heightmap heightmap = hgen.generateMap(xSize, ySize);
             * WaterMap watermap = new WaterMap(heightmap);
             * terrainmap = new TerrainMap(heightmap, watermap);
             * temperaturemap = new TemperatureMap(terrainmap, Random.Range(0, 11));
             * tr = new TemperatureRenderer(new LandmassMap(terrainmap), temperaturemap);
             * physical.draw(tr);*/
            physical = mapObject.GetComponent <PhysicalMap>();
            physical.init(xSize, ySize);
            MapSerializable mser      = MapSerializable.loadFromFile("testHM");
            Heightmap       heightmap = new Heightmap(xSize, ySize, 0.5f, mser.grid);
            WaterMap        watermap  = new WaterMap(heightmap);
            terrainmap     = new TerrainMap(heightmap, watermap);
            mser           = MapSerializable.loadFromFile("testTM");
            temperaturemap = new TemperatureMap(xSize, ySize, mser.grid, terrainmap);
            tr             = new TemperatureRenderer(new LandmassMap(terrainmap), temperaturemap);
            physical.draw(tr);
        }
        if (Input.GetMouseButtonDown(1))
        {
            if (state == 0)
            {
                RecursiveWindGenerator wgen = new RecursiveWindGenerator(temperaturemap);
                wm = new WindMap(xSize, ySize, terrainmap, temperaturemap, 3);

                WindSpeedRenderer     wsr = new WindSpeedRenderer(wm, new LandmassMap(terrainmap));
                WindDirectionRenderer wdr = new WindDirectionRenderer(wm, new LandmassMap(terrainmap));

                physical.draw(wsr);
                state++;
            }
            else if (state >= 1)
            {
                RecursiveWindGenerator wgen = new RecursiveWindGenerator(temperaturemap);
                wm = new WindMap(xSize, ySize, terrainmap, temperaturemap, state);

                WindSpeedRenderer     wsr = new WindSpeedRenderer(wm, new LandmassMap(terrainmap));
                WindDirectionRenderer wdr = new WindDirectionRenderer(wm, new LandmassMap(terrainmap));

                physical.draw(wdr);
                state++;
            }
        }
    }