Esempio n. 1
0
        /// <summary>
        /// Attempts to finish a drag at the given drag space position.
        /// </summary>
        public void EndDrag(DragHolder inHolder)
        {
            if (DraggingObject != null)
            {
                DragEndState endState;
                DragObject   dragObject = DraggingObject;
                DraggingObject = null;

                if (inHolder == null)
                {
                    endState = DragEndState.Empty;
                }
                else
                {
                    if (inHolder.AllowAddObject(dragObject))
                    {
                        dragObject.SetOwner(inHolder);
                        endState = DragEndState.ValidZone;
                    }
                    else
                    {
                        LastValidSeat lastSeat      = dragObject.GetComponent <LastValidSeat>();
                        bool          bValidSwap    = lastSeat != null && lastSeat.LastValidHolder != null;
                        DragObject    swappedObject = null;
                        if (bValidSwap)
                        {
                            bValidSwap = inHolder.AllowSwapObject(dragObject, out swappedObject);
                        }
                        if (bValidSwap)
                        {
                            bValidSwap = lastSeat.LastValidHolder.AllowAddObject(swappedObject);
                        }

                        if (bValidSwap)
                        {
                            swappedObject.SetOwner(lastSeat.LastValidHolder);
                            dragObject.SetOwner(inHolder);
                            endState = DragEndState.ValidZone;
                        }
                        else
                        {
                            endState = DragEndState.InvalidZone;
                        }
                    }
                }

                dragObject.DraggingStops(endState);

                if (OnDragEnd != null)
                {
                    OnDragEnd(dragObject, endState);
                }
            }
        }
Esempio n. 2
0
        void Dragger_OnDragEnd(DragObject arg1, DragEndState arg2)
        {
            Genie.I.LogEvent(OE_INTERACT.Create(OE_INTERACT.Type.DROP, m_IsOperator ? "minigame.expression.opChicken" : "minigame.expression.valueChicken"));
            GetComponent <Animator>().SetBool("dragging", false);
            if (arg2 != DragEndState.ValidZone)
            {
                Dragger.SetOwner(SlotFinder.FindNearestSlot(Dragger));
                SoundManager.instance.PlayOneShot(SoundManager.instance.minigameDropEmpty);
            }
            else
            {
                if (Dragger.Owner.GetComponent <ExpressionDragLink>() != null)
                {
                    Genie.I.LogEvent(OE_INTERACT.Create(OE_INTERACT.Type.DROP, m_IsOperator ? "minigame.expression.opNest" : "minigame.expression.valueNest"));
                    SoundManager.instance.PlayOneShot(SoundManager.instance.minigameDropNest);
                    Dragger.Owner.GetComponent <Animator>().SetTrigger("fill");
                }
                else
                {
                    SoundManager.instance.PlayOneShot(SoundManager.instance.minigameDropEmpty);
                }
            }

            m_Minigame.StopGlowing();
        }
Esempio n. 3
0
 public void SetHolder(DragHolder inHolder)
 {
     Holder = inHolder;
     m_DragObject.SetOwner(Holder, true);
     if (Holder.HasSeats)
     {
         Transform targetPosition = m_DragObject.Owner.GetSeat(m_DragObject);
         m_DragObject.transform.position = targetPosition.position;
     }
 }
Esempio n. 4
0
 void m_DragObject_OnDragEnd(DragObject arg1, DragEndState arg2)
 {
     if (SnapBack && arg2 != DragEndState.ValidZone && LastValidHolder != null)
     {
         if (LastValidHolder.AllowAddObject(m_DragObject))
         {
             m_DragObject.SetOwner(LastValidHolder);
         }
     }
 }