示例#1
0
        private bool CheckDiving(PlayerEntity player)
        {
            var             state          = player.stateInterface.State;
            PostureInConfig currentPosture = state.GetCurrentPostureState();
            var             ret            = PostureInConfig.Dive == currentPosture;

            var vehicle = PlayerVehicleUtility.GetVehicle(player, _vehicleContext);

            if (null != vehicle)
            {
                ret = ret || vehicle.IsPassagerInWater();
            }
            return(ret);
        }
        public int GetPostureTransitionTime(PostureInConfig stateOne, PostureInConfig stateTwo)
        {
            int id = CharacterStateConfigHelper.GenerateId(stateOne, stateTwo);

            if (_postureTransitionTime.ContainsKey(id))
            {
                return(_postureTransitionTime[id]);
            }
            else
            {
                Logger.WarnFormat("duration not defined for {0} to {1}", stateOne, stateTwo);
                return(DefaultTransitionTime);
            }
        }
示例#3
0
        public float GetSpeed(PostureInConfig posture, MovementInConfig movement, bool isFront, bool isBack, bool isLeft, bool isRight, float standardSpeed)
        {
            float ret = 0;

            int id = CharacterStateConfigHelper.GenerateId(posture, movement);

            if (_coefficients.ContainsKey(id))
            {
                var v = isFront ? Vertical.Front : isBack ? Vertical.Back : Vertical.Neutral;
                var h = isLeft ? Horizontal.Left : isRight ? Horizontal.Right : Horizontal.Neutral;
                ret = _coefficients[id].CoefficientByDirection[(int)v, (int)h] * standardSpeed;
            }

            return(ret);
        }
        public static PostureInConfig ConvertToPostureInConfig(ThirdPersonPosture pos)
        {
            PostureInConfig ret = PostureInConfig.Null;

            switch (pos)
            {
            case ThirdPersonPosture.Stand:
                ret = PostureInConfig.Stand;
                break;

            case ThirdPersonPosture.Crouch:
                ret = PostureInConfig.Crouch;
                break;

            case ThirdPersonPosture.Prone:
                ret = PostureInConfig.Prone;
                break;

            case ThirdPersonPosture.ProneTransit:
                ret = PostureInConfig.ProneTransit;
                break;

            case ThirdPersonPosture.ProneToStand:
                ret = PostureInConfig.ProneToStand;
                break;

            case ThirdPersonPosture.ProneToCrouch:
                ret = PostureInConfig.ProneToCrouch;
                break;

            case ThirdPersonPosture.Swim:
                ret = PostureInConfig.Swim;
                break;

            case ThirdPersonPosture.Dive:
                ret = PostureInConfig.Dive;
                break;

            case ThirdPersonPosture.Dying:
                ret = PostureInConfig.Dying;
                break;

            default:
                break;
            }

            return(ret);
        }
示例#5
0
        private EPlayerState PostureToState(PostureInConfig posture)
        {
            switch (posture)
            {
            case PostureInConfig.Crouch:
                return(EPlayerState.Crouch);

            case PostureInConfig.Dying:
            case PostureInConfig.DyingTransition:
                return(EPlayerState.Dying);

                break;

            case PostureInConfig.Climb:
                return(EPlayerState.Climb);

            case PostureInConfig.Dive:
                return(EPlayerState.Swim);

            case PostureInConfig.Jump:
                return(EPlayerState.Jump);

            case PostureInConfig.Prone:
                return(EPlayerState.Prone);

            case PostureInConfig.Sight:
                return(EPlayerState.Sight);

            case PostureInConfig.Stand:
            case PostureInConfig.Land:
                return(EPlayerState.Stand);

            case PostureInConfig.Swim:
                return(EPlayerState.Swim);

            case PostureInConfig.ProneToCrouch:
            case PostureInConfig.ProneToStand:
            case PostureInConfig.ProneTransit:
                return(EPlayerState.PostureTrans);

            default:
                return(EPlayerState.None);
            }
        }
 private Func <CharacterControllerCapsule> GetFunc(PostureInConfig config)
 {
     if (config == PostureInConfig.Stand)
     {
         return(() => _characterInfo.GetStandCapsule());
     }
     else if (config == PostureInConfig.Crouch)
     {
         return(() => _characterInfo.GetCrouchCapsule());
     }
     else if (config == PostureInConfig.Prone)
     {
         return(() => _characterInfo.GetProneCapsule());
     }
     else
     {
         return(() => _characterInfo.GetStandCapsule());
     }
 }
