Пример #1
0
        /// <summary>
        /// 총알을 생성하고 좌표를 위로 조금 올려준다.
        /// </summary>
        void FireBullet()
        {
            PlayerBullet bullet = GameObject.Instantiate <PlayerBullet>();

            Vec2D bulletPoint = gameObject.transform.position;

            bulletPoint.Y            -= 8;
            bullet.transform.position = bulletPoint;

            DamageSystem damageSystem = bullet.GetComponent <DamageSystem>();

            damageSystem.EventGiveDamage += () => GameObject.Destroy(bullet);

            GameManager.Instance.IncreaseFireCount(1);
        }
Пример #2
0
    private void Shoot()
    {
        PlayerBullet bullet = Instantiate(bulletPrefab, bulletParent.transform);

        // set position to player position(this.transform)
        bullet.transform.position = transform.position;

        Rigidbody2D rb = bullet.GetComponent <Rigidbody2D>();

        rb.velocity = Vector2.up * bulletSpeed;

        if (soundController)
        {
            // play shot when player uses shoot button
            soundController.PlayOneShot(shootClip);
        }
    }
Пример #3
0
    private void Shoot()
    {
        if (beam)
        {
            bullet = Instantiate(beamPrefab);
        }
        else
        {
            bullet = Instantiate(bulletPrefab);
        }
        bullet.transform.position = transform.position;
        var b = transform.position.y + 0.8f;

        bullet.transform.position = new Vector2(transform.position.x, b);
        Rigidbody2D rb = bullet.GetComponent <Rigidbody2D>();

        rb.velocity = Vector2.up * bulletSpeed;
    }
Пример #4
0
 //======================================================
 //	玩家〇移动函数
 //======================================================
 private void flashFindToMove()
 {
     if (inputOperation.isWannaFindMove)
     {
         GameObject[] playerBullets = null;                                 // 子弹列表
         playerBullets = GameObject.FindGameObjectsWithTag("PlayerBullet"); //寻址子弹
         if (playerBullets != null)                                         // 当列表不为空
         {
             foreach (GameObject bullet in playerBullets)                   //在列表中循环
             {
                 flashMoveTo(bullet.transform.position);                    //移动到第一个子弹的位置
                 bullet.GetComponent <PlayerBullet> ().breakSelf();         //子弹自我销毁
                 break;                                                     //退出循环
             }
         }
         else
         {
             flashMoveTo(transform.position);                  //移动到自己当前位置
         }
     }
 }