示例#1
0
    /// <summary>
    ///
    /// </summary>
    protected override void Update()
    {
        mTimeLiving += Time.deltaTime;

        // Check if the zombie should get buried again in the ground
        if (mTimeLiving > MaxTimeLiving)
        {
            this.State = eZombieState.Disappearing;
        }

        // Update animator and physics properties according to State
        switch (this.State)
        {
        case eZombieState.Appearing:
            this.mAnimator.Play("ZombieStart");
            this.mRigidBody.velocity     = Vector2.zero;
            this.mRigidBody.gravityScale = 0;
            break;

        case eZombieState.Walking:
            this.mAnimator.Play("ZombieWalk");
            this.mRigidBody.velocity     = new Vector2((mLookDir.LookLeft ? -1 : 1) * SpeedX, this.mRigidBody.velocity.y);
            this.mRigidBody.gravityScale = mGravityScaleOriginalValue;
            break;

        case eZombieState.Disappearing:
            this.mAnimator.Play("ZombieEnd");
            this.mRigidBody.velocity     = Vector2.zero;
            this.mRigidBody.gravityScale = 0;
            break;
        }

        base.Update();
    }
示例#2
0
 /// <summary>
 ///
 /// </summary>
 public void StartAnimationFinished()
 {
     // When the start animation ends, zombie needs to start walking and stop being harmless
     this.State = eZombieState.Walking;
     this.mCapsuleCollider.enabled = true;
 }