1 usingUnityengine;2 usingSystem.Collections;3 4 Public classFrightup_panlemng:monobehaviour {5 6 //Public static frightup_panlemng Instance;7 8 //Time9 Public floatTime_miao =2f;Ten One PublicUILabel frightnum;//Fighting capacity label A - PublicTweenalpha tweenalpha;//Show hidden tween animations - the floatStart =0;//Start Value - floatEnd =0;//End Value - - floatSpeed=0;//Speed + - voidAwake () + { A //Instance = this; at - - - - } - in voidStart () - { toPlayerInfo.Instance.OnPlayerInfoChanged + = This. onplayerinfochanged;//Registering events, + -Start =playerinfo.instance.fright;//Get the starting combat value the *Gameobject.setactive (false);//Hide First $ }Panax NotoginsengEvent method - Public voidonplayerinfochanged (infotype infotype) the { + if(infotype==infotype.frightnum)//If the type is combat effectiveness A { the Show (); + } - } $ $ Public voidShow () - { -End =playerinfo.instance.fright;//get the fighting power now theSpeed = (End-start)/time_miao;//Calculating the speed -Gameobject.setactive (true);//ActivationWuyi Tweenalpha. Playforward ();//Display animation the Startcoroutine (Ieshow ());//start co-process - } Wu - IEnumerator ieshow () About { $ - while(start!=end) - {//When the end and start gaps are less than the speed, - if(End>start&&end-start < speed) | | (End<start) &&start-end<mathf.abs (speed)) A {//directly equals end +Start =end; the } - Else $ {//otherwise add speed * per frame theStart + = speed *Time.deltatime; the } theLabel Assignment theFrightnum.text = ((int) Start). ToString (); -Wait for a frame in yield return 0; the } the Tweenalpha. Playreverse ();//Play The hidden animation at the end of the loop AboutWait for the animation to finish playing the yield return NewWaitforseconds (0.7f); theDisable theGameobject.setactive (false); + } - the}
The animation of the battle-fighting number enhancement.