예제 #1
0
    void Update()
    {
        Timestamp currentTime = timeManager.GetTime();

        foreach (Time_Based_Dynamic_Story dynamicStory in timeBasedDynamicStories)
        {
            if (dynamicStory.HasPlayed())
            {
                continue;
            }

            if (currentTime.day > dynamicStory.timeWhenToDisplay.day)
            {
                dynamicStories.Enqueue(dynamicStory.dynamicStory);
                dynamicStory.Played();
            }
            else if (currentTime.day == dynamicStory.timeWhenToDisplay.day && currentTime.hour >= dynamicStory.timeWhenToDisplay.hour)
            {
                dynamicStories.Enqueue(dynamicStory.dynamicStory);
                dynamicStory.Played();
            }
            else if (currentTime.day == dynamicStory.timeWhenToDisplay.day && currentTime.hour == dynamicStory.timeWhenToDisplay.hour && currentTime.minute >= dynamicStory.timeWhenToDisplay.minute)
            {
                dynamicStories.Enqueue(dynamicStory.dynamicStory);
                dynamicStory.Played();
            }
        }
    }
예제 #2
0
    void UpdateThirst()
    {
        Timestamp currentTime = timeManager.GetTime();
        uint      hoursUntilDeadFromThirst = timeManager.HoursBetweenTimestamps(currentTime, timeWhenDeadToThirst);

        if (hoursUntilDeadFromThirst == 0)
        {
            Debug.Log("Character died due to hydration");
            Kill();
        }
        else if (hoursUntilDeadFromThirst < hoursBelowForVeryThirsty)
        {
            hydration = Hydration.VERY_THIRSTY;
        }
        else if (hoursUntilDeadFromThirst < hoursBelowForThirsty)
        {
            hydration = Hydration.THIRSTY;
        }
        else if (hoursUntilDeadFromThirst < hoursBelowForSlightlyThirsty)
        {
            hydration = Hydration.SLIGHTLY_THIRSTY;
        }
        else
        {
            hydration = Hydration.HYDRATED;
        }
    }
예제 #3
0
    // Unity Callbacks -----------------------------
    void Awake()
    {
        gameStateManager = GameObject.Find("GameState_Manager").GetComponent <GameState_Manager>();
        timeManager      = GameObject.Find("Time_Manager").GetComponent <Time_Manager>();

        timeWhenDeadToThirst = timeManager.AddHoursToTimestamp(timeManager.GetTime(), startHydrationHours);
        timeWhenDeadToHunger = timeManager.AddHoursToTimestamp(timeManager.GetTime(), startFoodHours);
    }
    // Update is called once per frame
    void Update()
    {
        Timestamp currentTime = timeManager.GetTime();

        if (!endDayButton.isActiveAndEnabled)
        {
            if (currentTime.hour > timeManager.allowPlayerEndDayHour)
            {
                endDayButton.gameObject.SetActive(true);
            }
            else if (currentTime.hour == timeManager.allowPlayerEndDayHour && currentTime.minute > timeManager.allowPlayerEndDayMinute)
            {
                endDayButton.gameObject.SetActive(true);
            }
        }
    }
예제 #5
0
    void Update()
    {
        if (gameStateManager.GetState() == GameState.State.DAY)
        {
            Character          character = characterManager.GetCharacter();
            Character.Sickness sickness  = character.GetSickness();

            Timestamp timeWhenDeadToHunger = character.GetTimeWhenDeadToHunger();

            Timestamp currentTime = timeManager.GetTime();
            uint      hoursUntilDeadFromHunger = timeManager.HoursBetweenTimestamps(currentTime, timeWhenDeadToHunger);

            if (hoursUntilDeadFromHunger < hoursBelowForVerySick && sickness < Character.Sickness.VERY_SICK)
            {
                character.SetSickness(Character.Sickness.VERY_SICK);

                float random = Random.Range(0.0f, 100.0f);

                if (chanceToDieAtVerySick > random)
                {
                    character.Kill();
                }
            }
            else if (hoursUntilDeadFromHunger < hoursBelowForSick && sickness < Character.Sickness.SICK)
            {
                character.SetSickness(Character.Sickness.SICK);

                float random = Random.Range(0.0f, 100.0f);

                if (chanceToDieAtSick > random)
                {
                    character.Kill();
                }
            }
            else if (hoursUntilDeadFromHunger < hoursBelowForSlightlySick && sickness < Character.Sickness.SLIGHTLY_SICK)
            {
                character.SetSickness(Character.Sickness.SLIGHTLY_SICK);

                float random = Random.Range(0.0f, 100.0f);

                if (chanceToDieAtSlightlySick > random)
                {
                    character.Kill();
                }
            }
        }
    }
    public float GetWaterSystemQuantity()
    {
        uint minutesSinceLastUpdated = timeManager.MinutesBetweenTimestamps(waterSystemUpdateTime, timeManager.GetTime());

        if (minutesSinceLastUpdated > 0)
        {
            waterSystemQuantity  += minutesSinceLastUpdated * GetWaterSystemRatePerHour() / 60f;
            waterSystemUpdateTime = timeManager.GetTime();

            if (waterSystemQuantity > GetMaximumWaterSystemQuantity())
            {
                waterSystemQuantity = GetMaximumWaterSystemQuantity();
            }
        }

        return(waterSystemQuantity);
    }
