Example #1
0
        public virtual void Interpolate(object left, object right, IInterpolationInfo interpolationInfo)
        {
            AbstractNetworkAnimator leftComponent  = (AbstractNetworkAnimator)left;
            AbstractNetworkAnimator rightComponent = (AbstractNetworkAnimator)right;

            InitFields(leftComponent);

            BaseServerTime       = leftComponent.BaseServerTime;
            NeedChangeServerTime = leftComponent.NeedChangeServerTime;

            // 当动画状态机切换时(人<->怪物),不做插值,使用left,目前未对动画状态机切换做处理
            // 此处只是避免出错
            if (leftComponent.AnimatorLayers.Count == rightComponent.AnimatorLayers.Count)
            {
                AssignAnimatorLayers(leftComponent.AnimatorLayers,
                                     rightComponent.AnimatorLayers,
                                     leftComponent.BaseServerTime,
                                     interpolationInfo.CurrentRenderTime,
                                     rightComponent.BaseServerTime,
                                     interpolationInfo.Ratio);
//                AssignAnimatorParameters(leftComponent.FloatAnimatorParameters, rightComponent.FloatAnimatorParameters,
//                    interpolationInfo.Ratio);
                AssignAnimatorParameters(leftComponent.AnimatorParameters, rightComponent.AnimatorParameters, interpolationInfo.Ratio);
            }
        }
Example #2
0
        private void InitFields(AbstractNetworkAnimator leftComponent)
        {
            if (AnimatorLayers == null || AnimatorLayers.Count != leftComponent.AnimatorLayers.Count)
            {
                AnimatorLayers = new List <NetworkAnimatorLayer>(leftComponent.AnimatorLayers.Count);

                foreach (var layer in leftComponent.AnimatorLayers)
                {
                    AnimatorLayers.Add(layer.Clone());
                }
            }

            if (AnimatorParameters == null || AnimatorParameters.Count != leftComponent.AnimatorParameters.Count)
            {
                AnimatorParameters = new List <NetworkAnimatorParameter>(leftComponent.AnimatorParameters.Count);

                foreach (var parameter in leftComponent.AnimatorParameters)
                {
                    AnimatorParameters.Add(parameter.Clone());
                }
            }

//            if (FloatAnimatorParameters == null || FloatAnimatorParameters.Count != leftComponent.FloatAnimatorParameters.Count)
//            {
//                FloatAnimatorParameters = new List<CompressedNetworkAnimatorParameter>(leftComponent.FloatAnimatorParameters.Count);
//
//                foreach (var param in leftComponent.FloatAnimatorParameters)
//                {
//                    FloatAnimatorParameters.Add(param.Clone());
//                }
//            }
        }
Example #3
0
        public virtual void Interpolate(object left, object right, IInterpolationInfo interpolationInfo)
        {
            AbstractNetworkAnimator leftComponent  = (AbstractNetworkAnimator)left;
            AbstractNetworkAnimator rightComponent = (AbstractNetworkAnimator)right;

            InitFields(leftComponent);

            BaseServerTime       = leftComponent.BaseServerTime;
            BaseClientTime       = leftComponent.BaseClientTime;
            NeedChangeServerTime = leftComponent.NeedChangeServerTime;

            if (AnimatorLayers.Count > 0 && _networkAnimatorLogger.IsDebugEnabled)
            {
                _networkAnimatorLogger.DebugFormat("EntityName:{0}, before Interpolate, layer 0:{1}", _entityName,
                                                   AnimatorLayers[0].ToString());
            }

            if (leftComponent.AnimatorLayers.Count > 0 && _networkAnimatorLogger.IsDebugEnabled)
            {
                _networkAnimatorLogger.DebugFormat("EntityName:{2},Interpolate\n left layer 0:{0}\nright layer 0:{1}",
                                                   leftComponent.AnimatorLayers[0], rightComponent.AnimatorLayers[0], _entityName);
            }

            AssignAnimatorLayers(leftComponent.AnimatorLayers,
                                 rightComponent.AnimatorLayers,
                                 leftComponent.BaseServerTime,
                                 interpolationInfo.LeftServerTime,
                                 interpolationInfo.CurrentRenderTime,
                                 rightComponent.BaseServerTime,
                                 interpolationInfo.RightServerTime,
                                 interpolationInfo.Ratio);
            AssignAnimatorParameters(leftComponent.AnimatorParameters);

            if (AnimatorLayers.Count > 0 && _networkAnimatorLogger.IsDebugEnabled)
            {
                _networkAnimatorLogger.DebugFormat("EntityName:{1},after Interpolate, layer 0:{0}", AnimatorLayers[0], _entityName);
            }

            if (_networkAnimatorLogger.IsDebugEnabled)
            {
                _networkAnimatorLogger.DebugFormat(
                    "EntityName:{9},NetworkAnimatorComponent Interpolate, left.BaseServerTime:{0},right.BaseServerTime:{1},  baseServerTime delta:{2}\n interpolate.LeftServerTime:{3}, interpolate.RightServerTime:{4},interpolate.renderTime:{5},interpolate.Ratio:{6}\n interpolate deltaTime:{7}, render time delta:{8} ",
                    leftComponent.BaseServerTime,
                    rightComponent.BaseServerTime,
                    rightComponent.BaseServerTime - leftComponent.BaseServerTime,
                    interpolationInfo.LeftServerTime,
                    interpolationInfo.RightServerTime,
                    interpolationInfo.CurrentRenderTime,
                    interpolationInfo.Ratio,
                    interpolationInfo.RightServerTime - interpolationInfo.LeftServerTime,
                    interpolationInfo.CurrentRenderTime - _prevRenderTime,
                    _entityName
                    );
            }

            _prevRenderTime = interpolationInfo.CurrentRenderTime;
        }
Example #4
0
        //

        private void InitFields(AbstractNetworkAnimator leftComponent)
        {
            if (AnimatorLayers == null || AnimatorLayers.Count != leftComponent.AnimatorLayers.Count)
            {
                AnimatorLayers = new List <NetworkAnimatorLayer>(leftComponent.AnimatorLayers.Count);

                foreach (var layer in leftComponent.AnimatorLayers)
                {
                    AnimatorLayers.Add(layer.Clone());
                }
            }

            if (AnimatorParameters == null || AnimatorParameters.Count != leftComponent.AnimatorParameters.Count)
            {
                AnimatorParameters = new List <NetworkAnimatorParameter>(leftComponent.AnimatorParameters.Count);
                foreach (var param in leftComponent.AnimatorParameters)
                {
                    AnimatorParameters.Add(param.Clone());
                }

                _animatorParameterIndex = null;
            }
        }