示例#1
0
 private void Start()
 {
     this.varasm = base.GetComponent<clsurganimationstatesmanager>();
     if (this.varasm == null)
     {
         base.enabled = false;
     }
 }
示例#2
0
 public static AnimationClip metcreatetransitionanimation(Transform varpsource, string varptargetanimname, float varptransitiontime, string varpnewanimationname, ref Vector3 varprootnormalizer, clsurganimationstatesmanager varpanimationstatemanager = null, bool varppositioncurves = false)
 {
     if (varpanimationstatemanager == null)
     {
         varpanimationstatemanager = varpsource.root.GetComponentInChildren<clsurganimationstatesmanager>();
         if (varpanimationstatemanager == null)
         {
             Debug.Log("No animation states manager in the source");
             return null;
         }
     }
     int num = varpanimationstatemanager.vargamstatenames.IndexOf(varptargetanimname);
     if (num < 0)
     {
         Debug.LogError("Animation state not memorized in manager");
         return null;
     }
     if (varpanimationstatemanager.vargamrootname != varpsource.name)
     {
         Debug.LogWarning(string.Concat(new string[]
         {
             "The animation states root is different than the source passed in. Unexpected behavior may occur [passed ",
             varpsource.name,
             " expected ",
             varpanimationstatemanager.vargamrootname,
             "]"
         }));
     }
     AnimationClip animationClip = new AnimationClip();
     AnimationCurve curve = new AnimationCurve();
     AnimationCurve curve2 = new AnimationCurve();
     AnimationCurve curve3 = new AnimationCurve();
     AnimationCurve curve4 = new AnimationCurve();
     AnimationCurve curve5 = new AnimationCurve();
     AnimationCurve curve6 = new AnimationCurve();
     AnimationCurve curve7 = new AnimationCurve();
     animationClip.name = varpnewanimationname;
     varprootnormalizer = varpanimationstatemanager.vargamrootoriginallocalposition;
     Transform[] componentsInChildren = varpsource.GetComponentsInChildren<Transform>();
     if (componentsInChildren.Length != varpanimationstatemanager.vargamanimationstates[num].propanimationstate.Length)
     {
         Debug.LogError(string.Concat(new object[]
         {
             "Source and state body parts length missmatch. Can't continue [",
             componentsInChildren.Length,
             " - ",
             varpanimationstatemanager.vargamanimationstates[num].propanimationstate.Length,
             "]"
         }));
         return null;
     }
     varptransitiontime -= varptransitiontime / 24f;
     for (int i = 0; i < varpanimationstatemanager.vargamanimationstates[num].propanimationstate.Length; i++)
     {
         Vector3 localPosition = componentsInChildren[i].localPosition;
         Vector3 propposition = varpanimationstatemanager.vargamanimationstates[num].propanimationstate[i].propposition;
         if (localPosition != propposition)
         {
             curve = AnimationCurve.EaseInOut(0f, localPosition.x, varptransitiontime, propposition.x);
             curve2 = AnimationCurve.EaseInOut(0f, localPosition.y, varptransitiontime, propposition.y);
             curve3 = AnimationCurve.EaseInOut(0f, localPosition.z, varptransitiontime, propposition.z);
             animationClip.SetCurve(varpanimationstatemanager.vargamanimationstates[num].propanimationstate[i].proppath, typeof(Transform), "localPosition.x", curve);
             animationClip.SetCurve(varpanimationstatemanager.vargamanimationstates[num].propanimationstate[i].proppath, typeof(Transform), "localPosition.y", curve2);
             animationClip.SetCurve(varpanimationstatemanager.vargamanimationstates[num].propanimationstate[i].proppath, typeof(Transform), "localPosition.z", curve3);
         }
         Quaternion localRotation = componentsInChildren[i].localRotation;
         Quaternion proprotation = varpanimationstatemanager.vargamanimationstates[num].propanimationstate[i].proprotation;
         if (localRotation != proprotation)
         {
             curve4 = AnimationCurve.Linear(0f, localRotation.x, varptransitiontime, proprotation.x);
             curve5 = AnimationCurve.Linear(0f, localRotation.y, varptransitiontime, proprotation.y);
             curve6 = AnimationCurve.Linear(0f, localRotation.z, varptransitiontime, proprotation.z);
             curve7 = AnimationCurve.Linear(0f, localRotation.w, varptransitiontime, proprotation.w);
             animationClip.SetCurve(varpanimationstatemanager.vargamanimationstates[num].propanimationstate[i].proppath, typeof(Transform), "localRotation.x", curve4);
             animationClip.SetCurve(varpanimationstatemanager.vargamanimationstates[num].propanimationstate[i].proppath, typeof(Transform), "localRotation.y", curve5);
             animationClip.SetCurve(varpanimationstatemanager.vargamanimationstates[num].propanimationstate[i].proppath, typeof(Transform), "localRotation.z", curve6);
             animationClip.SetCurve(varpanimationstatemanager.vargamanimationstates[num].propanimationstate[i].proppath, typeof(Transform), "localRotation.w", curve7);
         }
     }
     animationClip.EnsureQuaternionContinuity();
     animationClip.wrapMode = WrapMode.ClampForever;
     return animationClip;
 }
