Exemplo n.º 1
0
    private IEnumerator getMeteo()
    {
        Dictionary <string, string> parameters = new Dictionary <string, string>();

        Debug.Log(_locationFinder);
        StartCoroutine(_locationFinder.Refresh(locationMaxTime));
        yield return(new WaitUntil(() => _locationFinder.getLastStatus() != LocationFinderStatus.ONGOING));

        if (_locationFinder.getLastStatus() == LocationFinderStatus.ERROR && _locationFinder.hasInitialized())
        {
            Debug.Log("Failed to Initialize Meteo");
            yield break;
        }

        Debug.Log(_locationFinder.getLastStatus() + " " + _locationFinder.getLastCoordinates().latitude + " " + _locationFinder.getLastCoordinates().longitude);

        parameters.Add("lat", _locationFinder.getLastCoordinates().latitude.ToString());
        parameters.Add("lon", _locationFinder.getLastCoordinates().longitude.ToString());
        parameters.Add("APPID", apiKey);
        parameters.Add("mode", "xml");

        UnityWebRequest resultRequest = _webRequester.Get("http://api.openweathermap.org/data/2.5/weather", parameters);

        yield return(new WaitUntil(() => resultRequest.isDone));

        meteoStatus.Init(resultRequest.downloadHandler.text);

        Debug.Log(resultRequest.downloadHandler.text);
        //text.text = meteoStatus.ToString();

        string meteoString = meteoStatus.ToString();

        if (meteoStatus.getWeatherType() == WeatherType.NO)
        {
            meteoVisual.transform.GetChild(0).gameObject.SetActive(true);
            meteoVisual.transform.GetChild(1).gameObject.SetActive(false);
            meteoVisual.transform.GetChild(2).gameObject.SetActive(false);
        }
        else if (meteoStatus.getWeatherType() == WeatherType.RAIN)
        {
            meteoVisual.transform.GetChild(0).gameObject.SetActive(false);
            meteoVisual.transform.GetChild(1).gameObject.SetActive(true);
            meteoVisual.transform.GetChild(2).gameObject.SetActive(false);
        }
        else if (meteoStatus.getWeatherType() == WeatherType.SNOW)
        {
            meteoVisual.transform.GetChild(0).gameObject.SetActive(false);
            meteoVisual.transform.GetChild(1).gameObject.SetActive(false);
            meteoVisual.transform.GetChild(2).gameObject.SetActive(true);
        }
    }
Exemplo n.º 2
0
    public void meteoChange(IMeteoStatus status)
    {
        Thorn.SetActive(true);
        Material[] materialArray = renderer.materials;
        if (status.getTemperature() < 10.0)
        {
            Thorn.SetActive(false);
        }
        else if (status.getTemperature() > 25.5)
        {
            Thorn.SetActive(false);
        }
        else
        {
            materialArray[0] = baseMaterial;
        }
        switch (status.getWeatherType())
        {
        case WeatherType.SNOW:
            Thorn.SetActive(false);
            break;

        default:
            break;
        }
        renderer.materials = materialArray;
    }
Exemplo n.º 3
0
    public void meteoChange(IMeteoStatus status)
    {
        CloudDisappear();
        if (status.getTemperature() < 10.0)
        {
        }
        else if (status.getTemperature() > 25.5)
        {
        }
        else
        {
        }
        switch (status.getWeatherType())
        {
        case WeatherType.SNOW:
            CloudDisappear();
            break;

        case WeatherType.RAIN:
            CloudAppear();
            break;

        default:
            CloudDisappear();
            break;
        }
    }
Exemplo n.º 4
0
    public void meteoChange(IMeteoStatus status)
    {
        Material[] materialArray = renderer.materials;

        if (status.getTemperature() < 10.0)
        {
            materialArray[1] = ColdMaterial;
        }
        else if (status.getTemperature() > 25.5)
        {
            materialArray[1] = HotMaterial;
        }
        else
        {
            materialArray[1] = baseMaterial;
        }
        switch (status.getWeatherType())
        {
        case WeatherType.SNOW:
            materialArray[1] = SnowMaterial;
            break;

        default:
            break;
        }
        renderer.materials = materialArray;
    }
Exemplo n.º 5
0
    public void meteoChange(IMeteoStatus status)
    {
        Node[]       nodes    = this.gameObject.GetComponentsInChildren <Node>();
        MeshCollider collider = this.gameObject.GetComponent <MeshCollider>();
        Water        water    = this.gameObject.GetComponent <Water>();

        Material[] materialArray = renderer.materials;

        if (status.getTemperature() < 10.0)
        {
            collider.enabled = true;
            liquid.moving    = false;
            foreach (var item in nodes)
            {
                item.cubeWalkable = true;
            }
            materialArray[0] = IceMaterial;
        }
        else if (status.getTemperature() > 25.5)
        {
            collider.enabled = false;
            liquid.moving    = true;
            foreach (var item in nodes)
            {
                item.cubeWalkable = false;
            }
            materialArray[0] = baseMaterial;
        }
        else
        {
            collider.enabled = false;
            liquid.moving    = true;
            foreach (var item in nodes)
            {
                item.cubeWalkable = false;
            }
            materialArray[0] = baseMaterial;
        }
        switch (status.getWeatherType())
        {
        case WeatherType.SNOW:
            materialArray[0] = IceMaterial;
            collider.enabled = true;
            liquid.moving    = false;
            foreach (var item in nodes)
            {
                item.cubeWalkable = true;
            }
            break;

        default:
            break;
        }
        renderer.materials = materialArray;
    }
Exemplo n.º 6
0
    public void meteoChange(IMeteoStatus status)
    {
        PauseEverything();
        if (status.getWeatherType() == WeatherType.NO)
        {
            if (hasWater)
            {
                waterFlow.UnPause();
            }
        }
        if (status.getWeatherType() == WeatherType.RAIN)
        {
            if (hasWater)
            {
                waterFlow.UnPause();
            }
        }
        if (status.getWeatherType() == WeatherType.SNOW)
        {
            if (hasWater)
            {
                waterFlow.Pause();
            }
        }

        if (status.getTemperature() < 10.0)
        {
            if (hasWater)
            {
                waterFlow.Pause();
            }
        }
        else if (status.getTemperature() > 25.5)
        {
            if (hasWater)
            {
                waterFlow.UnPause();
            }
        }
    }
Exemplo n.º 7
0
 public void meteoChange(IMeteoStatus status)
 {
     if (status.getTemperature() < 10.0)
     {
         currentStep = coldStep;
     }
     else if (status.getTemperature() > 25.5)
     {
         currentStep = hotStep;
     }
     if (status.getWeatherType() == WeatherType.NO)
     {
         currentStep = normalStep;
     }
     if (status.getWeatherType() == WeatherType.RAIN)
     {
         currentStep = rainStep;
     }
     if (status.getWeatherType() == WeatherType.SNOW)
     {
         currentStep = snowStep;
     }
 }