Page 1 of 1
Unity and Smartfox Server logic sharing
Posted: 24 Dec 2018, 08:12
by Henrryparth
I'm going to have a singleplayer and multiplayer mode. I want to avoid
http://movieseriesworld.com/ having 2 versions of my game logic. What's the best way to do this? My best guess is writing all core game logic in C++ so that it can interface with both Unity (C#) and SFS (Java), but maybe there's a better solution suited for this.
Re: Unity and Smartfox Server logic sharing
Posted: 24 Dec 2018, 08:24
by Lapo
Hi,
I don't know if using C++ is the best of ideas. Interfacing C++ with Java is a tedious job and it makes writing and debugging server side core more complex.
Generally speaking I don't think it's necessary to add C++ in the mix.
What you may want to do is abstract the parts of your game logic with interfaces so that you can swap their implementations with a single player or multiplayer versions, based on which mode is being played.
To give you an example: in single player mode you want your enemies to be controlled by the game's AI, while in multiplayer mode they will be controlled by actual players.
You can abstract these players with an interface and then implement the specific single player and multiplayer versions and activate them at runtime.
Hope it helps