private void Update() { // Shooting if (tag == "A") { // The slider should have a default value of the minimum launch force. m_AimSlider.value = m_MinLaunchForce; if (m_Controller == "Keyboard" && m_CanShoot) { // If the max force has been exceeded and the shell hasn't yet been launched... if (m_CurrentLaunchForce >= m_MaxLaunchForce && !m_Fired) { // ... use the max force and launch the shell. m_CurrentLaunchForce = m_MaxLaunchForce; Fire(); } // Otherwise, if the fire button has just started being pressed... else if (Input.GetButtonDown(m_FireButton)) { // ... reset the fired flag and reset the launch force. m_Fired = false; m_CurrentLaunchForce = m_MinLaunchForce; // Change the clip to the charging clip and start it playing. m_ShootingAudio.clip = m_ChargingClip; m_ShootingAudio.Play(); } // Otherwise, if the fire button is being held and the shell hasn't been launched yet... else if (Input.GetButton(m_FireButton) && !m_Fired) { // Increment the launch force and update the slider. m_CurrentLaunchForce += m_ChargeSpeed * Time.deltaTime; m_AimSlider.value = m_CurrentLaunchForce; } // Otherwise, if the fire button is released and the shell hasn't been launched yet... else if (Input.GetButtonUp(m_FireButton) && !m_Fired) { // ... launch the shell. m_ShootingAudio.Stop(); Fire(); } } else if (m_CanShoot) { // If the max force has been exceeded and the shell hasn't yet been launched... if (m_CurrentLaunchForce >= m_MaxLaunchForce && !m_Fired) { // ... use the max force and launch the shell. m_CurrentLaunchForce = m_MaxLaunchForce; Fire(); } // Otherwise, if the fire button has just started being pressed... else if (m_SerialController.m_Shoots [m_PlayerTeamID] && !m_Charging) { // ... reset the fired flag and reset the launch force. Set the charging flag. m_Fired = false; m_CurrentLaunchForce = m_MinLaunchForce; m_Charging = true; // Change the clip to the charging clip and start it playing. m_ShootingAudio.clip = m_ChargingClip; m_ShootingAudio.Play(); } // Otherwise, if the fire button is being held and the shell hasn't been launched yet... else if (m_SerialController.m_Shoots [m_PlayerTeamID] && m_Charging && !m_Fired) { // Increment the launch force and update the slider. m_CurrentLaunchForce += m_ChargeSpeed * Time.deltaTime; m_AimSlider.value = m_CurrentLaunchForce; } // Otherwise, if the fire button is released and the shell hasn't been launched yet... else if (!m_SerialController.GetComponent <SerialController> ().m_Shoots [m_PlayerTeamID] && !m_Fired) { //Set the charging flag. m_Charging = false; // ... launch the shell. Fire(); } } } else if (tag == "B" || tag == "C") { if (m_Controller == "Keyboard" && m_CanShoot) { // If the fire button is held and not on cooldown if (Input.GetButton(m_FireButton)) { //Fire a bullet Fire(); } } else if (m_CanShoot) { // If the fire button is held and not on cooldown if (m_SerialController.m_Shoots [m_PlayerTeamID] && m_CanShoot) { //Fire a bullet Fire(); } } } // Ultimate if (m_Controller == "Keyboard") { if (Input.GetButton(m_FireButton) && Input.GetAxis(m_AimAxisName) != 0 && Input.GetAxis(m_MovementAxisName) != 0) { if (m_UltimateCooldown == 0) { Ultimate(); m_UltimateCooldown = m_UltimateCooldownTime; } } } else { if (m_SerialController.m_Shoots [m_PlayerTeamID] == true && m_SerialController.m_AimValues [m_PlayerTeamID] != 0 && m_SerialController.m_MoveValues [m_PlayerTeamID] != 0 && m_SerialController.m_TurnValues [m_PlayerTeamID] != 0) { if (m_UltimateCooldown == 0) { Ultimate(); m_UltimateCooldown = m_UltimateCooldownTime; } } } // Rocket Cooldown if (m_RocketCooldown < 0f) { if (m_RocketNumber < 17) { m_RocketNumber += 1; } m_RocketCooldown = 1.4f; } else if (m_RocketCooldown > 0f) { m_RocketCooldown -= Time.deltaTime; if (m_RocketCooldown == 0f) { m_RocketCooldown = -1f; } } // Shooting Cooldown if (m_Cooldown < 0f) { m_CanShoot = true; m_Cooldown = 0f; } else if (m_Cooldown > 0f) { m_Cooldown -= Time.deltaTime; if (m_Cooldown == 0f) { m_Cooldown = -1f; } } // Ultimate Cooldown if (m_UltimateCooldown < 0f) { m_UltimateCooldown = 0f; if (m_Controller != "Keyboard") { m_SerialController.SendSerialMessage(m_PlayerTeamID + "U"); } } else if (m_UltimateCooldown > 0f) { m_UltimateCooldown -= Time.deltaTime; if (m_UltimateCooldown == 0f) { m_UltimateCooldown = -1f; } } }