Exemple #1
0
    public void OnDragEnded(BaseEventData data)
    {
        if (_dragState != DragStates.Dragging)
        {
            return;
        }

        //Debug.Log("DragEnded");
        _dragState = DragStates.WasDragging;
        Vector2 snapPos;

        if (BuildingController.Instance.TryPlacingPiece(this, out snapPos))
        {
            //success
            _locked = true;
            var tw = transform.DOMove(snapPos, .2f);
            GameController.Instance.OnPiecePlacedCorrectly(this);
        }
        else
        {
            //return back
            if (_goingBack != null)
            {
                _goingBack.Kill(true);
            }
            _goingBack = transform.DOMove(_initialPos, 1f);
            _goingBack.SetEase(Ease.OutBack);
        }
    }
Exemple #2
0
    public void Setup(GameObject boxPrefab, SO_PiecePattern pattern, bool isArt = false, int boxPixelSize = 9, int pixelUnit = 100)
    {
        PiecePattern = pattern;
        if (isArt)
        {
            BoxPositions = new Vector2[] { Vector2.one };
        }
        else
        {
            BoxPositions = PiecePattern.BoxPositions;
        }

        foreach (var pos in BoxPositions)
        {
            GameObject box = Instantiate(boxPrefab);
            float      x   = pos.x - 1;
            float      y   = pos.y - 1;
            x *= (float)boxPixelSize / pixelUnit;
            y *= (float)boxPixelSize / pixelUnit;
            box.transform.SetParent(transform);
            box.transform.localPosition = new Vector3(x, y, 0f);

            if (PiecePattern.LeadPosition == pos)
            {
                LeadingBox = box.transform;
            }
        }

        _dragState  = DragStates.NotDragging;
        _initialPos = transform.position;
    }
        private void MouseLeftButtonDown_Handler(object sender, MouseButtonEventArgs e)
        {
            DragState = DragStates.DragPending;
            (Tag as DockableCollection).Dock.IsBeingDragged = true;

            e.Handled = true;
        }
Exemple #4
0
 private void MouseLeftButtonDown_Handler(object sender, MouseButtonEventArgs e)
 {
     DragState           = DragStates.DragPending;
     Dock.IsBeingDragged = true;
     DragOrigin          = e.GetPosition(this);
     e.Handled           = true;
 }
 public void ResetDragObj()
 {
     draggingObj = null;
     GetComponent <Image>().raycastTarget = true;
     dragState = DragStates.notDragging;
     this.transform.position = pivot.transform.position;
 }
    public void CheckCorrectItem()
    {
        if (AvailableDistance() &&
            (this.gameObject == MatrizGameLogic.instance.currentGameProperties.lineItem ||
             this.gameObject == MatrizGameLogic.instance.currentGameProperties.colItem))
        {
            dragState = DragStates.notDragging;
            GetComponent <Image>().raycastTarget = false;
            draggingObj             = null;
            this.transform.position = MatrizGameLogic.instance.currentGameProperties.slot.transform.position;
            MatrizGameLogic.instance.MakeProgress();
            AudioManager.instance.PlaySound(MatrizGameLogic.instance.rightSound);
            GetComponent <Animator>().SetTrigger("popDown");
        }
        else
        {
            AudioManager.instance.StopAllSounds();
            if (MatrizGameLogic.instance.buzzSound != "")
            {
                AudioManager.instance.PlaySound(MatrizGameLogic.instance.buzzSound);
            }
            AudioManager.instance.PlayRandomFailSound();
            GetComponent <Animator>().SetTrigger("popDown");
            StartCoroutine(BackToDefaultPosition(this.transform, backAnimVelocity, pivot.transform));
        }

        Debug.Log("Distance: " + AvailableDistance() +
                  "\n" + this.gameObject + " ---- " + MatrizGameLogic.instance.currentGameProperties.lineItem +
                  "\n" + MatrizGameLogic.instance.currentGameProperties.colItem);
    }
Exemple #7
0
        public DockWindow(Dock rootDock)
        {
            RootDock  = rootDock;
            DragState = DragStates.NotDragging;
            InitializeComponent();

            Loaded += DockWindow_Loaded;
        }
Exemple #8
0
    public void HasStamped()
    {
        Vector3 spawnPos = new Vector3(mousePos.x, mousePos.y, -0.6f);

        Instantiate(stampSprite, spawnPos, Quaternion.identity);
        hasStamped = true;
        dragState  = DragStates.Free;
    }
Exemple #9
0
 private void MouseLeftButtonUp_Handler(object sender, MouseButtonEventArgs e)
 {
     if (DragState != DragStates.NotDragging)
     {
         DragState           = DragStates.NotDragging;
         Dock.IsBeingDragged = false;
         e.Handled           = true;
     }
 }
Exemple #10
0
 private void Target_OnDragEnd(Vector3 mousePos, GameObject target)
 {
     /*if (!this.draggable)
      * {
      *      Debug.LogWarning("Tried dragging but draggable: " + this.draggable);
      *      return;
      * }*/
     this.dragstate = DragStates.IDLE;
 }
Exemple #11
0
 public void OnDragStarted(BaseEventData data)
 {
     if (_goingBack != null)
     {
         _goingBack.Kill(true);
         _goingBack = null;
     }
     //Debug.Log("DragStarted");
     _dragState = DragStates.Dragging;
 }
Exemple #12
0
    void Update()
    {
        mousePos   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        mousePos.z = -1;

        switch (dragState)
        {
        case DragStates.Free:
        {
            LTextStamp.GetComponent <Button>().interactable = false;
            RTextStamp.GetComponent <Button>().interactable = false;
            gameObject.transform.localScale = stampSize;
            gameObject.transform.rotation   = rotation;
            currentPos = gameObject.transform.position;
            if (currentPos != stampPos)
            {
                timer  = 0;
                timer += Time.deltaTime;
                gameObject.transform.position = new Vector3(Mathf.Lerp(currentPos.x, stampPos.x, timer / 0.075f), Mathf.Lerp(currentPos.y, stampPos.y, timer / 0.075f), currentPos.z);
            }

            if (canClick)
            {
                if (Input.GetMouseButtonDown(0) && dragStamp == false)
                {
                    dragState = DragStates.Dragged;
                }
            }


            break;
        }

        case DragStates.Dragged:
        {
            LTextStamp.GetComponent <Button>().interactable = true;
            RTextStamp.GetComponent <Button>().interactable = true;
            gameObject.transform.position   = mousePos;
            gameObject.transform.localScale = stampSize * 1.2f;
            gameObject.transform.rotation   = new Quaternion(0.0f, 0.0f, 90.0f, gameObject.transform.rotation.w);


            //if (Input.GetMouseButtonDown(0))
            //{
            //    Vector3 spawnPos = new Vector3(mousePos.x, mousePos.y, -0.6f);
            //    Instantiate(stampSprite, spawnPos, Quaternion.identity);
            //    dragState = DragStates.Free;
            //}

            Debug.Log("testpush");

            break;
        }
        }
    }
 public virtual void ResetDragObj()
 {
     draggingObj = null;
     GetComponent <Image>().enabled = true;
     if (slotImage != null)
     {
         slotImage.SetActive(false);
     }
     GetComponent <Image>().raycastTarget = true;
     dragState = DragStates.notDragging;
     this.transform.position = pivot.transform.position;
 }