示例#7
0
 public void SetCurrentControllerType(PostureInConfig type)
 {
     if (type == PostureInConfig.Prone)
     {
         SetCurrentControllerType(CharacterControllerType.ProneKinematicCharacterController);
     }
     else if (type == PostureInConfig.Dive)
     {
         SetCurrentControllerType(CharacterControllerType.DiveKinematicCharacterController);
     }
     else if (type == PostureInConfig.Swim)
     {
         SetCurrentControllerType(CharacterControllerType.SwimKinematicCharacterController);
     }
     else
     {
         SetCurrentControllerType(CharacterControllerType.UnityCharacterController);
     }
 }
示例#8
0
        internal static PostureInConfig GetPostureStateId(PostureStateId stateId)
        {
            PostureInConfig ret = PostureInConfig.Null;

            switch (stateId)
            {
            case PostureStateId.Stand:
                ret = PostureInConfig.Stand;
                break;

            case PostureStateId.Crouch:
                ret = PostureInConfig.Crouch;
                break;

            case PostureStateId.Prone:
                ret = PostureInConfig.Prone;
                break;

            case PostureStateId.Dying:
                ret = PostureInConfig.Dying;
                break;

            case PostureStateId.Dive:
                ret = PostureInConfig.Dive;
                break;

            // go through
            case PostureStateId.JumpStart:
            case PostureStateId.Freefall:
                ret = PostureInConfig.Jump;
                break;

            case PostureStateId.JumpEnd:
                ret = PostureInConfig.Land;
                break;

            case PostureStateId.Swim:
                ret = PostureInConfig.Swim;
                break;

            case PostureStateId.ProneTransit:
                ret = PostureInConfig.ProneTransit;
                break;

            case PostureStateId.ProneToCrouch:
                ret = PostureInConfig.ProneToCrouch;
                break;

            case PostureStateId.ProneToStand:
                ret = PostureInConfig.ProneToStand;
                break;

            case PostureStateId.Climb:
                ret = PostureInConfig.Climb;
                break;

            default:
                ret = PostureInConfig.Null;
                Logger.ErrorFormat("can not convert PostureStateId type:{0} to PostureInConfig type", stateId);
                break;
            }

            return(ret);
        }
示例#9
0
 private void SetCurrentState(PostureInConfig posture, MovementInConfig movement)
 {
     _currentPosture  = posture;
     _currentMovement = movement;
 }
