Exemplo n.º 1
0
        public virtual void CopyFrom(object rightComponent)
        {
            var right = rightComponent as AbstractNetworkAnimator;

            InitFields(right);

            // used in clone
            BaseServerTime       = right.BaseServerTime;
            BaseClientTime       = right.BaseClientTime;
            NeedChangeServerTime = right.NeedChangeServerTime;

            int AnimatorLayersCount = AnimatorLayers.Count;

            for (int i = 0; i < AnimatorLayersCount; i++)
            {
                if (AnimatorLayers[i] == null)
                {
                    AnimatorLayers[i] = new NetworkAnimatorLayer();
                }
                AnimatorLayers[i].RewindTo(right.AnimatorLayers[i]);
            }

            int AnimatorParametersCount = AnimatorParameters.Count;

            for (int i = 0; i < AnimatorParametersCount; i++)
            {
                if (AnimatorParameters[i] == null)
                {
                    AnimatorParameters[i] = new NetworkAnimatorParameter();
                }
                AnimatorParameters[i].RewindTo(right.AnimatorParameters[i]);
            }

            NeedRewind = true;
        }
Exemplo n.º 2
0
        private static bool SetInt(Animator animator, FsmOutput output, NetworkAnimatorParameter latetstParam)
        {
            if (CompareParamHistory(output, latetstParam))
            {
                animator.SetInteger(output.TargetHash, output.IntValue);

                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        private static bool SetBool(Animator animator, FsmOutput output, NetworkAnimatorParameter latetstParam)
        {
            if (CompareParamHistory(output, latetstParam))
            {
                animator.SetBool(output.TargetHash, output.BoolValue);
                if (output.UpdateImmediate)
                {
                    animator.Update(0);
                }
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        private static bool CompareParamHistory(FsmOutput newValue, NetworkAnimatorParameter latestValue)
        {
            bool ret = false;

            switch (newValue.Type)
            {
            case FsmOutputType.Bool:
                ret = !CompareUtility.IsApproximatelyEqual(newValue.BoolValue, latestValue.BoolValue);
                if (ret)
                {
                    //Logger.ErrorFormat("change due to bool:{0}, from:{1},to:{2}", newValue.TargetHash, latestValue.BoolValue,newValue.BoolValue);
                    latestValue.SetParam(AnimatorControllerParameterType.Bool,
                                         newValue.BoolValue,
                                         newValue.TargetHash);
                }


                break;

            case FsmOutputType.Float:
                ret = !CompareUtility.IsApproximatelyEqual(newValue.FloatValue, latestValue.FloatValue, 0.001f);
                if (ret)
                {
                    //Logger.ErrorFormat("change due to FloatValue:{0}, from:{1},to:{2}", newValue.TargetHash, latestValue.FloatValue,newValue.FloatValue);
                    latestValue.SetParam(AnimatorControllerParameterType.Float,
                                         newValue.FloatValue,
                                         newValue.TargetHash);
                }



                break;

            case FsmOutputType.Int:
                ret = !CompareUtility.IsApproximatelyEqual(newValue.IntValue, latestValue.IntValue);
                if (ret)
                {
                    //Logger.ErrorFormat("change due to IntValue:{0}, from:{1},to:{2}", newValue.TargetHash, latestValue.IntValue,newValue.IntValue);
                    latestValue.SetParam(AnimatorControllerParameterType.Int,
                                         newValue.IntValue,
                                         newValue.TargetHash);
                }



                break;
            }

            return(ret);
        }
Exemplo n.º 5
0
        public virtual void CopyFrom(object rightComponent)
        {
            var right = rightComponent as AbstractNetworkAnimator;

            InitFields(right);

            // used in clone
            BaseServerTime       = right.BaseServerTime;
            NeedChangeServerTime = right.NeedChangeServerTime;

            int AnimatorLayersCount = AnimatorLayers.Count;

            for (int i = 0; i < AnimatorLayersCount; i++)
            {
                if (AnimatorLayers[i] == null)
                {
                    AnimatorLayers[i] = new NetworkAnimatorLayer();
                }
                AnimatorLayers[i].RewindTo(right.AnimatorLayers[i]);
            }

            int AnimatorParamsCount = AnimatorParameters.Count;

            for (int i = 0; i < AnimatorParamsCount; ++i)
            {
                if (AnimatorParameters[i] == null)
                {
                    AnimatorParameters[i] = new NetworkAnimatorParameter();
                }
                AnimatorParameters[i].RewindTo(right.AnimatorParameters[i]);
            }
//            int FloatParamCount = FloatAnimatorParameters.Count;
//            for (int i = 0; i < FloatParamCount; ++i)
//            {
//                if (FloatAnimatorParameters[i] == null)
//                    FloatAnimatorParameters[i] = new CompressedNetworkAnimatorParameter();
//
//                FloatAnimatorParameters[i].RewindTo(right.FloatAnimatorParameters[i]);
//            }
        }
Exemplo n.º 6
0
        private static bool SetAnimatorParameter(Animator animator, FsmOutput output, NetworkAnimatorParameter latestValue)
        {
            bool ret = false;

            switch (output.Type)
            {
            case FsmOutputType.Bool:
                ret = SetBool(animator, output, latestValue);
                break;

            case FsmOutputType.Float:
                ret = SetFloat(animator, output, latestValue);
                break;

            case FsmOutputType.Int:
                ret = SetInt(animator, output, latestValue);
                break;
            }

            return(ret);
        }