Exemplo n.º 1
0
 private void ChkInputState()
 {
     if (Input.GetMouseButtonDown(0))
     {
         inputState = INPUT_STATE.CREATE;
     }
     else if (Input.GetMouseButtonDown(1))
     {
         inputState = INPUT_STATE.DELETE;
     }
     else if(Input.GetKeyDown(KeyCode.I))
     {
         inputState = INPUT_STATE.INVEN_OPEN;
     }
     else if (Input.GetKeyDown(KeyCode.F10))
     {
         inputState = INPUT_STATE.MENU_OPEN;
     }
     else if (Input.GetKeyDown(KeyCode.U))
     {
         inputState = INPUT_STATE.CRAFT_ITEM_OPEN;
     }
     else
     {
         inputState = INPUT_STATE.NONE;
     }
 }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        // Set up player varible
        m_mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();

        if (XboxCtrlrInput.XCI.GetNumPluggedCtrlrs() > 0)
        {
            m_inputState = INPUT_STATE.CONTROLLER; //Controller is detected
        }
        //Set up dictionaries

        //Xbox Controls
        //Axis
        m_stringToFloat.Add("MovementHorizontal", XboxCtrlrInput.XboxAxis.LeftStickX);
        m_stringToFloat.Add("MovementVertical", XboxCtrlrInput.XboxAxis.LeftStickY);
        m_stringToFloat.Add("AimingHorizontal", XboxCtrlrInput.XboxAxis.RightStickX);
        m_stringToFloat.Add("AimingVertical", XboxCtrlrInput.XboxAxis.RightStickY);
        m_stringToFloat.Add("HeavyAttack", XboxCtrlrInput.XboxAxis.RightTrigger);

        //Buttons
        m_stringToBool.Add("Jump", XboxCtrlrInput.XboxButton.A);
        m_stringToBool.Add("Sprint", XboxCtrlrInput.XboxButton.B);
        m_stringToBool.Add("Dash", XboxCtrlrInput.XboxButton.X);
        m_stringToBool.Add("LightAttack", XboxCtrlrInput.XboxButton.RightBumper);
        m_stringToBool.Add("SwapWeapon", XboxCtrlrInput.XboxButton.Y);
    }
 public void startEndEffects()
 {
     Debug.Log("StartEndEffects");
     nowState = INPUT_STATE.END_DANCE;
     gameSetUI.gameObject.SetActive(true);
     Debug.Log(gameSetUI);
 }
    void SetInputMode(INPUT_STATE state)
    {
        settingsPanel.Play("Close");

        input_state = state;

        switch (input_state)
        {
        case INPUT_STATE.TALK:
            talkPanel.gameObject.SetActive(true);
            assistant.chatResponse      = talkWatsonResponse;
            assistant.watsonMediaViewer = talkWatsonMedia;
            talkWatsonResponse.text     = assistant.chat_response;
            talkPanel.Play("Open");
            break;

        case INPUT_STATE.TYPE:
            typePanel.gameObject.SetActive(true);
            assistant.chatResponse      = typeWatsonResponse;
            assistant.watsonMediaViewer = typeWatsonMedia;
            typeWatsonResponse.text     = assistant.chat_response;
            typePanel.Play("Open");
            break;

        case INPUT_STATE.MULTIPLE_CHOICE:
            multipleChoicePanel.gameObject.SetActive(true);
            multipleChoicePanel.Play("Open");
            break;
        }
    }
Exemplo n.º 5
0
    /*
     * ドラッグ方向のチェック
     */
    void GetDirection()
    {
        float dX = tapEndPos.x - tapStartPos.x;
        float dY = tapEndPos.y - tapStartPos.y;

        //! 左右チェック
        if (Mathf.Abs(dY) < Mathf.Abs(dX))
        {
            float absdX = Mathf.Abs(dX);
            if (absdX > 15)
            {
                inputState = INPUT_STATE.DRAG;
                dragState  = (Mathf.Sign(dX) > 0) ? DRAG_STATE.RIGHT : DRAG_STATE.LEFT;
            }
        }

        //! 上下チェック
        else if (Mathf.Abs(dX) < Mathf.Abs(dY))
        {
            float absdY = Mathf.Abs(dY);
            if (absdY > 15)
            {
                inputState = INPUT_STATE.DRAG;
                dragState  = (Mathf.Sign(dY) > 0) ? DRAG_STATE.UP : DRAG_STATE.DOWN;
            }
        }

        //! そうで無い場合はホールド
        else
        {
            inputState = INPUT_STATE.HOLD;
        }
    }
        public IEnumerator rememberWait()
        {
            //暗記時間が終わったら入力ステートへ以降。
            yield return(new WaitForSeconds(rememberTime));

            nowState = INPUT_STATE.COMMAND_INPUT;
            CommandManager.Instance.commandTextSetInactive();
        }
