I’m developing a board game in Unity, similar to chess, 2 players on a tiled board. The other player can be an AI, or a human in multiplayer mode. For easier development, my plan is to write all game logic in pure C# classes, with no dependency to Unity classes. Then I can write test cases and develop the AI more easily. Would be something like this: GitHub - tomi901/Unity-Chess-MVC: A Chess game made with Unity to learn the MVC, thanks to that you could reuse the code in another engine (Using the Model folder).
The individual cells of the board will be prefabs, because they can be more complex with animations etc. But how would I implement the GUI? I guess a simple concept would be to write a class, which reads the data model objects and instantiates the prefabs each frame and attach it to a GameObject. But I guess the instantiate calls are expensive regarding runtime and memory? Would be also a problem for animations and effects, because they are only visual and not model driven. Is there a better way?
For the multiplayer support I think it would be best to run a C# server as well. In single player mode the server classes would just run locally, no changes in the rest of the program needed (at least during the game play, of course extra work is required for match making in multiplayer mode). The server would implement the game logic and provide the data to the clients, including fog-of-war restrictions, so no client has access to the full data to avoid cheating in multiplayer mode.
What network library would you recommend? It is a turn based game, I don’t think I need something big like Multiplay and can just roll my own C# server for it. Some years ago I wrote a multiplayer server in Java for hundreds of clients, also for a turn based game, was not that much work.