예제 #1
0
 public float GetJumpSpeed()
 {
     return(_currentInfo.GetJumpSpeed());
 }
예제 #2
0
        public Vector3 GetSpeed(Vector3 lastVel, float deltaTime, float buff)
        {
            var vel = lastVel;

            vel.y = 0;
            var lastSpeed = vel.magnitude;

            if (_posture.GetNextPostureState() == PostureInConfig.Jump)
            {
                SetDefaultSpeeedRatio(buff);
                CalcMoveSpeedReduce(deltaTime, true);
            }
            else if (_posture.GetNextPostureState() == PostureInConfig.Slide)
            {
                SetDefaultSpeeedRatio(buff);
                CalcMoveSpeedReduce(deltaTime, false);
            }
            else
            {
                CalcMoveSpeedReduce(deltaTime, false);
                vel.Set(_movement.HorizontalValue, 0, _movement.VerticalValue);
                //_logger.InfoFormat("_movement data:{0}", vel.ToStringExt());
                if (CompareUtility.IsApproximatelyEqual(vel.sqrMagnitude, 0))
                {
                    vel.Set(lastVel.x, 0, lastVel.z);
                }
                vel.Normalize();

                var maxSpeed = GetMaxSpeed(buff);

                //_logger.InfoFormat("maxspeed:{0}, buff:{1}, next pos:{2}, next move:{3}", maxSpeed, buff,_postureInConfig.NextPosture(), _movementInConfig.NextMovement());
                if (CompareUtility.IsApproximatelyEqual(maxSpeed, lastSpeed))
                {
                    vel *= maxSpeed;
                }
                else
                {
                    if (_postureInConfig.InTransition() || _movementInConfig.InTransition())
                    {
                        var scale            = Mathf.Abs(CalcTransitionSpeedScale(deltaTime));
                        var remainTime       = Math.Max(_postureInConfig.TransitionRemainTime(), _movementInConfig.TransitionRemainTime()) * 0.001f;
                        var acceleratedSpeed = lastSpeed + (maxSpeed - lastSpeed) * deltaTime * scale / remainTime;
                        //_logger.InfoFormat("prev speed:{0}, nextspeed:{1}, maxSpeed:{2}", lastSpeed, acceleratedSpeed, maxSpeed);
                        if (lastSpeed <= maxSpeed)
                        {
                            acceleratedSpeed = Math.Min(acceleratedSpeed, maxSpeed);
                        }
                        else
                        {
                            acceleratedSpeed = Math.Max(acceleratedSpeed, maxSpeed);
                        }
                        vel *= acceleratedSpeed;
                    }
                    else
                    {
                        vel *= maxSpeed;
                    }
                }

                CalcSpeedRatio(maxSpeed, vel.magnitude, buff);
            }

            if (_posture.IsNeedJumpSpeed())
            {
                vel.y = _characterInfoProvider.GetJumpSpeed() * (1 + _player.playerMove.JumpAffect);
                //_logger.InfoFormat("start jump!!!!!!vel.y:{0}, _player.playerMove.JumpAffect:{1}", vel.y,_player.playerMove.JumpAffect );
            }
            else if (_posture.GetNextPostureState() == PostureInConfig.Swim)
            {
                vel.y = 0;
            }
            else if (_posture.GetNextPostureState() != PostureInConfig.Dive)
            {
                vel.y = lastVel.y - deltaTime * Gravity;
                //_logger.InfoFormat("jumpTime:{0}, vel.y:{1}, expected:{2}", JumpTime, vel.y, 3.4 - JumpTime * Gravity);
            }

            return(vel);
        }