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