// Update is called once per frame private void Update() { fireTimer += Time.deltaTime; int ret; if (ammosystem.bullet == 0) { Debug.Log("Reloading"); if (reloadtimetracker == 0) { SoundManager.PlaySoundEffect(SoundManager.SoundEffect.Reload); } reloadtimetracker += Time.deltaTime; if (reloadtimetracker >= ReloadTime) { Debug.Log("Reloaded"); ammosystem.Reload(); reloadtimetracker = 0; } } //If wiimote is assigned if (wiimote != null) { //Read Data do { ret = wiimote.ReadWiimoteData(); } while (ret > 0); if (wiimote.Button.a) { if (ammosystem.bullet != 0) { if (fireTimer >= FireRate && overheat.overHeated == false) { if (player.IsAlive) { Fire(); //Update the Ammo Bar ammosystem.AmmoUpdateUI(); } } } } else if (wiimote.Button.home) { UIPanelManager.ShowUIPanel(UIPanelManager.UIPanel.ReturnToMainMenu); } else { //Decrease the heating guage every 0.5 second overheat.CoolDownHeating(); //Decreasing bullet spread over time currentBulletSpread -= Time.deltaTime * SpreadIncreaseRate; if (currentBulletSpread <= defaultBulletSpread) { currentBulletSpread = defaultBulletSpread; } } } //Fall back on Mouse Input else { //If Left Click if (Input.GetMouseButton(0)) { if (ammosystem.bullet != 0) { if (fireTimer >= FireRate && overheat.overHeated == false) { if (player.IsAlive) { Fire(); //Update the Ammo Bar ammosystem.AmmoUpdateUI(); } } } } else if (Input.GetKeyDown(KeyCode.Escape)) { // Show the going back to main menu panel UIPanelManager.ShowUIPanel(UIPanelManager.UIPanel.ReturnToMainMenu); } else { //Decrease the heating guage every 0.5 second overheat.CoolDownHeating(); //Decreasing bullet spread over time currentBulletSpread -= Time.deltaTime * SpreadIncreaseRate; if (currentBulletSpread <= defaultBulletSpread) { currentBulletSpread = defaultBulletSpread; } } } overheat.CoolDownWhileShooting(); //Wiimote detected and connected if (wiimote != null) { //Setting final position to IR's detected position float[] pointer = wiimote.Ir.GetPointingPosition(); //Mapping the position to screen PointerPosition.x = pointer[0] * Screen.width; PointerPosition.y = pointer[1] * Screen.height; } else { PointerPosition = Input.mousePosition; } Crosshair.transform.position = PointerPosition; if (player.Health <= 0) { UIPanelManager.ShowUIPanel(UIPanelManager.UIPanel.GameOver); } }