98 lines
1.6 KiB
C#
98 lines
1.6 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class DayController : MonoBehaviour {
|
|
|
|
public Animator machine;
|
|
public int maxDay;
|
|
public int maxNight;
|
|
public int maxKilling;
|
|
|
|
float timer;
|
|
int maxDiscussion;
|
|
int maxAccusation;
|
|
int dayNb;
|
|
|
|
//appel de Window Chat
|
|
GameObject chatWindowScroll;
|
|
ChatWindow chatWindow;
|
|
|
|
|
|
|
|
// Use this for initialization
|
|
void Start () {
|
|
|
|
//calcul des différent timing.
|
|
machine.SetInteger ("day_status", 0);
|
|
maxDiscussion = (int) maxDay / 2;
|
|
maxAccusation = maxDay - maxDiscussion;
|
|
|
|
//appel de Window Chat
|
|
chatWindowScroll = GameObject.Find ("ChatWindowScroll");
|
|
chatWindow = chatWindowScroll.GetComponent<ChatWindow> ();
|
|
|
|
dayNb = 1;
|
|
chatWindow.writeDay (dayNb);
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
|
|
//DISUCSSION
|
|
if (machine.GetInteger("day_status")==0){
|
|
|
|
|
|
if (timer >= (float)maxDiscussion){
|
|
machine.SetInteger("day_status",1);
|
|
print("Accusation!");
|
|
}
|
|
|
|
else{
|
|
timer += Time.deltaTime;
|
|
}
|
|
|
|
}
|
|
|
|
//ACCUSATION
|
|
if (machine.GetInteger("day_status")==1){
|
|
|
|
|
|
if (timer >= (float)maxDay){
|
|
machine.SetInteger("day_status",3);
|
|
print("il fait nuit!");
|
|
timer = 0;
|
|
}
|
|
|
|
else{
|
|
timer += Time.deltaTime;
|
|
}
|
|
|
|
}
|
|
|
|
//NUIT
|
|
if (machine.GetInteger("day_status")==3){
|
|
|
|
|
|
if (timer >= (float)maxNight){
|
|
machine.SetInteger("day_status",0);
|
|
timer = 0;
|
|
dayNb ++;
|
|
|
|
string message = "\n\n\n JOUR "+ dayNb.ToString()+"\n";
|
|
chatWindow.writeDay(dayNb);
|
|
print("le jour se lève, discutez!");
|
|
|
|
}
|
|
|
|
else{
|
|
timer += Time.deltaTime;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|