-
Notifications
You must be signed in to change notification settings - Fork 1
Configuring Entities
Entities can be configured using config files with pre-defined properties. This makes gameplay testing easier as the gameplay experience can be tweaked without having to edit code.
The core idea is that the FileLoader
reads JSON config files which store entity properties such as attack: 10
or health: 100
and transforms them into config classes. The properties can then be read from these config classes and passed into the entity creation methods in Entity Factories.
-
File Loader - :
FileLoader
. -
Entity Factory - Factory for creating similar types of entities: e.g.
PlayerFactory
,NPCFactory
. -
Group Config Class - Defines the config classes for groups of entities: e.g.
NPCConfigs
. -
Config Class - Defines a config class with default properties: e.g.
PlayerConfig
,BaseEntityConfig
,GhostKingConfig
, etc. -
Config File - JSON file with values for properties that are defined in the corresponding config class or group config class, e.g.
NPCs.json
,player.json
.
In this example, we're going to look at how to use properties stored in the player's config file.
Config File - "configs/player.json":
{
"health": 100,
"baseAttack": 10
"gold": 50,
"favouriteColour": "peach"
}
Config Class:
public class PlayerConfig {
public int health = 1;
public int baseAttack = 0;
public int gold = 1;
public String favouriteColour = "none";
}
Load config using the FileLoader
:
private static final PlayerConfig stats = FileLoader.loadClass(PlayerConfig.class, "configs/player.json");
int health = stats.health;
int baseAttack = stats.baseAttack;
int gold = stats.gold;
String favouriteColour = stats.favouriteColour;
When we have multiple entities with similar properties, it is useful to be able to store all of their configs in a single JSON file. The following is an example of this for multiple NPC entities.
Config File - "configs/NPCs.json":
{
"ghost": {
"health": 40,
"baseAttack": 10
},
"ghostKing": {
"health": 100,
"baseAttack": 25
"spookyFactor": 7
}
}
Group Config Class:
public class NPCConfigs {
public GhostConfigghost = new GhostConfig();
public GhostKingConfig ghostKing = new GhostKingConfig();
}
Config Classes:
public class GhostConfig {
public int health = 1;
public int baseAttack = 0;
}
public class GhostKingConfig extends GhostConfig {
public int spookyFactor = 0;
}
Load configs using the FileLoader
:
private static final NPCConfigs configs = FileLoader.loadClass(NPCConfigs.class, "configs/NPCs.json");
GhostConfig ghostConfig = configs.ghost;
GhostKingConfig ghostKingConfig = configs.ghostKing;
int ghostHealth = ghostConfig .health;
int ghostBaseAttack = ghostConfig .baseAttack;
int ghostKingHealth = ghostKingConfig .health;
int ghostKingBaseAttack = ghostKingConfig .baseAttack;
int ghostKingSpookyFactor = ghostKingConfig.spookyFactor;
- Uniform Pixel Grid Resolution
- Storyline
- Instruction
- NPC info
- NPC Communication Script
- Inventory-System-and-Consumables
- Storyline User Test
- Traitor Clues
- Game Characters
- Player Profile User Test
- Player Eviction Menu Sprint1: User survey (Team 7)
- Player Eviction Menu Sprint2: User survey (Team 7)
- Sprint3 - Win/lose Condition: User survey (Team 7)
- Sprint4 - Polishing-tasks: User survey (Team 7)
- Transition Animation/Special Effects/Sound Effects: Feature Overviews
- Transition Animation and Effects: Design Process & Guideline
- Sprint 4 User Testing
- Transition Animation & Effect: Code Guideline-Sprint4
- Sound effect when players complete npc tasks and hover over npc cards
- Fixing the clue bug
- Music Test
- Player Eviction Menu: Design Process & Guideline
- Player Eviction Menu (Feature Overviews)
- Player Eviction Menu: Code Guideline - Sprint1
- Sprint 1 User Testing
- Detailed Eviction Card: Design Process & Guideline
- Detailed Eviction Card: Feature Overviews
- Sprint 2 User Testing
- Player Eviction Menu: Code Guideline - Sprint2
- Sprint 2 Inventory System and Consumables Items User Testing
- Sprint 2 Inventory System and Consumables Items Functionality
- NPC interaction testing plan sprint3
- NPC interaction testing results sprint3
- NPC Dialogue Scripts
- Code Guideline
- Win/lose Condition: Design Process & Guideline
- Win/lose Condition: Feature Overviews
- Sprint 3 User Testing
- Win/lose condition: Code Guideline - Sprint3
- Enemy List
- User Testing 1: Enemy Image Filter
- User Testing 2: Enemy Animation and AI
- User Testing 3: Basic Attack