Example #1
0
 public void OnDeselect(BaseEventData eventData)
 {
     if (hasFocused)
     {
         OnStateEnd?.Invoke(eventData);
     }
 }
Example #2
0
        public void EndState()
        {
            HasEnded = true;
            OnStateEnd?.Invoke(this);

            foreach (SpriteAnimation a in AssignedAnimations)
            {
                a.Reset();
            }
        }
Example #3
0
    void Update()
    {
        if (!IsPlaying)
        {
            return;
        }

        if (OnStateBegin == null || OnStateBegin(this))
        {
            if (CurrentState != null && CurrentState.OnState != null &&
                StateStartTime <= Time.time)
            {
                // Note:
                //  OnState()でCurrentStateの更新がある可能性があるので,
                //  previousStateの更新は, その前にやる.
                IsStateChange = (previousState != CurrentState);
                previousState = CurrentState;

                CurrentState.OnState(CurrentState);
            }

            if (StateStartTime + StateTimeLength < Time.time)
            {
                if (StateLinkSeries.Count > 0)
                {
                    ignoreSeriesRunningCheck = true;
                    {
                        Goto(StateLinkSeries.First.Value.stateName, StateLinkSeries.First.Value.timeLength, StateLinkSeries.First.Value.delayTime);
                    }
                    ignoreSeriesRunningCheck = false;


                    StateLinkSeries.RemoveFirst();
                }
                else
                {
                    Goto(IdleState, 0.0f);
                }
            }

            OnStateEnd?.Invoke(this);
        }
    }
        private void SelectedObjectChanged()
        {
            var transform = this.transform;
            var current   = selectedObject?.transform;

            while (current != null)
            {
                if (current == transform)
                {
                    hasFocus = true;
                    OnStateStart?.Invoke(null);
                    return;
                }

                current = current.parent;
            }

            if (hasFocus)
            {
                OnStateEnd?.Invoke(null);
            }
        }
Example #5
0
 public void OnDeselect(BlurEvent eventData)
 {
     OnStateEnd?.Invoke(null);
 }
Example #6
0
        public override void Tick()
        {
            Ray inputRay = m_camera.ScreenPointToRay(Input.mousePosition);

            float penetration;

            if (m_inputPlane.Raycast(inputRay, out penetration))
            {
                //get world input position
                Vector3 inputPosition = m_inputPlane.ClosestPointOnPlane(inputRay.GetPoint(penetration));

#if UNITY_EDITOR
                Debug.DrawLine(inputRay.origin, inputPosition);
#endif
                //convert to 'board' space
                inputPosition -= m_cornerTransform.position;

                Vector2Int boardInputPosition = new Vector2Int(Mathf.RoundToInt(inputPosition.x / Constants.GridSize), Mathf.RoundToInt(inputPosition.y / Constants.GridSize));

                OnHoverEvent.Invoke(boardInputPosition);

                if (m_firstPieceClicked)
                {
                    OnHoverEvent.Invoke(m_clickOriginPosition);
                }

                //handle mouse drag
                if (Input.GetMouseButtonDown(0))
                {
                    m_dragOriginPosition = boardInputPosition;
                    OnOriginSelectedEvent.Invoke(m_dragOriginPosition);
                }
                else if (Input.GetMouseButton(0))
                {
                    Vector2Int delta = boardInputPosition - m_dragOriginPosition;
                    if (Mathf.Abs(delta.x) + Mathf.Abs(delta.y) == 1)
                    {
                        //end input state
                        OnStateEnd.Invoke(this);

                        OnSwapEvent.Invoke(new PieceMoveData(-1, m_dragOriginPosition, boardInputPosition));
                        return;
                    }
                }

                //handle click
                if (Input.GetMouseButtonUp(0))
                {
                    if (m_firstPieceClicked)
                    {
                        Vector2Int delta = boardInputPosition - m_clickOriginPosition;
                        if (Mathf.Abs(delta.x) + Mathf.Abs(delta.y) == 1)
                        {
                            OnSwapEvent.Invoke(new PieceMoveData(-1, m_clickOriginPosition, boardInputPosition));

                            //end input state
                            OnStateEnd.Invoke(this);
                            return;
                        }
                    }

                    m_firstPieceClicked   = true;
                    m_clickOriginPosition = boardInputPosition;
                }
            }
        }
Example #7
0
 public void OnPointerExit(PointerEventData eventData)
 {
     OnStateEnd?.Invoke(eventData);
 }
Example #8
0
 public void OnPointerUp(MouseUpEvent eventData)
 {
     OnStateEnd?.Invoke(null);
 }
Example #9
0
 public void OnDeselect(BaseEventData eventData)
 {
     OnStateEnd?.Invoke(eventData);
 }
Example #10
0
 public void OnPointerLeave(MouseLeaveEvent eventData)
 {
     OnStateEnd?.Invoke(null);
 }
Example #11
0
 public void EndState()
 {
     OnStateEnd?.Invoke(sender: this);
 }