Virtual Pet Game (Using the Bathroom)
Hello,
I am creating a virtual pet game and am unable to apply a few concepts (other questions have been posted as well). Currently I am struggling to combine both the DateTime method as well as Random to achieve my desired goal. In this case, I would like to have my character leave (poop) for the player to clean every 3-5 (Random) hours. The player must then click a button to clean the screen (Reset character location? I am unsure of how to apply this action). This concept seems relatively simplistic - though I am new to Unity (though not C#) and am on a press for time.
Additionally, I would like the (poop) to decrease the character's happiness if it is not cleaned fast enough. Currently I have:
TimeSpan ts = getTimeSpan();
_hunger -= (int)(ts.TotalHours * 4);
if (_hunger < 0)
_hunger = 0;
if (_hunger > 100)
_hunger = 100;
_happiness -= (int)(ts.TotalHours * 7);
if (_happiness < 0)
_happiness = 0;
if (_happiness > 100)
_happiness = 100;
_discipline -= (int)((100 - happiness) * (ts.TotalHours / 10));
if (_discipline < 0)
_discipline = 0;
if (_discipline > 100)
_discipline = 100;
Though I am not sure as to how I can apply the aforementioned (poop / happiness). Any help would be appreciated.
Your answer
![](https://koobas.hobune.stream/wayback/20220612085822im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
What does "Assertion failed on expression: 'prefab.IsPrefabParent()'" mean on my source data? 4 Answers
Help to Add some Sort and Binary Search in the code. 1 Answer
How to make a Ragdoll move? 0 Answers
Index out of range exeption error help 0 Answers
Why Would Trie Data Retrieval Work in Windows Build but not Mac/HTML? 0 Answers