Esempio n. 1
0
    public void EquationCreationTest()
    {
        SingleValueLayer.WORLDX = 50;
        SingleValueLayer.WORLDZ = 50;
        // Test initialize what is needed for the test
        EquationLayer    testEquation   = new EquationLayer("TemperatureEquations", "Semi-static");
        SingleValueLayer testhighTemp   = new SingleValueLayer("HighTemp", "Semi-static", 0);
        SingleValueLayer testlowTemp    = new SingleValueLayer("LowTemp", "Semi-static", 0);
        SingleValueLayer testtempMidpt  = new SingleValueLayer("TempMidpoint", "Semi-static", 1);
        SingleValueLayer testvariance   = new SingleValueLayer("Variance", "Semi-static", 1);
        string           filePathPrefix = @"C:\Users\William\Documents\World Generator Maps\CavemanWorld\DynamicCavemanWorld\Assets\Resources\CSV\";

        testhighTemp.readCSVFile(filePathPrefix + "HighTempNiceMapA.csv");
        testlowTemp.readCSVFile(filePathPrefix + "LowTempNiceMapA.csv");
        testtempMidpt.readCSVFile(filePathPrefix + "MidptNiceMapA.csv");
        testvariance.readCSVFile(filePathPrefix + "VarianceNiceMapA.csv");
        testEquation.createEquations(testhighTemp, testlowTemp, testtempMidpt, testvariance);

        // Test conditions
        // Basic correct info
        Assert.AreEqual(50 * 50, testEquation.worldArray.Length);
        Assert.AreEqual(100, testhighTemp.worldArray[0, 0]);
        Assert.AreEqual(1, testlowTemp.worldArray[0, 0]);
        Assert.AreEqual((float)20.4, testtempMidpt.worldArray[0, 0]);
        Assert.AreEqual((float)8.0, testvariance.worldArray[0, 0]);
        // Check for correct X-Z axes
        Assert.AreEqual(98, testhighTemp.worldArray[2, 1]);
        Assert.AreEqual(-5, testlowTemp.worldArray[2, 1]);
        Assert.AreEqual((float)26.6, testtempMidpt.worldArray[2, 1]);
        Assert.AreEqual((float)9.8, testvariance.worldArray[2, 1]);
    }
Esempio n. 2
0
    public void EquationLayerTest()
    {
        // Test the TempEquation Constructor
        EquationLayer testEquation = new EquationLayer("TemperatureEquations", "Semi-static");

        Assert.AreEqual("TemperatureEquations", testEquation.layerName);
        Assert.AreEqual("Semi-static", testEquation.getType());
        Assert.AreEqual(50, EquationLayer.WORLDX);
        Assert.AreEqual(50, EquationLayer.WORLDZ);
    }
Esempio n. 3
0
    // Mineral Layers
    // public MineralLayer surfaceStone;
    // public MineralLayer surfaceIron;
    // public MineralLayer surfaceMinerals;
    // public MineralLayer miningStone;
    // public MineralLayer miningIron;
    // public MineralLayer miningMinerals;

    // Constructor
    public World(int x, int z, bool random)
    {
        // Initialize the variables
        WorldX = x;
        WorldZ = z;
        SingleValueLayer.WORLDX = WorldX;
        SingleValueLayer.WORLDZ = WorldZ;
        this.elevation          = new SingleValueLayer("Elevation", "Semi-static", 1);
        this.elevationVertices  = new SingleValueLayer("ElevationVertices", "Semi-static", 1);
        this.highTemp           = new SingleValueLayer("HighTemp", "Semi-static", 0);
        this.lowTemp            = new SingleValueLayer("LowTemp", "Semi-static", 0);
        this.tempMidpt          = new SingleValueLayer("TempMidpoint", "Semi-static", 1);
        this.variance           = new SingleValueLayer("Variance", "Semi-static", 1);
        this.tempEquations      = new EquationLayer("TemperatureEquations", "Semi-static");
        this.temps    = new IntDayList[WorldX, WorldZ];
        this.humidity = new HumidityLayer("HumidityLayer", 6, 1);

        if (!random)
        {
            string filePathPrefix = @"CSV\";
            elevation.readCSVFile(filePathPrefix + "ElevationNiceMapA");
            // Debug.Log("**************************************");
            highTemp.readCSVFile(filePathPrefix + "HighTempNiceMapA");
            lowTemp.readCSVFile(filePathPrefix + "LowTempNiceMapA");
            tempMidpt.readCSVFile(filePathPrefix + "MidptNiceMapA");
            variance.readCSVFile(filePathPrefix + "VarianceNiceMapA");
            humidity.readCSVFiles(filePathPrefix);
        }
        else
        {
            DataGenerator generator = new DataGenerator(WorldX, WorldZ);
            Debug.Log(x + ", " + z);
            // Generate elevation layer
            elevation.worldArray = generator.CreateElevationLayer();
            // Generate temperature info
            float[][,] temporaryTemps = generator.CreateTemperatureLayers(4);
            highTemp.worldArray       = temporaryTemps[0];
            lowTemp.worldArray        = temporaryTemps[1];
            tempMidpt.worldArray      = generator.CreateStandardFloatLayer(20.2, 40.6, 4.0);
            variance.worldArray       = generator.CreateStandardFloatLayer(1.0, 16.0, 2.0);
            // Generate rain info
            for (int i = 0; i < 6; i++)
            {
                humidity.worldArray[i] = generator.CreateStandardFloatLayer(0.0, 10.0, 1.0);
            }
        }

        // Elevation info
        ConvertElevationToVertices();
        hillPer  = CalculateHillPercentage();
        oceanPer = CalculateOceanPercentage();
        Debug.Log("Elevation Models Complete!");
        // Temperature info
        tempEquations.createEquations(highTemp, lowTemp, tempMidpt, variance);
        // Calculate Years worth of temperature data
        // CreateYearsTemps();
        Debug.Log("Temperature Models Complete!");
        // Rainfall info
        rainfall      = humidity.GenerateWorldsYearOfRain();
        rainfallTotal = new SingleValueLayer("Yearly Rain Total", "Yearly", 1);
        // rainfallTotal.worldArray = rainfall.findYearTotalArray();
        Debug.Log("Rainfall Models Complete!");
        // Rivers info
        // Initialize Water Stats
        riverStats = new ObjectLayer("River Stats", "Semi-static");
        PopulateRivers();
        Debug.Log("Rivers Populated!");
        ResetStaticRiverLayers();
        ResetLastDayLayer();
        // Calculate Habitat Layer - ** for that we need 20 years of time run forward at initialization **
        HabitatInitialization();
        // When done initializing the habitats calculate a new year
        TempAndRainNewYear();
        Debug.Log("Habitats Created!");
    }