Exemplo n.º 1
0
 protected IEnumerator ShootingRoutine()
 {
     for (int i = 0; i < numBullets; ++i)
     {
         Shootable shootable = Instantiate(bulletPrefab);
         shootable.OnShot(transform);
         yield return(new WaitForSeconds(bulletFrequency));
     }
 }
Exemplo n.º 2
0
    void Update()
    {
        Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2 dir      = mousePos - transform.position;

        transform.rotation = Quaternion.FromToRotation(Vector2.up, dir);
        if (Input.GetButtonDown("Fire"))
        {
            if (shootableObject.gameObject.activeInHierarchy)
            {
                shootableObject.gameObject.SetActive(false);
            }
            else
            {
                shootableObject.OnShot(transform);
            }
        }
    }