Exemple #14
0
    IEnumerator BackToDefaultPosition(RectTransform objRect, float velocity, Vector2 anchoredPosition)
    {
        dragState = DragStates.backing;

        while (objRect.anchoredPosition != pivot.anchoredPosition)
        {
            objRect.anchoredPosition = Vector3.MoveTowards(objRect.anchoredPosition, anchoredPosition, velocity * Time.deltaTime);
            yield return(null);
        }

        dragState   = DragStates.notDragging;
        draggingObj = null;
    }
 private void MouseMove_Handler(object sender, MouseEventArgs e)
 {
     if (DragState == DragStates.DragPending)
     {
         DragState = DragStates.NotDragging;
         Dispatcher.BeginInvoke((Action) delegate
         {
             Dock dock = (Tag as DockableCollection).Dock;
             DragDrop.DoDragDrop((Tag as DockableCollection), (Tag as DockableCollection), DragDropEffects.Move);
             dock.SetDragDropTarget(null);
         }, System.Windows.Threading.DispatcherPriority.Background);
         e.Handled = true;
     }
 }
    IEnumerator BackToDefaultPosition(Transform objTransform, float velocity, Transform targetTransform)
    {
        dragState = DragStates.backing;

        while (objTransform.position != targetTransform.position)
        {
            objTransform.position = Vector3.MoveTowards(objTransform.position, targetTransform.position, velocity * Time.deltaTime);
            yield return(null);
        }

        dragState   = DragStates.notDragging;
        draggingObj = null;

        MatrizGameLogic.instance.currentGameProperties.colItem.gameObject.transform.SetAsLastSibling();
        MatrizGameLogic.instance.currentGameProperties.lineItem.gameObject.transform.SetAsLastSibling();
    }
Exemple #17
0
    void Start()
    {
        this.tower = GetComponent <Tower>();
        this.tower.OnCharacterChanged += Tower_OnCharacterChanged;
        this.draggable = this.canDrag;

        this.tower.gridObject.pos = Root.instance.grid.WorldToGridPos(this.transform.position);
        Root.instance.grid.AddObject(GetComponent <GridObject>(), this.tower.gridObject.pos);

        this.dragstate           = DragStates.IDLE;
        this.target              = GetComponent <ClickTarget>();
        this.target.OnDragStart += Target_OnDragStart;
        this.target.OnDragEnd   += Target_OnDragEnd;

        Root.instance.grid.TowerColorChanged += Grid_TowerColorChanged;
    }
    public IEnumerator BackToDefaultPosition(Transform objTransform, float velocity, Transform targetTransform)
    {
        dragState = DragStates.backing;
        if (resetScaleOnSendBack)
        {
            transform.localScale = Vector3.one;
        }

        while (objTransform.position != targetTransform.position)
        {
            objTransform.position = Vector3.MoveTowards(objTransform.position, targetTransform.position, velocity * Time.deltaTime);
            yield return(null);
        }

        dragState   = DragStates.notDragging;
        draggingObj = null;
    }
Exemple #19
0
        private void MouseMove_Handler(object sender, MouseEventArgs e)
        {
            if (DragState == DragStates.DragPending)
            {
                DragState = DragStates.Dragging;
            }

            if (DragState == DragStates.Dragging)
            {
                DragState = DragStates.Dragging;
                Point currentLocation = e.GetPosition(this);
                currentLocation = PointToScreen(new Point(currentLocation.X - DragOrigin.X, currentLocation.Y - DragOrigin.Y));
                Left            = currentLocation.X;
                Top             = currentLocation.Y;
                e.Handled       = true;
            }
        }
Exemple #20
0
 void CheckCorrectItem()
 {
     if (isCorrectItem && AvailableDistance())
     {
         dragState = DragStates.notDragging;
         GetComponent <Image>().raycastTarget = false;
         Fungus.Flowchart.BroadcastFungusMessage(fungusCallMessage);
         draggingObj = null;
     }
     else if (isCorrectItem)
     {
         StartCoroutine(BackToDefaultPosition(GetComponent <RectTransform>(), backVelocity, pivot.anchoredPosition));
     }
     else
     {
         StartCoroutine(BackToDefaultPosition(GetComponent <RectTransform>(), backVelocity, pivot.anchoredPosition));
         Fungus.Flowchart.BroadcastFungusMessage(fungusCallMessage);
     }
 }
