示例#1
0
    void Update()
    {
        if (Input.GetButtonDown("Fire"))
        {
            // TODO: Shoot a bullet!
            //       Instantiate it and get a reference of its Bullet Component.
            //       You're going to need it ;)
            GameObject bulletObject = Instantiate(mBulletPrefab, transform.position, Quaternion.identity);
            Bullet     bullet       = bulletObject.GetComponent <Bullet>();
            // GameObject bulletObject =        //Call instantiate
            // Bullet bullet =        //Get the Bullet Component

            // TODO: Set the direction of the bullet
            //       Use the SetDirection() function from the Bullet class
            //       and using MegamanRef GetFacingDirection() function
            bullet.SetDirection(mMegaManRef.GetFacingDirection());

            // TODO: Play the mBusterSound!
            mBusterSound.Play();

            // Set animation params
            mShooting = true;
            mTime     = 0.0f;
        }

        if (mShooting)
        {
            mTime += Time.deltaTime;
            if (mTime > kShootDuration)
            {
                mShooting = false;
            }
        }

        UpdateAnimator();
    }