void Awake() { if (instance == null) instance = this; isInited = false; watcher = 0; }
public override void Initialize() { battleSelection = transform.root.GetComponent<BattleSelection> (); Canvas canvas = transform.FindChild ("BattleCanvas").GetComponent<Canvas>(); foreach(GameObject g in GameObject.FindGameObjectsWithTag("Canvas")){ g.SetActive(false); //set all other canvases inactive to be sure } canvas.gameObject.SetActive (true); //activate the canvas we want if (!initialized) { if (canvas != null) { //is this nessisary? probs not because I think that setactive call above will throw an exception leftPanel = canvas.transform.FindChild ("Left Panel").GetComponent<RectTransform> (); mothershipLeftPanel = canvas.transform.FindChild ("Mothership Left Panel").GetComponent<RectTransform> (); mothershipPanel = mothershipLeftPanel.GetComponent<BattleMothershipPanel> (); infoPanel = leftPanel.GetComponent<BattleInfoPanel> (); infoPanel.Initialize (); mothershipPanel.Initialize (); timer = GetComponent<Timer> (); jumpbutton = GameObject.Find ("BattleCanvas/Top Panel/JumpButton"); jumpbutton.SetActive (false); initialized = true; } else { Debug.Log ("Null canvas for Battle?"); } } }
void Awake() { if (instance == null) { instance = this; } isInited = false; watcher = 0; }
void ParseBattleInfo(Dictionary <string, object> json) { string state = json["state"].ToString(); if (state == "finish") { OnGameFinish(); return; } if (state == "exit") { OnRivalExit(); return; } int id = System.Convert.ToInt32(json ["turn_player"]); int turn = System.Convert.ToInt32(json ["turn_count"]); int watcher = System.Convert.ToInt32(json ["watcher_count"]); BattleInfoPanel panel = BattleInfoPanel.Instance; if (panel.Watcher < watcher) { panel.IncreaseWatcher(); if (!NoticePanel.IsShowing) { NoticePanel.Show(); } } if (id == GetTurnPlayer().UserId) { if (!panel.Inited) { panel.SetPanel(GetTurnPlayer().Name, turn); return; } } isTurnChanged = true; panel.SetPanel(GetTurnPlayer().Name, turn); if (id == first.UserId) { first.SetTurn(true); last.SetTurn(false); return; } if (id == last.UserId) { first.SetTurn(false); last.SetTurn(true); return; } }