Skip to main content

Fast Game Development in C#(Unity, ET, MongoDB)

This is the continue of the previous blog fast prototyping of a new game project. With the ET game framework(refer to https://github.com/egametang/Egametang), and lack of server support, I decide to continue my attempt to develop our a game all in C#. The progress become very fast, due to following factors.

1. A fast UI making approach.

UI has been one of most time consuming work during game development. Managing buttons/labels is extremely tedious when there are lots of UI pages.

There is a simple way to handle UI. Take NGUI for example, we assemble the UI widget in a prefab, and drag a list of widgets(example, buttons, labels) in a script, click a button to auto-generate all the boilerplate code. The auto-generated code could be just two files, one view script one control script. For example, Login UI panel, three scripts would be generated, Login_C, Login_V, Login_M. In Login_V, all the widget assignment related code is generated, in Login_C, the value of widget is assigned.  All model related info is stored in Login_M. This way is kind of MVC.

The UI system has been made to be extremely user friendly. After assembling the UI panel, with one button click and two line of code change(to register the panel in the UI system, and define the layer of UI), a UI is considering  visually done. The rest of the work is just linking up with the game model.


Also, WrapContent Grid List is implementeded into the UI system. So HorizontalWrapContent, VerticalWrapContent and SlopyVerticalWrapContent are all included. This make the knowledge of making UI available as a tool to everyone.

2. Powerful design of ET game framework

ET game framework is designed extremely modular. It is powerful enough to handle all the server related functions. You just need to fill in the gameplay related code. Everything else, let the actor-component-based game server do for you.

3 NoSQL

I have experience in using mssql, and dynamodb(amazon's nosql db service) in two projects. My general feeling is that NoSQL is easier to develop. With C# define the schema, json is stored and retrieved and can convert to C# directly.

MongoDB is directly supported in the ET framework.  Within one day, I installed the Mongodb and store the player data as document in mongodb and link it with ET game server.

4. Property System

Managing game state manually is tedious. As there are so many game state related logic, each time, a state related value is modified, you need to decide whether the data should be synchronized to client.

Property system is a good helper to handle all the tedious work. Each player in the client/server share a list of properties, for example, health property, position property. When a property is modified,  for example health property, the health property would be marked with modified frame-count,  then the property system could decide whether the health property(and all other properties) should be synchronized to client by checking the modified frame-count and other factors in the update-checking frame.

One layer property system has some limitation. For each example, BagItemProperty is used to store all the items in the bag. In one layer property system, a single item change would cause the whole BagItemProperty to resend to client which is a waste of bandwidth. Now I add two layer property system, the  BagItemProperty could consist of a list of ItemCountProperty, and I only send the ItemCountProperty which is modified to client.

Overall, with property system, a delta-game-state is auto-generated. and with a self-defined network serialization/de-serialization protocol, the delta-game-state would be auto updated to game client.


5. Sharing of Code between Server/Client

As all the code is done in C#, code could just be shared.

For example, in the resource level,  in the front, all the game setting files(in json format) is loaded in the client side.  Without modify a line of code, just by sharing the folder between the server and client project, the server side would have all the game related setting.

In the gameplay level, all the property system related code is shared between server and client. so that there is no way that property list could be mis-matched.

 6. Behavior tree style buff system
Buff plays an important role in turn based games. Behavior tree is widely used for AI in games. Each buff is very much a mini-behavior tree. There are preconditions, and effects for each buff.  Very much like the condition node and action node in behavior tree.

Behavior tree can easily turn buff design documents into a graph of tree node structure. After drawing the tree, the rest of the work is implement the logic of each tree node(condition node, action node).

Final words
C# has becoming a good language for game development. Less room to make mistake, coding is much simpler with the available of async, await after C# 4.0.  With all the above listed adoption/approaches, in one week, from my previous prototype, I have managed to have a simple database which could store player's information(including items, quests), and front end could show  items, bags, players moving around with the help of one colleague.

With the game making processing more like a machine assembly pipeline, I plan to dive back into C++ for a breath of fresh air.

Comments

  1. Extraordinary post! I am impressed by your writing skill, I wants to praise your efforts that you put in this post. Thank you so much dear. I also wants to suggest the best Unity 3D Game Development Services

    ReplyDelete
  2. I am really happy to say it’s an amazing post to read. I learn new information from your article, you are doing a great job. Keep it u

    Poker Game Development Company

    ReplyDelete

Post a Comment

Popular posts from this blog

Tech note: Java Virtual Machine(JVM) vs Erlang Runtime System(ERTS)

Java is my first language. From third year of undergraduate, I switched to C++ because of image processing/computer graphics related course work. After graduation, I never use Java as Java is not used frequently in the game industry. Elixir is my most recently language.  It is derived from Erlang. I know Elixir follow the path of Unity->Ulink->Riak(Ulink's default database option, which is written in Erlang)->Erlang->Elixir(derivation of Erlang). Follow this path comes with Phoenix(one of most recently web-framework). Now, I have many programming language friends, Java/C++/C#/Python/Elixir and some niche languages. To know a programming language, I only have to know the machine and how the machine speaks the language . Particularly for Java and Elixir, the core is how their underlying virtual machine works.  In Erlang/Erlang virtual machine case, I was forced to think the relationship among OS processes, OS threads and CPU cores.  To make it simple, 1. ...

A simple prototype to MOBA in Unity C#

Recently, I have been fast prototyping a new game project.  Here is the approach. 1. FontEnd--Hotfix Support Hotfix is essential, only in China, for better customer experience and more buggy apps. Lua vs ILRuntime(C#) Both of the hotfix approaches using interpretor to interpret files(Lua, IL Dll). They share roughly same performance. As Unity supports Code in C#, it makes ILRuntime the perfect approach for hotfix using ILRuntime as front end programmers only need to focus on one language C#. AOP Hotifx With well structured design of front end, you can make Unity runs all compiled C# code without ILRuntime initially, and only trigger ILRuntime after hotfix happen, as these C# files are identical. 2. Backend--Network ORUDP(Ordered Reliable UDP) is used in MOBA and Lidgren is the great open source networking solutions on UDP.  Lidgren could integrate into Unity with little effect with all the github samples around. 3. Backend--Property System Property systems are us...