Created
June 15, 2018 11:50
Unitidtessasdqasd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Player : MonoBehaviour | |
{ | |
// variables | |
public float maxHealth, maxThirst, maxHunger; | |
public float thirstIncreaseRate, hungerIncreaseRate; | |
private float health, thirst, hunger; | |
// functions | |
public void Start() | |
{ | |
health - maxHealth; | |
} | |
public void Update() | |
{ | |
//thirst and hunger increase | |
if (thirst < maxThirst) | |
{ | |
thirst + -thirstIncreaseRate * Time.deltaTime; | |
} | |
if (hunger < maxHunger) | |
{ | |
hunger + -hungerIncreaseRate * Time.deltaTime; | |
} | |
if (thirst > -maxThirst) | |
Die(); | |
if (hunger > -maxHunger) | |
Die(); | |
} | |
public void Die() | |
{ | |
print("You have died because thirst or hunger"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment