Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class Shop : MonoBehaviour {
- public GUISkin mySkin;
- public int bmn;
- //TOOL BARS
- private string[]playerTypetoolbarStrings = new string[] {"Box","Sphere"};
- private int playerTypetoolbarInt=0;
- private string[]categoriestoolbarStrings = new string[] {"Weapons","Materials","Buildings"};
- private int categoriestoolbarInt=0;
- private string[]categories1toolbarStrings = new string[] {"Weapons","Technique"};
- private int categories1toolbarInt=0;
- private string[]classtoolbarStrings = new string[] {"Knight","Berseker","Mage","Ranger"};
- private int classtoolbarInt=0;
- private string[]materialstoolbarStrings = new string[] {"Blocks","Planks","Columns"};
- private int materialstoolbarInt=0;
- private string[]buildingstoolbarStrings = new string[] {"Houses","Walls","Towers"};
- private int buildingstoolbarInt=0;
- //ITEM LISTS
- public List <InvItem> weaponKnightItem=new List<InvItem>();
- public List <InvItem> weaponBersekerItem=new List<InvItem>();
- public List <InvItem> weaponMageItem=new List<InvItem>();
- public List <InvItem> weaponRangerItem=new List<InvItem>();
- //DINAMIC STATS ITEMS
- private InvItem _itemBuy;
- private Texture2D _icon;
- private string _itemName;
- private string _description;
- private int _damage;
- private int _durability;
- private int _cost;
- private string _playerClass;
- private bool showShop=false;
- void Update(){
- if(Input.GetKeyDown(KeyCode.E))showShop=!showShop;
- }
- void OnGUI(){
- GUI.skin=mySkin;
- if(showShop==true)ShowShop();
- }
- private void ShowShop(){
- //SHOP ITEMS CATEGORIES
- GUILayout.BeginArea(new Rect(20,20,200,Screen.height-200),"Shop Categories","ShopWindow");
- playerTypetoolbarInt = GUI.Toolbar(new Rect(10,30,180,85),playerTypetoolbarInt,playerTypetoolbarStrings);
- if(playerTypetoolbarInt==0)categoriestoolbarInt = GUI.SelectionGrid(new Rect(10,130,120,30*categoriestoolbarStrings.Length),categoriestoolbarInt,categoriestoolbarStrings,1);
- if(playerTypetoolbarInt==1 && Input.GetKeyDown(KeyCode.G))categories1toolbarInt = GUI.SelectionGrid(new Rect(10,130,120,30*categories1toolbarStrings.Length),categories1toolbarInt,categories1toolbarStrings,1);
- GUILayout.EndArea();
- //ITEMS IN SHOP
- GUILayout.BeginArea(new Rect(225,20,Screen.width-275,Screen.height-200),"","ShopWindow");
- //CATEGORIES
- if(categoriestoolbarInt==0)classtoolbarInt = GUI.Toolbar(new Rect(10,10,100*classtoolbarStrings.Length,30),classtoolbarInt,classtoolbarStrings);
- if(categoriestoolbarInt==1)materialstoolbarInt = GUI.Toolbar(new Rect(10,10,100*materialstoolbarStrings.Length,30),materialstoolbarInt,materialstoolbarStrings);
- if(categoriestoolbarInt==2)buildingstoolbarInt = GUI.Toolbar(new Rect(10,10,100*buildingstoolbarStrings.Length,30),buildingstoolbarInt,buildingstoolbarStrings);
- //CATEGORIES1
- //ITEMS BY TYPES
- if(categoriestoolbarInt==0 && classtoolbarInt==0){ShowShopCategory();
- /*int cnt=0;int cols=(Screen.width-275)/60;int rows=(Screen.height-200)/60;
- for(int y=0;y<rows;y++){
- for(int x=0;x<cols;x++){
- if(cnt<weaponKnightItem.Count){
- if(GUI.Button(new Rect(10+(x*60),80+(y*60),50,50),weaponKnightItem[cnt].icon)){
- _itemBuy=weaponKnightItem[cnt];
- _icon=weaponKnightItem[cnt].icon;
- _itemName=weaponKnightItem[cnt].itemName;
- _description=weaponKnightItem[cnt].description;
- _playerClass=weaponKnightItem[cnt].playerClass;
- _damage=weaponKnightItem[cnt].damage;
- _durability=weaponKnightItem[cnt].durability;
- _cost=weaponKnightItem[cnt].cost;
- //showWeaponWindow=true;
- }cnt++;}}}}
- if(categoriestoolbarInt==0 && classtoolbarInt==1){
- int cnt=0;int cols=(Screen.width-275)/60;int rows=(Screen.height-200)/60;
- for(int y=0;y<rows;y++){
- for(int x=0;x<cols;x++){
- if(cnt<weaponBersekerItem.Count){
- if(GUI.Button(new Rect(10+(x*60),80+(y*60),50,50),weaponBersekerItem[cnt].icon)){
- _itemBuy=weaponBersekerItem[cnt];
- _icon=weaponBersekerItem[cnt].icon;
- _itemName=weaponBersekerItem[cnt].itemName;
- _description=weaponBersekerItem[cnt].description;
- _playerClass=weaponBersekerItem[cnt].playerClass;
- _damage=weaponBersekerItem[cnt].damage;
- _durability=weaponBersekerItem[cnt].durability;
- _cost=weaponBersekerItem[cnt].cost;
- //showWeaponWindow=true;
- }cnt++;}}}}*/
- GUILayout.EndArea();
- }}
- private void ShowShopCategory(){
- int cnt=0;/*int y=0;int x=0*/;int cols=(Screen.width-275)/60;int rows=(Screen.height-200)/60;
- foreach(InvItem _weaponKnightItem in weaponKnightItem){
- if(_weaponKnightItem.damage==2){
- //if(y<rows){
- //if(x<cols){
- for(int y=0;y<rows;y++){
- for(int x=0;x<cols;x++){
- GUI.Button(new Rect(10+(x*60),80+(y*60),50,50),_weaponKnightItem.icon);cnt++;
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment