public void UpdateWeather(EWeather weather)
    {
        switch (weather)
        {
        case EWeather.Sunny:
            AmbientAudio.clip = clip_birds;
            AmbientAudio.Play();
            break;

        case EWeather.Rainy:
            RainAudio.clip = clip_lightRian;
            RainAudio.Play();
            break;

        case EWeather.Strom:
            AmbientAudio.clip = clip_wind;
            OtherAudio.clip   = clip_HeavyRian;
            ThunderAudio.clip = clip_FarTunder;
            AmbientAudio.Play();
            OtherAudio.Play();
            break;

        case EWeather.Snow:
            OtherAudio.clip = clip_snowWind;
            OtherAudio.Play();
            break;
        }
    }
    void OnTurnEvent(TurnEvent _event)
    {
        switch(_event.type)
        {
            case TurnEvent.Type.NewSeason:
                probabilitySeason.Clear();
                int season = (int)TimeManager.Instance.season;
                for(int i = 0; i < 4; i++)
                    {
                        probabilitySeason.AddRange(Enumerable.Repeat(CFG.seasons[season].weather[i].weather, CFG.seasons[season].weather[i].probability));
                    }
            break;

            case TurnEvent.Type.NewDay:
                //Nouvelle météo basée sur la saison
                actualWeather = probabilitySeason.ElementAt(Random.Range(0,probabilitySeason.Count));

                //Si la météo est la même qu'hier
                if(consecutiveWeather.ElementAt(0).Key == actualWeather)
                    consecutiveWeather[actualWeather] = consecutiveWeather.ElementAt(0).Value+1;
                else
                {
                    consecutiveWeather.Clear();
                    consecutiveWeather.Add(actualWeather, 0);
                }

                if(consecutiveWeather.ElementAt(0).Value >= CFG.disastersBeginAt)
                    OnDisaster(actualWeather);

            break;
        }
    }
Esempio n. 3
0
    private void OnWeatherChanged(EWeather eWeather)
    {
        if (!isNewDay)
        {
            return;
        }

        if (eWeather == EWeather.Rainy)
        {
            Tilemap dirtHoleTileMap = gridManager?.DirtHoleTileMap;

            if (dirtHoleTileMap == null)
            {
                return;
            }

            // Set all tiles wet
            foreach (var pos in dirtHoleTileMap.cellBounds.allPositionsWithin)
            {
                if (dirtHoleTileMap.HasTile(pos))
                {
                    gridManager.SetWateredDirtTile(pos);
                }
            }
        }
        else
        {
            gridManager.WateredDirtTileMap.ClearAllTiles();
            gridManager.ClearTileMapData(gridManager.WateredDirtTileMap);
        }
    }
Esempio n. 4
0
    public void UpdateWeather(EWeather weather, EWeather last)
    {
        WS.IsPlaying = true;
        switch (weather)
        {
        case EWeather.Sunny:
            StopAllParticles(last);
            Invoke("StartSunny", 5.0f);
            break;

        case EWeather.Rainy:
            StopAllParticles(last);
            if (!(last == EWeather.Strom))
            {
                Invoke("StartRainy", 5.0f);
            }
            break;

        case EWeather.Strom:
            if (!(last == EWeather.Rainy))
            {
                StopAllParticles(last);
            }
            WS.anim.Play("Anim_StormStart");
            break;

        case EWeather.Snow:
            StopAllParticles(last);
            Invoke("StartSnow", 5.0f);
            break;
        }
    }
Esempio n. 5
0
    public override IEnumerator ItemUseAction(Inventory userInventory, int itemIndex)
    {
        GridSelector gridSelector = userInventory.GetComponent <GridSelector>();

        if (gridManager == null)
        {
            gridManager = gridManagerReference.Reference?.GetComponent <GridManager>();
        }

        if (gridManager != null)
        {
            if (weatherEvent.HasParameter)
            {
                currentWeather = weatherEvent.LastParameter;
            }
        }

        if (gridSelector != null && gridManager != null)
        {
            Vector3Int selectionLocation = gridSelector.GetGridSelectionPosition();

            userInventory.GetComponent <Aimer>().LookAt(gridManager.Grid.CellToWorld(selectionLocation));

            Mover getMover = userInventory.GetComponent <Mover>();
            getMover?.FreezeMovement(true);

            BodyAnimation[] getEntityAnimator = userInventory.GetComponentsInChildren <BodyAnimation>();

            float animationTime = 0;

            for (int i = 0; i < getEntityAnimator.Length; i++)
            {
                animationTime = getEntityAnimator[i].ApplySmashAnimation(speed, userInventory.GetItem(itemIndex).Data.Icon);
            }

            gridSelector.SetFrozen(true);

            yield return(new WaitForSeconds(animationTime * 0.5f));

            if (!gridManager.HasDirtHole(selectionLocation) && !gridManager.HasWater(selectionLocation) && gridManager.HasDirt(selectionLocation))
            {
                gridManager.SetDirtHoleTile(selectionLocation);

                if (currentWeather == EWeather.Rainy)
                {
                    gridManager.SetWateredDirtTile(selectionLocation);
                }

                onSuccess.Invoke();
            }

            yield return(new WaitForSeconds(animationTime * 0.5f));

            getMover.FreezeMovement(false);
            gridSelector.SetFrozen(false);
        }
    }