Exemple #21
0
        public bool DoTimeline(Rect timeRect)
        {
            bool flag = false;

            this.Init();
            this.m_Rect = timeRect;
            float a    = this.m_TimeArea.PixelToTime(timeRect.xMin, timeRect);
            float num2 = this.m_TimeArea.PixelToTime(timeRect.xMax, timeRect);

            if (!Mathf.Approximately(a, this.StartTime))
            {
                this.StartTime = a;
                GUI.changed    = true;
            }
            if (!Mathf.Approximately(num2, this.StopTime))
            {
                this.StopTime = num2;
                GUI.changed   = true;
            }
            this.Time = Mathf.Max(this.Time, 0f);
            if (Event.current.type == EventType.Repaint)
            {
                this.m_TimeArea.rect = timeRect;
            }
            this.m_TimeArea.BeginViewGUI();
            this.m_TimeArea.EndViewGUI();
            GUI.BeginGroup(timeRect);
            Event current  = Event.current;
            Rect  rect     = new Rect(0f, 0f, timeRect.width, timeRect.height);
            Rect  position = new Rect(0f, 0f, timeRect.width, 18f);
            Rect  rect3    = new Rect(0f, 18f, timeRect.width, 132f);
            float x        = this.m_TimeArea.TimeToPixel(this.SrcStartTime, rect);
            float pixelX   = this.m_TimeArea.TimeToPixel(this.SrcStopTime, rect);
            float num5     = this.m_TimeArea.TimeToPixel(this.DstStartTime, rect) + this.m_DstDragOffset;
            float num6     = this.m_TimeArea.TimeToPixel(this.DstStopTime, rect) + this.m_DstDragOffset;
            float num7     = this.m_TimeArea.TimeToPixel(this.TransitionStartTime, rect) + this.m_LeftThumbOffset;
            float num8     = this.m_TimeArea.TimeToPixel(this.TransitionStopTime, rect) + this.m_RightThumbOffset;
            float num9     = this.m_TimeArea.TimeToPixel(this.Time, rect);
            Rect  rect4    = new Rect(x, 85f, pixelX - x, 32f);
            Rect  rect5    = new Rect(num5, 117f, num6 - num5, 32f);
            Rect  rect6    = new Rect(num7, 0f, num8 - num7, 18f);
            Rect  rect7    = new Rect(num7, 18f, num8 - num7, rect.height - 18f);
            Rect  rect8    = new Rect(num7 - 9f, 5f, 9f, 15f);
            Rect  rect9    = new Rect(num8, 5f, 9f, 15f);
            Rect  rect10   = new Rect(num9 - 7f, 4f, 15f, 15f);

            if (current.type == EventType.KeyDown)
            {
                if ((GUIUtility.keyboardControl == this.id) && (this.m_DragState == DragStates.Destination))
                {
                    this.m_DstDragOffset = 0f;
                }
                if (this.m_DragState == DragStates.LeftSelection)
                {
                    this.m_LeftThumbOffset = 0f;
                }
                if (this.m_DragState == DragStates.RightSelection)
                {
                    this.m_RightThumbOffset = 0f;
                }
                if (this.m_DragState == DragStates.FullSelection)
                {
                    this.m_LeftThumbOffset  = 0f;
                    this.m_RightThumbOffset = 0f;
                }
            }
            if ((current.type == EventType.MouseDown) && rect.Contains(current.mousePosition))
            {
                GUIUtility.hotControl      = this.id;
                GUIUtility.keyboardControl = this.id;
                if (rect10.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.Playhead;
                }
                else if (rect4.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.Source;
                }
                else if (rect5.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.Destination;
                }
                else if (rect8.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.LeftSelection;
                }
                else if (rect9.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.RightSelection;
                }
                else if (rect6.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.FullSelection;
                }
                else if (position.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.TimeArea;
                }
                else if (rect3.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.TimeArea;
                }
                else
                {
                    this.m_DragState = DragStates.None;
                }
                current.Use();
            }
            if ((current.type == EventType.MouseDrag) && (GUIUtility.hotControl == this.id))
            {
                switch (this.m_DragState)
                {
                case DragStates.LeftSelection:
                    if (((current.delta.x > 0f) && (current.mousePosition.x > x)) || ((current.delta.x < 0f) && (current.mousePosition.x < num8)))
                    {
                        this.m_LeftThumbOffset += current.delta.x;
                    }
                    this.EnforceConstraints();
                    break;

                case DragStates.RightSelection:
                    if (((current.delta.x > 0f) && (current.mousePosition.x > num7)) || (current.delta.x < 0f))
                    {
                        this.m_RightThumbOffset += current.delta.x;
                    }
                    this.EnforceConstraints();
                    break;

                case DragStates.FullSelection:
                    this.m_RightThumbOffset += current.delta.x;
                    this.m_LeftThumbOffset  += current.delta.x;
                    this.EnforceConstraints();
                    break;

                case DragStates.Destination:
                    this.m_DstDragOffset += current.delta.x;
                    this.EnforceConstraints();
                    break;

                case DragStates.Source:
                    this.m_TimeArea.m_Translation.x += current.delta.x;
                    break;

                case DragStates.Playhead:
                    if (((current.delta.x > 0f) && (current.mousePosition.x > x)) || ((current.delta.x < 0f) && (current.mousePosition.x <= this.m_TimeArea.TimeToPixel(this.SampleStopTime, rect))))
                    {
                        this.Time = this.m_TimeArea.PixelToTime(num9 + current.delta.x, rect);
                    }
                    break;

                case DragStates.TimeArea:
                    this.m_TimeArea.m_Translation.x += current.delta.x;
                    break;
                }
                current.Use();
                GUI.changed = true;
            }
            if ((current.type == EventType.MouseUp) && (GUIUtility.hotControl == this.id))
            {
                this.SrcStartTime        = this.m_TimeArea.PixelToTime(x, rect);
                this.SrcStopTime         = this.m_TimeArea.PixelToTime(pixelX, rect);
                this.DstStartTime        = this.m_TimeArea.PixelToTime(num5, rect);
                this.DstStopTime         = this.m_TimeArea.PixelToTime(num6, rect);
                this.TransitionStartTime = this.m_TimeArea.PixelToTime(num7, rect);
                this.TransitionStopTime  = this.m_TimeArea.PixelToTime(num8, rect);
                GUI.changed             = true;
                this.m_DragState        = DragStates.None;
                flag                    = this.WasDraggingData();
                this.m_LeftThumbOffset  = 0f;
                this.m_RightThumbOffset = 0f;
                this.m_DstDragOffset    = 0f;
                GUIUtility.hotControl   = 0;
                current.Use();
            }
            GUI.Box(position, GUIContent.none, this.styles.header);
            GUI.Box(rect3, GUIContent.none, this.styles.background);
            this.m_TimeArea.DrawMajorTicks(rect3, 30f);
            GUIContent content = EditorGUIUtility.TempContent(this.SrcName);
            int        num10   = !this.srcLoop ? 1 : (1 + ((int)((num8 - rect4.xMin) / (rect4.xMax - rect4.xMin))));
            Rect       rect11  = rect4;

            if (rect4.width < 10f)
            {
                rect11 = new Rect(rect4.x, rect4.y, (rect4.xMax - rect4.xMin) * num10, rect4.height);
                num10  = 1;
            }
            for (int i = 0; i < num10; i++)
            {
                GUI.BeginGroup(rect11, GUIContent.none, this.styles.leftBlock);
                float width = num7 - rect11.xMin;
                float num13 = num8 - num7;
                float num14 = (rect11.xMax - rect11.xMin) - (width + num13);
                if (width > 0f)
                {
                    GUI.Box(new Rect(0f, 0f, width, rect4.height), GUIContent.none, this.styles.onLeft);
                }
                if (num13 > 0f)
                {
                    GUI.Box(new Rect(width, 0f, num13, rect4.height), GUIContent.none, this.styles.onOff);
                }
                if (num14 > 0f)
                {
                    GUI.Box(new Rect(width + num13, 0f, num14, rect4.height), GUIContent.none, this.styles.offRight);
                }
                float b     = 1f;
                float num16 = this.styles.block.CalcSize(content).x;
                float num17 = Mathf.Max(0f, width) - 20f;
                float num18 = num17 + 15f;
                if (((num17 < num16) && (num18 > 0f)) && (this.m_DragState == DragStates.LeftSelection))
                {
                    b = 0f;
                }
                GUI.EndGroup();
                float num19 = this.styles.leftBlock.normal.textColor.a;
                if (!Mathf.Approximately(num19, b) && (Event.current.type == EventType.Repaint))
                {
                    num19 = Mathf.Lerp(num19, b, 0.1f);
                    this.styles.leftBlock.normal.textColor = new Color(this.styles.leftBlock.normal.textColor.r, this.styles.leftBlock.normal.textColor.g, this.styles.leftBlock.normal.textColor.b, num19);
                    HandleUtility.Repaint();
                }
                GUI.Box(rect11, content, this.styles.leftBlock);
                rect11 = new Rect(rect11.xMax, 85f, rect11.xMax - rect11.xMin, 32f);
            }
            GUIContent content2 = EditorGUIUtility.TempContent(this.DstName);
            int        num20    = !this.dstLoop ? 1 : (1 + ((int)((num8 - rect5.xMin) / (rect5.xMax - rect5.xMin))));

            rect11 = rect5;
            if (rect5.width < 10f)
            {
                rect11 = new Rect(rect5.x, rect5.y, (rect5.xMax - rect5.xMin) * num20, rect5.height);
                num20  = 1;
            }
            for (int j = 0; j < num20; j++)
            {
                GUI.BeginGroup(rect11, GUIContent.none, this.styles.rightBlock);
                float num22 = num7 - rect11.xMin;
                float num23 = num8 - num7;
                float num24 = (rect11.xMax - rect11.xMin) - (num22 + num23);
                if (num22 > 0f)
                {
                    GUI.Box(new Rect(0f, 0f, num22, rect5.height), GUIContent.none, this.styles.offLeft);
                }
                if (num23 > 0f)
                {
                    GUI.Box(new Rect(num22, 0f, num23, rect5.height), GUIContent.none, this.styles.offOn);
                }
                if (num24 > 0f)
                {
                    GUI.Box(new Rect(num22 + num23, 0f, num24, rect5.height), GUIContent.none, this.styles.onRight);
                }
                float num25 = 1f;
                float num26 = this.styles.block.CalcSize(content2).x;
                float num27 = Mathf.Max(0f, num22) - 20f;
                float num28 = num27 + 15f;
                if (((num27 < num26) && (num28 > 0f)) && ((this.m_DragState == DragStates.LeftSelection) || (this.m_DragState == DragStates.Destination)))
                {
                    num25 = 0f;
                }
                GUI.EndGroup();
                float num29 = this.styles.rightBlock.normal.textColor.a;
                if (!Mathf.Approximately(num29, num25) && (Event.current.type == EventType.Repaint))
                {
                    num29 = Mathf.Lerp(num29, num25, 0.1f);
                    this.styles.rightBlock.normal.textColor = new Color(this.styles.rightBlock.normal.textColor.r, this.styles.rightBlock.normal.textColor.g, this.styles.rightBlock.normal.textColor.b, num29);
                    HandleUtility.Repaint();
                }
                GUI.Box(rect11, content2, this.styles.rightBlock);
                rect11 = new Rect(rect11.xMax, rect11.yMin, rect11.xMax - rect11.xMin, 32f);
            }
            GUI.Box(rect7, GUIContent.none, this.styles.select);
            GUI.Box(rect6, GUIContent.none, this.styles.selectHead);
            this.m_TimeArea.TimeRuler(position, 30f);
            GUI.Box(rect8, GUIContent.none, !this.m_HasExitTime ? this.styles.handLeftPrev : this.styles.handLeft);
            GUI.Box(rect9, GUIContent.none, this.styles.handRight);
            GUI.Box(rect10, GUIContent.none, this.styles.playhead);
            Color color = Handles.color;

            Handles.color = Color.white;
            Handles.DrawLine(new Vector3(num9, 19f, 0f), new Vector3(num9, rect.height, 0f));
            Handles.color = color;
            bool flag2 = (this.SrcStopTime - this.SrcStartTime) < 0.03333334f;
            bool flag3 = (this.DstStopTime - this.DstStartTime) < 0.03333334f;

            if ((this.m_DragState == DragStates.Destination) && !flag3)
            {
                Rect   rect12 = new Rect(num7 - 50f, rect5.y, 45f, rect5.height);
                string t      = string.Format("{0:0%}", (num7 - num5) / (num6 - num5));
                GUI.Box(rect12, EditorGUIUtility.TempContent(t), this.styles.timeBlockRight);
            }
            if (this.m_DragState == DragStates.LeftSelection)
            {
                if (!flag2)
                {
                    Rect   rect13 = new Rect(num7 - 50f, rect4.y, 45f, rect4.height);
                    string str2   = string.Format("{0:0%}", (num7 - x) / (pixelX - x));
                    GUI.Box(rect13, EditorGUIUtility.TempContent(str2), this.styles.timeBlockRight);
                }
                if (!flag3)
                {
                    Rect   rect14 = new Rect(num7 - 50f, rect5.y, 45f, rect5.height);
                    string str3   = string.Format("{0:0%}", (num7 - num5) / (num6 - num5));
                    GUI.Box(rect14, EditorGUIUtility.TempContent(str3), this.styles.timeBlockRight);
                }
            }
            if (this.m_DragState == DragStates.RightSelection)
            {
                if (!flag2)
                {
                    Rect   rect15 = new Rect(num8 + 5f, rect4.y, 45f, rect4.height);
                    string str4   = string.Format("{0:0%}", (num8 - x) / (pixelX - x));
                    GUI.Box(rect15, EditorGUIUtility.TempContent(str4), this.styles.timeBlockLeft);
                }
                if (!flag3)
                {
                    Rect   rect16 = new Rect(num8 + 5f, rect5.y, 45f, rect5.height);
                    string str5   = string.Format("{0:0%}", (num8 - num5) / (num6 - num5));
                    GUI.Box(rect16, EditorGUIUtility.TempContent(str5), this.styles.timeBlockLeft);
                }
            }
            this.DoPivotCurves();
            GUI.EndGroup();
            return(flag);
        }
 public DockableContentHeader()
 {
     InitializeComponent();
     DragState = DragStates.NotDragging;
 }
 private void MouseLeftButtonUp_Handler(object sender, MouseButtonEventArgs e)
 {
     DragState = DragStates.NotDragging;
     e.Handled = true;
 }
    public virtual void CheckCorrectItem()
    {
        if (Mathf.Abs(transform.position.x - slot.transform.position.x) <= xLimitDistance &&
            Mathf.Abs(transform.position.y - slot.transform.position.y) <= yLimitDistance)
        {
            dragState = DragStates.notDragging;
            if (slot.GetComponent <DragAndDropSlot>() != null)
            {
                slot.GetComponent <DragAndDropSlot>().checkedSlot = true;
                slot.GetComponent <DragAndDropSlot>().OnCheckedSlot.Invoke();
            }
            GetComponent <Image>().raycastTarget = false;
            draggingObj = null;
            if (refPos)
            {
                refObj.transform.position = this.transform.position;
            }
            this.transform.position        = slot.transform.position;
            GetComponent <Image>().enabled = false;
            if (slotImage != null)
            {
                slotImage.SetActive(true);
            }

            if (playRightSound)
            {
                if (!holdProgress)
                {
                    DragAndDropLogic.instance.MakeProgress();
                }
                if (!truePlayNoRightSound)
                {
                    AudioManager.instance.StopAllSounds();
                    AudioManager.instance.PlaySound(DragAndDropLogic.instance.rightSound);
                    AudioManager.instance.PlayRandomSuccessSound();
                }
            }
            else
            {
                if (!holdProgress)
                {
                    DragAndDropLogic.instance.MakeProgress();
                }
                if (!truePlayNoRightSound)
                {
                    AudioManager.instance.StopAllSounds();
                    AudioManager.instance.PlaySound(DragAndDropLogic.instance.rightSound);
                }
            }
            if (activityAnalytics != null)
            {
                activityAnalytics.AddRight();
            }
        }
        else
        {
            if (playFailSound)
            {
                AudioManager.instance.StopAllSounds();
                AudioManager.instance.PlayRandomFailSound();
            }
            //GetComponent<Animator>().SetTrigger("popDown");
            StartCoroutine(BackToDefaultPosition(this.transform, backAnimVelocity, pivot.transform));
            if (activityAnalytics != null)
            {
                activityAnalytics.AddWrong();
            }
        }
    }
        public bool DoTimeline(Rect timeRect)
        {
            bool hasModifiedData = false;

            Init();
            m_Rect = timeRect;

            float timeAreaStart = m_TimeArea.PixelToTime(timeRect.xMin, timeRect);
            float timeAreaStop  = m_TimeArea.PixelToTime(timeRect.xMax, timeRect);

            if (!Mathf.Approximately(timeAreaStart, StartTime))
            {
                StartTime   = timeAreaStart;
                GUI.changed = true;
            }
            if (!Mathf.Approximately(timeAreaStop, StopTime))
            {
                StopTime    = timeAreaStop;
                GUI.changed = true;
            }

            Time = Mathf.Max(Time, 0f);

            if (Event.current.type == EventType.Repaint)
            {
                m_TimeArea.rect = timeRect;
            }

            m_TimeArea.BeginViewGUI();
            m_TimeArea.EndViewGUI();

            GUI.BeginGroup(timeRect);
            {
                Event evt        = Event.current;
                Rect  r          = new Rect(0, 0, timeRect.width, timeRect.height);
                Rect  headerRect = new Rect(0, 0, timeRect.width, 18);
                Rect  bodyRect   = new Rect(0, 18, timeRect.width, 132);

                // get the relevant positions in pixels
                float srcStart   = m_TimeArea.TimeToPixel(SrcStartTime, r);
                float srcStop    = m_TimeArea.TimeToPixel(SrcStopTime, r);
                float dstStart   = m_TimeArea.TimeToPixel(DstStartTime, r) + m_DstDragOffset;
                float dstStop    = m_TimeArea.TimeToPixel(DstStopTime, r) + m_DstDragOffset;
                float transStart = m_TimeArea.TimeToPixel(TransitionStartTime, r) + m_LeftThumbOffset;
                float transStop  = m_TimeArea.TimeToPixel(TransitionStopTime, r) + m_RightThumbOffset;
                float playPoint  = m_TimeArea.TimeToPixel(Time, r);

                // get the relevant Rects

                Rect srcRect         = new Rect(srcStart, 85, srcStop - srcStart, 32);
                Rect dstRect         = new Rect(dstStart, 117, dstStop - dstStart, 32);
                Rect transHeaderRect = new Rect(transStart, 0, transStop - transStart, 18);
                Rect transRect       = new Rect(transStart, 18, transStop - transStart, r.height - 18);
                Rect leftThumbRect   = new Rect(transStart - 9, 5, 9, 15);
                Rect rightThumbRect  = new Rect(transStop, 5, 9, 15);
                Rect playHeadRect    = new Rect(playPoint - 7, 4, 15, 15);


                // handle keyboard
                if (evt.type == EventType.KeyDown)
                {
                    if (EditorGUIUtility.keyboardControl == id)
                    {
                        if (m_DragState == DragStates.Destination)
                        {
                            m_DstDragOffset = 0f;
                        }
                    }
                    if (m_DragState == DragStates.LeftSelection)
                    {
                        m_LeftThumbOffset = 0f;
                    }
                    if (m_DragState == DragStates.RightSelection)
                    {
                        m_RightThumbOffset = 0f;
                    }
                    if (m_DragState == DragStates.Playhead)
                    {
                        m_TimeOffset = 0f;
                    }
                    if (m_DragState == DragStates.FullSelection)
                    {
                        m_LeftThumbOffset  = 0f;
                        m_RightThumbOffset = 0f;
                    }
                }

                // handle mouse down
                if (evt.type == EventType.MouseDown)
                {
                    if (r.Contains(evt.mousePosition))
                    {
                        EditorGUIUtility.hotControl      = id;
                        EditorGUIUtility.keyboardControl = id;
                        if (playHeadRect.Contains(evt.mousePosition))
                        {
                            m_DragState     = DragStates.Playhead;
                            m_TimeStartDrag = m_TimeArea.TimeToPixel(Time, r);
                        }
                        else if (srcRect.Contains(evt.mousePosition))
                        {
                            m_DragState = DragStates.Source;
                        }
                        else if (dstRect.Contains(evt.mousePosition))
                        {
                            m_DragState = DragStates.Destination;
                        }
                        else if (leftThumbRect.Contains(evt.mousePosition))
                        {
                            m_DragState = DragStates.LeftSelection;
                        }
                        else if (rightThumbRect.Contains(evt.mousePosition))
                        {
                            m_DragState = DragStates.RightSelection;
                        }
                        else if (transHeaderRect.Contains(evt.mousePosition))
                        {
                            m_DragState = DragStates.FullSelection;
                        }
                        else if (headerRect.Contains(evt.mousePosition))
                        {
                            m_DragState = DragStates.TimeArea;
                        }
                        else if (bodyRect.Contains(evt.mousePosition))
                        {
                            m_DragState = DragStates.TimeArea;
                        }
                        else
                        {
                            m_DragState = DragStates.None;
                        }
                        evt.Use();
                    }
                }

                // handle mouse drag
                if (evt.type == EventType.MouseDrag)
                {
                    if (EditorGUIUtility.hotControl == id)
                    {
                        switch (m_DragState)
                        {
                        case DragStates.Source:
                        case DragStates.TimeArea:
                            m_TimeArea.m_Translation.x += evt.delta.x;
                            break;

                        case DragStates.Destination:
                            m_DstDragOffset += evt.delta.x;
                            EnforceConstraints();
                            break;

                        case DragStates.LeftSelection:
                            // clamp the delta when off range
                            if ((evt.delta.x > 0 && evt.mousePosition.x > srcStart) ||
                                (evt.delta.x < 0 && evt.mousePosition.x < transStop))
                            {
                                m_LeftThumbOffset += evt.delta.x;
                            }
                            EnforceConstraints();
                            break;

                        case DragStates.RightSelection:
                            // clamp the delta when off range
                            if (evt.delta.x > 0 && evt.mousePosition.x > transStart || evt.delta.x < 0)
                            {
                                m_RightThumbOffset += evt.delta.x;
                            }
                            EnforceConstraints();
                            break;

                        case DragStates.FullSelection:
                            m_RightThumbOffset += evt.delta.x;
                            m_LeftThumbOffset  += evt.delta.x;
                            EnforceConstraints();
                            break;

                        case DragStates.Playhead:
                            if ((evt.delta.x > 0 && evt.mousePosition.x > srcStart) ||
                                (evt.delta.x < 0 && evt.mousePosition.x <= m_TimeArea.TimeToPixel(SampleStopTime, r)))
                            {
                                m_TimeOffset += evt.delta.x;
                            }
                            Time = m_TimeArea.PixelToTime(m_TimeStartDrag + m_TimeOffset, r);

                            break;

                        case DragStates.None:
                            break;
                        }
                        evt.Use();
                        GUI.changed = true;
                    }
                }


                // handle mouse up both when it happens over the control area and outside control area (case 834214)
                if (Event.current.GetTypeForControl(id) == EventType.MouseUp)
                {
                    SrcStartTime        = m_TimeArea.PixelToTime(srcStart, r);
                    SrcStopTime         = m_TimeArea.PixelToTime(srcStop, r);
                    DstStartTime        = m_TimeArea.PixelToTime(dstStart, r);
                    DstStopTime         = m_TimeArea.PixelToTime(dstStop, r);
                    TransitionStartTime = m_TimeArea.PixelToTime(transStart, r);
                    TransitionStopTime  = m_TimeArea.PixelToTime(transStop, r);
                    GUI.changed         = true;
                    m_DragState         = DragStates.None;

                    hasModifiedData             = WasDraggingData();
                    m_LeftThumbOffset           = 0f;
                    m_RightThumbOffset          = 0f;
                    m_TimeOffset                = 0f;
                    m_DstDragOffset             = 0f;
                    EditorGUIUtility.hotControl = 0;
                    evt.Use();
                }


                // draw the background boxes
                GUI.Box(headerRect, GUIContent.none, styles.header);
                GUI.Box(bodyRect, GUIContent.none, styles.background);

                // draw ticks and curves on top of background boxes
                m_TimeArea.DrawMajorTicks(bodyRect, 30);


                GUIContent srcContent = EditorGUIUtility.TempContent(SrcName);

                // draw src Loop
                int  srcLoopCount = srcLoop ? (1 + (int)((transStop - srcRect.xMin) / (srcRect.xMax - srcRect.xMin))) : 1;
                Rect loopRect     = srcRect;
                if (srcRect.width < 10) // if smaller than 10 pixel, group
                {
                    loopRect     = new Rect(srcRect.x, srcRect.y, (srcRect.xMax - srcRect.xMin) * srcLoopCount, srcRect.height);
                    srcLoopCount = 1;
                }

                for (int loopSrcIt = 0; loopSrcIt < srcLoopCount; loopSrcIt++)
                {
                    GUI.BeginGroup(loopRect, GUIContent.none, styles.leftBlock);
                    float widthBefore = transStart - loopRect.xMin;
                    float widthDuring = transStop - transStart;
                    float widthAfter  = (loopRect.xMax - loopRect.xMin) - (widthBefore + widthDuring);
                    if (widthBefore > 0)
                    {
                        GUI.Box(new Rect(0, 0, widthBefore, srcRect.height), GUIContent.none, styles.onLeft);
                    }
                    if (widthDuring > 0)
                    {
                        GUI.Box(new Rect(widthBefore, 0, widthDuring, srcRect.height), GUIContent.none, styles.onOff);
                    }
                    if (widthAfter > 0)
                    {
                        GUI.Box(new Rect(widthBefore + widthDuring, 0, widthAfter, srcRect.height), GUIContent.none, styles.offRight);
                    }
                    float srcAlphaTarget  = 1f;
                    float srcLabelRight   = styles.block.CalcSize(srcContent).x;
                    float srcPercentLeft  = Mathf.Max(0, widthBefore) - 20;
                    float srcPercentRight = srcPercentLeft + 15;
                    if (srcPercentLeft < srcLabelRight && srcPercentRight > 0f && m_DragState == DragStates.LeftSelection)
                    {
                        srcAlphaTarget = 0f;
                    }
                    GUI.EndGroup();

                    float srcAlpha = styles.leftBlock.normal.textColor.a;
                    if (!Mathf.Approximately(srcAlpha, srcAlphaTarget) && Event.current.type == EventType.Repaint)
                    {
                        srcAlpha = Mathf.Lerp(srcAlpha, srcAlphaTarget, 0.1f);
                        styles.leftBlock.normal.textColor = new Color(styles.leftBlock.normal.textColor.r, styles.leftBlock.normal.textColor.g, styles.leftBlock.normal.textColor.b, srcAlpha);
                        HandleUtility.Repaint();
                    }
                    GUI.Box(loopRect, srcContent, styles.leftBlock);
                    loopRect = new Rect(loopRect.xMax, 85, loopRect.xMax - loopRect.xMin, 32);
                }


                GUIContent dstContent   = EditorGUIUtility.TempContent(DstName);
                int        dstLoopCount = dstLoop  ? (1 + (int)((transStop - dstRect.xMin) / (dstRect.xMax - dstRect.xMin))) : 1;
                loopRect = dstRect;
                if (dstRect.width < 10) // if smaller than 10 pixel, group
                {
                    loopRect     = new Rect(dstRect.x, dstRect.y, (dstRect.xMax - dstRect.xMin) * dstLoopCount, dstRect.height);
                    dstLoopCount = 1;
                }

                for (int loopDstIt = 0; loopDstIt < dstLoopCount; loopDstIt++)
                {
                    // draw the DST box
                    GUI.BeginGroup(loopRect, GUIContent.none, styles.rightBlock);
                    float widthBefore = transStart - loopRect.xMin;
                    float widthDuring = transStop - transStart;
                    float widthAfter  = (loopRect.xMax - loopRect.xMin) - (widthBefore + widthDuring);
                    if (widthBefore > 0)
                    {
                        GUI.Box(new Rect(0, 0, widthBefore, dstRect.height), GUIContent.none, styles.offLeft);
                    }
                    if (widthDuring > 0)
                    {
                        GUI.Box(new Rect(widthBefore, 0, widthDuring, dstRect.height), GUIContent.none, styles.offOn);
                    }
                    if (widthAfter > 0)
                    {
                        GUI.Box(new Rect(widthBefore + widthDuring, 0, widthAfter, dstRect.height), GUIContent.none, styles.onRight);
                    }
                    float dstAlphaTarget  = 1f;
                    float dstLabelRight   = styles.block.CalcSize(dstContent).x;
                    float dstPercentLeft  = Mathf.Max(0, widthBefore) - 20;
                    float dstPercentRight = dstPercentLeft + 15;
                    if (dstPercentLeft < dstLabelRight && dstPercentRight > 0f && (m_DragState == DragStates.LeftSelection || m_DragState == DragStates.Destination))
                    {
                        dstAlphaTarget = 0f;
                    }
                    GUI.EndGroup();
                    float dstAlpha = styles.rightBlock.normal.textColor.a;
                    if (!Mathf.Approximately(dstAlpha, dstAlphaTarget) && Event.current.type == EventType.Repaint)
                    {
                        dstAlpha = Mathf.Lerp(dstAlpha, dstAlphaTarget, 0.1f);
                        styles.rightBlock.normal.textColor = new Color(styles.rightBlock.normal.textColor.r, styles.rightBlock.normal.textColor.g, styles.rightBlock.normal.textColor.b, dstAlpha);
                        HandleUtility.Repaint();
                    }
                    GUI.Box(loopRect, dstContent, styles.rightBlock);

                    loopRect = new Rect(loopRect.xMax, loopRect.yMin, loopRect.xMax - loopRect.xMin, 32);
                }

                // draw the transition selection box in the body
                GUI.Box(transRect, GUIContent.none, styles.select);

                // draw the transition selection box in the header
                GUI.Box(transHeaderRect, GUIContent.none, styles.selectHead);

                m_TimeArea.TimeRuler(headerRect, 30);

                // draw the thumbs
                GUI.Box(leftThumbRect, GUIContent.none, (m_HasExitTime) ? styles.handLeft : styles.handLeftPrev);
                GUI.Box(rightThumbRect, GUIContent.none, styles.handRight);

                // playhead and bar
                GUI.Box(playHeadRect, GUIContent.none, styles.playhead);
                Color oldColor = Handles.color;
                Handles.color = Color.white;
                Handles.DrawLine(new Vector3(playPoint, 19, 0), new Vector3(playPoint, r.height, 0));
                Handles.color = oldColor;


                bool oneFrameSrc = (SrcStopTime - SrcStartTime) < 1.0f / 30.0f;
                bool oneFrameDst = (DstStopTime - DstStartTime) < 1.0f / 30.0f;
                // show normalized time label when moving destination state
                if (m_DragState == DragStates.Destination && !oneFrameDst)
                {
                    Rect   transLabelRect = new Rect(transStart - 50, dstRect.y, 45, dstRect.height);
                    string transLabel     = String.Format("{0:0%}", (transStart - dstStart) / (dstStop - dstStart));
                    GUI.Box(transLabelRect, EditorGUIUtility.TempContent(transLabel), styles.timeBlockRight);
                }

                // show normalized time label on left side when moving left edge of transition
                if (m_DragState == DragStates.LeftSelection)
                {
                    if (!oneFrameSrc)
                    {
                        Rect   srcLabelRect = new Rect(transStart - 50, srcRect.y, 45, srcRect.height);
                        string srcLabel     = String.Format("{0:0%}", (transStart - srcStart) / (srcStop - srcStart));
                        GUI.Box(srcLabelRect, EditorGUIUtility.TempContent(srcLabel), styles.timeBlockRight);
                    }

                    if (!oneFrameDst)
                    {
                        Rect   dstLabelRect = new Rect(transStart - 50, dstRect.y, 45, dstRect.height);
                        string dstLabel     = String.Format("{0:0%}", (transStart - dstStart) / (dstStop - dstStart));
                        GUI.Box(dstLabelRect, EditorGUIUtility.TempContent(dstLabel), styles.timeBlockRight);
                    }
                }

                // show normalized time label on right side when moving right edge of transition
                if (m_DragState == DragStates.RightSelection)
                {
                    if (!oneFrameSrc)
                    {
                        Rect   srcLabelRect = new Rect(transStop + 5, srcRect.y, 45, srcRect.height);
                        string srcLabel     = String.Format("{0:0%}", (transStop - srcStart) / (srcStop - srcStart));
                        GUI.Box(srcLabelRect, EditorGUIUtility.TempContent(srcLabel), styles.timeBlockLeft);
                    }

                    if (!oneFrameDst)
                    {
                        Rect   dstLabelRect = new Rect(transStop + 5, dstRect.y, 45, dstRect.height);
                        string dstLabel     = String.Format("{0:0%}", (transStop - dstStart) / (dstStop - dstStart));
                        GUI.Box(dstLabelRect, EditorGUIUtility.TempContent(dstLabel), styles.timeBlockLeft);
                    }
                }

                DoPivotCurves();
            }
            GUI.EndGroup();

            return(hasModifiedData);
        }
