Ejemplo n.º 1
0
        private void Update()
        {
            if (mCheckEndJumpAnimation)
            {
                if (isGrounded)
                {
                    // continue doing the animation state he left on.
                    mLiveObjectAnimator.DoAnimation(mAnimStateBeforeJump);
                    mCheckEndJumpAnimation = false;
                }
            }

            DoJump();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Walk depends on the status.
        /// </summary>
        /// <param name="status"></param>
        public void WalkByStatus(Status status)
        {
            switch (status)
            {
            case Status.IDLE:
            {
                Walk(0);                // stop walking

                if (mLiveObjectAnimator != null)
                {
                    mLiveObjectAnimator.DoAnimation(JCS_LiveObjectState.STAND);
                }
            }
            break;

            case Status.LEFT:
            {
                Walk(JCS_Mathf.ToNegative(mWalkSpeed));

                if (mLiveObjectAnimator != null)
                {
                    mLiveObjectAnimator.DoAnimation(JCS_LiveObjectState.WALK);
                }
            }
            break;

            case Status.RIGHT:
            {
                Walk(JCS_Mathf.ToPositive(mWalkSpeed));

                if (mLiveObjectAnimator != null)
                {
                    mLiveObjectAnimator.DoAnimation(JCS_LiveObjectState.WALK);
                }
            }
            break;
            }
        }
        private void Update()
        {
            // if still could damage this live object,
            // mean this object isn't dead yet.
            if (0 < mLiveObject.HP)
            {
                return;
            }

            // if dies
            if (!mSoundPlayed)
            {
                // just play one time.
                JCS_SoundManager.instance.GetGlobalSoundPlayer().PlayOneShot(mDieSound);
                mSoundPlayed = true;
            }

            // do the dead animation
            if (mLiveObjectAnimator.Animator.AnimDisplayHolder != null)
            {
                mLiveObjectAnimator.Animator.AnimDisplayHolder.StopHolding();
            }
            mLiveObjectAnimator.DoAnimation(JCS_LiveObjectState.DIE);

            if (mFreezeWhileDie)
            {
                mLiveObject.VelocityInfo.Freeze();
            }

            // disable other un-necessary components
            if (mDisableOtherComponentWhileDie)
            {
                for (int index = 0;
                     index < mDisableComponents.Length;
                     ++index)
                {
                    // disable all un-necessary component
                    if (mDisableComponents[index] == null)
                    {
                        continue;
                    }

                    // disable the component
                    mDisableComponents[index].enabled = false;
                }

                // after disable it dont do it agian in next frame.
                mDisableOtherComponentWhileDie = false;
            }

            // if the animation starts,
            // start timer and check the
            // dead animation is end or not.
            if (mLiveObjectAnimator.IsInState(JCS_LiveObjectState.DIE))
            {
                if (mLiveObjectAnimator.Animator.CurrentAnimation.IsDonePlaying)
                {
                    // if is end destroy the object itself.
                    Destroy(this.gameObject);
                }
            }
        }