Example #1
0
    float DetermineSleepDuration()
    {
        float startTime = TimeManager.GetCurrentTime();

        if (startTime % 30 >= 15)
        {
            startTime = (startTime - (startTime % 30)) + 30;
        }
        else
        {
            startTime -= (startTime % 30);
        }

        float sleepDuration = 0;

        if (startTime < TimeManager.morningTime)
        {
            sleepDuration = (TimeManager.morningTime - startTime) / 60;
        }
        else
        {
            sleepDuration = ((1440 - startTime) + TimeManager.morningTime) / 60;
        }
        sleepDuration = Mathf.Clamp(sleepDuration, 0, PlayerRooms.GetBedRoomValue());

        // Debug.Log("Sleep Start Time: " + startTime);
        // Debug.Log("Sleep Duration: " + sleepDuration);

        return(sleepDuration);
    }
Example #2
0
    public static void RestoreEnergyPercentage(float sleepDuration)
    {
        float restorePercentage = sleepDuration / PlayerRooms.GetBedRoomValue();
        int   restoreAmount     = Mathf.RoundToInt(PlayerSkills.GetMaxEnergyValue() * restorePercentage);

        // Debug.Log("Current Energy: " + currentEnergyValue);
        // Debug.Log("Restore Perc: " + restorePercentage);
        // Debug.Log("Resore Min Amount: " + restoreAmount);

        currentEnergyValue = Mathf.Clamp(currentEnergyValue, restoreAmount, PlayerSkills.GetMaxEnergyValue());
    }