示例#10
0
        private bool WaterTest(PlayerEntity player)
        {
            var             state               = player.stateInterface.State;
            PostureInConfig postureInConfig     = state.GetCurrentPostureState();
            PostureInConfig nextPostureInConfig = state.GetNextPostureState();

            if (SingletonManager.Get <MapConfigManager>().InWater(player.position.Value))
            {
                var waterSurfaceHeight = SingletonManager.Get <MapConfigManager>().WaterSurfaceHeight(player.position.Value);
                var inWaterDepth       = waterSurfaceHeight - player.position.Value.y;
                //_logger.InfoFormat("inWaterDepth:{0}", inWaterDepth);
                float dist = 0f;
                switch (postureInConfig)
                {
                case PostureInConfig.Swim:
                {
                    if (nextPostureInConfig != PostureInConfig.Stand && (inWaterDepth < (AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset - HeightStandSwimOffset) || GroundTest(player, out dist)))
                    {
                        Ashore(player, AshoreDepth);
                        //_logger.InfoFormat("in water, swim to stand, inWaterDepth:{0}, thread:{1}", inWaterDepth, AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset);
                    }
                    break;
                }

                case PostureInConfig.Dive:
                {
                    var groundTest = GroundTest(player, out dist);
                    if (inWaterDepth < (AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset) && !groundTest && nextPostureInConfig != PostureInConfig.Stand && nextPostureInConfig != PostureInConfig.Swim)
                    {
                        Swim(player);
                        //_logger.InfoFormat("Dive to swim, inWaterDepth:{0}, thread:{1}, new In water depth:{2}", inWaterDepth, AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset, SingletonManager.Get<MapConfigManager>().WaterSurfaceHeight(player.position.Value) - player.position.Value.y);
                    }
                    else if ((inWaterDepth < (AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset
                                              - HeightStandSwimOffset) || groundTest) && nextPostureInConfig != PostureInConfig.Stand)
                    {
                        //Ashore(player, CompareUtility.IsApproximatelyEqual(0f, dist) ? 0 : waterSurfaceHeight - dist);
                        Ashore(player, groundTest ? inWaterDepth - dist:AshoreDepth);
                        //_logger.InfoFormat("in Dive, Dive to stand, inWaterDepth:{0}, thread:{1}", inWaterDepth, AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset);
                    }
                    break;
                }

                case PostureInConfig.Jump:
                {
                    // 在水里从载具中跳出,或者高处跳水
                    if ((inWaterDepth > AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset) && nextPostureInConfig != PostureInConfig.Dive)
                    {
                        Dive(player);
                    }
                    break;
                }

                case PostureInConfig.Stand:
                {
                    if (inWaterDepth > (AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset) && nextPostureInConfig != PostureInConfig.Swim)
                    {
                        Swim(player);
                        //_logger.InfoFormat("stand to swim, inWaterDepth:{0}, thread:{1}, new In water depth:{2}", inWaterDepth, AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset, SingletonManager.Get<MapConfigManager>().WaterSurfaceHeight(player.position.Value) - player.position.Value.y);
                    }
                    break;
                }

                case PostureInConfig.Crouch:
                {
                    if (inWaterDepth > AnimatorParametersHash.FirstPersonCrouchCameraHeight && nextPostureInConfig != PostureInConfig.Stand)
                    {
                        state.Stand();
                    }
                    break;
                }

                case PostureInConfig.Prone:
                {
                    if (inWaterDepth > AnimatorParametersHash.FirstPersonProneCameraHeight && nextPostureInConfig != PostureInConfig.Crouch)
                    {
                        state.Crouch();
                    }
                    break;
                }
                }
            }
            else
            {
                if (postureInConfig == PostureInConfig.Swim || postureInConfig == PostureInConfig.Dive)
                {
                    Ashore(player, SwimPositionUnderWater);
                    //_logger.InfoFormat("out of  water, swim to stand, postureInConfig:{0}", postureInConfig);
                }
            }

            return(true);
        }
        public static AudioGrp_Footstep GetFootStepState(this PlayerEntity player)
        {
            PostureInConfig curPosture = player.stateInterface.State.GetCurrentPostureState();

            return(AudioUtil.ToAudioFootGrp(curPosture));
        }
        private bool WaterTest(PlayerEntity player)
        {
            var             state               = player.stateInterface.State;
            PostureInConfig postureInConfig     = state.GetCurrentPostureState();
            PostureInConfig nextPostureInConfig = state.GetNextPostureState();

            if (SingletonManager.Get <MapConfigManager>().InWater(player.position.Value))
            {
                var inWaterDepth = SingletonManager.Get <MapConfigManager>().WaterSurfaceHeight(player.position.Value) - player.position.Value.y;
                switch (postureInConfig)
                {
                case PostureInConfig.Swim:
                {
                    if (inWaterDepth < (AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset - HeightStandSwimOffset))
                    {
                        Ashore(player, AshoreDepth);
                        //_logger.InfoFormat("in water, swim to stand, inWaterDepth:{0}, thread:{1}, prevPos:{2}, " +
                        //                  "seq:{3}", inWaterDepth, AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset, prevPos.ToStringExt(), cmd.Seq);
                    }
                    break;
                }

                case PostureInConfig.Dive:
                {
                    if (inWaterDepth < (AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset) && GroundTest(player))
                    {
                        Ashore(player, AshoreDepth);
                        //_logger.InfoFormat("in Dive, Dive to stand, inWaterDepth:{0}, thread:{1}, prevPos:{2}, seq:{3}", inWaterDepth, AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset, prevPos.ToStringExt(), cmd.Seq);
                    }
                    else if (inWaterDepth < (AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset) && nextPostureInConfig != PostureInConfig.Swim)
                    {
                        Swim(player);
                        //_logger.InfoFormat("Dive to swim, inWaterDepth:{0}, thread:{1}, new In water depth:{2}, seq:{3}", inWaterDepth, AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset, SingletonManager.Get<MapConfigManager>().WaterSurfaceHeight(player.position.Value) - player.position.Value.y, cmd.Seq);
                    }
                    break;
                }

                case PostureInConfig.Jump:
                {
                    // 在水里从载具中跳出,或者高处跳水
                    if ((inWaterDepth > AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset) && nextPostureInConfig != PostureInConfig.Dive)
                    {
                        Dive(player);
                    }
                    break;
                }

                case PostureInConfig.Stand:
                {
                    if (inWaterDepth > (AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset - HeightStandSwimOffset) && nextPostureInConfig != PostureInConfig.Swim)
                    {
                        Swim(player);
                        //_logger.InfoFormat("stand to swim, inWaterDepth:{0}, thread:{1}, new In water depth:{2}, prevPos:{3}, seq:{4}", inWaterDepth, AnimatorParametersHash.FirstPersonStandCameraHeight + HeightOffset, SingletonManager.Get<MapConfigManager>().WaterSurfaceHeight(player.position.Value) - player.position.Value.y, prevPos.ToStringExt(), cmd.Seq);
                    }
                    break;
                }

                case PostureInConfig.Crouch:
                {
                    if (inWaterDepth > AnimatorParametersHash.FirstPersonCrouchCameraHeight && nextPostureInConfig != PostureInConfig.Stand)
                    {
                        state.Stand();
                    }
                    break;
                }

                case PostureInConfig.Prone:
                {
                    if (inWaterDepth > AnimatorParametersHash.FirstPersonProneCameraHeight && nextPostureInConfig != PostureInConfig.Crouch)
                    {
                        state.Crouch();
                    }
                    break;
                }
                }
            }
            else
            {
                if (postureInConfig == PostureInConfig.Swim || postureInConfig == PostureInConfig.Dive)
                {
                    Ashore(player, SwimPositionUnderWater);
                    //_logger.InfoFormat("out of  water, swim to stand, postureInConfig:{0}, seq:{1}", postureInConfig, cmd.Seq);
                }
            }

            return(true);
        }
示例#13
0
 public static int GenerateId(PostureInConfig enumOne, PostureInConfig enumTwo)
 {
     return(((int)enumOne << 16) + (int)enumTwo);
 }
示例#14
0
 public static bool FilterPlayerIK(ActionInConfig action, ActionKeepInConfig keepAction, PostureInConfig posture,
                                   PostureInConfig nextPosture, MovementInConfig movement)
 {
     return(!(IsStateInActionFilter(action) ||
              IsStateInKeepActionFilter(keepAction) ||
              IsStateInPostureFilter(posture) ||
              IsStateInPostureFilter(nextPosture) ||
              IsStateInMovementFilter(movement)));
 }
示例#15
0
 public static bool FilterPlayerIK(ActionInConfig action, ActionKeepInConfig keepAction, PostureInConfig posture)
 {
     return(!(IsStateInActionFilter(action) ||
              IsStateInKeepActionFilter(keepAction) ||
              IsStateInPostureFilter(posture)));
 }