示例#1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            //imageCustom.Push();
            switch (e.Button)
            {
            case MouseButtons.Left:
                state_mouse = MOUSE_STATE.Left;
                break;

            case MouseButtons.Middle:
                state_mouse = MOUSE_STATE.Middle;
                break;

            case MouseButtons.Right:
                state_mouse = MOUSE_STATE.Right;
                break;
            }

            switch (state_mouse)
            {
            case MOUSE_STATE.Right:
                return;
            }

            m_MouseHandler.Down(e);

            base.OnMouseDown(e);
        }
示例#2
0
        private MOUSE_STATE GetMouseState()
        {
            bool        CurrentMouseDown = Input.GetMouseButton(0);
            MOUSE_STATE state            = MOUSE_STATE.NONE;

            if (CurrentMouseDown == true)
            {
                if (LastMouseDown == true)
                {
                    state = MOUSE_STATE.DRAG;
                }
                else
                {
                    state = MOUSE_STATE.DOWN;
                }
            }
            else
            {
                if (LastMouseDown == true)
                {
                    state = MOUSE_STATE.UP;
                }
                else
                {
                    state = MOUSE_STATE.NONE;
                }
            }
            LastMouseDown = CurrentMouseDown;

            return(state);
        }
示例#3
0
 public static void SetMouseState(MOUSE_STATE iState)
 {
     if (iState == MOUSE_STATE.SELECT_UNIT)
     {
         Active.ClearPlacement();
     }
     Active.MouseState = iState;
 }
示例#4
0
    //这里是使用Ray射线来控制物体移动。
    private void RayMove()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Input.GetMouseButton(0))
        {
            if (!oldHitObj)
            {
                if (mouseState == MOUSE_STATE.NORMAL)
                {
                    if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
                    {
                        GameObject            hitObj = hit.transform.gameObject;
                        ChessController       chess  = hitObj.GetComponent <ChessController> ();
                        CommonUtil.ChessState state  = chess.GetState();
                        int chessTeam = chess.team;
                        if (state == CommonUtil.ChessState.MANAGE && chessTeam == team)
                        {
                            mouseState = MOUSE_STATE.DRAGING;
                            oldHitObj  = hitObj;
                        }
                    }
                    if (mouseState != MOUSE_STATE.DRAGING)
                    {
                        mouseState = MOUSE_STATE.DRAG_NOTHING;
                    }
                }
                else
                {
                    //is drag nothing
                }
                // Vector3 offset = Input.mousePosition;
                // hit.transform.position = new Vector3(hit.point.x, hit.point.y, hit.transform.position.z);
                // Debug.DrawLine(ray.origin, hit.point);
            }
            else
            {
                float   enter;
                bool    banana = BOARD_CHESS_PLAIN.Raycast(ray, out enter);
                Vector3 point  = ray.GetPoint(enter);
                oldHitObj.transform.position = point;
            }
            // oldMouse = hit.point;
        }
        else
        {
            if (oldHitObj)
            {
                ChessController chess = oldHitObj.GetComponent <ChessController> ();
                chess.NearBySitDown();
                oldHitObj = null;
            }
            mouseState = MOUSE_STATE.NORMAL;
        }
    }
示例#5
0
 /// <summary>
 /// Changes the MouseState to the give MouseState, or none if it is already set.
 /// </summary>
 /// <param name="iState"></param>
 public static void ToggleMouseState(MOUSE_STATE iState)
 {
     if (Active.MouseState == iState)
     {
         Active.MouseState = MOUSE_STATE.SELECT_UNIT;
         Active.ClearPlacement();
     }
     else
     {
         Active.MouseState = iState;
     }
 }
示例#6
0
        /// *******************************************************
        /// <summary>更新処理</summary>
        /// *******************************************************
        protected override void OnUpdate()
        {
            base.OnUpdate();

            if (StageManager.Instance.IsMovableWall == true)
            {
                MOUSE_STATE state = GetMouseState();
                Vector2     position;

                switch (state)
                {
                case MOUSE_STATE.DOWN:
                    if (Draggable == null)
                    {
                        position = GetMousePosition();
                        if ((ColliderScale - Vector2.Distance(position, Position)) > 0f)
                        {
                            Draggable = this;
                            Position  = position;
                        }
                    }
                    break;

                case MOUSE_STATE.UP:
                    if (Draggable == this)
                    {
                        Position  = GetMousePosition();
                        Draggable = null;
                    }
                    break;

                case MOUSE_STATE.DRAG:
                    if (Draggable == this)
                    {
                        Position = GetMousePosition();
                    }
                    break;
                }
            }
            else
            {
                LastMouseDown = false;
                Draggable     = null;
            }
        }
示例#7
0
        /// *******************************************************
        /// <summary>更新処理</summary>
        /// *******************************************************
        protected void Update()
        {
            //if (StageManager.Instance.IsMovableMirror == true)
            //{
            MOUSE_STATE state = GetMouseState();
            Vector2     position;

            switch (state)
            {
            case MOUSE_STATE.DOWN:
                if (Draggable == null)
                {
                    position = GetMousePosition();
                    if ((ColliderScale - Vector2.Distance(position, Position)) > 0f)
                    {
                        Draggable = this;
                        Position  = position;
                    }
                }
                break;

            case MOUSE_STATE.UP:
                if (Draggable == this)
                {
                    Position  = GetMousePosition();
                    Draggable = null;
                }
                break;

            case MOUSE_STATE.DRAG:
                if (Draggable == this)
                {
                    Position = GetMousePosition();
                }
                break;
            }
            //}
            //else
            //{
            //    LastMouseDown = false;
            //    Draggable = null;
            //}
        }
示例#8
0
 public void SetMouseSprite(MOUSE_STATE spriteId)
 {
     GetComponent <SpriteRenderer>().sprite = mouseSpriteMap[spriteId];
     mouseState = spriteId;
 }