コード例 #1
0
        private void CheckUIKeyMessage()
        {
            if (FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(FuntionShortCutSlotIndex.Exit) && StageManager.Instance.getCurrentState() != Stage_ManagerDef.EStage_State.ESS_LOADSCENE)
            {
                OnKeyMessage(FuntionShortCutSlotIndex.Exit, KeyStatus.Down);
            }

            for (int i = 1; i < (int)KeyStatus.Max; i++)
            {
                foreach (FuntionShortCutSlotIndex index in m_keyMessageList[i].Keys)
                {
                    if (i == (int)KeyStatus.Down)
                    {
                        if (FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(index))
                        {
                            OnKeyMessage(index, KeyStatus.Down);
                        }
                    }
                    else if (i == (int)KeyStatus.Up)
                    {
                        if (FuntionShortCutCtrl.CheckFunctionShortcutKeyUp(index))
                        {
                            OnKeyMessage(index, KeyStatus.Up);
                        }
                    }
                    else if (i == (int)KeyStatus.Pressing)
                    {
                        if (FuntionShortCutCtrl.CheckFunctionShortcutKeyPressing(index))
                        {
                            OnKeyMessage(index, KeyStatus.Pressing);
                        }
                    }
                }
            }
        }
コード例 #2
0
    public bool skillautoForward = false; //技能导致的自动前进

    void GetUserInputs()
    {
        inputDir = new Vector3(InputManager.GetAxis(InputAxisSet.Axis_Horizontal), 0, InputManager.GetAxis(InputAxisSet.Axis_Vertical));
        inputDir.Normalize();

        if (m_resetAxis)
        {
            moveDir  = Vector3.zero;
            isMoving = false;
            return;
        }

        if (FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(FuntionShortCutSlotIndex.AutoForward))
        {
            if (autoForward)
            {
                autoForward = false;
            }
            else if (inputDir.sqrMagnitude < 0.0001f)
            {
                autoForward = true;
            }
        }

        if (inputDir.sqrMagnitude > 0.0001f)
        {
            if (autoForward)
            {
                autoForward = false;
            }
        }

        if (autoForward || skillautoForward)
        {
            moveDir = Vector3.forward;
        }
        else
        {
            moveDir = inputDir;
        }
        //Check if the user wants the soldier to walk
        isMoving = moveDir.sqrMagnitude > 0;


        /*这里导致移动按鼠标攻击时角色不能转动,取消的话,按鼠标左键光标不会隐藏
         * //按鼠标左键,相机绕角色旋转
         * if (InputManager.InputManager_GetMouseButton(0) && !dead )
         * {
         *  fire = true;
         *  //移动时间没按左键则,取消fire状态
         *  if (!IsInvoking("ClearFireStateTimer"))
         *      Invoke("ClearFireStateTimer", ClearFireStateTime);
         *  else
         *  {
         *      CancelInvoke("ClearFireStateTimer");
         *      Invoke("ClearFireStateTimer", ClearFireStateTime);
         *  }
         * }
         */
    }
コード例 #3
0
ファイル: GuideStructure_Con.cs プロジェクト: zwong91/Titan
        protected override bool CustomPrecondition(TBTWorkingData wData)
        {
            bool result = false;

            if (m_eShortCutIndex == FuntionShortCutSlotIndex.None)
            {
                for (int i = 0; i < m_eCheckKeyCode.Length; ++i)
                {
                    if (m_bInputMgrEnableAffected)
                    {
                        result = InputManager.GetKeyDown(m_eCheckKeyCode[i]);
                    }
                    else
                    {
                        result = InputManager.Raw_GetKeyDown(m_eCheckKeyCode[i]);
                    }

                    if (result)
                    {
                        break;
                    }
                }
            }
            else
            {
                result = FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(m_eShortCutIndex);
            }

            return(result);
        }
