Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int CurWeapon;
- public int LastWeapon;
- public static GUIManager Instance;
- public bool ShowBoard;
- public WeaponManager manager;
- public RankManager rank;
- // Use this for initialization
- void Start () {
- Instance = this;
- /*foreach (Sight s in NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[0].Sights.ToArray())
- {
- SightNames.Add (s.Name);
- }*/
- //UpdateWeapons ();
- }
- // Update is called once per frame
- void Update () {
- if (LastWeapon != CurWeapon)
- {
- ChangedGun();
- }
- UpdateWeapons ();
- if (Input.GetKey (KeyCode.Tab))
- ShowBoard = true;
- else
- ShowBoard = false;
- }
- void OnGUI()
- {
- if (NetworkManager.Instance.MatchStarted && !NetworkManager.Instance.MyPlayer.IsAlive)
- {
- CurWeapon = GUILayout.SelectionGrid (CurWeapon, WeaponNames.ToArray(), 4);
- NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].CurSight = GUILayout.SelectionGrid(NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].CurSight,SightNames.ToArray(), 4);
- if(!NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].Bought)
- {
- if(NetworkManager.Instance.MyPlayer.Score >= NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].Cost)
- {
- GUI.BeginGroup(new Rect(Screen.width / 2 - 256,Screen.height / 2 - 128,512,256),"","box");
- GUI.Label(new Rect(128,16,256,32),"Would you like to buy this gun?");
- if(GUI.Button (new Rect(128,64,256,32),"Yes"))
- {
- NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].Bought = true;
- NetworkManager.Instance.MyPlayer.Score -= NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont.Weapons[CurWeapon].Cost;
- }
- }
- else
- {
- GUI.BeginGroup(new Rect(Screen.width/2 - 256,Screen.height/2 - 128,512,256),"","box");
- GUI.Label(new Rect(128,16,256,32),"You do not have enough money!");
- }
- GUI.EndGroup();
- }
- }
- if (ShowBoard && NetworkManager.Instance.MatchStarted)
- {
- GUILayout.BeginArea(new Rect(Screen.width/4,Screen.height/4,(Screen.width) - (Screen.width/2),(Screen.height) - (Screen.height/2)),GUIContent.none,"box");
- foreach (NetworkManager.Player pl in NetworkManager.Instance.PlayerList)
- {
- GUILayout.BeginHorizontal();
- GUILayout.Label(pl.PlayerName);
- GUILayout.Label(pl.Score.ToString());
- GUILayout.Label(pl.Kills.ToString());
- GUILayout.Label(pl.Deaths.ToString());
- GUILayout.EndHorizontal();
- }
- GUILayout.EndArea();
- }
- if(NetworkManager.Instance.MyPlayer.IsAlive)
- {
- 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());
- }
- }
- public void UpdateWeapons()
- {
- WeaponNames.Clear ();
- foreach(Gun g in manager.Weapons)
- {
- if(rank.CurLevel >= g.UnlockLevel)
- {
- WeaponNames.Add(g.Name);
- }
- }
- ChangedGun ();
- }
- void ChangedGun()
- {
- SightNames.Clear ();
- //LastWeapon = CurWeapon;
- foreach(Sight s in manager.Weapons[CurWeapon].Sights)
- {
- if(manager.Weapons[0].Kills >= s.UnlockKills)
- {
- SightNames.Add(s.Name);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement