예제 #1
0
 protected virtual void OnDragDropRelease(GameObject surface)
 {
     if (!this.cloneOnDrag)
     {
         UIDragScrollView[] componentsInChildren = base.GetComponentsInChildren <UIDragScrollView>();
         UIDragScrollView[] array = componentsInChildren;
         for (int i = 0; i < array.Length; i++)
         {
             UIDragScrollView uIDragScrollView = array[i];
             uIDragScrollView.scrollView = null;
         }
         if (this.mButton != null)
         {
             this.mButton.isEnabled = true;
         }
         else if (this.mCollider != null)
         {
             this.mCollider.enabled = true;
         }
         else if (this.mCollider2D != null)
         {
             this.mCollider2D.enabled = true;
         }
         UIDragDropContainer uIDragDropContainer = (!surface) ? null : NGUITools.FindInParents <UIDragDropContainer>(surface);
         if (uIDragDropContainer != null)
         {
             this.mTrans.parent = ((!(uIDragDropContainer.reparentTarget != null)) ? uIDragDropContainer.transform : uIDragDropContainer.reparentTarget);
             Vector3 localPosition = this.mTrans.localPosition;
             localPosition.z           = 0f;
             this.mTrans.localPosition = localPosition;
         }
         else
         {
             this.mTrans.parent = this.mParent;
         }
         this.mParent = this.mTrans.parent;
         this.mGrid   = NGUITools.FindInParents <UIGrid>(this.mParent);
         this.mTable  = NGUITools.FindInParents <UITable>(this.mParent);
         if (this.mDragScrollView != null)
         {
             base.Invoke("EnableDragScrollView", 0.001f);
         }
         NGUITools.MarkParentAsChanged(base.gameObject);
         if (this.mTable != null)
         {
             this.mTable.repositionNow = true;
         }
         if (this.mGrid != null)
         {
             this.mGrid.repositionNow = true;
         }
     }
     this.OnDragDropEnd();
     if (this.cloneOnDrag)
     {
         this.DestroySelf();
     }
 }
예제 #2
0
 protected virtual void OnDragDropRelease(GameObject surface)
 {
     if (!this.cloneOnDrag)
     {
         if (this.mButton != null)
         {
             this.mButton.isEnabled = true;
         }
         else
         {
             if (this.mCollider != null)
             {
                 this.mCollider.enabled = true;
             }
             else
             {
                 if (this.mCollider2D != null)
                 {
                     this.mCollider2D.enabled = true;
                 }
             }
         }
         UIDragDropContainer uIDragDropContainer = (!surface) ? null : NGUITools.FindInParents <UIDragDropContainer>(surface);
         if (uIDragDropContainer != null)
         {
             this.mTrans.parent = ((!(uIDragDropContainer.reparentTarget != null)) ? uIDragDropContainer.transform : uIDragDropContainer.reparentTarget);
             Vector3 localPosition = this.mTrans.localPosition;
             localPosition.z           = 0f;
             this.mTrans.localPosition = localPosition;
         }
         else
         {
             this.mTrans.parent = this.mParent;
         }
         this.mParent = this.mTrans.parent;
         this.mGrid   = NGUITools.FindInParents <UIGrid>(this.mParent);
         this.mTable  = NGUITools.FindInParents <UITable>(this.mParent);
         if (this.mDragScrollView != null)
         {
             base.Invoke("EnableDragScrollView", 0.001f);
         }
         NGUITools.MarkParentAsChanged(base.gameObject);
         if (this.mTable != null)
         {
             this.mTable.repositionNow = true;
         }
         if (this.mGrid != null)
         {
             this.mGrid.repositionNow = true;
         }
     }
     else
     {
         NGUITools.Destroy(base.gameObject);
     }
     this.OnDragDropEnd();
 }
예제 #3
0
    /// <summary>
    /// Drop the item onto the specified object.
    /// </summary>

    protected virtual void OnDragDropRelease(GameObject surface)
    {
        if (!cloneOnDrag)
        {
            mTouchID = int.MinValue;
            if (mCollider != null)
            {
                mCollider.enabled = true;
            }

            // Is there a droppable container?
            UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

            if (container != null)
            {
                // Container found -- parent this object to the container
                mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

                Vector3 pos = mTrans.localPosition;
                pos.z = 0f;
                mTrans.localPosition = pos;
            }
            else
            {
                // No valid container under the mouse -- revert the item's parent
                mTrans.parent = mParent;
            }

            // Update the grid and table references
            mParent = mTrans.parent;
            mGrid   = NGUITools.FindInParents <UIGrid>(mParent);
            mTable  = NGUITools.FindInParents <UITable>(mParent);

            // Re-enable the drag scroll view script
            if (mDragScrollView != null)
            {
                mDragScrollView.enabled = true;
            }

            // Notify the widgets that the parent has changed
            NGUITools.MarkParentAsChanged(gameObject);

            if (mTable != null)
            {
                mTable.repositionNow = true;
            }
            if (mGrid != null)
            {
                mGrid.repositionNow = true;
            }
        }
        else
        {
            NGUITools.Destroy(gameObject);
        }
    }
예제 #4
0
    public void Fill(Component com, MyJson.IJsonNode json)
    {
        UIDragDropContainer t = com as UIDragDropContainer;
        var jsono             = json as MyJson.JsonNode_Object;

        if (jsono.ContainsKey("reparentTarget"))
        {
            t.reparentTarget = (GameObjParser.IDToObj(jsono["reparentTarget"] as MyJson.JsonNode_ValueNumber)).transform;
        }
    }
 static public int get_reparentTarget(IntPtr l)
 {
     try {
         UIDragDropContainer self = (UIDragDropContainer)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.reparentTarget);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #6
0
    public MyJson.IJsonNode Parser(Component com, NeedList needlist)
    {
        UIDragDropContainer t = com as UIDragDropContainer;
        var json = new MyJson.JsonNode_Object();

        if (t.reparentTarget != null)
        {
            json["reparentTarget"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.reparentTarget.gameObject));
        }

        return(json);
    }
 protected virtual void OnDragDropRelease(GameObject surface)
 {
     if (!cloneOnDrag)
     {
         mTouchID = -2147483648;
         if (mButton != null)
         {
             mButton.isEnabled = true;
         }
         else if (mCollider != null)
         {
             mCollider.enabled = true;
         }
         else if (mCollider2D != null)
         {
             mCollider2D.enabled = true;
         }
         UIDragDropContainer uIDragDropContainer = (!(bool)surface) ? null : NGUITools.FindInParents <UIDragDropContainer>(surface);
         if (uIDragDropContainer != null)
         {
             mTrans.parent = ((!(uIDragDropContainer.reparentTarget != null)) ? uIDragDropContainer.transform : uIDragDropContainer.reparentTarget);
             Vector3 localPosition = mTrans.localPosition;
             localPosition.z      = 0f;
             mTrans.localPosition = localPosition;
         }
         else
         {
             mTrans.parent = mParent;
         }
         mParent = mTrans.parent;
         mGrid   = NGUITools.FindInParents <UIGrid>(mParent);
         mTable  = NGUITools.FindInParents <UITable>(mParent);
         if (mDragScrollView != null)
         {
             StartCoroutine(EnableDragScrollView());
         }
         NGUITools.MarkParentAsChanged(base.gameObject);
         if (mTable != null)
         {
             mTable.repositionNow = true;
         }
         if (mGrid != null)
         {
             mGrid.repositionNow = true;
         }
         OnDragDropEnd();
     }
     else
     {
         NGUITools.Destroy(base.gameObject);
     }
 }
예제 #8
0
 protected virtual void OnDragDropRelease(GameObject surface)
 {
     if (!this.cloneOnDrag)
     {
         if (this.mButton != null)
         {
             this.mButton.isEnabled = true;
         }
         else if (this.mCollider != null)
         {
             this.mCollider.set_enabled(true);
         }
         else if (this.mCollider2D != null)
         {
             this.mCollider2D.set_enabled(true);
         }
         UIDragDropContainer uIDragDropContainer = (!surface) ? null : NGUITools.FindInParents <UIDragDropContainer>(surface);
         if (uIDragDropContainer != null)
         {
             this.mTrans.set_parent((!(uIDragDropContainer.reparentTarget != null)) ? uIDragDropContainer.get_transform() : uIDragDropContainer.reparentTarget);
             Vector3 localPosition = this.mTrans.get_localPosition();
             localPosition.z = 0f;
             this.mTrans.set_localPosition(localPosition);
         }
         else
         {
             this.mTrans.set_parent(this.mParent);
         }
         this.mParent = this.mTrans.get_parent();
         this.mGrid   = NGUITools.FindInParents <UIGrid>(this.mParent);
         this.mTable  = NGUITools.FindInParents <UITable>(this.mParent);
         if (this.mDragScrollView != null)
         {
             base.StartCoroutine(this.EnableDragScrollView());
         }
         NGUITools.MarkParentAsChanged(base.get_gameObject());
         if (this.mTable != null)
         {
             this.mTable.repositionNow = true;
         }
         if (this.mGrid != null)
         {
             this.mGrid.repositionNow = true;
         }
         this.OnDragDropEnd();
     }
     else
     {
         NGUITools.Destroy(base.get_gameObject());
     }
 }
 static public int set_reparentTarget(IntPtr l)
 {
     try {
         UIDragDropContainer   self = (UIDragDropContainer)checkSelf(l);
         UnityEngine.Transform v;
         checkType(l, 2, out v);
         self.reparentTarget = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #10
0
 protected virtual void OnDragDropRelease(GameObject surface)
 {
     if (!this.cloneOnDrag)
     {
         this.mTouchID = -2147483648;
         if (this.mButton != null)
         {
             this.mButton.isEnabled = true;
         }
         else if (this.mCollider != null)
         {
             this.mCollider.enabled = true;
         }
         UIDragDropContainer uIDragDropContainer = (!surface) ? null : NGUITools.FindInParents <UIDragDropContainer>(surface);
         if (uIDragDropContainer != null)
         {
             this.mTrans.parent = ((!(uIDragDropContainer.reparentTarget != null)) ? uIDragDropContainer.transform : uIDragDropContainer.reparentTarget);
             Vector3 localPosition = this.mTrans.localPosition;
             localPosition.z           = 0f;
             this.mTrans.localPosition = localPosition;
         }
         else
         {
             this.mTrans.parent = this.mParent;
         }
         this.mParent = this.mTrans.parent;
         this.mGrid   = NGUITools.FindInParents <UIGrid>(this.mParent);
         this.mTable  = NGUITools.FindInParents <UITable>(this.mParent);
         if (this.mDragScrollView != null)
         {
             this.mDragScrollView.enabled = true;
         }
         NGUITools.MarkParentAsChanged(base.gameObject);
         if (this.mTable != null)
         {
             this.mTable.repositionNow = true;
         }
         if (this.mGrid != null)
         {
             this.mGrid.repositionNow = true;
         }
         EventDelegate.Execute(this.onFinished);
     }
     else
     {
         NGUITools.Destroy(base.gameObject);
         EventDelegate.Execute(this.onFinished);
     }
 }
예제 #11
0
 protected virtual void OnDragDropRelease(GameObject surface)
 {
     if (!cloneOnDrag)
     {
         mTouchID = int.MinValue;
         if (mButton != null)
         {
             mButton.isEnabled = true;
         }
         else if (mCollider != null)
         {
             mCollider.enabled = true;
         }
         UIDragDropContainer uIDragDropContainer = (surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null);
         if (uIDragDropContainer != null)
         {
             mTrans.parent = ((uIDragDropContainer.reparentTarget != null) ? uIDragDropContainer.reparentTarget : uIDragDropContainer.transform);
             Vector3 localPosition = mTrans.localPosition;
             localPosition.z      = 0f;
             mTrans.localPosition = localPosition;
         }
         else
         {
             mTrans.parent = mParent;
         }
         mParent = mTrans.parent;
         mGrid   = NGUITools.FindInParents <UIGrid>(mParent);
         mTable  = NGUITools.FindInParents <UITable>(mParent);
         if (mDragScrollView != null)
         {
             mDragScrollView.enabled = true;
         }
         NGUITools.MarkParentAsChanged(base.gameObject);
         if (mTable != null)
         {
             mTable.repositionNow = true;
         }
         if (mGrid != null)
         {
             mGrid.repositionNow = true;
         }
     }
     else
     {
         NGUITools.Destroy(base.gameObject);
     }
 }
예제 #12
0
    void successDrop(UIDragDropContainer container)                                                          // 컨테이너가 존재하는 경우 매개변수로 컨테이너를 받아와 Drop을 성공시킨다.
    {
        mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform; // 컨테이너의 타겟이 있으면 타겟으로, 없으면 컨테이너 트랜스폼으로 드롭 아이템의 부모를 설정
        Vector3 pos = mTrans.localPosition;

        pos.z = 0f;
        mTrans.localPosition = pos;


        if (container.tag == "shopItemSlot")                                                                                                          // 콘테이너가 상점 아이템슬롯이면
        {
            int saleGoldCount = GameObject.Find("ItemWindow").GetComponent <ItemManager>().getBuyGold(mTrans.GetComponent <UIButton>().normalSprite); // 아이템 구매 가격을 받아와 플레이어 골드 상승
            CharacterInfoManager.instance.m_playerInfo.m_iGold += saleGoldCount;                                                                      // 캐릭터 정보에 골드량을 증가시킨다.
            GameObject.Find("ProfileUI").GetComponent <ProfileUIManager>().changeGold();                                                              // UI에 골드량을 바꾼다.
            Destroy(mTrans.gameObject);                                                                                                               // 아이템 삭제
        }
    }
예제 #13
0
    /// <summary>
    /// Drop the item onto the specified object.
    /// </summary>

    protected virtual void OnDragDropRelease(GameObject surface)
    {
        // Is there a droppable container?
        UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

        if (container != null)
        {
            // Container found -- parent this object to the container
            mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

            Vector3 pos = mTrans.localPosition;
            pos.z = 0f;
            mTrans.localPosition = pos;
        }
        else
        {
            // No valid container under the mouse -- revert the item's parent
            mTrans.parent = mParent;
        }
    }
    /// <summary>
    /// Drop a 3D game object onto the surface.
    /// </summary>

    protected override void OnDragDropRelease(GameObject surface)
    {
        UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

        if (container == null)
        {
            RaycastHit hitInfo;
            bool       hit = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, 100);

            if (hit)
            {
                Vector3 buildPos = hitInfo.point;
                buildPos.y += 1;
                Instantiate(prefab, buildPos, Quaternion.identity);

                // Destroy this icon as it's no longer needed
                NGUITools.Destroy(gameObject);
                return;
            }
        }

        base.OnDragDropRelease(surface);
    }
예제 #15
0
    /// <summary>
    /// Drop a 3D game object onto the surface.
    /// </summary>

    protected override void OnDragDropRelease(GameObject surface)
    {
        if (!cloneOnDrag)
        {
            // Re-enable the collider
            if (mButton != null)
            {
                mButton.isEnabled = true;
            }
            else if (mCollider != null)
            {
                mCollider.enabled = true;
            }
            else if (mCollider2D != null)
            {
                mCollider2D.enabled = true;
            }

            // Is there a droppable container?
            UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

            if (container != null)
            {
                Debug.Log(surface.name);
                // Container found -- parent this object to the container
                if (surface.name == "Slot1")
                {
                    mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

                    //Vector3 pos = mTrans.localPosition;
                    //Vector3 pos = mTrans.parent.position; //부모의 위치로 자신의 위치를 수정
                    Vector3 pos = mTrans.parent.position;
                    pos.z = 0f;
                    mTrans.localPosition = pos;
                }
                else if (surface.transform.parent.name == "Slot1")
                {
                    //Debug.Log(surface.transform.GetChild(0));
                    Transform targetTransfrom;

                    targetTransfrom = surface.transform; // 슬롯이 가지고 있는 기존 자식

                    targetTransfrom.parent = mParent;    //기존 자식의 부모를  그리드로 바꾼다.



                    targetTransfrom.GetComponent <DragAndDropMelting>().ResetPosition(mParent.GetChild(0));

                    Vector3 pos = targetTransfrom.position;
                    pos.z = 0;
                    targetTransfrom.position = pos;

                    //Vector3 pos = mTrans.parent.position;
                    //pos.z = 0f;
                    //mTrans.localPosition = pos;


                    mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

                    //Vector3 pos = mTrans.localPosition;
                    //Vector3 pos = mTrans.parent.position; //부모의 위치로 자신의 위치를 수정
                    pos   = mTrans.parent.position;
                    pos.z = 0f;
                    mTrans.localPosition = pos;
                }
                else
                {
                    mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

                    Vector3 pos = mTrans.localPosition;
                    pos.z = 0f;
                    mTrans.localPosition = pos;
                }
            }
            else
            {
                // No valid container under the mouse -- revert the item's parent
                if (mParent.GetComponent <UIGrid>() == null)
                {
                    mTrans.parent        = mParent;
                    mTrans.localPosition = mTrans.parent.position;
                }
                else
                {
                    mTrans.parent        = mParent;
                    mTrans.localPosition = mParent.position;
                }
            }

            // Update the grid and table references
            mParent = mTrans.parent;


            mGrid = NGUITools.FindInParents <UIGrid>(mParent);

            mTable = NGUITools.FindInParents <UITable>(mParent);


            // Re-enable the drag scroll view script
            if (mDragScrollView != null)
            {
                Invoke("EnableDragScrollView", 0.001f);
            }

            // Notify the widgets that the parent has changed
            NGUITools.MarkParentAsChanged(gameObject);

            if (mTable != null)
            {
                mTable.repositionNow = true;
            }
            if (mGrid != null)
            {
                mGrid.repositionNow = true;
            }
        }
        else
        {
            NGUITools.Destroy(gameObject);
        }

        // We're now done
        OnDragDropEnd();
    }
예제 #16
0
    protected virtual void OnDragDropRelease(GameObject surface)
    {
        var drags = GetComponentsInChildren <UIDragScrollView>();

        foreach (var d in drags)
        {
            d.scrollView = null;
        }

        Collider2D[] cols            = Physics2D.OverlapPointAll(new Vector2(mTrans.position.x, mTrans.position.y));
        float        zDepth          = 0;
        float        closestZDepth   = float.MaxValue;
        int          closestZDepthID = 0;

        for (int i = 0; i < cols.Length; i++)
        {
            //remove any collider which GO doesn't contain the tag 'Slot'
            if (cols[i].gameObject.tag != "Slot")
            {
                continue;
            }
            //collect all z-depths
            zDepth = cols[i].gameObject.transform.localPosition.z;

            //get closest z-depth index
            if (zDepth < closestZDepth)
            {
                closestZDepth   = zDepth;
                closestZDepthID = i;
            }
        }

        if (cols[closestZDepthID] && cols[closestZDepthID].gameObject.tag == "Slot")
        {
            try
            {
                GDEDataManager.SetString("DroppedSurface", "Value", cols[closestZDepthID].gameObject.name);
            } catch (UnityException ex)
            {
                UnityEngine.Debug.LogError(ex.ToString());
            }
        }

        if (mButton != null)
        {
            mButton.isEnabled = true;
        }
        else if (mCollider != null)
        {
            mCollider.enabled = true;
        }
        else if (mCollider2D != null)
        {
            mCollider2D.enabled = true;
        }

        UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

        if (container != null)
        {
            mTrans.parent = container.reparentTarget ?? container.transform;
        }
        else
        {
            mTrans.parent = mParent;
        }

        //mTrans.localPosition = Vector3.zero;

        foreach (Transform child in mTrans)
        {
            child.gameObject.SetActive(true);
        }

        if (mDragScrollView != null)
        {
            Invoke("EnableDragScrollView", 0.001f);
        }

        NGUITools.MarkParentAsChanged(gameObject);

        OnDragDropEnd();
    }
예제 #17
0
    protected override void OnDragDropRelease(GameObject surface)
    {
        if (surface != null)
        {
            ExampleDragDropSurface component = surface.GetComponent <ExampleDragDropSurface>();
            if (component != null)
            {
                GameObject gameObject = NGUITools.AddChild(component.gameObject, this.prefab);
                gameObject.transform.localScale = component.transform.localScale;
                Transform transform = gameObject.transform;
                transform.position = UICamera.lastHit.point;
                if (component.rotatePlacedObject)
                {
                    transform.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f);
                }
                NGUITools.Destroy(base.gameObject);
                Singleton <PvpRoomView> .Instance.IsLock = false;
                return;
            }
        }
        if (!this.cloneOnDrag)
        {
            this.mTouchID = -2147483648;
            if (this.mCollider != null)
            {
                this.mCollider.enabled = true;
            }
            UIDragDropContainer uIDragDropContainer = (!surface) ? null : NGUITools.FindInParents <UIDragDropContainer>(surface);
            if (uIDragDropContainer != null)
            {
                this.mTrans.parent = ((!(uIDragDropContainer.reparentTarget != null)) ? uIDragDropContainer.transform : uIDragDropContainer.reparentTarget);
                Vector3 localPosition = this.mTrans.localPosition;
                localPosition.z           = 0f;
                this.mTrans.localPosition = localPosition;
            }
            else
            {
                this.mTrans.parent = this.mParent;
            }
            this.mParent = this.mTrans.parent;
            this.mGrid   = NGUITools.FindInParents <UIGrid>(this.mParent);
            this.mTable  = NGUITools.FindInParents <UITable>(this.mParent);
            if (this.mDragScrollView != null)
            {
                this.mDragScrollView.enabled = true;
            }
            NGUITools.MarkParentAsChanged(base.gameObject);
            if (this.mTable != null)
            {
                this.mTable.repositionNow = true;
            }
            if (this.mGrid != null)
            {
                this.mGrid.repositionNow = true;
            }
        }
        else
        {
            Singleton <PvpRoomView> .Instance.ReplaceMatchPosition(base.GetComponent <MatchItem>());

            NGUITools.Destroy(base.gameObject);
        }
        Singleton <PvpRoomView> .Instance.IsLock = false;
        AudioMgr.PlayUI("Play_UI_Page", null, false, false);
    }
예제 #18
0
    /// <summary>
    /// Drop the item onto the specified object.
    /// </summary>

    protected virtual void OnDragDropRelease(GameObject surface)
    {
        if (!cloneOnDrag)
        {
            // Re-enable the collider
            if (mButton != null)
            {
                mButton.isEnabled = true;
            }
            else if (mCollider != null)
            {
                mCollider.enabled = true;
            }
            else if (mCollider2D != null)
            {
                mCollider2D.enabled = true;
            }

            // Is there a droppable container?
            UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

            if (container != null)
            {
                // Container found -- parent this object to the container
                mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

                Vector3 pos = mTrans.localPosition;
                pos.z = 0f;
                mTrans.localPosition = pos;
            }
            else
            {
                // No valid container under the mouse -- revert the item's parent
                mTrans.parent = mParent;
            }

            // Update the grid and table references
            mParent = mTrans.parent;
            mGrid   = NGUITools.FindInParents <UIGrid>(mParent);
            mTable  = NGUITools.FindInParents <UITable>(mParent);

            // Re-enable the drag scroll view script
            if (mDragScrollView != null)
            {
                StartCoroutine(EnableDragScrollView());
            }

            // Notify the widgets that the parent has changed
            NGUITools.MarkParentAsChanged(gameObject);

            if (mTable != null)
            {
                mTable.repositionNow = true;
            }
            if (mGrid != null)
            {
                mGrid.repositionNow = true;
            }
            // We're now done
            OnDragDropEnd();
        }
        else
        {
            NGUITools.Destroy(gameObject);
        }
        if (GameObject.Find("DragItemController"))
        {
            DragItemController item = GameObject.Find("DragItemController").GetComponent <DragItemController>();
            item.SetObjInWindows();
            item.chooseDragObject = null;
        }
    }
예제 #19
0
    /// <summary>
    /// Drop the item onto the specified object.
    /// </summary>

    protected virtual void OnDragDropRelease(GameObject surface)
    {
        if (!cloneOnDrag)
        {
            // Clear the reference to the scroll view since it might be in another scroll view now
            var drags = GetComponentsInChildren <UIDragScrollView>();
            foreach (var d in drags)
            {
                d.scrollView = null;
            }

            // Re-enable the collider
            if (mButton != null)
            {
                mButton.isEnabled = true;
            }
            else if (mCollider != null)
            {
                mCollider.enabled = true;
            }
            else if (mCollider2D != null)
            {
                mCollider2D.enabled = true;
            }

            // Is there a droppable container?
            UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

            if (container != null)
            {
                // Container found -- parent this object to the container
                mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

                Vector3 pos = mTrans.localPosition;
                pos.z = 0f;
                mTrans.localPosition = pos;
            }
            else
            {
                // No valid container under the mouse -- revert the item's parent
                mTrans.parent = mParent;
            }

            // Update the grid and table references
            mParent = mTrans.parent;
            mGrid   = NGUITools.FindInParents <UIGrid>(mParent);
            mTable  = NGUITools.FindInParents <UITable>(mParent);

            // Re-enable the drag scroll view script
            if (mDragScrollView != null)
            {
                Invoke("EnableDragScrollView", 0.001f);
            }

            // Notify the widgets that the parent has changed
            NGUITools.MarkParentAsChanged(gameObject);

            if (mTable != null)
            {
                mTable.repositionNow = true;
            }
            if (mGrid != null)
            {
                mGrid.repositionNow = true;
            }
        }

        // We're now done
        OnDragDropEnd();

        if (cloneOnDrag)
        {
            DestroySelf();
        }
    }
예제 #20
0
    /// <summary>
    /// Drop a 3D game object onto the surface.
    /// </summary>

    protected override void OnDragDropRelease(GameObject surface)
    {
        if (!cloneOnDrag)
        {
            // Re-enable the collider
            if (mButton != null)
            {
                mButton.isEnabled = true;
            }
            else if (mCollider != null)
            {
                mCollider.enabled = true;
            }
            else if (mCollider2D != null)
            {
                mCollider2D.enabled = true;
            }

            // Is there a droppable container?
            UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

            if (container != null)
            {
                Debug.Log(surface.name);
                // Container found -- parent this object to the container
                if (surface.name == "Slot1" || surface.name == "Slot2" || surface.name == "Slot3")
                {
                    mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

                    //Vector3 pos = mTrans.localPosition;
                    //Vector3 pos = mTrans.parent.position; //부모의 위치로 자신의 위치를 수정
                    Vector3 pos = new Vector3(mTrans.parent.position.x - 5f, mTrans.parent.position.y + 5f, mTrans.parent.position.z);
                    pos.z = 0f;
                    mTrans.localPosition = pos;

                    DBManager.Instance.SetCardUsing(mTrans.GetComponent <Card>().idx, true);  //  사용중으로 변경

                    GameObject.Find("UIManager").GetComponent <SetPlayerStat>().SetStat();
                }
                else if (surface.transform.parent.name == "Slot1" || surface.transform.parent.name == "Slot2" || surface.transform.parent.name == "Slot3")
                {
                    //Debug.Log(surface.transform.GetChild(0));
                    Transform targetTransform;

                    targetTransform = surface.transform; // 슬롯이 가지고 있는 기존 자식

                    targetTransform.parent = mParent;    //기존 자식의 부모를  그리드로 바꾼다.

                    targetTransform.GetComponent <DragAndDragTest>().ResetPosition(mParent.GetChild(0));

                    mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

                    //Vector3 pos = mTrans.localPosition;
                    //Vector3 pos = mTrans.parent.position; //부모의 위치로 자신의 위치를 수정
                    Vector3 pos = new Vector3(mTrans.parent.position.x - 5f, mTrans.parent.position.y + 5f, mTrans.parent.position.z);
                    pos.z = 0f;
                    mTrans.localPosition = pos;

                    DBManager.Instance.SetCardUsing(mTrans.GetComponent <Card>().idx, true);  //  사용중으로 변경
                    DBManager.Instance.SetCardUsing(targetTransform.GetComponent <Card>().idx, false);
                    Debug.Log(mTrans.GetComponent <Card>().idx);

                    GameObject.Find("UIManager").GetComponent <SetPlayerStat>().SetStat();
                }
                else
                {
                    mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

                    //Vector3 pos = mTrans.localPosition;
                    //Vector3 pos = mTrans.parent.position; //부모의 위치로 자신의 위치를 수정
                    //pos.z = 0f;
                    Quaternion rotation = Quaternion.Euler(0f, -8f, 0);
                    mTrans.localRotation = rotation;

                    DBManager.Instance.SetCardUsing(mTrans.GetComponent <Card>().idx, false);  //  비사용중으로 변경

                    GameObject.Find("UIManager").GetComponent <SetPlayerStat>().SetStat();
                }
            }
            else
            {
                // No valid container under the mouse -- revert the item's parent
                if (mParent.GetComponent <UIGrid>() == null)
                {
                    mTrans.parent        = mParent;
                    mTrans.localPosition = mTrans.parent.position;
                }
                else
                {
                    mTrans.parent = mParent;
                }
            }

            // Update the grid and table references
            mParent = mTrans.parent;


            mGrid = NGUITools.FindInParents <UIGrid>(mParent);

            mTable = NGUITools.FindInParents <UITable>(mParent);


            // Re-enable the drag scroll view script
            if (mDragScrollView != null)
            {
                Invoke("EnableDragScrollView", 0.001f);
            }

            // Notify the widgets that the parent has changed
            NGUITools.MarkParentAsChanged(gameObject);

            if (mTable != null)
            {
                mTable.repositionNow = true;
            }
            if (mGrid != null)
            {
                mGrid.repositionNow = true;
            }
        }
        else
        {
            NGUITools.Destroy(gameObject);
        }

        // We're now done
        OnDragDropEnd();
    }
예제 #21
0
    private Dictionary <string, DefaultItemInfo> m_dicItemInfo = new Dictionary <string, DefaultItemInfo>(); // 아이템 고유 정보를 가진 딕셔너리

    protected override void OnDragDropRelease(GameObject surface)
    {
        if (!cloneOnDrag)
        {
            // Clear the reference to the scroll view since it might be in another scroll view now
            var drags = GetComponentsInChildren <UIDragScrollView>();
            foreach (var d in drags)
            {
                d.scrollView = null;
            }

            // Re-enable the collider
            if (mButton != null)
            {
                mButton.isEnabled = true;
            }
            else if (mCollider != null)
            {
                mCollider.enabled = true;
            }
            else if (mCollider2D != null)
            {
                mCollider2D.enabled = true;
            }

            // Is there a droppable container?
            UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

            if (container != null && container.transform.childCount == 0)                                                                                   // 컨테이너의 자식갯수가 0일때만 움직이도록 추가적인 제약
            {
                if (container.name == "ArmorSlot")                                                                                                          // 컨테이너가 방어구 슬롯이면
                {
                    ITEM_TYPE type = GameObject.Find("ItemWindow").GetComponent <ItemManager>().getItemType(mTrans.GetComponent <UIButton>().normalSprite); // 아이템 타입 정보를 받아와서
                    if (type == ITEM_TYPE.ARMOR)                                                                                                            // 타입이 같으면
                    {
                        successDrop(container);                                                                                                             // 드롭 성공
                    }
                    else                                                                                                                                    // 타입이 다르면
                    {
                        mTrans.parent = mParent;                                                                                                            // 드롭 실패
                    }
                }
                else if (container.name == "WeaponSlot")
                {
                    ITEM_TYPE type = GameObject.Find("ItemWindow").GetComponent <ItemManager>().getItemType(mTrans.GetComponent <UIButton>().normalSprite);
                    if (type == ITEM_TYPE.WEAPON)
                    {
                        successDrop(container);
                    }
                    else
                    {
                        mTrans.parent = mParent;        // 드롭 실패
                    }
                }
                else if (container.name == "PotionSlot")
                {
                    ITEM_TYPE type = GameObject.Find("ItemWindow").GetComponent <ItemManager>().getItemType(mTrans.GetComponent <UIButton>().normalSprite);
                    if (type == ITEM_TYPE.POTION)
                    {
                        successDrop(container);
                    }
                    else
                    {
                        mTrans.parent = mParent;        // 드롭 실패
                    }
                }
                else
                {
                    successDrop(container);
                }
            }
            else
            {
                // No valid container under the mouse -- revert the item's parent
                mTrans.parent = mParent;
            }

            // Update the grid and table references
            mParent = mTrans.parent;
            mGrid   = NGUITools.FindInParents <UIGrid>(mParent);
            mTable  = NGUITools.FindInParents <UITable>(mParent);

            // Re-enable the drag scroll view script
            if (mDragScrollView != null)
            {
                Invoke("EnableDragScrollView", 0.001f);
            }

            // Notify the widgets that the parent has changed
            NGUITools.MarkParentAsChanged(gameObject);

            if (mTable != null)
            {
                mTable.repositionNow = true;
            }
            if (mGrid != null)
            {
                mGrid.repositionNow = true;
            }
        }

        // We're now done
        OnDragDropEnd(surface);

        if (cloneOnDrag)
        {
            DestroySelf();
        }
    }
