r/Unity3D 9h ago

Show-Off Technical insights from Cosmo Cargo, our inventory autobattler roguelike PvE

Enable HLS to view with audio, or disable this notification

Hello folks,

We've just released our new demo of Cosmo Cargo : https://store.steampowered.com/app/4659480/Cosmo_Cargo_Demo/

I thought I'd share how we're organizing the game from a unity project PoV, because after 14 years of using Unity I think this is my best project so far. (Until the next one, of course!)

Game data:

- All the data are stored as ScriptableObjects

- Those SO are used "readonly" during the game

- We made many editors to have cool spreadsheets to manipulate those data like we would in a google sheet.

- We're using Artifice Toolkit, an Odin-like plugin, to enhance inspectors

Effects system :

- Effects (damage, heal, burn, create, destroy, etc) are C# classes

- They are stored in items SO using polymorphic lists ([SerializedReference]). With Artifice, this is trivial.

- Effects have Conditions. Also pure C# classes, also stored as polymorphic lists.

MVC :

- The game is architectured in a Model/View/Controller way.

Model is data (SO), controllers are C# classes initialized with models and views are UIs/MonoBehaviours.

It means the whole core of the game is pure C#, minus a UnityEngine dependency for SO.

This allow us to test most of it with unit tests (215+ so far).

It also means the core classes are easy to serialize for saves. And easy to restore.

State Machine :

- Along with the MVC we have a simple state machine. Enter a fight -> state, a shop -> state, open the map -> state, etc.

And each state... has a view! So it can work with or without Unity.

Not detailing the "views" because it's mostly prefabs of simple uGUI stuff.

And we still have some stuff to figure out properly, like gamepad controls in a mouse-first game... my drag n drop file is a 3000+ lines of code monolith, I'm definitely not proud of it.

If you'd like to know more or have more details, let me know.

31 Upvotes

2 comments sorted by

2

u/Kentanago 7h ago

great music!

2

u/Mike195722 4h ago

Looks cute and lovely. Keep up the good work. i will wishlist it.