// Update is called once per frame void Update() { switch (CurrentState) { case xbowState.idle: break; case xbowState.shoot: if (Time.time > nextTimeFire) { if (target_ != null) { shoot(); nextTimeFire = Time.time + gameObject.GetComponent <towerInf>().fireRate; } else { CurrentState = xbowState.idle; } } break; } }
public void stopShoot() { CurrentState = xbowState.idle; target_ = null; }
public void shoot(GameObject targetGameObject) { CurrentState = xbowState.shoot; target_ = targetGameObject; rotation(); }