private void Update()
    {
        float hozAxis = Input.GetAxis("Horizontal");

        if (!Mathf.Approximately(hozAxis, 0.0f))
        {
            m_pivot.Rotate(Vector3.up, hozAxis * m_rotateSpeed);
        }

        m_lastFire += Time.deltaTime;
        if (m_lastFire >= m_fireRate)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                CannonBall ball = Instantiate(m_cannonBall, m_turret.position, m_turret.rotation);
                ball.Shoot((m_turret.position - m_origin.position).normalized);

                // Play the particles & sfx
                m_particles.Play();
                AudioEvent e = Helpers.RandomElement(m_cannonBlasts);
                AudioController.Instance.PlaySfx(e);

                m_lastFire = 0.0f;
            }
        }
        else
        {
            float scale_t = Mathf.Clamp01(m_lastFire / m_fireRate);
            m_turret.localScale = Vector3.Lerp(new Vector3(1.5f, 1.5f, 1.5f), Vector3.one, scale_t);
        }
    }
예제 #2
0
 public bool Shoot()
 {
     if (ball.ready)
     {
         ball.Shoot(transform.localPosition.x, force);
         return(true);
     }
     return(false);
 }