/* * Script par Tanguy Gimenez * */ using UnityEngine; public class PlayerNature : MonoBehaviour { // l'instance de PlayerNature (pour un singleton) public static PlayerNature instance; // Nombre max de points de nature que le joueur peut avoir (objectif à atteindre) public int maxNature = 200; // Quantité de points actuel public int currentNature; // Jauge de points de nature public Bar natureBar; private Animator animator; void Start() { animator = GetComponent<Animator>(); this.currentNature = this.maxNature / 2; this.natureBar.SetMaxNature(this.maxNature); } void Update() { // DEBUG if (Input.GetKeyDown(KeyCode.Space)) this.LooseNature(1); } // Perd un certain nombre de points de nature public void LooseNature(int damage) { this.currentNature -= damage; this.natureBar.SetValue(this.currentNature); } // Gagne un certain nombre de points de nature public void WinNature(int bonus) { this.currentNature += bonus; this.natureBar.SetValue(this.currentNature); } // Singleton private void Awake() { if (instance != null) { Debug.LogWarning("Il y a + d'une instance de PlayerNature"); return; } instance = this; } }