public void Update() { if (this.isStop) { return; } if (this.gamerMotionType == GamerMotionType.None) { return; } try { //this.Animator.SetFloat("MotionSpeed", this.MontionSpeed); //设置一次参数 this.Animator.SetTrigger(this.gamerMotionType.ToString()); //触发一次 //this.MontionSpeed = 1; //默认1秒一次 this.gamerMotionType = GamerMotionType.None; //默认无操作 } catch (Exception ex) { throw new Exception($"动作播放失败: {this.gamerMotionType}", ex); } }
public void Play(GamerMotionType motionType, float motionSpeed = 1f) { if (!this.HasParameter(motionType.ToString())) { return; } this.gamerMotionType = motionType; this.MontionSpeed = motionSpeed; }
public float AnimationTime(GamerMotionType motionType) { AnimationClip animationClip; if (!this.animationClips.TryGetValue(motionType.ToString(), out animationClip)) { throw new Exception($"找不到该动作: {motionType}"); } return(animationClip.length); }
public void PlayInTime(GamerMotionType motionType, float time) { AnimationClip animationClip; if (!this.animationClips.TryGetValue(motionType.ToString(), out animationClip)) { throw new Exception($"找不到该动作: {motionType}"); } float motionSpeed = animationClip.length / time; if (motionSpeed < 0.01f || motionSpeed > 1000f) { Log.Error($"motionSpeed数值异常, {motionSpeed}, 此动作跳过"); return; } this.gamerMotionType = motionType; this.MontionSpeed = motionSpeed; }