How to organize classes more than one GameMode/GameState.

Luqaz
Wed, 07 Feb 2024 18:48:55 +0000
Programming & Scripting

Looking for some advice how to organize communication between Game Modes, Game States, Characters etc.
I’m facing a problem, when I have one a bit complex PlayerCharacter class where part of the functionality is directly related with specific game mode.
I’m aware that’s not the perfect solution and that’s why I would like to get some hints how to organize it better. Maybe, some of you have an experinence in managing more than one GameMode/GameState with the same character. I mean about using the same character class for let’s say GameModeTeamDeadMatch and GameModeSearchAndDestroy.
I have some ideas, but i’m not sure which one I shoud go for:

1. Delagates for character related events.
Each specific character event should be handled on delagates. E.g when the player is dead, Character class broadcasts on a “Dead” delagate.
Each GameMode should implement character dead event by itself, e.g GameModeTeamDeadMatch has it’s own implementation for OnPlayerDead() which is binded to player character “Dead” delagate and GameMode respawns a player after some short delay. In case GameModeSearchAndDestroy will be respawned at the beggining of the next round.

2. Game mode/Game state intefaces interface
From character perspective, each communication with GameMode or GameState should be done through common interface.
Each specific GameMode/GameState implements the Interface by it self to provide a custom functionality.

3. More OOP architecture

Specific character class for each game mode. The first would be some basic character with common functionality for all modes(movement, shooting etc.).
Child classed created for specific modes, e.g PlayerCharacterDeadMatch which works only with GameModeTeamDeadMatch, and other PlayerCharacterSearchAndDestroy which is used only for GameModeSearchAndDestroy. Child character classes adds some specific per mode functionality to the character, e.g PlayerCharacterSearchAndDestroy can equip/plant/defuse bomb.

Thanks in advance to any advice.

3 posts - 3 participants