コード例 #4
0
ファイル: EntityFactory.cs プロジェクト: zwong91/Titan
 public void Update()
 {
     //F11,打开调试信息
     if (FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(FuntionShortCutSlotIndex.EntityViewDebugOpen))
     {
         bOpenDebugInfo = !bOpenDebugInfo;
     }
 }
コード例 #5
0
ファイル: WarHeroTalentView.cs プロジェクト: zwong91/Titan
 // 检查学习天赋快捷键是否按下
 private void CheckFastLearnShortcut()
 {
     for (int slotID = 0; slotID < 6; slotID++)
     {
         if (FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(FuntionShortCutSlotIndex.Ctrl_1 + slotID))
         {
             int nIndex = slotID;
             OnHeroTalentItemClick(nIndex, null);
         }
     }
 }
コード例 #6
0
 /// <summary>
 /// 检测是否有通过快捷键升级技能
 /// </summary>
 private void CheckSpellUpdateByShortcut()
 {
     //没技能点就不检测
     if (currentSpellUpgradePoint <= 0)
     {
         return;
     }
     for (int slotID = 0; slotID < 3; slotID++)
     {
         if (FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(FuntionShortCutSlotIndex.Com_UpgradeSpellSlot0 + slotID))
         {
             onSkillUpgradeButtonClick(slotID);
         }
     }
 }
コード例 #7
0
ファイル: MouseCtrl.cs プロジェクト: zwong91/Titan
    void CheckAttachFunc()
    {
        if (m_multiAttachFunc)
        {
            if ((isAttackSign(m_currentAttachType) && FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(FuntionShortCutSlotIndex.AttackSign)) ||
                (m_currentAttachType == MouseAttachFuncType.RetreatSign && (FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(FuntionShortCutSlotIndex.DangerSign))))
            {
                SetAttachType(MouseAttachFuncType.None);
            }
        }

        if (InputManager.GetKeyUp(KeyCode.LeftAlt) || InputManager.GetKeyUp(KeyCode.LeftControl))
        {
            SetAttachType(MouseAttachFuncType.None);
        }

        if (InputManager.GetMouseButtonDown(1)) //右键取消
        {
            SetAttachType(MouseAttachFuncType.None);
        }

        if (FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(FuntionShortCutSlotIndex.AttackSign) || InputManager.GetKeyDown(KeyCode.LeftControl))
        {
            SetAttachType(MouseAttachFuncType.CtrlAttackSign);
        }

        if (FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(FuntionShortCutSlotIndex.AttackSign) || InputManager.GetKeyDown(KeyCode.LeftAlt))
        {
            SetAttachType(MouseAttachFuncType.AltAttackSign);
        }

        if (FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(FuntionShortCutSlotIndex.DangerSign))
        {
            SetAttachType(MouseAttachFuncType.DangerSign);
        }
    }
