示例#1
0
    //public void OnClickUseItem()
    //{
    //    ItemDragDrop i = Instantiate(foodPrefab, GameObject.Find("CanvasDragDrop").transform,false);
    //    i.Config(()=> {
    //        Player.instance.OnItemFoodUp();
    //        GameController.instance.UseFood(comida);
    //        PopupFreezer.instance.Show();
    //    }, comida.icon);
    //    PopupFreezer.instance.Hidden();

    //}


    public void OnDrag(PointerEventData eventData)
    {
        if (inDrag && childInstantiate != null)
        {
            childInstantiate.OnDrag(eventData);
        }
        else
        {
            inDrag = true;

            ItemDragDrop i = Instantiate(foodPrefab, GameObject.Find("CanvasDragDrop").transform, false);

            i.Config(() =>
            {
                Player.instance.OnItemFoodUp(comida);
                GameController.instance.UseFood(comida);
                PopupFreezer.instance.Show();
            }, ItemDragDrop.TypeObject.food, comida.icon);

            i.transform.position = Input.mousePosition;

            childInstantiate = i;

            PopupFreezer.instance.Hidden();
        }
    }
示例#2
0
    public void OnDrag(PointerEventData eventData)
    {
        if (inDrag && childInstantiate != null)
        {
            childInstantiate.OnDrag(eventData);
        }
        else
        {
            inDrag = true;

            ItemDragDrop i = Instantiate(medicamentoPrefab, GameObject.Find("CanvasDragDrop").transform, false);

            i.Config(() =>
            {
                Player.instance.OnItemMedicamentoUp(medicamento);
                PopupMedicamentos.instance.Show();
            }, ItemDragDrop.TypeObject.medicamento, IconeMedicamento[medicamento.Icone]);

            i.transform.position = Input.mousePosition;

            childInstantiate = i;

            PopupMedicamentos.instance.Hidden();
        }
    }
示例#3
0
 public void OnEndDrag(PointerEventData eventData)
 {
     if (inDrag)
     {
         inDrag = false;
         childInstantiate.OnEndDrag(eventData);
         childInstantiate = null;
     }
 }
示例#4
0
    IEnumerator UpdateItemUI(GameObject slot, ItemDragDrop itemScr)
    {
        yield return(new WaitForEndOfFrame());

        if (itemScr.item != null)
        {
            itemScr.item.UpdateUI(slot);
        }
    }
示例#5
0
        /// <summary>
        ///     技術ツリーピクチャーボックスにドロップした時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPictureBoxDragDrop(object sender, DragEventArgs e)
        {
            // ドラッグアンドドロップが無効ならば何もしない
            if (!AllowDragDrop)
            {
                return;
            }

            // ラベルでなければ何もしない
            if (!e.Data.GetDataPresent(typeof(Label)))
            {
                return;
            }

            Label label = e.Data.GetData(typeof(Label)) as Label;

            if (label == null)
            {
                return;
            }

            // 技術ツリー上のドロップ座標を計算する
            Point p = new Point(e.X, e.Y);

            p   = _pictureBox.PointToClient(p);
            p.X = label.Left + p.X - _dragPoint.X;
            p.Y = label.Top + p.Y - _dragPoint.Y;

            // ラベル情報の座標を更新する
            TechLabelInfo info = label.Tag as TechLabelInfo;

            if (info == null)
            {
                return;
            }
            info.Position.X = DeviceCaps.GetUnscaledWidth(p.X);
            info.Position.Y = DeviceCaps.GetUnscaledHeight(p.Y);

            // ラベルの座標を更新する
            label.Location = p;

            // イベントハンドラを呼び出す
            ItemDragDrop?.Invoke(this, new ItemDragEventArgs(info.Item, info.Position, e));
        }
示例#6
0
 /// <summary>
 /// Raises the <see cref="ItemDragDrop" /> event.
 /// </summary>
 /// <param name="e">The <see cref="ListViewItemDragEventArgs" /> instance containing the event data.</param>
 protected virtual void OnItemDragDrop(ListViewItemDragEventArgs e)
 {
     ItemDragDrop?.Invoke(this, e);
 }