Systems Dev - Network Multiplayer Upgrade System
Purpose
Develop a light-weight, flexible and iterable upgrade system that works within the framework of Photon’s Fusion Network Multiplayer solution for Unity.
Decoupled classes with clear separation of concerns between interface, logic, and data.
Support pre-production design exploration with modular code that supports significant changes to the purchasing mechanics.
Implement the current state of the design (see requirements).
Requirements
Upgrade mechanical design requires:
Upgrades acquired through interacting with vending machine
Players must purchase credits at any given vending machine using their individual funds
Purchased credits allows any player to roll a set of 3 upgrade offers
The upgrade offers are purchasable until a visible timer reaches 0
Players may purchase any or all of the upgrade offers they can afford with their funds
While players are interacting with a vending machine, they cannot move or shoot
Potential future rules:
Only one player may interact with a vending machine at a time
The cost of tokens increase based on the number of tokens purchased previously at that machine
The cost of tokens decreases as time goes on
The cost of upgrades increases for every upgrade a player’s avatar has
Constraints
The project supports 2 player cooperative play over HOST-CLIENT topology.
Photon Fusion considers Remote Procedural Calls (RPCs) to be relatively less reliable than object spawning.
Fusion does not permit a native method to support state synchronization of collections => upgrades as pure data require additional bandwidth to upkeep.
Solution
Upgrades are genericized prefabs that are instantiated using Fusion’s NetworkSpawn() function to permit for state synchronization and lifecycle management without bandwidth consuming upkeep.
The upgrade prefab self initializes based on network events so performant data-only model of upgrades per avatar can be used to calculate changes in avatar stats and behaviors.
The upgrade prefab also permits for HOST simulated behaviors for future upgrades’ mechanical expansion.
VENDING MACHINE UI code is decoupled from UPGRADE CONTROLLER by use of a simple interface.
UPGRADE CONTROLLER is decoupled from INPUT STATE CONTROLLER by use of an EVENT and EVENT MANAGER system.
Data required for the View and Controller codes are stored externally and is readable through Service Locator pattern.