コード例 #8
0
        //处理用户输入
        protected void GetInputNormally(Vector2 angleClamp)
        {
            if (mouseCtrl == null)
            {
                return;
            }

            float fMouseScrollValue = 0.0f;

            if (InputManager.IsMouseInScreen())
            {
                fMouseScrollValue = InputManager.GetAxis(InputAxisSet.Axis_MouseScrollWheel);
            }

            if (Mathf.Abs(fMouseScrollValue) > 0.01f)
            {
                if ((Application.isEditor) && (InputManager.GetKey(KeyCode.LeftControl) || InputManager.GetKey(KeyCode.RightControl)))
                {
                    //m_userDesireFov = CurCameraProperty.NormalFOV;
                    m_userDesireFov = m_userDesireFov - fMouseScrollValue * CurCameraProperty.ScrollSpeed;
                    m_userDesireFov = Mathf.Clamp(m_userDesireFov, 10.0f, 120.0f);
                }
                else if (canUserControlCamera())
                {
                    // normalDistance -= InputManager.GetAxis("Mouse ScrollWheel") * Time.deltaTime * CurCameraProperty.ScrollSpeed;//normalDistance -= InputManager.GetAxis("Mouse ScrollWheel") * Time.deltaTime * scrollSpeed;
                    m_userDesireDistance = Mathf.Lerp(m_userDesireDistance, m_userDesireDistance - fMouseScrollValue * CurCameraProperty.ScrollSpeed, Time.deltaTime);
                    m_userDesireDistance = Mathf.Clamp(m_userDesireDistance, curCameraModeParam.distanceRange.x, curCameraModeParam.distanceRange.y);//normalDistance = Mathf.Clamp(normalDistance, minDistance, maxDistance);
                }

                soldierCam.NavPauseTime = Time.time;//如果用户操作了暂停自动导航一会
            }

            //m_userDesireDir = new Vector3(CurCameraProperty.NormalDirection.z, CurCameraProperty.NormalDirection.y, CurCameraProperty.NormalDirection.x);

            //m_userDesireTran = new Vector3(0, CurCameraProperty.NormalHeight, 0);

            if (!soldier.gameObject)
            {
                Trace.Warning("SoliderCamera.soldier.gameObject is null!");
                return;
            }

            float dis = (m_userDesirePos - soldier.gameObject.transform.position).magnitude;

            if (dis > 10.0f || curCameraMode == CameraMode.FPSMode)
            {
                m_userDesirePos = soldier.gameObject.transform.position;
            }
            else
            {
                //帧率波动距离时,摄像机会抖动,特别是左右移动时此现象明显
                //这里对摄像机位移利用逼近方案平滑,解决抖动
                //位移逼近方案
                Vector3 apprMoveX   = CameraUtil.approximateVec(m_userDesirePos, soldier.gameObject.transform.position, soldierCam.smoothFactor.x) - m_userDesirePos;
                Vector3 apprMoveY   = CameraUtil.approximateVec(m_userDesirePos, soldier.gameObject.transform.position, soldierCam.smoothFactor.y) - m_userDesirePos;
                Vector3 apprMoveZ   = CameraUtil.approximateVec(m_userDesirePos, soldier.gameObject.transform.position, soldierCam.smoothFactor.z) - m_userDesirePos;
                float   moveRight   = Vector3.Dot(apprMoveX, camTransform.right);
                float   moveForward = Vector3.Dot(apprMoveZ, camTransform.forward);
                float   moveUp      = Vector3.Dot(apprMoveY, camTransform.up);

                //以下代码帧率突变进行统计,为平滑参数提供参考
                if (adaptSmooth)
                {
                    //用标准差的方式算帧率突变的程度
                    //每m_deviationN帧算一组,该组的平均值作为下一组的平均值使用
                    //累计m_deviationN后平滑因子按(0.75f - Mathf.Sqrt(deviation)*2.0f)计算,并且和上一个平滑因子37开叠加,避免平滑因子突变
                    float deltaTime = Time.deltaTime;
                    if (m_avgDetaTime < 0.01f)
                    {
                        m_avgDetaTime = deltaTime;
                    }

                    m_accDetaTime += deltaTime;
                    float k = deltaTime - m_avgDetaTime;
                    k = k * k;
                    m_accDeviation += k;

                    m_deviationCount++;
                    if (m_deviationCount >= m_deviationN)
                    {
                        m_avgDetaTime = m_accDetaTime / m_deviationN;
                        float deviation = Mathf.Sqrt(m_accDeviation / m_deviationN);
                        soldierCam.smoothFactor.x = soldierCam.smoothFactor.x * 0.3f + (0.75f - Mathf.Sqrt(deviation) * 2.0f) * 0.7f;
                        if (soldierCam.smoothFactor.x < 0.2f)
                        {
                            soldierCam.smoothFactor.x = 0.2f;
                        }
                        m_accDetaTime    = 0.0f;
                        m_accDeviation   = 0.0f;
                        m_deviationCount = 0;
                    }
                }


                /*
                 * //速度逼近方案
                 * Vector3 moveVec = soldier.position - m_userDesirePos;
                 * float moveRight = Vector3.Dot(moveVec, camTransform.right);
                 * float moveForward = Vector3.Dot(moveVec, camTransform.forward);
                 * float moveUp = Vector3.Dot(moveVec, camTransform.up);
                 * float speedRight = moveRight - m_lastMoveRight;
                 * float apprSpeedRight = approximateFloat(m_lastSpeedRight, speedRight, smoothFactor.x);
                 * if (Mathf.Abs(speedRight) > Mathf.Abs(apprSpeedRight))
                 * {
                 *  speedRight = apprSpeedRight;
                 * }
                 * if (Mathf.Abs(moveRight) > Mathf.Abs(m_lastMoveRight + speedRight))
                 * {
                 *  moveRight = m_lastMoveRight + speedRight;
                 * }
                 * m_lastMoveRight = moveRight;
                 * m_lastSpeedRight = speedRight;
                 */
                Vector3 offset = moveForward * camTransform.forward + moveUp * camTransform.up + moveRight * camTransform.right;
                m_userDesirePos += offset;
            }
            //m_userDesirePos = soldier.position;

            if ((mouseCtrl.cameraRotateButton || canMouseRotateCamera()) && canCameraRotate() && !UISystem.Instance.IsMouseOverUI())
            {
                float _x = mouseCtrl.fMouseAxisX;
                float _y = mouseCtrl.fMouseAxisY;


                if (k1 < 1.0f)
                {
                    k1 = 1.0f;
                }

                //Vector2 a = soldierController.aim ? aimSpeed : speed;
                Vector2 a = CurCameraProperty.Speed * CurCameraProperty.SpeedScale; //speed;
                dx = Mathf.Clamp(_x * a.x, -999999999.0f, 99999999.0f);
                dy = Mathf.Clamp(_y * a.y, -999999999.0f, 99999999.0f);

                n = k1 * Mathf.Pow(Mathf.Sqrt(_x * _x + _y * _y) / (k3 * deltaTime), k2);

                n  = Mathf.Clamp(n, minn, maxn);
                rx = dx * n;
                ry = dy * n;

                if (Mathf.Abs(rx) > 0.1f || Mathf.Abs(ry) > 0.1f)
                {
                    soldierCam.exitNavMode(CameraNavMode.Target);        //其他操作中断镜头追踪攻击对象
                    soldierCam.exitNavMode(CameraNavMode.FloatingAngle); //其他操作中断自动转镜头
                }

                soldierCam.SetUserDesireAngleY(m_userDesireAngle.y + rx);                                     //x += Mathf.Clamp(_x * a.x, -maxSpeed.x, maxSpeed.x) * deltaTime;
                soldierCam.SetUserDesireAngleX(m_userDesireAngle.x - ry);                                     //y -= Mathf.Clamp(_y * a.y, -maxSpeed.y, maxSpeed.y) * deltaTime;
                //这里限制仰俯角,不能去掉
                soldierCam.SetUserDesireAngleX(Mathf.Clamp(m_userDesireAngle.x, angleClamp.x, angleClamp.y)); //y = ClampAngle(y, yMinLimit, yMaxLimit);
                soldierCam.SetUserDesireAngleY(m_userDesireAngle.y - Mathf.Floor(m_userDesireAngle.y / 360.0f) * 360.0f);
            }

            if (FuntionShortCutCtrl.CheckFunctionShortcutKeyDown(FuntionShortCutSlotIndex.MoveCameraPositionToFront))
            {
                if (soldier != null)
                {
                    if (soldier.gameObject)
                    {
                        bool reached = false;

                        soldierCam.SetUserDesireAngleY(CameraUtil.approximateAngleFloat(soldierCam, m_userDesireAngle.y, soldier.gameObject.transform.eulerAngles.y, 0.5f, ref reached));
                    }
                }
                soldierCam.exitNavMode(CameraNavMode.Target);        //其他操作中断自动旋转
                soldierCam.exitNavMode(CameraNavMode.FloatingAngle); //其他操作中断自动旋转
            }
        }