Price of Opportunity – Code Samples

Jan 2023 (~5 Days, University Project)

The Price of Opportunity is a management game in which players manage a farm in South America. The game was developed during the Science, Technology, and Society game jam at Technical University Munich. The goal of was to highlight the issues faced by coca farmers in South America, who often have no real alternative but to cultivate coca if they want to survive, using a game

Team size: 2

Game Engine: Unity

Tasks: Game Design, Programming

The core of this project consists of three systems that I wrote. The buildings, the worker simulation, and most importantly the narrative event system.

Buildings

Our game has two types of buildings. Farming and production buildings. The Building class handles which type a building is, what kind of product it produces and with what inputs, as well as how much effort is required to produce that product, or whether that product can spoil if work isn’t completed in time.

Since we needed several buildings in our game we needed a system that allowed us to create different buildings with as little effort as possible.

You can find the code here

Worker Simulation

The worker simulation allows players to hire two types of workers, farmers and laborers, that provide labor to farming and production buildings correspondingly. Workers provide labor based on a number of different internal parameters and recharges over time.

The WorkerManager keeps track of all the different farming and production buildings as well as the workers. It then distributes the labor provided by workers to the different buildings which in turn yields resources for the player.

You can find the code here

Narrative Event System

One core component of our game design was a narrative event system that could affect the workers and buildings within our game and that would allow us to easily create different narrative events.

The NarrativeEventSystem class is a global singleton that keeps track of all possible events and attempts to draw a narrative event at the end of every in-game month. Whenever the NarrativeEventSystem is unsuccessful in drawing a narrative event it increases the probability of that event occuring for the next draw. If it succeeds in drawing a narrative event, it triggers it, which notifies all buildings and workers that that type of event could affect. The buildings and workers then decide how to react to that event.

Narrative events are stored by the NarrativeEventData class which is a data object storing its name, description, what kind of effects and effect modifiers it has, and the base probability with which the event should be triggered.

The NarrativeEventSystem allowed us to author content quickly and certainly did what it was supposed to do. However, I think that I ultimately overengineered the system, and a simpler system probably could have done the job just as well. I also think that the system didn’t take advantage of Unity’s component-driven architecture which could have made the whole system a lot more flexible while also reducing complexity.

You can find the code here