Exemple #1
0
 //把当前的物品槽的信息 复制给pickitem
 public void PickupItem(ItemUI itemUI)
 {
     PickedItem.SetItemUI(itemUI);
     isPickedItem = true;
     PickedItem.Show();
     toolTip.Hide();
 }
 private void Start()
 {
     toolTip    = GameObject.FindObjectOfType <ToolTip>();
     canvas     = GameObject.Find("Canvas").GetComponent <Canvas>();
     PickedItem = GameObject.Find("PickedItem").GetComponent <ItemUI>();
     PickedItem.HideItemUI();
 }
Exemple #3
0
 public void PickupItem(Item item, int amount)
 {
     pickedItem.SetItem(item, amount);
     isPickedItem = true;
     PickedItem.Show();
     toolTip.Hide();
 }
Exemple #4
0
 public void PickUpItem(Item item, int amount)
 {
     PickedItem.SetItemUI(item, amount);
     isPickedItem = true;
     PickedItem.Show();
     this.toolTip.Hide();
 }
 /// <summary>
 /// 捡起物品槽中指定数量的物品
 /// </summary>
 /// <param name="itemUI"></param>
 /// <param name="amount"></param>
 public void PickedItemUI(Item item, int amount)
 {
     PickedItem.SetItem(item, amount); //将当前物品信息复制给PickedItem(跟随鼠标移动)
     isPickedItem = true;              //当前鼠标上有物品了
     PickedItem.ShowItemUI();          //显示PickedItem
     toolTip.Hide();                   //隐藏物品信息框的提示
 }
Exemple #6
0
 /// <summary>
 /// 交换两个物品槽中的物品
 /// </summary>
 public void ExchangeItem(Item item, int amount)
 {
     PreviousSlot.StoreItem(item);
     PreviousSlot.GetComponentInChildren <ItemUI>().SetItem(item, amount);
     PickedItem.Hide();
     IsPicked = false;
 }
Exemple #7
0
 private void Awake()
 {
     ParseItemJson();
     toolTip    = GameObject.FindObjectOfType <ToolTip>();
     canvas     = GameObject.Find("Canvas").GetComponent <Canvas>();
     PickedItem = GameObject.Find("PickedItem").GetComponent <ItemUi>();
     PickedItem.Hide();
 }
 //从鼠标上减少(移除)指定数量的物品
 public void ReduceAmountItem(int amount = 1)
 {
     this.pickedItem.RemoveItemAmount(amount);
     if (pickedItem.Amount <= 0)
     {
         isPickedItem = false;
         PickedItem.Hide();//如果鼠标上没有物品了那就隐藏了
     }
 }
Exemple #9
0
 public void RemoveItem(int amount)
 {
     PickedItem.ReduceAmount(amount);
     if (PickedItem.Amount <= 0)
     {
         isPickedItem = false;
         PickedItem.Hide();
     }
 }
Exemple #10
0
 public void RemoveItemByAmount(int amount)
 {
     PickedItem.ReduceAmount(amount);
     if (PickedItem.m_amount <= 0)
     {
         PickedItem.Hide();
         m_isPickedItem = false;
     }
 }
Exemple #11
0
 public void RemoveItem(int amount = 1)
 {
     amount = -amount;
     PickedItem.AddAmount(amount);
     if (PickedItem.Amount <= 0)
     {
         isPickedItem = false;
         PickedItem.Hide();
     }
 }
    /**
     * 获取物品槽里的指定数量的物品
     */
    public void PickUpItem(ItemDetail item, int amount)
    {
        PickedItem.SetItem(item, amount);
        this.isPickedItem = true;
        PickedItem.Show();
        this.toolTip.Hide();

        Vector2 postionPickeItem;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, Input.mousePosition, null, out postionPickeItem);
        pickedItem.SetLocalPosition(postionPickeItem);
    }
