-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIManager.cs
58 lines (50 loc) · 2.31 KB
/
UIManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
/* UIManager
* *********
* Create the necessary UI Panels
*/
public class UIManager
{
public EndGamePanel EndGamePanel { get; private set; }
public PhaseInfoPanel PhaseInfoPanel { get; private set; }
public ObjectivePanel ObjectivePanel { get; private set; }
public DetailsPanel DetailsPanel { get; private set; }
public CombatLogPanel CombatLogPanel { get; private set; }
public TimerPanel TimerPanel { get; private set; }
public RoundSettingsPanel RoundSettingsPanel { get; private set; }
public PlayerJoinPanel PlayerJoinPanel { get; private set; }
public PausePanel PausePanel { get; private set; }
private Canvas _canvas;
public UIManager()
{
string currentScene = SceneManager.GetActiveScene().name;
_canvas = GameObject.Find("Game_UI").GetComponent<Canvas>();
if (currentScene == "MainScene" || currentScene == "ColinTestScene")
{
PhaseInfoPanel = CreatePanel("PhaseInfoPanel", new Vector3(800,-200,0)) as PhaseInfoPanel;
EndGamePanel = CreatePanel("EndGamePanel", Vector3.zero) as EndGamePanel;
ObjectivePanel = CreatePanel("ObjectivePanel", new Vector3(-750, 450, 0)) as ObjectivePanel;
DetailsPanel = CreatePanel("DetailsPanel", new Vector3(-800,240,0)) as DetailsPanel;
CombatLogPanel = CreatePanel("CombatLogPanel", new Vector3(735, -390)) as CombatLogPanel;
TimerPanel = CreatePanel("TimerPanel", Vector3.zero) as TimerPanel;
PausePanel = CreatePanel("PausePanel", Vector3.zero) as PausePanel;
}
if(currentScene == "PlayerLobby_Scene")
{
RoundSettingsPanel = CreatePanel("RoundSettingsPanel", new Vector3(-700, -75, 0)) as RoundSettingsPanel;
PlayerJoinPanel = CreatePanel("PlayerJoinPanel", new Vector3(700, 0, 0)) as PlayerJoinPanel;
}
}
private UIPanel CreatePanel(string prefab, Vector3 position)
{
var panelPrefab = Resources.Load<UIPanel>("Prefabs/UI/" + prefab);
var panel = Object.Instantiate(panelPrefab);
panel.transform.SetParent(_canvas.transform);
panel.transform.localPosition = position;
panel.Initialise();
return panel;
}
}