예제 #22
0
    protected virtual void OnDragDropRelease(UnityEngine.GameObject surface)
    {
        ChangeSlotState(false);
        UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

        if (container != null)
        {
            if (container.reparentTarget.name == "Equipment")
            {
                ItemClick ic = mTrans.gameObject.GetComponent <ItemClick>();
                if (ic != null)
                {
                    if (surface != null)
                    {
                        ArkCrossEngine.RoleInfo roleInfo = ArkCrossEngine.LobbyClient.Instance.CurrentRole;
                        if (roleInfo != null)
                        {
                            ArkCrossEngine.ItemConfig itemConfig = ArkCrossEngine.ItemConfigProvider.Instance.GetDataById(ic.ID);
                            if (itemConfig != null)
                            {
                                if (itemConfig.m_WearLevel > roleInfo.Level)
                                {
                                    string tip = ArkCrossEngine.StrDictionaryProvider.Instance.GetDictString(46);
                                    ArkCrossEngine.LogicSystem.EventChannelForGfx.Publish("ge_screen_tip", "ui", tip, UIScreenTipPosEnum.AlignCenter, new UnityEngine.Vector3(0f, 0f, 0f));
                                }
                                else
                                {
                                    int    slotid = 0;
                                    string str    = surface.transform.name;
                                    if (str != null)
                                    {
                                        char[] ch = str.ToCharArray();
                                        if (ch != null && ch.Length >= 5)
                                        {
                                            if (System.Int32.TryParse(ch[4].ToString(), out slotid))
                                            {
                                                EquipmentInfo ei = GamePokeyManager.GetEquipmentInfo(slotid);
                                                if (ei != null)
                                                {
                                                    ArkCrossEngine.GfxSystem.EventChannelForLogic.Publish("ge_mount_equipment", "lobby", ic.ID, ic.PropertyId, slotid);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        if (mDragScrollView != null)
        {
            mDragScrollView.enabled = true;
        }

        if (mCollider != null)
        {
            mCollider.enabled = true;
        }
    }
 protected virtual void OnDragDropRelease(GameObject surface)
 {
     //IL_00b3: Unknown result type (might be due to invalid IL or missing references)
     //IL_00c3: Unknown result type (might be due to invalid IL or missing references)
     //IL_00c8: Unknown result type (might be due to invalid IL or missing references)
     //IL_00db: Unknown result type (might be due to invalid IL or missing references)
     //IL_00fe: Unknown result type (might be due to invalid IL or missing references)
     //IL_0103: Expected O, but got Unknown
     //IL_0142: Unknown result type (might be due to invalid IL or missing references)
     //IL_0149: Unknown result type (might be due to invalid IL or missing references)
     //IL_014e: Expected O, but got Unknown
     //IL_0199: Unknown result type (might be due to invalid IL or missing references)
     //IL_019e: Expected O, but got Unknown
     if (!cloneOnDrag)
     {
         if (mButton != null)
         {
             mButton.isEnabled = true;
         }
         else if (mCollider != null)
         {
             mCollider.set_enabled(true);
         }
         else if (mCollider2D != null)
         {
             mCollider2D.set_enabled(true);
         }
         UIDragDropContainer uIDragDropContainer = (!Object.op_Implicit(surface)) ? null : NGUITools.FindInParents<UIDragDropContainer>(surface);
         if (uIDragDropContainer != null)
         {
             mTrans.set_parent((!(uIDragDropContainer.reparentTarget != null)) ? ((object)uIDragDropContainer.get_transform()) : ((object)uIDragDropContainer.reparentTarget));
             Vector3 localPosition = mTrans.get_localPosition();
             localPosition.z = 0f;
             mTrans.set_localPosition(localPosition);
         }
         else
         {
             mTrans.set_parent(mParent);
         }
         mParent = mTrans.get_parent();
         mGrid = NGUITools.FindInParents<UIGrid>(mParent);
         mTable = NGUITools.FindInParents<UITable>(mParent);
         if (mDragScrollView != null)
         {
             this.StartCoroutine(EnableDragScrollView());
         }
         NGUITools.MarkParentAsChanged(this.get_gameObject());
         if (mTable != null)
         {
             mTable.repositionNow = true;
         }
         if (mGrid != null)
         {
             mGrid.repositionNow = true;
         }
         OnDragDropEnd();
     }
     else
     {
         NGUITools.Destroy(this.get_gameObject());
     }
 }