예제 #1
0
 void Ready()
 {
     for (int i = 0; i < pooledObjects.Count; i++)
     {
         Misile m = (Misile)pooledObjects[i];
         m.GetInPosition(setupPositions[i] + transform.position);
         m.Aim(GameController.GC.Player.position);
     }
 }
예제 #2
0
 protected override void FillPool()
 {
     pooledObjects = new List <Bullet>();
     for (int t = 0; t < Turrets.Length; t++)
     {
         for (int i = 0; i < amountToPoolPerTurret; i++)
         {
             Misile obj = new Misile(t, objectToPool, poolParent);
             pooledObjects.Add(obj);
         }
     }
 }
예제 #3
0
    void Update()
    {
        //Fire1 が押された時
        if (Input.GetButtonDown("Fire1") && this.count <= 1)
        {
            this.count += 15;
            //弾丸の複製
            GameObject bullets = GameObject.Instantiate(bullet) as GameObject;
            //銃弾は2秒後に破壊
            Destroy(bullets, 2);

            //銃弾を発射する力
            Vector3 force;
            force = this.gameObject.transform.forward * (speed + player.getMoveSpeed());
            //Rigidbodyに力を加えて発射
            bullets.GetComponent <Rigidbody> ().AddForce(force);
            //弾丸の位置を調整
            bullets.transform.position = muzzle.position;
            //発射音再生
            bulletAs.PlayOneShot(bulletSound);
        }

        if (Input.GetButtonDown("Fire2") && maxMisile > 0)
        {
            maxMisile--;
            //一番近い敵を発見し、一時保存
            ApperEnemy ae       = GameObject.Find("Boss").GetComponent <ApperEnemy>();
            GameObject tmpEnemy = ae.EnemySearch();

            //ミサイルの複製
            GameObject misiles = GameObject.Instantiate(misile) as GameObject;

            //作ったミサイルのスクリプトを取得し, フィールドに直接アクセス. さっきの一番近い敵を格納.
            Misile tmpMisile = misiles.GetComponent <Misile>();
            tmpMisile.target = tmpEnemy;

            //5秒後に破壊
            Destroy(misiles, 5);

            //ミサイルを発射位置まで移動
            misiles.transform.position = muzzle.position;
            //発射音再生
            misileAs.PlayOneShot(misileSound);
        }

        if (this.count > 0)
        {
            this.count -= 1;
        }
    }
예제 #4
0
    void Aim()
    {
        int arriveCount = 0;

        for (int i = 0; i < pooledObjects.Count; i++)
        {
            Misile m = (Misile)pooledObjects[i];

            m.GetInPosition(setupPositions[i] + transform.position);
            if (m.InPosition)
            {
                arriveCount++;
                m.Aim(GameController.GC.Player.position);
            }
        }
        if (arriveCount >= pooledObjects.Count)
        {
            StartCoroutine(ReadyTimer());
        }
    }