/// <summary> /// Update() /// Called once per frame /// </summary> void Update() { if (!lockdown) { // Ship movement shipMovement.InputForward = Input.GetKey(shipForward); shipMovement.InputBackward = Input.GetKey(shipBackward); shipMovement.InputLeft = Input.GetKey(shipLeft); shipMovement.InputRight = Input.GetKey(shipRight); // Shooting shipShooting.InputShoot = Input.GetKeyDown(shipShoot); // Game start if (Input.GetKeyDown(gameStart)) { shipInfo.OnCollision(); guiHandler.Stage = 1; asteroidSpawner.InputStart = true; } } else { shipMovement.InputForward = false; shipMovement.InputBackward = false; shipMovement.InputLeft = false; shipMovement.InputRight = false; shipShooting.InputShoot = false; } }
/// <summary> /// Update() /// Called once per frame /// </summary> void Update() { // Asteroid/Bullet collisions foreach (Transform asteroid in asteroidContainer) { foreach (Transform bullet in bulletContainer) { if (Collision(asteroid, bullet)) { asteroid.GetComponent <ObjectInfo>().OnCollision(); bullet.GetComponent <BulletInfo>().OnCollision(); playerData.AddScore(); } } } // Asteroid/Ship collisions if (!shipInfo.isInvincible) { foreach (Transform asteroid in asteroidContainer) { if (Collision(asteroid, ship.transform)) { asteroid.GetComponent <ObjectInfo>().OnCollision(); shipInfo.OnCollision(); playerData.LoseLife(); if (playerData.Lives == 0) { EndGame(); } break; } } } }