Skip to content

UGS Overview

harland-jensen edited this page Oct 4, 2022 · 12 revisions

Summary

The Unified Grid System (UGS), is a grid system which will be designed for the use of the whole studio, and will store the state of the game.

What is the UGS?

The UGS is a square grid which stores the state of all areas in the game which can be interacted with by entities. This grid consists of tiles which have various attributes, including:

  • What (if any) entity is present in the tile
  • What type the tile is (e.g. "Grass" or "Water")

Each tile has an x,y 'coordinate' which is the key to a hashmap that has a Tile associated with it.

More code-specific detail about the UGS can be acessed here.

Why is a UGS needed?

Upon evaluating the code and progress made by all teams in sprint 1 and 2, there is a noticeable underlying issue revolving the integration of different coordinates systems used by most teams. Multiple different features had implemented their own coordinate systems to the detriment of the overall game.

From research and testing it was recognised that an updateable, deterministic world state is needed to improve the playability of the game.

Benefits

With a Unified Grid System, several current game bugs will have a simple solution. The table below outlines some of the major issues and the proposed solution using UGS.

Major Issue Proposed UGS solution
Entities being placed on top of each other UGS will store the state of every game tile including if it is occupied or not. Before entities are added to the map their position will be checked against the UGS.
Main character moving freely relative to the map in their own coordinate plane UGS will be consulted before the player moves. If the user’s input for the player is invalid the player will simply not try to move and the user will be alerted that their input is an illegal move.
Enemy path finding UGS will be a deterministic representation of the state of the game. This deterministic property allows for the simple implementation of popular search/path finding algorithms such as BFS, DFS, UCS, Dijkstra’s, A*.
Entities can walk and be placed anywhere regardless of island size UGS will allow for hard limits / predefined rules to be set for the generation and movement of objects. For example, the main character cannot walk on water tiles, or no character can walk on building tiles, or the shipwreck can only spawn on the shore.
Building range attack component UGS will allow for buildings to know the state of the game including the position of all characters and objects. This allows them to easily only attack enemies in specific ranges along with support for projectiles.
Entity scale relative to other entities (i.e the player is bigger than a building, the shipwreck is the same size as a tree, etc) With UGS several grid points can be easily grouped together and point to the same entity. This allows entities to take up more than one map tile with the scaleEntity function. (i.e. the shipwreck can be assigned to take up 5x4 map tiles allowing the game to scale it accordingly)

Sequence Diagram

A typical use scenario for the UGS is shown below, demonstrating the integration required amongst many game systems (in this case between enemy NPCs and the Player's character), in a situation where the main character is trying to move onto a tile occupied by an enemy. image

The steps in this scenario are described by:

  1. Before the enemy entity is spawned, the Tile's type is verified by calling getTileType
  2. The Tile's type is verified and the enemy entity sets its location in the UGS by calling setEntity
  3. During the game, the player's character attempts to move onto the Tile occupied by the enemy, first it verifies the Tile type
  4. The Tile's type is verified and the player attempts to move onto the Tile by calling moveEntity, however, given that the enemy is currently occupying the tile, the player's move is rejected.

Future Expansion

In general for future expansion for the UGS, research should be conducted with developers (seeing as players are not exposed to the UGS), to determine whether any additional information should be stored / accounted for by the UGS. This would add additional complexity and depth to the system.

Table of Contents

Home

How to Play

Introduction

Game Features

Main Character

Enemies
The Final Boss

Landscape Objects

Shop
Inventory
Achievements
Camera

Crystal

Infrastructure

Audio

User Interfaces Across All Pages
Juicy UI
User Interfaces Buildings
Guidebook
[Resource Management](Resource-Management)
Map
Day and Night Cycle
Unified Grid System (UGS)
Polishing

Game Engine

Getting Started

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally