2014-11-09 19:21:28 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using System.Collections;
|
2015-01-22 00:26:08 +00:00
|
|
|
|
using UnityEngine.UI;
|
2014-11-09 19:21:28 +00:00
|
|
|
|
|
|
|
|
|
public class Clock : MonoBehaviour {
|
|
|
|
|
|
|
|
|
|
public GameObject clock;
|
2015-01-22 00:26:08 +00:00
|
|
|
|
GameObject day_controller;
|
|
|
|
|
DayController daycontroller;
|
|
|
|
|
int maxDay;
|
|
|
|
|
int maxNight;
|
2015-03-04 14:03:15 +00:00
|
|
|
|
|
2014-11-09 19:21:28 +00:00
|
|
|
|
|
|
|
|
|
// Use this for initialization
|
2015-03-04 14:03:15 +00:00
|
|
|
|
void Start() {
|
|
|
|
|
day_controller = GameObject.Find("day_controller");
|
2015-01-22 00:26:08 +00:00
|
|
|
|
daycontroller = day_controller.GetComponent<DayController> ();
|
2014-11-09 19:21:28 +00:00
|
|
|
|
|
2015-01-22 00:26:08 +00:00
|
|
|
|
maxDay = daycontroller.maxDay;
|
|
|
|
|
maxNight = daycontroller.maxNight;
|
2014-11-09 19:21:28 +00:00
|
|
|
|
}
|
2015-03-04 14:03:15 +00:00
|
|
|
|
|
2014-11-09 19:21:28 +00:00
|
|
|
|
// Update is called once per frame
|
2015-03-04 14:03:15 +00:00
|
|
|
|
void Update() {
|
2014-11-09 19:21:28 +00:00
|
|
|
|
//TODO: Sync clock with the server
|
|
|
|
|
//TODO: Set var as for day % or hour
|
|
|
|
|
|
2015-03-08 14:03:07 +00:00
|
|
|
|
float fRot = clock.transform.rotation.eulerAngles.z;
|
2014-11-09 19:21:28 +00:00
|
|
|
|
|
2015-03-08 14:03:07 +00:00
|
|
|
|
if(fRot>=180) {
|
2015-01-22 17:32:01 +00:00
|
|
|
|
clock.transform.Rotate(0, 0, (float)(Time.deltaTime * (-180.0)/maxNight));//2.5min
|
2014-11-09 19:21:28 +00:00
|
|
|
|
}
|
2015-03-04 14:03:15 +00:00
|
|
|
|
else {
|
2015-01-22 17:32:01 +00:00
|
|
|
|
clock.transform.Rotate(0, 0, (float)(Time.deltaTime * (-180.0)/maxDay));//1min
|
2014-11-09 19:21:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|