예제 #1
0
    private void Start()
    {
        Color.RGBToHSV(Camera.backgroundColor, out _, out _, out CameraMaxBrightness);

        DiscordRichPresenceManager.UpdateActivity("Tutorial", 1);

        UpdateObjective();
    }
예제 #2
0
    IEnumerator WaitForData()
    {
        if (GameStatics.Loading)
        {
            yield return(new WaitUntil(() => !GameStatics.Loading));
        }

        // Code after wait
        DiscordRichPresenceManager.UpdateActivity("Playing", Days); // Load rich presence
    }
    // Start is called before the first frame update
    void Start()
    {
        // Reset game statics
        GameStatics.NewGame    = true;
        GameStatics.LoadedGame = new GameData();
        GameStatics.GameGuid   = Guid.Empty.ToString();

        // Load & Apply Settings
        // Audio
        float MasterVolume = PlayerPrefs.GetFloat("MasterVolume", 1);

        AudioMixer.SetFloat("MasterVolume", Mathf.Log10(MasterVolume) * 20);
        float MusicVolume = PlayerPrefs.GetFloat("MusicVolume", 0.35f);

        AudioMixer.SetFloat("MusicVolume", Mathf.Log10(MusicVolume) * 20);
        float SoundEffectVolume = PlayerPrefs.GetFloat("SoundEffectVolume", 0.5f);

        AudioMixer.SetFloat("SoundEffectVolume", Mathf.Log10(SoundEffectVolume) * 20);

        GameUpdates.CheckForUpdates(PopupManager); // Check for game updates

        DiscordRichPresenceManager.UpdateActivity("Main Menu");
    }
예제 #4
0
    void Start()
    {
        // Set vars
        Color.RGBToHSV(Camera.backgroundColor, out float _, out float _, out CameraMaxBrightness);

        // Show today's storyline
        StorylineManager.CheckForNewStoryline(Days);

        if (GameStatics.NewGame)                                        // only do this if it's a new game
        {
            DiscordRichPresenceManager.UpdateActivity("Playing", Days); // Rich Presence 1st day
            SetWeather(Weather.Sunny);                                  // Always sunny first day
        }
        else
        {
            StartCoroutine(WaitForData());
        }

        // Set variables in randomiser
        RandomEvents.Player           = Player;
        RandomEvents.Shop             = Shop;
        RandomEvents.PopupManager     = PopupManager;
        RandomEvents.FlowerBedManager = FlowerBedManager;
    }
예제 #5
0
    private IEnumerator FinishDay()
    {
        Debug.Log("Finishing a totally not rigged day");

        // Play sound
        MajorClick.Play();

        // Check if tutorial is over
        if (Days == 5)
        {
            PlayerPrefs.SetInt("TutorialComplete", 1); // Set variable
            SceneManager.LoadScene(0);                 // Go back to main menu
        }

        // Show black screen
        NextDayScreen.gameObject.SetActive(true);
        StartCoroutine(NextDayScreen.ShowScreen(++Days));
        yield return(new WaitUntil(() => NextDayScreen.time >= 1));

        DiscordRichPresenceManager.UpdateActivity("Tutorial", Days); // Discord Rich Presence

        // PLAYER
        Player.InHand = TutorialPlayer.Items.Nothing; // Empty hands
        Player.Navigate(new List <Vector3> {
            new Vector3(6, 2, 1)
        }, playSelectSound: false);                                                          // Return to spawn loc

        // FLOWER BEDS
        // Get Flower Beds States
        var FlowerBedScripts = FlowerBeds.GetComponentsInChildren <TutorialFlowerBed>();

        // WEATHER
        Debug.Log(weather);

        // Apply "logic" to flower beds

        // Go through flowerbeds
        switch (Days)
        {
        case 2:
            foreach (var flowerBed in FlowerBedScripts)
            {
                flowerBed.UpdateFlowerbedState(TutorialFlowerBed.FlowerBedState.NormalFlowers);
            }

            SetWeather(Weather.Rainy);
            break;

        case 3:
            foreach (var flowerBed in FlowerBedScripts)
            {
                flowerBed.UpdateFlowerbedState(TutorialFlowerBed.FlowerBedState.BeautifulFlowers);
            }

            SetWeather(Weather.Superstorm);
            break;

        case 4:
            foreach (var flowerBed in FlowerBedScripts)
            {
                int randomNumber = Random.Range(0, 69420);
                if (randomNumber % 2 == 0)
                {
                    flowerBed.UpdateFlowerbedState(TutorialFlowerBed.FlowerBedState.SuperFlowers);
                }
                else
                {
                    flowerBed.UpdateFlowerbedState(TutorialFlowerBed.FlowerBedState.WeakFlowers);
                }
            }

            SetWeather(Weather.NaturalDisaster);
            break;

        case 5:
            int flowersKilled = 0;
            foreach (var flowerBed in FlowerBedScripts)
            {
                if (flowerBed.state == TutorialFlowerBed.FlowerBedState.WeakFlowers)
                {
                    if (flowersKilled < 2)
                    {
                        flowerBed.UpdateFlowerbedState(TutorialFlowerBed.FlowerBedState.DeadFlowers);
                        flowersKilled++;
                    }
                    else
                    {
                        flowerBed.UpdateFlowerbedState(TutorialFlowerBed.FlowerBedState.SuperFlowers);
                    }
                }
            }

            SetWeather(Weather.Sunny);
            break;
        }

        nextObjectiveNumber = 0;
        UpdateObjective();
    }
