akadoc/Assets/scripts/Gui_DayController.cs

118 lines
2.2 KiB
C#
Raw Normal View History

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