Exemple #26
0
        public bool DoTimeline(Rect timeRect)
        {
            bool flag = false;
            this.Init();
            this.m_Rect = timeRect;
            float a = this.m_TimeArea.PixelToTime(timeRect.xMin, timeRect);
            float num2 = this.m_TimeArea.PixelToTime(timeRect.xMax, timeRect);
            if (!Mathf.Approximately(a, this.StartTime))
            {
                this.StartTime = a;
                GUI.changed = true;
            }
            if (!Mathf.Approximately(num2, this.StopTime))
            {
                this.StopTime = num2;
                GUI.changed = true;
            }
            this.Time = Mathf.Max(this.Time, 0f);
            if (Event.current.type == EventType.Repaint)
            {
                this.m_TimeArea.rect = timeRect;
            }
            this.m_TimeArea.BeginViewGUI();
            this.m_TimeArea.EndViewGUI();
            GUI.BeginGroup(timeRect);
            Event current = Event.current;
            Rect rect = new Rect(0f, 0f, timeRect.width, timeRect.height);
            Rect position = new Rect(0f, 0f, timeRect.width, 18f);
            Rect rect3 = new Rect(0f, 18f, timeRect.width, 132f);
            float x = this.m_TimeArea.TimeToPixel(this.SrcStartTime, rect);
            float pixelX = this.m_TimeArea.TimeToPixel(this.SrcStopTime, rect);
            float num5 = this.m_TimeArea.TimeToPixel(this.DstStartTime, rect) + this.m_DstDragOffset;
            float num6 = this.m_TimeArea.TimeToPixel(this.DstStopTime, rect) + this.m_DstDragOffset;
            float num7 = this.m_TimeArea.TimeToPixel(this.TransitionStartTime, rect) + this.m_LeftThumbOffset;
            float num8 = this.m_TimeArea.TimeToPixel(this.TransitionStopTime, rect) + this.m_RightThumbOffset;
            float num9 = this.m_TimeArea.TimeToPixel(this.Time, rect);
            Rect rect4 = new Rect(x, 85f, pixelX - x, 32f);
            Rect rect5 = new Rect(num5, 117f, num6 - num5, 32f);
            Rect rect6 = new Rect(num7, 0f, num8 - num7, 18f);
            Rect rect7 = new Rect(num7, 18f, num8 - num7, rect.height - 18f);
            Rect rect8 = new Rect(num7 - 9f, 5f, 9f, 15f);
            Rect rect9 = new Rect(num8, 5f, 9f, 15f);
            Rect rect10 = new Rect(num9 - 7f, 4f, 15f, 15f);
            if (current.type == EventType.KeyDown)
            {
                if ((GUIUtility.keyboardControl == this.id) && (this.m_DragState == DragStates.Destination))
                {
                    this.m_DstDragOffset = 0f;
                }
                if (this.m_DragState == DragStates.LeftSelection)
                {
                    this.m_LeftThumbOffset = 0f;
                }
                if (this.m_DragState == DragStates.RightSelection)
                {
                    this.m_RightThumbOffset = 0f;
                }
                if (this.m_DragState == DragStates.FullSelection)
                {
                    this.m_LeftThumbOffset = 0f;
                    this.m_RightThumbOffset = 0f;
                }
            }
            if ((current.type == EventType.MouseDown) && rect.Contains(current.mousePosition))
            {
                GUIUtility.hotControl = this.id;
                GUIUtility.keyboardControl = this.id;
                if (rect10.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.Playhead;
                }
                else if (rect4.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.Source;
                }
                else if (rect5.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.Destination;
                }
                else if (rect8.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.LeftSelection;
                }
                else if (rect9.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.RightSelection;
                }
                else if (rect6.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.FullSelection;
                }
                else if (position.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.TimeArea;
                }
                else if (rect3.Contains(current.mousePosition))
                {
                    this.m_DragState = DragStates.TimeArea;
                }
                else
                {
                    this.m_DragState = DragStates.None;
                }
                current.Use();
            }
            if ((current.type == EventType.MouseDrag) && (GUIUtility.hotControl == this.id))
            {
                switch (this.m_DragState)
                {
                    case DragStates.LeftSelection:
                        if (((current.delta.x > 0f) && (current.mousePosition.x > x)) || ((current.delta.x < 0f) && (current.mousePosition.x < num8)))
                        {
                            this.m_LeftThumbOffset += current.delta.x;
                        }
                        this.EnforceConstraints();
                        break;

                    case DragStates.RightSelection:
                        if (((current.delta.x > 0f) && (current.mousePosition.x > num7)) || (current.delta.x < 0f))
                        {
                            this.m_RightThumbOffset += current.delta.x;
                        }
                        this.EnforceConstraints();
                        break;

                    case DragStates.FullSelection:
                        this.m_RightThumbOffset += current.delta.x;
                        this.m_LeftThumbOffset += current.delta.x;
                        this.EnforceConstraints();
                        break;

                    case DragStates.Destination:
                        this.m_DstDragOffset += current.delta.x;
                        this.EnforceConstraints();
                        break;

                    case DragStates.Source:
                        this.m_TimeArea.m_Translation.x += current.delta.x;
                        break;

                    case DragStates.Playhead:
                        this.Time = this.m_TimeArea.PixelToTime(num9 + current.delta.x, rect);
                        break;

                    case DragStates.TimeArea:
                        this.m_TimeArea.m_Translation.x += current.delta.x;
                        break;
                }
                current.Use();
                GUI.changed = true;
            }
            if ((current.type == EventType.MouseUp) && (GUIUtility.hotControl == this.id))
            {
                this.SrcStartTime = this.m_TimeArea.PixelToTime(x, rect);
                this.SrcStopTime = this.m_TimeArea.PixelToTime(pixelX, rect);
                this.DstStartTime = this.m_TimeArea.PixelToTime(num5, rect);
                this.DstStopTime = this.m_TimeArea.PixelToTime(num6, rect);
                this.TransitionStartTime = this.m_TimeArea.PixelToTime(num7, rect);
                this.TransitionStopTime = this.m_TimeArea.PixelToTime(num8, rect);
                GUI.changed = true;
                this.m_DragState = DragStates.None;
                flag = this.WasDraggingData();
                this.m_LeftThumbOffset = 0f;
                this.m_RightThumbOffset = 0f;
                this.m_DstDragOffset = 0f;
                GUIUtility.hotControl = 0;
                current.Use();
            }
            GUI.Box(position, GUIContent.none, this.styles.header);
            GUI.Box(rect3, GUIContent.none, this.styles.background);
            this.m_TimeArea.DrawMajorTicks(rect3, 30f);
            GUIContent content = EditorGUIUtility.TempContent(this.SrcName);
            int num10 = !this.srcLoop ? 1 : (1 + ((int) ((num8 - rect4.xMin) / (rect4.xMax - rect4.xMin))));
            Rect rect11 = rect4;
            if (rect4.width < 10f)
            {
                rect11 = new Rect(rect4.x, rect4.y, (rect4.xMax - rect4.xMin) * num10, rect4.height);
                num10 = 1;
            }
            for (int i = 0; i < num10; i++)
            {
                GUI.BeginGroup(rect11, GUIContent.none, this.styles.leftBlock);
                float width = num7 - rect11.xMin;
                float num13 = num8 - num7;
                float num14 = (rect11.xMax - rect11.xMin) - (width + num13);
                if (width > 0f)
                {
                    GUI.Box(new Rect(0f, 0f, width, rect4.height), GUIContent.none, this.styles.onLeft);
                }
                if (num13 > 0f)
                {
                    GUI.Box(new Rect(width, 0f, num13, rect4.height), GUIContent.none, this.styles.onOff);
                }
                if (num14 > 0f)
                {
                    GUI.Box(new Rect(width + num13, 0f, num14, rect4.height), GUIContent.none, this.styles.offRight);
                }
                float b = 1f;
                float num16 = this.styles.block.CalcSize(content).x;
                float num17 = Mathf.Max(0f, width) - 20f;
                float num18 = num17 + 15f;
                if (((num17 < num16) && (num18 > 0f)) && (this.m_DragState == DragStates.LeftSelection))
                {
                    b = 0f;
                }
                GUI.EndGroup();
                float num19 = this.styles.leftBlock.normal.textColor.a;
                if (!Mathf.Approximately(num19, b) && (Event.current.type == EventType.Repaint))
                {
                    num19 = Mathf.Lerp(num19, b, 0.1f);
                    this.styles.leftBlock.normal.textColor = new Color(this.styles.leftBlock.normal.textColor.r, this.styles.leftBlock.normal.textColor.g, this.styles.leftBlock.normal.textColor.b, num19);
                    HandleUtility.Repaint();
                }
                GUI.Box(rect11, content, this.styles.leftBlock);
                rect11 = new Rect(rect11.xMax, 85f, rect11.xMax - rect11.xMin, 32f);
            }
            GUIContent content2 = EditorGUIUtility.TempContent(this.DstName);
            int num20 = !this.dstLoop ? 1 : (1 + ((int) ((num8 - rect5.xMin) / (rect5.xMax - rect5.xMin))));
            rect11 = rect5;
            if (rect5.width < 10f)
            {
                rect11 = new Rect(rect5.x, rect5.y, (rect5.xMax - rect5.xMin) * num20, rect5.height);
                num20 = 1;
            }
            for (int j = 0; j < num20; j++)
            {
                GUI.BeginGroup(rect11, GUIContent.none, this.styles.rightBlock);
                float num22 = num7 - rect11.xMin;
                float num23 = num8 - num7;
                float num24 = (rect11.xMax - rect11.xMin) - (num22 + num23);
                if (num22 > 0f)
                {
                    GUI.Box(new Rect(0f, 0f, num22, rect5.height), GUIContent.none, this.styles.offLeft);
                }
                if (num23 > 0f)
                {
                    GUI.Box(new Rect(num22, 0f, num23, rect5.height), GUIContent.none, this.styles.offOn);
                }
                if (num24 > 0f)
                {
                    GUI.Box(new Rect(num22 + num23, 0f, num24, rect5.height), GUIContent.none, this.styles.onRight);
                }
                float num25 = 1f;
                float num26 = this.styles.block.CalcSize(content2).x;
                float num27 = Mathf.Max(0f, num22) - 20f;
                float num28 = num27 + 15f;
                if (((num27 < num26) && (num28 > 0f)) && ((this.m_DragState == DragStates.LeftSelection) || (this.m_DragState == DragStates.Destination)))
                {
                    num25 = 0f;
                }
                GUI.EndGroup();
                float num29 = this.styles.rightBlock.normal.textColor.a;
                if (!Mathf.Approximately(num29, num25) && (Event.current.type == EventType.Repaint))
                {
                    num29 = Mathf.Lerp(num29, num25, 0.1f);
                    this.styles.rightBlock.normal.textColor = new Color(this.styles.rightBlock.normal.textColor.r, this.styles.rightBlock.normal.textColor.g, this.styles.rightBlock.normal.textColor.b, num29);
                    HandleUtility.Repaint();
                }
                GUI.Box(rect11, content2, this.styles.rightBlock);
                rect11 = new Rect(rect11.xMax, rect11.yMin, rect11.xMax - rect11.xMin, 32f);
            }
            GUI.Box(rect7, GUIContent.none, this.styles.select);
            GUI.Box(rect6, GUIContent.none, this.styles.selectHead);
            this.m_TimeArea.TimeRuler(position, 30f);
            GUI.Box(rect8, GUIContent.none, !this.m_HasExitTime ? this.styles.handLeftPrev : this.styles.handLeft);
            GUI.Box(rect9, GUIContent.none, this.styles.handRight);
            GUI.Box(rect10, GUIContent.none, this.styles.playhead);
            Color color = Handles.color;
            Handles.color = Color.white;
            Handles.DrawLine(new Vector3(num9, 19f, 0f), new Vector3(num9, rect.height, 0f));
            Handles.color = color;
            bool flag2 = (this.SrcStopTime - this.SrcStartTime) < 0.03333334f;
            bool flag3 = (this.DstStopTime - this.DstStartTime) < 0.03333334f;
            if ((this.m_DragState == DragStates.Destination) && !flag3)
            {
                Rect rect12 = new Rect(num7 - 50f, rect5.y, 45f, rect5.height);
                string t = string.Format("{0:0%}", (num7 - num5) / (num6 - num5));
                GUI.Box(rect12, EditorGUIUtility.TempContent(t), this.styles.timeBlockRight);
            }
            if (this.m_DragState == DragStates.LeftSelection)
            {
                if (!flag2)
                {
                    Rect rect13 = new Rect(num7 - 50f, rect4.y, 45f, rect4.height);
                    string str2 = string.Format("{0:0%}", (num7 - x) / (pixelX - x));
                    GUI.Box(rect13, EditorGUIUtility.TempContent(str2), this.styles.timeBlockRight);
                }
                if (!flag3)
                {
                    Rect rect14 = new Rect(num7 - 50f, rect5.y, 45f, rect5.height);
                    string str3 = string.Format("{0:0%}", (num7 - num5) / (num6 - num5));
                    GUI.Box(rect14, EditorGUIUtility.TempContent(str3), this.styles.timeBlockRight);
                }
            }
            if (this.m_DragState == DragStates.RightSelection)
            {
                if (!flag2)
                {
                    Rect rect15 = new Rect(num8 + 5f, rect4.y, 45f, rect4.height);
                    string str4 = string.Format("{0:0%}", (num8 - x) / (pixelX - x));
                    GUI.Box(rect15, EditorGUIUtility.TempContent(str4), this.styles.timeBlockLeft);
                }
                if (!flag3)
                {
                    Rect rect16 = new Rect(num8 + 5f, rect5.y, 45f, rect5.height);
                    string str5 = string.Format("{0:0%}", (num8 - num5) / (num6 - num5));
                    GUI.Box(rect16, EditorGUIUtility.TempContent(str5), this.styles.timeBlockLeft);
                }
            }
            this.DoPivotCurves();
            GUI.EndGroup();
            return flag;
        }