SHOW:
|
|
- or go back to the newest paste.
1 | public int CurWeapon; | |
2 | public int LastWeapon; | |
3 | public static GUIManager Instance; | |
4 | public bool ShowBoard; | |
5 | public WeaponManager manager; | |
6 | public RankManager rank; | |
7 | // Use this for initialization | |
8 | void Start () { | |
9 | Instance = this; | |
10 | /*foreach (Sight s in NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[0].Sights.ToArray()) | |
11 | { | |
12 | SightNames.Add (s.Name); | |
13 | }*/ | |
14 | //UpdateWeapons (); | |
15 | } | |
16 | ||
17 | // Update is called once per frame | |
18 | void Update () { | |
19 | if (LastWeapon != CurWeapon) | |
20 | { | |
21 | ChangedGun(); | |
22 | } | |
23 | UpdateWeapons (); | |
24 | ||
25 | if (Input.GetKey (KeyCode.Tab)) | |
26 | ShowBoard = true; | |
27 | else | |
28 | ShowBoard = false; | |
29 | } | |
30 | ||
31 | void OnGUI() | |
32 | { | |
33 | if (NetworkManager.Instance.MatchStarted && !NetworkManager.Instance.MyPlayer.IsAlive) | |
34 | { | |
35 | CurWeapon = GUILayout.SelectionGrid (CurWeapon, WeaponNames.ToArray(), 4); | |
36 | NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].CurSight = GUILayout.SelectionGrid(NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].CurSight,SightNames.ToArray(), 4); | |
37 | if(!NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].Bought) | |
38 | { | |
39 | if(NetworkManager.Instance.MyPlayer.Score >= NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].Cost) | |
40 | { | |
41 | GUI.BeginGroup(new Rect(Screen.width / 2 - 256,Screen.height / 2 - 128,512,256),"","box"); | |
42 | GUI.Label(new Rect(128,16,256,32),"Would you like to buy this gun?"); | |
43 | if(GUI.Button (new Rect(128,64,256,32),"Yes")) | |
44 | { | |
45 | NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].Bought = true; | |
46 | NetworkManager.Instance.MyPlayer.Score -= NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].Cost; | |
47 | } | |
48 | } | |
49 | else | |
50 | { | |
51 | GUI.BeginGroup(new Rect(Screen.width/2 - 256,Screen.height/2 - 128,512,256),"","box"); | |
52 | GUI.Label(new Rect(128,16,256,32),"You do not have enough money!"); | |
53 | ||
54 | ||
55 | } | |
56 | GUI.EndGroup(); | |
57 | } | |
58 | } | |
59 | if (ShowBoard && NetworkManager.Instance.MatchStarted) | |
60 | { | |
61 | GUILayout.BeginArea(new Rect(Screen.width/4,Screen.height/4,(Screen.width) - (Screen.width/2),(Screen.height) - (Screen.height/2)),GUIContent.none,"box"); | |
62 | foreach (NetworkManager.Player pl in NetworkManager.Instance.PlayerList) | |
63 | { | |
64 | GUILayout.BeginHorizontal(); | |
65 | GUILayout.Label(pl.PlayerName); | |
66 | GUILayout.Label(pl.Score.ToString()); | |
67 | GUILayout.Label(pl.Kills.ToString()); | |
68 | GUILayout.Label(pl.Deaths.ToString()); | |
69 | GUILayout.EndHorizontal(); | |
70 | } | |
71 | ||
72 | GUILayout.EndArea(); | |
73 | } | |
74 | if(NetworkManager.Instance.MyPlayer.IsAlive) | |
75 | { | |
76 | GUI.Box(new Rect(Screen.width - (128 * (NetworkManager.Instance.MyPlayer.Health/100)),16,(NetworkManager.Instance.MyPlayer.Health/100) * 256,32),NetworkManager.Instance.MyPlayer.Health.ToString()); | |
77 | } | |
78 | } | |
79 | public void UpdateWeapons() | |
80 | { | |
81 | WeaponNames.Clear (); | |
82 | foreach(Gun g in manager.Weapons) | |
83 | { | |
84 | if(rank.CurLevel >= g.UnlockLevel) | |
85 | { | |
86 | WeaponNames.Add(g.Name); | |
87 | ||
88 | } | |
89 | } | |
90 | ChangedGun (); | |
91 | } | |
92 | ||
93 | void ChangedGun() | |
94 | { | |
95 | SightNames.Clear (); | |
96 | - | //LastWeapon = CurWeapon; |
96 | + | LastWeapon = CurWeapon; |
97 | foreach(Sight s in manager.Weapons[CurWeapon].Sights) | |
98 | { | |
99 | if(manager.Weapons[0].Kills >= s.UnlockKills) | |
100 | { | |
101 | SightNames.Add(s.Name); | |
102 | } | |
103 | } | |
104 | } | |
105 | } |