예제 #7
0
    void OnGUI()
    {
        Timestamp currentTime   = timeManager.GetTime();
        uint      currentHour   = currentTime.hour;
        uint      currentMinute = currentTime.minute;

        dayText.text = "Day " + currentTime.day;

        // Time
        string suffix = "";

        // Set hour
        string hour = "";

        if (currentHour > 12)
        {
            suffix = "PM";
            hour   = (currentHour - 12).ToString();
        }
        else if (currentHour == 12)
        {
            suffix = "PM";
            hour   = currentHour.ToString();
        }
        else
        {
            suffix = "AM";
            hour   = currentHour.ToString();
        }

        // Set minute
        string minute = "";

        if (currentMinute < 10)
        {
            minute = "0";
        }

        minute += currentMinute.ToString();

        minuteText.text = hour + ":" + minute + " " + suffix;
    }
예제 #8
0
    void Update()
    {
        if (gameStateManager.GetState() == GameState.State.STATUS)
        {
            Character character = characterManager.GetCharacter();

            if (waterManager.GetWater() >= 1)
            {
                EnableHydrate();
            }
            else
            {
                DisableHydrate();
            }

            if (foodManager.GetFood() >= 1)
            {
                EnableFeed();
            }
            else
            {
                DisableFeed();
            }

            Timestamp timeWhenDeadToThirst = character.GetTimeWhenDeadToThirst();
            Timestamp timeWhenDeadToHunger = character.GetTimeWhenDeadToHunger();

            Timestamp currentTime = timeManager.GetTime();
            uint      hoursUntilDeadFromThirst = timeManager.HoursBetweenTimestamps(currentTime, timeWhenDeadToThirst);
            uint      hoursUntilDeadFromHunger = timeManager.HoursBetweenTimestamps(currentTime, timeWhenDeadToHunger);

            if (hoursUntilDeadFromThirst == 0)
            {
                characterHydratedStatusText.text = "Dead from thirst";
            }
            else if (hoursUntilDeadFromThirst < hoursBelowForVeryThirsty)
            {
                characterHydratedStatusText.text = "Very Thirsty";
            }
            else if (hoursUntilDeadFromThirst < hoursBelowForThirsty)
            {
                characterHydratedStatusText.text = "Thirsty";
            }
            else if (hoursUntilDeadFromThirst < hoursBelowForSlightlyThirsty)
            {
                characterHydratedStatusText.text = "Slightly Thirsty";
            }
            else
            {
                characterHydratedStatusText.text = "Hydrated";
                DisableHydrate();
            }

            if (hoursUntilDeadFromHunger == 0)
            {
                characterFedStatusText.text = "Dead from hunger";
            }
            else if (hoursUntilDeadFromHunger < hoursBelowForVeryHungry)
            {
                characterFedStatusText.text = "Very Hungry";
            }
            else if (hoursUntilDeadFromHunger < hoursBelowForHungry)
            {
                characterFedStatusText.text = "Hungry";
            }
            else if (hoursUntilDeadFromHunger < hoursBelowForSlightlyHungry)
            {
                characterFedStatusText.text = "Slightly Hungry";
            }
            else
            {
                characterFedStatusText.text = "Well Fed";
                DisableFeed();
            }

            // SICKNESS
            switch (character.GetSickness())
            {
            case Character.Sickness.HEALTHY:
                sicknessText.text = "Healthy";
                break;

            case Character.Sickness.SLIGHTLY_SICK:
                sicknessText.text = "Slightly Sick";
                break;

            case Character.Sickness.SICK:
                sicknessText.text = "Sick";
                break;

            case Character.Sickness.VERY_SICK:
                sicknessText.text = "Very Sick";
                break;
            }

            // INJURY
            switch (character.GetInjury())
            {
            case Character.Injury.NOT_INJURED:
                injuryText.text = "Not Injured";
                break;

            case Character.Injury.SLIGHTLY_INJURED:
                injuryText.text = "Slightly Injured";
                break;

            case Character.Injury.INJURED:
                injuryText.text = "Injured";
                break;

            case Character.Injury.VERY_INJURED:
                injuryText.text = "Very Injured";
                break;
            }
        }
    }