protected void PropagateToChildren(e_AnimationType _animType) { foreach (var cAnimator in this.childrenCascadingAnimators) { cAnimator.RequestAnim(_animType); } }
public void RequestAnim(e_AnimationType _animType) { if (HasAnim(_animType)) { CancelCurAnim(); PlayAnim(_animType); } // propagate animation request even if doesnt have the animation itself PropagateToChildren(_animType); }
protected virtual void Start() { AssertPrerequisites(); this.curAnim = e_AnimationType.None; this.animator = GetComponent <Animator>(); /* * this.childrenCascadingAnimators = GetComponentsInChildren<CascadingAnimator>().ToList(); * this.childrenCascadingAnimators.Remove(this); */ this.childrenCascadingAnimators = this.GetComponentsInDirectChildren <CascadingAnimator>(); }
protected override void PlayAnim(e_AnimationType _animType) { switch (_animType) { case e_AnimationType.Idle: PlayIdleAnim(); break; // if animTypes has _animType but switch doesnt call the corresponding func default: LogErrorPlayAnim(_animType); return; } this.curAnim = _animType; LogPlayAnim(_animType); }
protected void LogCancelAnim(e_AnimationType _animType) { Debug.Log(this.gameObject.name + " cancel anim : " + _animType.ToString()); }
protected void LogPlayAnim(e_AnimationType _animType) { Debug.Log(this.gameObject.name + " plays anim : " + _animType.ToString()); }
protected void LogErrorPlayAnim(e_AnimationType _animType) { Debug.LogError("You tried to play the '" + _animType.ToString() + "' animation on the '" + this.gameObject.name + "' whereas its 'CascadingAnimator' component can't. \n" + "You may have forgotten to call the corresponding function in the 'PlayAnim(e_AnimType)' switch."); }
protected abstract void PlayAnim(e_AnimationType _animType);
protected bool HasAnim(e_AnimationType _animType) { return(this.animationTypes.Contains(_animType)); }