Skip to content
Snippets Groups Projects
PlayerNature.cs 1.3 KiB
Newer Older
GIMENEZ TANGUY's avatar
GIMENEZ TANGUY committed
/*
 *      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
GIMENEZ TANGUY's avatar
GIMENEZ TANGUY committed
    public int currentNature;

    // Jauge de points de nature
GIMENEZ TANGUY's avatar
GIMENEZ TANGUY committed
    public Bar natureBar;

    void Start()
    {
        this.currentNature = this.maxNature / 2;
GIMENEZ TANGUY's avatar
GIMENEZ TANGUY committed

        this.natureBar.SetMaxNature(this.maxNature);
    }

GIMENEZ TANGUY's avatar
GIMENEZ TANGUY committed
    void Update()
    {
        // DEBUG
GIMENEZ TANGUY's avatar
GIMENEZ TANGUY committed
        if (Input.GetKeyDown(KeyCode.Space))
            this.LooseNature(1);
    }
v.bloch's avatar
v.bloch committed
    
    // Perd un certain nombre de points de nature
GIMENEZ TANGUY's avatar
GIMENEZ TANGUY committed
    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;
    }
GIMENEZ TANGUY's avatar
GIMENEZ TANGUY committed
}