void Update()
    {
        enmblt     = GetComponent <EnemyBullet2>();
        managerObj = FindObjectOfType <Manager> ();

        if (managerObj.selectedPlayer != null)
        {
            player_obj = GameObject.Find(managerObj.selectedPlayer.name + "(Clone)");
        }
        else
        {
            player_obj = GameObject.Find("Player(Clone)");
        }

        player_obj = GameObject.Find("Player(Clone)");

        if (player_obj != null)
        {
            player_obj = serchTag(gameObject, "Player");
            Missile_Homing(player_obj);
            LookAt2D(player_obj);
            //Destroy (gameObject, lifeTime);
        }

        /*
         * //まっすぐ飛ぶ
         * rigidbody2D.velocity = transform.up.normalized * speed;
         */
        //lifeTimeが経過したら削除
        timer += Time.deltaTime;
        if (timer > lifeTime)
        {
            ObjectPool.instance.shootingGamePool(gameObject);
        }
    }
Example #2
0
    void UseGun()
    {
        fireRate_timer += Time.deltaTime;
        if (fireRate_timer >= fireRate && ammoCount > 0)
        {
            Fire();

            ammoCount -= 1;

            fireRate_timer = 0;
        }

        else if (ammoCount <= 0)
        {
            reloadSpeed_timer += Time.deltaTime;
            if (reloadSpeed_timer >= reloadSpeed)
            {
                ammoCount         = maxAmmoCount;
                reloadSpeed_timer = 0;
            }
        }

        /////////////////////////////   Internal Functions
        void Fire()
        {
            GameObject   thisBullet       = bullet;
            EnemyBullet2 thisBulletScript = thisBullet.GetComponent <EnemyBullet2>();

            thisBulletScript.accuracy = accuracy;
            thisBulletScript.damage   = damage;
            thisBulletScript.speed    = bulletSpeed;

            Vector3 bulletRotation = gun.transform.localEulerAngles;

            bulletRotation.y = 0;

            GetComponent <AudioSource>().PlayOneShot(shotSFX);

            Instantiate(thisBullet, barrelEnd.position, Quaternion.Euler(bulletRotation));
        }
    }
Example #3
0
    void Update()
    {
        enmblt = GetComponent <EnemyBullet2>();

        player_obj = GameObject.Find("Player(Clone)");

        if (player_obj != null)
        {
            player_obj = serchTag(gameObject, "Player");
            Missile_Homing(player_obj);
            LookAt2D(player_obj);
            Destroy(gameObject, lifeTime);
        }

        /*
         * //まっすぐ飛ぶ
         * rigidbody2D.velocity = transform.up.normalized * speed;
         */
        // lifeTime秒後に削除
        Destroy(gameObject, lifeTime);
    }