Arcade
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Step 7: Challenge

Just for fun, let's make things get tougher over time.

  • In GameStage.cs, keep track of how long the player's survived with the _elapsedTime variable. Increment it with the Timestep property in OnUpdate.
  • In GameStage's SpawnBullets coroutine, make the delay between shots get shorter over time:
float delay = Mathf.Max(0.5f - _elapsedTime * 0.01f, 0.05f);
  • In the constructor in Bullet.cs, increase the max movement speed of created bullets as the elapsed time increases:
float maxSpeed = Mathf.Min(40.0f + (elapsedTime * 1.5f), 400.0f);
_moveSpeed = Mathf.Random(40.0f, maxSpeed);
  • And pass in _elapsedTime when creating new bullets in GameStage.cs:
Bullet bullet = Add(new Bullet(movingDownward, _elapsedTime), 1);

Prev Page :: Back to Index :: Next Page