Exemplo n.º 7
0
 /** Attack 1 - SWORD
 **/
 public void InputAttack1(bool down)
 {
     if (down)
     {
         input_attack1 = INPUT_STATE.DOWN;
     }
     else
     {
         input_attack1 = INPUT_STATE.RELEASED;
     }
 }
Exemplo n.º 8
0
    /*
     * 入力のチェック関数
     */
    void InputCheck()
    {
        //! ダウンしたのかそうでないのか
        if (Input.GetMouseButtonDown(0))
        {
            tapStartPos = new Vector3(Input.mousePosition.x,
                                      Input.mousePosition.y,
                                      Input.mousePosition.z);
            StockTapObject();
            inputState = INPUT_STATE.TAP;
            return;
        }

        else if (Input.GetMouseButton(0))
        {
            tapEndPos = new Vector3(Input.mousePosition.x,
                                    Input.mousePosition.y,
                                    Input.mousePosition.z);

            //! 方向チェック
            GetDirection();
            return;
        }



        //! リリースした際の処理
        if (Input.GetMouseButtonUp(0))
        {
            tapEndPos = new Vector3(Input.mousePosition.x,
                                    Input.mousePosition.y,
                                    Input.mousePosition.z);

            inputState  = INPUT_STATE.RELEASE;
            disableDrag = false;
            return;
        }

        //! 保持するゲームオブジェクトを破棄
        stockTapObject = null;
        inputState     = INPUT_STATE.NONE;
    }
Exemplo n.º 9
0
 private void MouseInputProcess()
 {
     Vector3 clickPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
     Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     Debug.DrawRay(ray.origin, ray.direction * 100, Color.magenta);
     switch (inputState)
     {
         case INPUT_STATE.CREATE:
             inputState = INPUT_STATE.NONE;
             if(UIPopupManager.isAllpopupClose == true)
                 modifyTerrian.AddBlockCursor(ray, blockSelector.curSelectBlockType);
             break;
         case INPUT_STATE.DELETE:
             inputState = INPUT_STATE.NONE;
             if (UIPopupManager.isAllpopupClose == true)
                 modifyTerrian.ReplaceBlockCursor(ray, 0);
             break;
         default:
             break;
     }
 }
Exemplo n.º 10
0
 private void KeyBoardInputProcess()
 {
     switch (inputState)
     {
         case INPUT_STATE.INVEN_OPEN:
             inputState = INPUT_STATE.NONE;
             UIPopupManager.OpenInven();
             break;
         case INPUT_STATE.MENU_OPEN:
             inputState = INPUT_STATE.NONE;
             UIPopupManager.OpenInGameMenu();
             break;
         case INPUT_STATE.CRAFT_ITEM_OPEN:
             inputState = INPUT_STATE.NONE;
             UIPopupManager.OpenCraftItem();
             break;
         default:
             break;
     }
 }
Exemplo n.º 11
0
    // OVERRIDE END

    private void HandleAttack()
    {
        COMBAT_STATE statePrev = state;

        switch (state)
        {
        case COMBAT_STATE.IDDLE:
            if (input_attack1 == INPUT_STATE.DOWN)
            {
                state         = COMBAT_STATE.BASIC_ATTACK1_CHARGING;
                input_attack1 = 0;
            }
            break;

        case COMBAT_STATE.BASIC_ATTACK1_CHARGING:
            animationTimer++;

            if (animationTimer >= state1_Charging)
            {
                state = COMBAT_STATE.BASIC_ATTACK1_CHARGED;
            }

            if (input_attack1 == INPUT_STATE.RELEASED)
            {
                if (state == COMBAT_STATE.BASIC_ATTACK1_CHARGED)
                {
                    state = COMBAT_STATE.BASIC_ATTACK1_STRONG;
                }
                else
                {
                    state = COMBAT_STATE.BASIC_ATTACK1_WEAK;
                }

                input_attack1 = 0;
            }
            break;

        case COMBAT_STATE.BASIC_ATTACK1_CHARGED:
            if (input_attack1 == INPUT_STATE.RELEASED)
            {
                state = COMBAT_STATE.BASIC_ATTACK1_STRONG;

                weaponRight.transform.localScale = new Vector3(4, 4, 1.2f);

                input_attack1 = 0;
            }
            break;

        case COMBAT_STATE.BASIC_ATTACK1_WEAK:
            animationTimer++;
            if (animationTimer >= animationTimerEnd)
            {
                state = COMBAT_STATE.IDDLE;
            }
            break;

        case COMBAT_STATE.BASIC_ATTACK1_STRONG:
            animationTimer++;
            if (animationTimer >= animationTimerEnd)
            {
                state = COMBAT_STATE.IDDLE;
                weaponRight.transform.localScale = new Vector3(1, 1, 1);
            }
            break;
        }

        if (statePrev != state)
        {
            // Init();
            animationTimer    = 0;
            animationTimerEnd = animationEnd[(int)state];
        }
    }
