Guest User

Untitled

a guest
May 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.75 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public class Shop : MonoBehaviour {
  5.     public GUISkin mySkin;
  6.     public int bmn;
  7.     //TOOL BARS
  8.     private string[]playerTypetoolbarStrings = new string[] {"Box","Sphere"};
  9.     private int playerTypetoolbarInt=0;
  10.     private string[]categoriestoolbarStrings = new string[] {"Weapons","Materials","Buildings"};
  11.     private int categoriestoolbarInt=0;
  12.     private string[]categories1toolbarStrings = new string[] {"Weapons","Technique"};
  13.     private int categories1toolbarInt=0;
  14.     private string[]classtoolbarStrings = new string[] {"Knight","Berseker","Mage","Ranger"};
  15.     private int classtoolbarInt=0;
  16.     private string[]materialstoolbarStrings = new string[] {"Blocks","Planks","Columns"};
  17.     private int materialstoolbarInt=0;
  18.     private string[]buildingstoolbarStrings = new string[] {"Houses","Walls","Towers"};
  19.     private int buildingstoolbarInt=0;
  20.     //ITEM LISTS
  21.     public List <InvItem> weaponKnightItem=new List<InvItem>();
  22.     public List <InvItem> weaponBersekerItem=new List<InvItem>();
  23.     public List <InvItem> weaponMageItem=new List<InvItem>();
  24.     public List <InvItem> weaponRangerItem=new List<InvItem>();
  25.             //DINAMIC STATS ITEMS
  26.         private InvItem _itemBuy;
  27.         private Texture2D _icon;
  28.         private string _itemName;
  29.         private string _description;
  30.         private int _damage;
  31.         private int _durability;
  32.         private int _cost;
  33.         private string _playerClass;
  34.     private bool showShop=false;
  35.     void Update(){
  36.         if(Input.GetKeyDown(KeyCode.E))showShop=!showShop;
  37.     }
  38.     void OnGUI(){
  39.         GUI.skin=mySkin;
  40.         if(showShop==true)ShowShop();
  41.     }
  42.     private void ShowShop(){
  43.         //SHOP ITEMS CATEGORIES
  44.         GUILayout.BeginArea(new Rect(20,20,200,Screen.height-200),"Shop Categories","ShopWindow");
  45.         playerTypetoolbarInt = GUI.Toolbar(new Rect(10,30,180,85),playerTypetoolbarInt,playerTypetoolbarStrings);
  46.         if(playerTypetoolbarInt==0)categoriestoolbarInt = GUI.SelectionGrid(new Rect(10,130,120,30*categoriestoolbarStrings.Length),categoriestoolbarInt,categoriestoolbarStrings,1);
  47.         if(playerTypetoolbarInt==1 && Input.GetKeyDown(KeyCode.G))categories1toolbarInt = GUI.SelectionGrid(new Rect(10,130,120,30*categories1toolbarStrings.Length),categories1toolbarInt,categories1toolbarStrings,1);
  48.         GUILayout.EndArea();
  49.         //ITEMS IN SHOP
  50.         GUILayout.BeginArea(new Rect(225,20,Screen.width-275,Screen.height-200),"","ShopWindow");
  51.         //CATEGORIES
  52.         if(categoriestoolbarInt==0)classtoolbarInt = GUI.Toolbar(new Rect(10,10,100*classtoolbarStrings.Length,30),classtoolbarInt,classtoolbarStrings);
  53.         if(categoriestoolbarInt==1)materialstoolbarInt = GUI.Toolbar(new Rect(10,10,100*materialstoolbarStrings.Length,30),materialstoolbarInt,materialstoolbarStrings);
  54.         if(categoriestoolbarInt==2)buildingstoolbarInt = GUI.Toolbar(new Rect(10,10,100*buildingstoolbarStrings.Length,30),buildingstoolbarInt,buildingstoolbarStrings);
  55.         //CATEGORIES1
  56.        
  57.         //ITEMS BY TYPES
  58.         if(categoriestoolbarInt==0 && classtoolbarInt==0){ShowShopCategory();
  59.         /*int cnt=0;int cols=(Screen.width-275)/60;int rows=(Screen.height-200)/60;
  60.                 for(int y=0;y<rows;y++){
  61.                 for(int x=0;x<cols;x++){
  62.                 if(cnt<weaponKnightItem.Count){
  63.                 if(GUI.Button(new Rect(10+(x*60),80+(y*60),50,50),weaponKnightItem[cnt].icon)){
  64.                             _itemBuy=weaponKnightItem[cnt];
  65.                             _icon=weaponKnightItem[cnt].icon;
  66.                             _itemName=weaponKnightItem[cnt].itemName;
  67.                             _description=weaponKnightItem[cnt].description;
  68.                             _playerClass=weaponKnightItem[cnt].playerClass;
  69.                             _damage=weaponKnightItem[cnt].damage;
  70.                             _durability=weaponKnightItem[cnt].durability;
  71.                             _cost=weaponKnightItem[cnt].cost;
  72.                             //showWeaponWindow=true;
  73.                             }cnt++;}}}}
  74.         if(categoriestoolbarInt==0 && classtoolbarInt==1){
  75.         int cnt=0;int cols=(Screen.width-275)/60;int rows=(Screen.height-200)/60;
  76.                 for(int y=0;y<rows;y++){
  77.                 for(int x=0;x<cols;x++){
  78.                 if(cnt<weaponBersekerItem.Count){
  79.                 if(GUI.Button(new Rect(10+(x*60),80+(y*60),50,50),weaponBersekerItem[cnt].icon)){
  80.                             _itemBuy=weaponBersekerItem[cnt];
  81.                             _icon=weaponBersekerItem[cnt].icon;
  82.                             _itemName=weaponBersekerItem[cnt].itemName;
  83.                             _description=weaponBersekerItem[cnt].description;
  84.                             _playerClass=weaponBersekerItem[cnt].playerClass;
  85.                             _damage=weaponBersekerItem[cnt].damage;
  86.                             _durability=weaponBersekerItem[cnt].durability;
  87.                             _cost=weaponBersekerItem[cnt].cost;
  88.                             //showWeaponWindow=true;
  89.                             }cnt++;}}}}*/
  90.         GUILayout.EndArea();
  91.     }}
  92.     private void ShowShopCategory(){
  93.     int cnt=0;/*int y=0;int x=0*/;int cols=(Screen.width-275)/60;int rows=(Screen.height-200)/60;
  94.             foreach(InvItem _weaponKnightItem in weaponKnightItem){
  95.             if(_weaponKnightItem.damage==2){
  96.             //if(y<rows){
  97.             //if(x<cols){
  98.             for(int y=0;y<rows;y++){
  99.             for(int x=0;x<cols;x++){
  100.             GUI.Button(new Rect(10+(x*60),80+(y*60),50,50),_weaponKnightItem.icon);cnt++;
  101.                     }
  102.                 }
  103.             }
  104.         }
  105.  
  106.     }
  107. }
Add Comment
Please, Sign In to add comment