示例#3
0
 public static int metcrossfadetransitionanimation(Transform varpcharacter, string varpdestinationanimname, float varptransitiontime, Transform varpcontroller = null, string varpstateanimationname = "", bool varpgokinematic = true, string varpnewanimname = "transition", Animation varpanimationsystem = null, SkinnedMeshRenderer varprenderer = null, clsurganimationstatesmanager varpstatesmanager = null)
 {
     if (varpcharacter == null)
     {
         return -1;
     }
     if (varptransitiontime == 0f)
     {
         return -2;
     }
     if (varpanimationsystem == null)
     {
         varpanimationsystem = varpcharacter.root.GetComponentInChildren<Animation>();
         if (varpanimationsystem == null)
         {
             return -3;
         }
         varpanimationsystem.Stop();
     }
     if (varprenderer == null)
     {
         varprenderer = varpcharacter.root.GetComponentInChildren<SkinnedMeshRenderer>();
         if (varprenderer == null)
         {
             return -4;
         }
     }
     if (varpgokinematic)
     {
         clsurgutils.metgodriven(varpcharacter, true);
     }
     Vector3 localPosition = default(Vector3);
     if (varpcontroller != null)
     {
         Vector3 position = varpcharacter.position;
         varpcontroller.position = position;
         varpcharacter.localPosition = localPosition;
     }
     AnimationClip animationClip = clsurgutils.metcreatetransitionanimation(varpcharacter, varpdestinationanimname, varptransitiontime, varpnewanimname, ref localPosition, varpstatesmanager, false);
     if (animationClip != null)
     {
         varpanimationsystem.Stop();
         AnimationState animationState = varpanimationsystem[varpdestinationanimname];
         if (animationState != null && animationState.name != varpdestinationanimname)
         {
             varpanimationsystem.RemoveClip(varpnewanimname);
         }
         varpanimationsystem.AddClip(animationClip, varpnewanimname);
         if (varpstateanimationname != string.Empty)
         {
             varpanimationsystem[varpnewanimname].wrapMode = WrapMode.Once;
             varpanimationsystem.CrossFade(varpnewanimname);
             varpanimationsystem.CrossFadeQueued(varpstateanimationname);
         }
         else
         {
             varpanimationsystem.CrossFade(varpnewanimname);
         }
         return 1;
     }
     Debug.LogError("Could not create transition");
     return -5;
 }
	void Start() {
		varasm = GetComponent<clsurganimationstatesmanager>();
		if (varasm == null) {
			enabled = false;
		}
	}