Exemplo n.º 12
0
    /// <summary>
    /// 检测双手拖动状态
    /// </summary>
    /// <returns>该事件是否发生过</returns>
    private bool testDoubleDrag()
    {
        //如果是非正常装填则跳出检测
        if (m_state != INPUT_STATE.NORMAL &&
            m_state != INPUT_STATE.DOUBLE_DARG &&
            m_state != INPUT_STATE.DRAG
            )
        {
            return(false);
        }


        if (Input.touchCount == 2)
        {
            m_state = INPUT_STATE.DOUBLE_DARG;
            //当前触摸点位置
            Vector2[] dp = new Vector2[2];
            dp[0] = Input.touches[0].position;
            dp[1] = Input.touches[1].position;
            Vector2 center   = Input.touches[1].position + ((Input.touches[0].position - Input.touches[1].position) * 0.5f);
            float   distance = Vector2.Distance(dp[0], dp[1]);

            if (!doubleDragTest)
            {
                //开始拖动
                //if(currentGameObject!=null)
                Messenger.Broadcast <GameObject, DragState, Vector2[], Vector2, float, float>(MySkyInputEvent.EventDoubleDrag, currentGameObject, DragState.Start, null, Vector2.zero, 0, 0);
                doubleDragTest = true;
            }
            //拖动过程中
            else
            {
                //检测上一次中心点的位置。
                //if(currentGameObject!=null)
                Messenger.Broadcast <GameObject, DragState, Vector2[], Vector2, float, float>(MySkyInputEvent.EventDoubleDrag, currentGameObject, DragState.OnDrag, dp, center - doubleDragOldCenter, distance - doubleDragDistance, Vector2.Angle(doubleDragPoint[0] - doubleDragPoint[1], Input.touches[0].position - Input.touches[1].position));
            }
            doubleDragPoint[0]  = Input.touches[0].position;
            doubleDragPoint[1]  = Input.touches[1].position;
            doubleDragOldCenter = center;
            doubleDragDistance  = distance;
            return(true);
        }
        //抬起事件
        else if (doubleDragTest)
        {
            //if(currentGameObject!=null)
            Messenger.Broadcast <GameObject, DragState, Vector2[], Vector2, float, float>(MySkyInputEvent.EventDoubleDrag, currentGameObject, DragState.End, null, Vector2.zero, 0, 0);
            doubleDragTest    = false;
            m_state           = INPUT_STATE.NORMAL;
            currentGameObject = null;
            return(true);
        }

        if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
        {
            if (Input.GetMouseButtonDown(1))
            {
                if (currentGameObject != null)
                {
                    Messenger.Broadcast <GameObject, DragState, Vector2[], Vector2, float, float>(MySkyInputEvent.EventDoubleDrag, currentGameObject, DragState.Start, null, Vector2.zero, 0, 0);
                }
            }
            else if (Input.GetMouseButton(1))
            {
                float     scale = Input.GetAxis("Mouse ScrollWheel");
                Vector2[] dp    = new Vector2[2];
                dp[0] = Input.mousePosition;
                dp[1] = Input.mousePosition;
                if (currentGameObject != null)
                {
                    Messenger.Broadcast <GameObject, DragState, Vector2[], Vector2, float, float>(MySkyInputEvent.EventDoubleDrag, currentGameObject, DragState.OnDrag, dp, Vector2.zero, scale, 0);
                }
            }
            else if (Input.GetMouseButtonUp(1))
            {
                if (currentGameObject != null)
                {
                    Messenger.Broadcast <GameObject, DragState, Vector2[], Vector2, float, float>(MySkyInputEvent.EventDoubleDrag, currentGameObject, DragState.End, null, Vector2.zero, 0, 0);
                }
            }
        }
        return(false);
    }
