//---------------------- // Protected Functions //---------------------- // Private Functions /// <summary> /// Do the holding animation algorithm here... /// </summary> private void HoldAnim() { if (!mHolding) { return; } // start timer. mHoldTimer += Time.deltaTime; // record down whats the current animation playing. if (this.m2DAnimator.CurrentAnimId != mHoldAnimIndex) { this.mStoreAnimIndex = this.m2DAnimator.CurrentAnimId; } // start holding the animation. m2DAnimator.DoAnimation(mHoldAnimIndex); // check if done holding the animation. if (mHoldTime > mHoldTimer) { return; } // reset timer and trigger. mHoldTimer = 0; mHolding = false; // start the previous animation once. m2DAnimator.DoAnimation(mStoreAnimIndex); }
/*******************************************/ /* Protected Variables */ /*******************************************/ /*******************************************/ /* setter / getter */ /*******************************************/ /*******************************************/ /* Unity's function */ /*******************************************/ private void Start() { this.mAnimator = this.GetComponent <JCS_2DAnimator>(); // start the animation from the first id. mAnimator.DoAnimation(0, true); }
/* Functions */ private void Start() { this.mAnimator = this.GetComponent <JCS_2DAnimator>(); if (mPlayOnAwake) { // start the animation from the first id. mAnimator.DoAnimation(0, true); mActive = true; } }
/// <summary> /// Play a random animation in the animator. /// </summary> private void RandomPlayAnimationInAnimator() { int animLength = m2DAnimator.AnimationsLength; if (animLength == 0) { return; } /* * Just pick a random animation from the animator's animation array. */ int randIndex = JCS_Random.Range(0, animLength); // play this animation m2DAnimator.DoAnimation(randIndex); }
private void Update() { // check if animation done playing. if (!mAnimator.CurrentAnimation.IsDonePlaying) { return; } // add up for next animation. ++mCurrentAnimationId; // reset anim id. if (mCurrentAnimationId == mAnimator.AnimationsLength) { mCurrentAnimationId = 0; } // play animaiton. mAnimator.DoAnimation(mCurrentAnimationId, false, true); }
private void Update() { if (!mActive) { return; } // check if animation done playing. if (!mAnimator.CurrentAnimation.IsDonePlaying) { return; } // add up for next animation. ++mCurrentAnimationId; // reset anim id if loop. if (mCurrentAnimationId >= mAnimator.AnimationsLength) { if (mLoop) { mCurrentAnimationId = 0; } else { // set to the last animation in the array. mCurrentAnimationId = mAnimator.AnimationsLength - 1; // If not loop, just disable the cycle trigger. mActive = false; } } // play animaiton. mAnimator.DoAnimation(mCurrentAnimationId, false, true); }
/// <summary> /// Do the animation. /// </summary> /// <param name="state"></param> public override void DoAnimation(JCS_LiveObjectState state = JCS_LiveObjectState.STAND) { m2DAnimator.DoAnimation((int)state); mCurrentState = state; }