Newer
Older
/*
* Script par Tanguy Gimenez
*
*/
using UnityEngine;
using System;
using System.Timers;
// 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;
// durée en ms ou a chaque fois, le joueur perd un certain nombre de pv
public int duree = 1000;
// dommage pris tout les x ms si t'es dans la ville
public int TimeDamage;
private float nextActionTime = 0.0f;
public float period = 0.1f;
// initialisation des points de nature
this.natureBar.SetValue(this.currentNature);
////toutes les x secondes => on perd un certain nombre de secondes
//if (Time.time > nextActionTime)
//{
// nextActionTime += period;
// this.LooseNature(this.TimeDamage);
//}
public void LooseNature(int damage)
{
this.currentNature -= damage;
// Gagne un certain nombre de points de nature
public void WinNature(int bonus)
{
this.currentNature += bonus;
if (this.currentNature >= 100)
this.currentNature = 100;
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;
}