コード例 #1
0
    /// <summary>
    /// 按键检测(功能键)
    /// </summary>
    /// <param name="keyType"></param>
    /// <param name="rockValue"></param>
    private void Instance_KeyUpHandle(UIManager.KeyType keyType, Vector2 rockValue)
    {
        if (!fisrtKeyUP)
        {
            fisrtKeyUP = true;
            return;
        }
        switch (bigMapOperateState)
        {
        case EnumBigMapOperateState.OperateMap:    //操作地图
            switch (keyType)
            {
            case UIManager.KeyType.A:
                Vector2 handlePos = uiMapControl.GetHandlePosInTerrain();
                ActionAtTerrain(handlePos);
                break;

            case UIManager.KeyType.Y:
                bigMapOperateState = EnumBigMapOperateState.CheckSetting;
                showSettingPanel.gameObject.SetActive(true);
                if (uiFocusPath)
                {
                    nowUIFocus = uiFocusPath.GetFirstFocus();
                }
                if (nowUIFocus)
                {
                    nowUIFocus.SetForcus();
                }
                break;
            }
            break;

        case EnumBigMapOperateState.CheckSetting:    //操作设置
            if (!nowUIFocus)
            {
                if (uiFocusPath)
                {
                    nowUIFocus = uiFocusPath.GetFirstFocus();
                }
            }
            if (nowUIFocus)
            {
                Action <UIFocusPath.MoveType> MoveUIFocusAction = (moveType) =>
                {
                    UIFocus nextUIFocus = uiFocusPath.GetNewNextFocus(nowUIFocus, moveType);    //uiFocusPath.GetNextFocus(nowUIFocus, moveType);
                    if (nextUIFocus != null)
                    {
                        nowUIFocus.LostForcus();
                        nowUIFocus = nextUIFocus;
                        nowUIFocus.SetForcus();
                    }
                };
                switch (keyType)
                {
                case UIManager.KeyType.A:
                    if (nowUIFocus.GetType().Equals(typeof(UIFocusButton)))
                    {
                        ((UIFocusButton)nowUIFocus).ClickThisButton();
                    }
                    else if (nowUIFocus.GetType().Equals(typeof(UIFocusToggle)))
                    {
                        ((UIFocusToggle)nowUIFocus).MoveChild(UIFocusPath.MoveType.OK);
                    }
                    break;

                case UIManager.KeyType.B:
                    ExitSetting_Click();
                    break;

                case UIManager.KeyType.LEFT:
                    MoveUIFocusAction(UIFocusPath.MoveType.LEFT);
                    break;

                case UIManager.KeyType.RIGHT:
                    MoveUIFocusAction(UIFocusPath.MoveType.RIGHT);
                    break;

                case UIManager.KeyType.UP:
                case UIManager.KeyType.DOWN:
                    if (string.Equals(nowUIFocus.Tag, "SceneDropDown"))
                    {
                        UIFocusDropdown uiFocusDropDown = nowUIFocus as UIFocusDropdown;
                        if (uiFocusDropDown != null)
                        {
                            uiFocusDropDown.MoveChild(keyType == UIManager.KeyType.UP ? UIFocusPath.MoveType.UP : UIFocusPath.MoveType.DOWN);
                        }
                    }
                    break;
                }
            }
            break;
        }
    }