예제 #6
0
    IEnumerator FinishDay()
    {
        Debug.Log("Finishing day!");

        GameStatics.Loading = true;

        // Play sound
        MajorClick.Play();

        Player.Navigate(new List <Vector3> {
            new Vector3(6, 2, 1)
        }, playSelectSound: false);                                                          // Return to spawn loc

        // Show black screen
        NextDayScreen.gameObject.SetActive(true);
        StartCoroutine(NextDayScreen.ShowScreen(++Days));

        yield return(new WaitUntil(() => NextDayScreen.time >= 1));

        DiscordRichPresenceManager.UpdateActivity("Playing", Days); // Discord Rich Presence

        // Manage Debt
        if (Player.Money < 0)
        {
            if (InDebt)
            {
                Debug.Log("You are in debt");
                // Try to sell flowerbeds first to cover debt
                var shopItems = Shop.ShopItems.FindAll(shopItem => shopItem.IsDowngradable && shopItem.Level > 0);
                shopItems.Sort((shopItem1, shopItem2) => shopItem1.Price.CompareTo(shopItem2.Price));
                if (shopItems.Count == 0)
                {
                    // Display message
                    PopupManager.ShowWindowPopup("You've lost everything...", "Sadly, you've ended up with less money than you've started with. Luckily for you, your parents were nice enough to pay for your debts and give you a fresh start.", goodAlert: false);

                    // Reset values
                    Player.Money = 100;
                }
                else
                {
                    int shopItemIndex = 0;
                    while (shopItems[shopItemIndex].Price + Player.Money < 0 && shopItemIndex < shopItems.Count)
                    {
                        shopItemIndex++;
                    }

                    // Display message
                    PopupManager.ShowWindowPopup($"You sold your {shopItems[shopItemIndex].Name}", $"Since you were still in debt, you were forced to sell some things to help you get back on your feet.", goodAlert: false);

                    Player.Money += shopItems[shopItemIndex].Price; // Return money
                    int newLevel = --shopItems[shopItemIndex].Level;

                    if (shopItems[shopItemIndex].Name == "Flower Beds")            // flower bed edge case
                    {
                        FlowerBedManager.SendMessage("RemoveFlowerBed", newLevel); // Sell flowerbed
                    }
                    Shop.UpdateBuyButtonVisual(shopItems[shopItemIndex]);          // Update visuals
                }
            }
            else
            {
                InDebt = true;
                PopupManager.ShowWindowPopup("You're in debt!", "You are in debt! Get out of debt or you'll soon need to start selling your things!", goodAlert: false);
            }
        }
        else
        {
            InDebt = false;

            Player.Money -= FamilyPayment;                 // Pay family
            Player.Money -= BorrowMoney.TotalDailyPayment; // Pay loans
            BorrowMoney.UpdateDailyPayments();
        }

        // Game won?
        if (!finishedGame && Player.Money > 5000 && Shop.IsMaxedOut)
        {
            Debug.Log($"You've made a lot of money, your family is proud of you. The end! :) ({Days} days to complete game)");
            StorylineManager.ShowStoryline("The End");
            finishedGame = true;
        }


        // PLAYER
        Player.InHand = Player.Items.Nothing; // Empty hands

        // STORYLINE
        StorylineManager.CheckForNewStoryline(Days);

        // FLOWER BEDS
        // Get Flower Beds States
        var FlowerBedScripts = FlowerBeds.GetComponentsInChildren <FlowerBed>();


        // WEATHER
        Debug.Log(weather);

        // Apply logic to flower beds

        // Get chances for weather
        if (!WeatherLogicData.TryGetValue(weather, out var flowerbedStateChances))
        {
            WeatherLogicData.TryGetValue(Weather.Sunny, out flowerbedStateChances);
        }

        // Go through flowerbeds
        foreach (FlowerBed flowerBed in FlowerBedScripts)
        {
            if (!flowerbedStateChances.TryGetValue(flowerBed.state, out var chances))
            {
                continue;
            }
            float randomChance = Random.value;

            foreach (var possibleChance in chances)
            {
                if (possibleChance.Value > randomChance)
                {
                    flowerBed.UpdateFlowerbedState(possibleChance.Key);
                    break;
                }

                randomChance -= possibleChance.Value;
            }
        }

        RandomEvents.Run(); // Random events

        // Create new weather for tomorrow
        GenerateWeather();

        GameFunctions.SaveGame(true, "finish_day_backup").Wait(); // Save data everyday while making backup copies just in case

        GameStatics.Loading = false;
    }