public void OnDropInPack(int _grid)        //物品放下格子里时调用
 {
     if (dragItem != null)
     {
         if (PackDatabaseMgr.CheckGrid(_grid) == null)
         {
             PackDatabaseMgr.Add(_grid, dragItem.uuid);
         }
         else
         {
             foreach (PackEntity packs in PackDatabaseMgr.List().Values)
             {
                 if (packs.itemID == "")
                 {
                     PackDatabaseMgr.Add(packs.grid, dragItem.uuid);
                     break;
                 }
             }
         }
         PackEntity pack = PackDatabaseMgr.Find(dragItem.uuid);
         PackView.Instance.UpdatePackView(pack.grid);
     }
     else if (dragPack != null)
     {
         PackDatabaseMgr.Exchage(dragPack.grid, _grid);
         PackView.Instance.UpdatePackView(dragPack.grid);
         PackView.Instance.UpdatePackView(_grid);
         DragView.DragInstance.OnDropItem();
         dragPack = null;
     }
 }
    public void OnDragItem(PointerEventData eventData, int _grid)      //从背包里拖动时调用
    {
        PackEntity pack = PackDatabaseMgr.CheckGrid(_grid);

        if (pack != null)
        {
            DragView.DragInstance.OnDragItem(eventData);        //调用View显示拖动
        }
    }
    public void OnChoosePack(int _grid)     //从背包里拖动东西时调用
    {
        PackEntity pack = PackDatabaseMgr.CheckGrid(_grid);

        if (pack != null)
        {
            dragPack = pack;
            DragView.DragInstance.CreateMouseItem(ItemDatabaseMgr.Find(dragPack.itemID).name, ItemDatabaseMgr.Find(dragPack.itemID).sprite, pack.count);
        }
    }
 public void OnEndDragItem(int _grid)        //从背包里拖动结束时调用
 {
     //PackEntity pack = PackDatabaseMgr.CheckGrid(_grid);
     if (dragPack != null)
     {
         PackDatabaseMgr.Remove(dragPack.grid);
         PackView.Instance.UpdatePackView(dragPack.grid);
         DragView.DragInstance.OnDropItem();     //调用View销毁鼠标实例
         dragPack = null;
     }
 }
예제 #5
0
    public void UpdatePackView(int _grid)
    {
        PackEntity waitUpdatePack = PackDatabaseMgr.CheckGrid(_grid);

        if (waitUpdatePack != null)
        {
            packViewList[_grid].sprite = ItemDatabaseMgr.Find(waitUpdatePack.itemID).sprite;
            packViewList[_grid].color  = Color.white;
            packViewList[_grid].transform.GetChild(0).GetComponent <Text>().text = waitUpdatePack.count.ToString();
        }
        else
        {
            packViewList[_grid].sprite = null;
            packViewList[_grid].color  = new Color(1, 1, 1, 0);
            packViewList[_grid].transform.GetChild(0).GetComponent <Text>().text = "";
        }
    }
 // Update is called once per frame
 void Update()
 {
     foreach (PackEntity packs in PackDatabaseMgr.List().Values)
     {
         if (packs.itemID != "")
         {
             print("背包格子:" + packs.grid + "商品名字:" + ItemDatabaseMgr.Find(packs.itemID).name + "数量:" + packs.count);
         }
     }
     if (dragItem != null)
     {
         print("DragItem:" + dragItem.name);
     }
     if (dragPack != null)
     {
         print("DragPack:" + ItemDatabaseMgr.Find(dragPack.itemID).name);
     }
 }
예제 #7
0
 private void Awake()
 {
     ThisGrid = PackDatabaseMgr.New(grid);
 }