Exemplo n.º 13
0
    private void testDrag()
    {
        if (Input.touchCount == 1 && Input.touches[0].phase == TouchPhase.Began)
        {
            //检测是否选中按钮等信息判断
            if (m_isShieldUGUI && EventSystem.current != null && EventSystem.current.currentSelectedGameObject != null)
            {
                return;
            }

            m_isDrage    = false;
            m_fingerId   = Input.touches[0].fingerId;
            lastPoint    = Input.touches[0].position;
            lastObjPoint = m_camera.ScreenToWorldPoint(new Vector3(lastPoint.x, lastPoint.y, m_Mhit.distance));
        }
        else if (Input.touchCount >= 1 && m_fingerId == Input.touches[0].fingerId &&
                 (Input.touches[0].phase == TouchPhase.Moved ||
                  Input.touches[0].phase == TouchPhase.Stationary))
        {
            if (m_isShieldUGUI && EventSystem.current != null &&
                EventSystem.current.currentSelectedGameObject != null)
            {
                return;
            }

            Vector2 temp = Input.touches[0].position - lastPoint;

            //滑动被启动
            if (!m_isDrage && Vector2.Distance(Input.touches[0].position, lastPoint) > 5)
            {
                m_isDrage = true;
                //产生点击事件
                Messenger.Broadcast <GameObject, DragState, Vector2, Vector2, Vector3>
                    (MySkyInputEvent.EventDrag, currentGameObject, DragState.Start, Input.touches[0].position, Vector2.zero, Vector3.zero);
                m_state = INPUT_STATE.DRAG;
                return;
            }

            if (!m_isDrage)
            {
                return;
            }

            //分析3D位移
            Vector3 screenPos   = Vector3.one;
            Vector3 newObjPoint = m_camera.ScreenToWorldPoint(new Vector3(lastPoint.x, lastPoint.y, m_Mhit.distance));
            if (currentGameObject != null)
            {
                screenPos = currentGameObject.transform.position;
            }
            screenPos = screenPos + newObjPoint - lastObjPoint;

            Messenger.Broadcast <GameObject, DragState, Vector2, Vector2, Vector3>
                (MySkyInputEvent.EventDrag, currentGameObject, DragState.OnDrag,
                Input.touches[0].position, Input.touches[0].deltaPosition, screenPos);

            lastPoint    = Input.touches[0].position;
            lastObjPoint = newObjPoint;
            m_state      = INPUT_STATE.DRAG;
        }
        //当用户抬起时结束抬起事件。
        else if ((Input.touchCount >= 2 &&
                  m_fingerId == Input.touches[0].fingerId &&
                  Input.touches[0].phase == TouchPhase.Ended) ||
                 (Input.touchCount == 1 &&
                  Input.touches[0].phase == TouchPhase.Ended)
                 )
        {
            Messenger.Broadcast <GameObject, DragState, Vector2, Vector2, Vector3>
                (MySkyInputEvent.EventDrag, currentGameObject, DragState.End, Input.touches[0].position,
                Input.touches[0].deltaPosition, Vector3.zero);
            m_state = INPUT_STATE.NORMAL;
        }

        //鼠标模拟
        if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
        {
            if (m_isShieldUGUI && EventSystem.current != null && EventSystem.current.currentSelectedGameObject != null)
            {
                return;
            }
            Vector2 mousePosition = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            if (Input.GetMouseButtonDown(0))
            {
                //产生点击事件
                lastPoint    = Input.mousePosition;
                lastObjPoint = m_camera.ScreenToWorldPoint(new Vector3(lastPoint.x, lastPoint.y, m_Mhit.distance));
            }
            else if (Input.GetMouseButton(0))
            {
                Vector2 temp = mousePosition - lastPoint;

                //滑动被启动
                if (!m_isDrage && Vector2.Distance(mousePosition, lastPoint) > 5)
                {
                    m_isDrage = true;
                    //产生点击事件
                    Messenger.Broadcast <GameObject, DragState, Vector2, Vector2, Vector3>
                        (MySkyInputEvent.EventDrag, currentGameObject, DragState.Start,
                        Input.mousePosition, Vector2.zero, Vector3.zero);
                    m_state = INPUT_STATE.DRAG;
                    return;
                }
                if (!m_isDrage)
                {
                    return;
                }

                Vector3 screenPos   = Vector3.one;
                Vector3 newObjPoint = m_camera.ScreenToWorldPoint(new Vector3(lastPoint.x, lastPoint.y, m_Mhit.distance));
                if (currentGameObject != null)
                {
                    screenPos = currentGameObject.transform.position;
                }
                screenPos = screenPos + newObjPoint - lastObjPoint;

                Messenger.Broadcast <GameObject, DragState, Vector2, Vector2, Vector3>
                    (MySkyInputEvent.EventDrag, currentGameObject, DragState.OnDrag, mousePosition, temp, screenPos);

                lastPoint    = Input.mousePosition;
                lastObjPoint = newObjPoint;
            }
            //当用户抬起时结束抬起事件。
            else if (Input.GetMouseButtonUp(0))
            {
                Vector2 temp = mousePosition - lastPoint;
                Messenger.Broadcast <GameObject, DragState, Vector2, Vector2, Vector3>
                    (MySkyInputEvent.EventDrag, currentGameObject, DragState.End,
                    mousePosition, temp, Vector3.zero);
                m_isDrage = false;
            }
        }
    }
Exemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     inputState = INPUT_STATE.NONE;
 }