2015-01-21 23:09:21 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
2015-01-22 00:26:08 +00:00
|
|
|
|
public class DayController : MonoBehaviour {
|
2015-01-21 23:09:21 +00:00
|
|
|
|
|
|
|
|
|
public Animator machine;
|
|
|
|
|
public int maxDay;
|
|
|
|
|
public int maxNight;
|
2015-01-22 17:32:01 +00:00
|
|
|
|
public int maxKilling;
|
|
|
|
|
|
2015-01-21 23:09:21 +00:00
|
|
|
|
float timer;
|
2015-01-22 17:32:01 +00:00
|
|
|
|
int maxDiscussion;
|
|
|
|
|
int maxAccusation;
|
|
|
|
|
int dayNb;
|
|
|
|
|
|
|
|
|
|
//appel de Window Chat
|
|
|
|
|
GameObject chatWindowScroll;
|
|
|
|
|
ChatWindow chatWindow;
|
|
|
|
|
|
2015-01-25 17:05:54 +00:00
|
|
|
|
//appel de CreateScrollList
|
|
|
|
|
GameObject createScrollListObject;
|
|
|
|
|
CreateScrollList createScrollList;
|
2015-01-22 17:32:01 +00:00
|
|
|
|
|
2015-01-26 11:29:35 +00:00
|
|
|
|
//appel de ManaStack
|
|
|
|
|
GameObject manaStackObject;
|
|
|
|
|
ManaStack manaStack;
|
|
|
|
|
|
2015-01-22 17:32:01 +00:00
|
|
|
|
|
2015-01-21 23:09:21 +00:00
|
|
|
|
// Use this for initialization
|
|
|
|
|
void Start () {
|
|
|
|
|
|
2015-01-22 17:32:01 +00:00
|
|
|
|
//calcul des différent timing.
|
2015-01-21 23:09:21 +00:00
|
|
|
|
machine.SetInteger ("day_status", 0);
|
2015-01-22 17:32:01 +00:00
|
|
|
|
maxDiscussion = (int) maxDay / 2;
|
|
|
|
|
maxAccusation = maxDay - maxDiscussion;
|
2015-01-21 23:09:21 +00:00
|
|
|
|
|
2015-01-22 17:32:01 +00:00
|
|
|
|
//appel de Window Chat
|
|
|
|
|
chatWindowScroll = GameObject.Find ("ChatWindowScroll");
|
|
|
|
|
chatWindow = chatWindowScroll.GetComponent<ChatWindow> ();
|
|
|
|
|
|
2015-01-25 17:05:54 +00:00
|
|
|
|
//appel de CreateScrollList
|
|
|
|
|
createScrollListObject = GameObject.Find ("log_controller");
|
|
|
|
|
createScrollList = createScrollListObject.GetComponent<CreateScrollList> ();
|
|
|
|
|
|
2015-01-26 11:29:35 +00:00
|
|
|
|
//appel de ManaStack
|
|
|
|
|
manaStackObject = GameObject.Find ("mana_controller");
|
|
|
|
|
manaStack = manaStackObject.GetComponent<ManaStack> ();
|
|
|
|
|
|
2015-01-22 17:32:01 +00:00
|
|
|
|
dayNb = 1;
|
2015-01-25 15:00:11 +00:00
|
|
|
|
chatWindow.writeDay (dayNb);
|
2015-01-26 11:29:35 +00:00
|
|
|
|
manaStack.addDaily (dayNb);
|
2015-01-22 17:32:01 +00:00
|
|
|
|
|
2015-01-21 23:09:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update () {
|
|
|
|
|
|
2015-01-22 17:32:01 +00:00
|
|
|
|
//DISUCSSION
|
2015-01-21 23:09:21 +00:00
|
|
|
|
if (machine.GetInteger("day_status")==0){
|
|
|
|
|
|
2015-01-22 00:26:08 +00:00
|
|
|
|
|
2015-01-22 17:32:01 +00:00
|
|
|
|
if (timer >= (float)maxDiscussion){
|
2015-01-21 23:09:21 +00:00
|
|
|
|
machine.SetInteger("day_status",1);
|
2015-01-22 17:32:01 +00:00
|
|
|
|
print("Accusation!");
|
2015-01-25 17:05:54 +00:00
|
|
|
|
createScrollList.writeNotification("Denoncez-vous, pauvres fous!!!");
|
2015-01-21 23:09:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
timer += Time.deltaTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-22 17:32:01 +00:00
|
|
|
|
//ACCUSATION
|
2015-01-21 23:09:21 +00:00
|
|
|
|
if (machine.GetInteger("day_status")==1){
|
2015-01-22 00:26:08 +00:00
|
|
|
|
|
2015-01-21 23:09:21 +00:00
|
|
|
|
|
2015-01-22 17:32:01 +00:00
|
|
|
|
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){
|
|
|
|
|
|
|
|
|
|
|
2015-01-22 00:26:08 +00:00
|
|
|
|
if (timer >= (float)maxNight){
|
2015-01-21 23:09:21 +00:00
|
|
|
|
machine.SetInteger("day_status",0);
|
2015-01-22 17:32:01 +00:00
|
|
|
|
timer = 0;
|
|
|
|
|
dayNb ++;
|
|
|
|
|
|
2015-01-25 15:00:11 +00:00
|
|
|
|
chatWindow.writeDay(dayNb);
|
2015-01-26 11:29:35 +00:00
|
|
|
|
manaStack.addDaily (dayNb);
|
2015-01-22 17:32:01 +00:00
|
|
|
|
print("le jour se lève, discutez!");
|
|
|
|
|
|
2015-01-21 23:09:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
timer += Time.deltaTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2015-01-25 22:22:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getDay(){return dayNb;}
|
2015-01-21 23:09:21 +00:00
|
|
|
|
}
|