Solution Samples

 

A collection of software architecture models and code samples used in my game projects, such as character behaviour state machines, inventory and procedural generated map systems.

Character Behaviour State Machine

Character Behaviour State Machine UML model

Character Behaviour State Machine UML model

Above is the UML representation of a C# Behaviour State Machine implementation. It was used in Kasoré and keeps being used to aid the implementation of different character mechanics.
Benefits:

  • State based modularization, easier maintenance.

  • Possibility of creating machines for different groups of characters with different states (i.e.: PlayerMachine [Walk, Fall, Jump] and EnemyMachine [Patrol, Hunt]).

  • The entry and exit methods are executed when a state begins and right before transitioning to the next one, which helps organizing when sfx and animations should play and stop.

  • The Behaviour classes contains the implementation for the functionality of each state, in which they are called.

  • Each State inherits the State’s Update method, which works just like Unity’s Update. In this method, called every frame, there are several checks to decide if the state should transition, in to which one.

Update example

Update example

2D Procedural Map Generation

Procedural Map Generation UML Model

Procedural Map Generation UML Model

Example of a procedurally generated 4x4 map

Example of a procedurally generated 4x4 map

A system to procedurally generate maps for 2D games based on the map generation of Spelunky.

  • Generates predefined square rooms separated by types. These types are defined by the location of the room’s exit or exits.

  • The height and width of the map needs to be defined beforehand

  • The Spawner class has the the abstract method Spawn, which is implemented by its children classes, responsible for instantiating rooms, various objects and enemies to populate the map. Each spawner needs to have access to an array or list of what is designed to instantiate.

  • The logic that determines if something can spawn or where it should spawn is contained within the Level Generation class.

Simple Inventory System

Simple Inventory System ER Model

Simple Inventory System ER Model

Inventory System

Inventory System

This diagram describes a simple inventory system with 2 basic mechanics:

  • The player can pick up items.

  • The player can drop items.

Items of the same kind are grouped up on the same slot, incrementing its item quantity.

This system was used on the Pirate Ship demo to aid in quest objectives.

Long-term Relationship Model Between the Player and NPC

Simple Inventory System ER Model

Simple Inventory System ER Model

System Architecture from the game developer point of view.

System Architecture from the game developer point of view.

This is the class diagram for an academic project, which goal was to describe and implement a new relationship model between the player and the NPCs. This new model can then be used to decide an NPC’s behaviour towards the player using as basis the empathy calculated between them. To calculate that empathy we capture the player’s personality in runtime inside the Big Five Personality Model using his answers to 10 dialogues with the NPCs. This method is known as BFGI-10 ( Big Five Game Inventory 10 ).

The Big Five Personality Model represents a personality as a set of 5 traits:

  • Openness to new experiences

  • Conscientiousness

  • Extraversion

  • Agreeableness

  • Neuroticism

Each trait has its own way of being determined, which is why the method CalculateTrait is overriden in each one.

The empathy model I developed consists of 5 levels of empathy between the player and the NPC, each defining how the NPC will behave in relation to the player ( i.e.: being helpful, neutral or actively trying to make the player’s objective harder ):

System architecture from the player’s point of view.

System architecture from the player’s point of view.

  • Sympathetic

  • Comprehensive

  • Neutral

  • Incomprehensive

  • Unsympathetic

Anterior
Anterior

Melting Escape