Esempio n. 6
0
    public void OnLoad(string data)
    {
        SaveData saveData = JsonUtility.FromJson <SaveData>(data);

        this.baseSeed = saveData.baseSeed;
        this.seed     = new System.Random(saveData.baseSeed);

        this.dayIndex       = saveData.dayIndex;
        this.dayOfYear      = saveData.dayOfYear;
        this.currentWeather = (EWeather)saveData.currentWeather;
    }
Esempio n. 7
0
    IEnumerator ChangeWeather()
    {
        while (true)
        {
            int   weather = Random.Range(0, (int)EWeather.None);
            float sec     = Random.Range(10 + MinTime, 10 + MaxTime);
            yield return(new WaitForSeconds(sec));

            switch ((EWeather)weather)
            {
            case EWeather.Sunny:
                if (Weather != EWeather.Strom)
                {
                    Weather = (EWeather)weather;
                }
                else
                {
                    Weather = EWeather.Rainy;
                }
                break;

            case EWeather.Rainy:
                Weather = (EWeather)weather;
                break;

            case EWeather.Strom:
                if (Weather == EWeather.Rainy)
                {
                    Weather = (EWeather)weather;
                }
                else
                {
                    Weather = EWeather.Rainy;
                }
                break;

            case EWeather.Snow:
                if (Weather != EWeather.Strom)
                {
                    Weather = (EWeather)weather;
                }
                else
                {
                    Weather = EWeather.Rainy;
                }
                break;
            }
        }
    }
Esempio n. 8
0
    void StopAllParticles(EWeather weather)
    {
        switch (weather)
        {
        case EWeather.Sunny:
            WS.anim.Play("Anim_SunnyEnd");
            break;

        case EWeather.Rainy:
            WS.anim.Play("Anim_lightRainEnd");
            break;

        case EWeather.Strom:
            WS.anim.Play("Anim_StormEnd");
            break;

        case EWeather.Snow:
            WS.anim.Play("Anim_SnowEnd");
            break;
        }
    }
    void OnDisaster(EWeather _weather)
    {
        switch(_weather)
        {
            case EWeather.SOLEIL:
                if(TimeManager.Instance.season == ESeasons.ETE)
                    Debug.Log("C'est la canicule ! Tout le monde s'arrête boire un verre à l'auberge !");
            break;

            case EWeather.PLUIE:
                Debug.Log("La pluie et la boue rendent le voyage pénible et fatiguant, beaucoup de voyageurs s'arrêtent dans votre auberge.");
            break;

            case EWeather.NEIGE:
                Debug.Log("La route est impraticable, plus personne ne passe, les voyageurs présents dorment sur place.");
            break;

            case EWeather.TEMPETE:
                Debug.Log("Le pont est impraticable et subit des dégâts à cause des troncs flottant dans le fleuve ...");
            break;
        }
    }
Esempio n. 10
0
    public void CheckWeather()
    {
        float random = Random.Range(1f, 100f);

        if (sunyProbability >= random - Random.Range(0f, 41f))
        {
            if (Weather == EWeather.Thunder)
            {
                OnWeatherChange?.Invoke();
            }

            Weather = EWeather.SunnyDay;
        }
        else
        {
            if (Weather == EWeather.SunnyDay)
            {
                OnWeatherChange?.Invoke();
            }
            Weather = EWeather.Thunder;
        }
    }
Esempio n. 11
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Time.timeScale = 10;
        }
        if (Input.GetKeyUp(KeyCode.Space))
        {
            Time.timeScale = 1;
        }

        if (lastWeather != Weather)
        {
            ParticleMana.UpdateWeather(Weather, lastWeather);
            AudioMana.UpdateWeather(Weather);
            lastWeather = Weather;
        }

        if (IsPlaying)
        {
            Invoke("ResetIsPlaying", 5.0f);
        }
    }
Esempio n. 12
0
    private void OnNewDay(DateTime time)
    {
        // Execute if the current time doesn't match the given day time
        // In case the game loads a save game, we don't want to set the weather again on the same day.
        if (time.DayOfYear != dayOfYear)
        {
            dayOfYear = time.DayOfYear;
            dayIndex++;

            var cumulativeWeight = 0;
            foreach (var weatherType in weatherTypes)
            {
                cumulativeWeight += weatherType.weight;
            }

            var randomWeight = seed.Next(1, cumulativeWeight + 1);

            foreach (var weatherType in weatherTypes)
            {
                randomWeight -= weatherType.weight;

                if (randomWeight <= 0)
                {
                    currentWeather = weatherType.type;

                    break;
                }
            }

            // TODO: Create a season system, that swaps out the option for rain with snow.
        }

        onWeather.Invoke(currentWeather);

        isSaveable = true;
    }