/// <summary> /// Updates the Gun Status /// </summary> /// <param name="newStatus">The new status for the Tank Gun</param> void UpdateGunStatus(GUN_STATUS newStatus) { switch (newStatus) { case GUN_STATUS.GUN_READY: gunStatus = GUN_STATUS.GUN_READY; break; case GUN_STATUS.CHARGING: gunStatus = GUN_STATUS.CHARGING; break; case GUN_STATUS.MAX_CHARGE: gunStatus = GUN_STATUS.MAX_CHARGE; break; case GUN_STATUS.REARMING: gunStatus = GUN_STATUS.REARMING; break; case GUN_STATUS.NONE: gunStatus = GUN_STATUS.NONE; Debug.LogError("TankGun status is currently NONE"); Debug.LogError("Check the reload timer"); break; default: break; } OnGunStatusUpdate(); }
private void Awake() { gunTransform = GetComponent <Transform>(); _audioSource = GetComponentInParent <AudioSource>(); if (!gunTransform) { Debug.LogError("No gun transform set in TankGun instance on " + gameObject.name.ToString() + ", setting gun transform to parent transform"); gunTransform = gameObject.transform; } if (!projectile) { Debug.LogError("No projectile found on " + gameObject.name.ToString() + ", you probably forgot to set it in the Inspector!"); } if (!_audioSource) { Debug.LogError("No Audio Source found on " + gameObject.name.ToString() + ", creating one now.."); _audioSource = gameObject.AddComponent <AudioSource>(); } if (!fireSound) { Debug.LogWarning("No Fire Sound provided for TankGun!"); } if (!rearmSound) { Debug.LogWarning("No Rearm Sound provided for TankGun!"); } if (!maxChargeSound) { Debug.LogWarning("No Max Charge sound provided for TankGun!"); } _reloadTime = 1; _maxChargeTime = 2.0f; _gunCharge = 0.0f; isReadyToFire = true; isChargeCuePlayed = false; gunStatus = GUN_STATUS.GUN_READY; }