Hey, today I’ll show our newest game, called Fire for your Life, a twin brother of already released Race for your Life. As you may know 🙂 or not yet :(, it’s a tank battle game with retro style, multiplayer and cross platform. More specifically I’ll demonstrate its game modes, which are five:
- Death match – last player in the map wins.
- Capture the flag – player with more captured flags wins or the last survival wins.
- Domination – player with more bases wins at end time or the last survival wins.
- Protect base – each player has a base, if it is destroyed his tank dies, the last survival wins.
- One shot one kill – each shot is mortal, the last survival wins.
So after that said, you noticed that each mode share one specific rule, the last tank is the winner. The point is that usually in Unity, we programmers blind ourselves in some basic object orientated programming. For example this is a good case to use a base class with common properties and functionalities.
Also provide an interface that forces classes to implement game mode functions.
Later we can create another script class that handle Domination game mode logic. Note that we don’t need to write all code checking tank deaths and so on, keeping our code clean and lean.
So next time implementing things like this I hope you can use this approach to help your game development. Here is dev video showing it in action.