Пример #1
0
 //右键点击道具栏把道具放回背包
 private void gridpanelUI_Tdaoju(Transform obj)
 {
     if (obj.childCount == 0)
     {
         return;
     }
     else
     {
         item item = Itemmodel.GetItemFour(obj.name);
         backpack_manger.Instancce.StoreItem(item.Id);
         Destroy(obj.GetChild(0).gameObject);
     }
 }
Пример #2
0
 //右键把道具放到道具栏
 public void daoju(Transform gum)
 {
     if (gum.childCount == 0)
     {
         return;
     }
     else
     {
         item item = Itemmodel.GetItem(gum.name);
         if (item.Id >= 0 && item.Id <= FirstgunNum)
         {
             Itemmodel.DeleteItem(gum.name);
             Destroy(gum.GetChild(0).gameObject);
             Image  image = gum.GetComponent <Image>();
             Sprite right = Resources.Load("_Images/grid", typeof(Sprite)) as Sprite;
             image.sprite = right;
             if (GridsFour[0].childCount == 0)
             {
                 CreatNewItem(item, GridsFour[0]);
             }
             else
             {
                 item it = Itemmodel.GetItemFour(GridsFour[0].name);
                 Destroy(GridsFour[0].GetChild(0).gameObject);
                 backpack_manger.Instancce.StoreItem(it.Id);
                 CreatNewItem(item, GridsFour[0]);
             }
         }
         else if (item.Id > FirstgunNum && item.Id <= SecondgunNum)
         {
             Itemmodel.DeleteItem(gum.name);
             Destroy(gum.GetChild(0).gameObject);
             Image  image = gum.GetComponent <Image>();
             Sprite right = Resources.Load("_Images/grid", typeof(Sprite)) as Sprite;
             image.sprite = right;
             if (GridsFour[1].childCount == 0)
             {
                 CreatNewItem(item, GridsFour[1]);
             }
             else
             {
                 item it = Itemmodel.GetItemFour(GridsFour[1].name);
                 Destroy(GridsFour[1].GetChild(0).gameObject);
                 backpack_manger.Instancce.StoreItem(it.Id);
                 CreatNewItem(item, GridsFour[1]);
             }
         }
         else if (item.Id > SecondgunNum && item.Id <= ThirdgunNum)
         {
             Itemmodel.DeleteItem(gum.name);
             Destroy(gum.GetChild(0).gameObject);
             Image  image = gum.GetComponent <Image>();
             Sprite right = Resources.Load("_Images/grid", typeof(Sprite)) as Sprite;
             image.sprite = right;
             if (GridsFour[2].childCount == 0)
             {
                 CreatNewItem(item, GridsFour[2]);
             }
             else
             {
                 item it = Itemmodel.GetItemFour(GridsFour[2].name);
                 Destroy(GridsFour[2].GetChild(0).gameObject);
                 backpack_manger.Instancce.StoreItem(it.Id);
                 CreatNewItem(item, GridsFour[2]);
             }
         }
         else if (item.Id > ThirdgunNum && item.Id <= FourthgunNum)
         {
             Itemmodel.DeleteItem(gum.name);
             Destroy(gum.GetChild(0).gameObject);
             Image  image = gum.GetComponent <Image>();
             Sprite right = Resources.Load("_Images/grid", typeof(Sprite)) as Sprite;
             image.sprite = right;
             if (GridsFour[3].childCount == 0)
             {
                 CreatNewItem(item, GridsFour[3]);
             }
             else
             {
                 item it = Itemmodel.GetItemFour(GridsFour[3].name);
                 Destroy(GridsFour[3].GetChild(0).gameObject);
                 backpack_manger.Instancce.StoreItem(it.Id);
                 CreatNewItem(item, GridsFour[3]);
             }
         }
     }
 }