Beispiel #1
0
        private float CalcTransitionSpeedScale(float deltaTime)
        {
            var ret = 1.0f;

            if (_movementInConfig.InTransition())
            {
                var normalizeTime = 1 - _movementInConfig.TransitionRemainTime() / _movementInConfig.TransitionTime();
                var target        = Mathf.Clamp01(normalizeTime + deltaTime * 1000f / _movementInConfig.TransitionTime());
                ret = SingletonManager.Get <CharacterStateConfigManager>()
                      .GetMovementTransitionSpeedScale(_movementInConfig.CurrentMovement(),
                                                       _movement.GetNextMovementState(), normalizeTime, target);
                //_logger.InfoFormat("current:{0}, next:{1}, normalize time:{2},target:{3} ret:{4}",_movementInConfig.CurrentMovement(),
                //    _movement.GetNextMovementState(), 1 - _movementInConfig.TransitionRemainTime()/_movementInConfig.TransitionTime(),target,ret);
            }
            return(ret);
        }
Beispiel #2
0
        private float GetMaxSpeed(float buff)
        {
            float maxSpeed     = 0;
            var   totalBuff    = 1 + buff;
            bool  valid        = false;
            var   candidateId1 = CharacterStateConfigHelper.GenerateId(_postureInConfig.InTransition() ? _postureInConfig.NextPosture() : _postureInConfig.CurrentPosture(),
                                                                       _movementInConfig.InTransition() ? _movementInConfig.NextMovement() : _movementInConfig.CurrentMovement());
            var candidateId2 = CharacterStateConfigHelper.GenerateId(_postureInConfig.CurrentPosture(), MovementInConfig.Null);

            //_logger.InfoFormat("posture in transition:{0}, next posture:{1}, cur posture:{2}, move in transition:{3}, next move:{4}, CURRENT MOVE:{5}",_postureInConfig.InTransition() , _postureInConfig.NextPosture() , _postureInConfig.CurrentPosture(),
            //   _movementInConfig.InTransition() , _movementInConfig.NextMovement() , _movementInConfig.CurrentMovement());
            if (_speedConditionDictionary.ContainsKey(candidateId2))
            {
                valid = true;
                _speedConditionDictionary[candidateId2].Invoke();
            }
            else if (_speedConditionDictionary.ContainsKey(candidateId1))
            {
                valid = true;
                _speedConditionDictionary[candidateId1].Invoke();
            }


            if (valid)
            {
                float weaponSpeed = GetWeaponSpeed(_currentPosture, _currentMovement, _speedProvider.GetBaseSpeed(),
                                                   _speedProvider.GetDefaultSpeed());
                maxSpeed = SingletonManager.Get <CharacterStateConfigManager>().GetSpeed(_currentPosture,
                                                                                         _currentMovement,
                                                                                         _movement.IsForth,
                                                                                         _movement.IsBack,
                                                                                         _movement.IsLeft,
                                                                                         _movement.IsRight,
                                                                                         weaponSpeed);
                //_logger.InfoFormat("_currentPosture:{0}, _currentMovement:{1},_movement hor:{2}, _movemnt vert:{3}", _currentPosture, _currentMovement, _movement.HorizontalValue, _movement.VerticalValue);
            }
            //_logger.InfoFormat("valid:{4}, _currentPosture:{0}, _currentMovement:{1},_movement hor:{2}, _movemnt vert:{3}", _currentPosture, _currentMovement, _movement.HorizontalValue, _movement.VerticalValue, valid);
            return(maxSpeed * totalBuff);
        }