Beispiel #1
0
    Sprite GetIcon(Place pl)
    {
        Sprite icn = null;

        JsonReader.Fecha temp = database.lugaresJson[pl.index].fecha[day];
        foreach (MiniWeather mini in miniWeathers)
        {
            if (temp.meteo.intprecipitation > 0)
            {
                if (mini.minRain >= temp.meteo.intprecipitation)
                {
                    icn = mini.icon;
                }
            }
            else
            {
                if (mini.minClouds >= temp.meteo.nubes)
                {
                    icn = mini.icon;
                }
            }
        }
        if (icn == null)
        {
            return(miniWeathers[0].icon);
        }
        return(icn);
    }
Beispiel #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        map.transform.position = zoom[zoomNum].position;
        if (day > 365)
        {
            endScreen.SetActive(true);
            scoreText.text     = "Final Score: " + (int)plantGrowth;
            maxGrowthText.text = "Maximum Score: " + maxGrowth;
            return;
        }

        if (Time.time - lastDayTime > dayDuration)
        {
            day++;
            lastDayTime = Time.time;
        }
        sprite.sprite = plantSprites[Mathf.Clamp(Mathf.FloorToInt(plantGrowth / plantSprites.Length), 0, plantSprites.Length - 1)];
        calendar.text = "" + database.lugaresJson[0].fecha[day].dia + "/" + database.lugaresJson[0].fecha[day].mes;
        foreach (Place pl in places)
        {
            if (pl.selected)
            {
                selectedPlaceStat = database.lugaresJson[pl.index].fecha[day];
            }
        }
        var em = rain.emission;

        em.enabled      = true;
        em.rateOverTime = new ParticleSystem.MinMaxCurve(10 * selectedPlaceStat.meteo.intprecipitation);
        var clr  = rain.colorOverLifetime;
        var main = rain.main;

        if (selectedPlaceStat.meteo.nieve)
        {
            clr.color            = Color.white;
            rainMat.mainTexture  = snowTexture;
            main.gravityModifier = 0.1f;
            main.startSize       = new ParticleSystem.MinMaxCurve(0.5f, 1.5f);
        }
        else
        {
            clr.color            = Color.blue;
            rainMat.mainTexture  = rainTexture;
            main.gravityModifier = 1;
            main.startSize       = new ParticleSystem.MinMaxCurve(0.1f, 0.5f);
        }
        var clem = clouds.emission;

        clem.rateOverTime = selectedPlaceStat.meteo.nubes;
        foreach (Place pl in places)
        {
            pl.temp.text          = "" + database.lugaresJson[pl.index].fecha[day].temp.intmaxx + "°";
            pl.temp2.text         = "" + database.lugaresJson[pl.index].fecha[day].temp.intminn + "°";
            pl.miniWeather.sprite = GetIcon(pl);
            if (pl.selected)
            {
                pl.nameMesh.color = Color.green;
            }
            else
            {
                pl.nameMesh.color = Color.black;
            }
        }
        GrowPlant();
    }