Exemple #13
0
    protected virtual void Awake()
    {
        m_KnapsackPanel = GameObject.FindGameObjectWithTag(Tags.Knapsack).GetComponent <KnapsackPanel>();
        M_COIN          = 1000000;
        itemList        = ItemManager.Instance.M_AllItem;
        GetAllGrid();
        tooltip    = GameObject.FindGameObjectWithTag("AssistUI").transform.Find("TooltipPanel").GetComponent <Tooltip>();
        pickedItem = GameObject.FindGameObjectWithTag("AssistUI").transform.Find("PickedItemPanel").GetComponent <PickedItem>();
        canvas     = GameObject.FindGameObjectWithTag("Canvas").GetComponent <Canvas>();

        m_KnapsackPanel.UpdateShowCoin(M_COIN);
    }
    //获取(拾取)物品槽里的指定数量的(amount)物品UI
    public void PickUpItem(_Item item, int amount)
    {
        PickedItem.SetItem(item, amount);
        this.isPickedItem = true;
        PickedItem.Show();   //获取到物品之后把跟随鼠标的容器(用来盛放捡起的物品的容器)显示出来
        this.toolTip.Hide(); //同时隐藏物品信息提示框

        //控制盛放物品的容器UI跟随鼠标移动
        Vector2 postionPickeItem;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, Input.mousePosition, null, out postionPickeItem);
        pickedItem.SetLocalPosition(postionPickeItem);//设置容器的位置,二维坐标会自动转化为三维坐标但Z坐标为0
    }
Exemple #15
0
    /// <summary>
    /// 鼠标点击 拖拽物品
    /// 按照数量拿取东西TODO
    /// </summary>IPointerDownHandler
    /// <param name="eventData"></param>
    public virtual void OnPointerDown(PointerEventData eventData)
    {
        //点击右键进行装备的穿戴操作
        if (eventData.button == PointerEventData.InputButton.Right)
        {
            //显示人物面板
            UIController._instance.ShowPanel(UIPanelType.PlayerInfo);
            PlayerInfoPanel playerInfoPanel = UIController._instance.GetPanelGameObject("PlayerInfoPanel(Clone)").GetComponent <PlayerInfoPanel>();
            //playerInfoPanel.GetPlayerEquipmentGridList();
            if (grid_item != null && (grid_item is Equipment || grid_item is Weapon))
            {
                //先找到合适的格子
                //1、装备格子为空 穿上装备 清空当前个格子
                //2、装备格子不为空 先把已经穿上的装备脱下(和当前格子互换) 再穿上装备
                playerInfoPanel.PutOn(grid_item, this);
            }
        }

        if (eventData.button == PointerEventData.InputButton.Left)
        {
            if (Inventory.Instance.isPicked)
            {//鼠标上已经有物品
                PickedItem picked_Item  = Inventory.Instance.pickedItem;
                Item       picked_item  = picked_Item.picked_Item;
                int        picked_count = picked_Item.PickedCount;
                if (grid_item != null)
                {
                    //默认全部拿起 全部交换
                    Inventory.Instance.SetPickedItem(grid_item, current_count);
                    grid_item = null;
                    StoreItem(picked_item, picked_count);
                }
                else
                {
                    StoreItem(picked_item, picked_count);
                    Inventory.Instance.isPicked = false;
                    Inventory.Instance.pickedItem.Hide();
                }
            }
            else
            {//鼠标上没有物品
                if (grid_item != null)
                {
                    //Item picked_Item = Inventory.Instance.pickedItem.picked_Item;
                    Inventory.Instance.SetPickedItem(grid_item, current_count);
                    ResetGrid();
                }
            }
        }
    }
Exemple #16
0
 private void Update()
 {
     if (isPickedItem)
     {
         PickedItem.SetPosition(MousePosition());
     }
     else if (toolTipShow)
     {
         toolTip.SetLocalPosition(MousePosition() + toolTipPositionOffSet);
     }
     if (isPickedItem && Input.GetMouseButtonDown(0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject(-1))
     {
         isPickedItem = false;
         PickedItem.Hide();
     }
 }
 private void Update()
 {
     if (isPickedItem == true)
     {
         Vector2 position;
         RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, Input.mousePosition, null, out position);
         PickedItem.SetItemUIPosition(position);
     }
     if (isShowToolTip == true)
     {
         Vector2 position;
         RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, Input.mousePosition, null, out position);
         toolTip.SetToolTipPosition(position + vector2);
     }
     if (isPickedItem == true && Input.GetMouseButtonDown(0) && UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject(-1) == false)
     {
         isPickedItem = false;
         PickedItem.HideItemUI();
     }
 }
Exemple #18
0
 //移除物品
 public void RemoveItem()
 {
     isPickedItem = false;
     PickedItem.Hide();
 }
 /// <summary>
 /// 鼠标上所有的物品都放入物品槽内
 /// </summary>
 public void ReduceAllPickedItem()
 {
     PickedItem.ReduceAmount(PickedItem.Amount);
     isPickedItem = false;
     PickedItem.HideItemUI();
 }