Author Topic: TNET for mobile MMO in offline mode  (Read 1846 times)

vikti

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 25
    • View Profile
TNET for mobile MMO in offline mode
« on: September 12, 2014, 04:59:09 AM »
Hi,

I wonder if TNET could fit my needs.

I am working on a MMO for mobile. I have :
- a WorldServerModel which is the representation of all objects (monster, player, items...) on the whole map.
- a LocalWorldModel which is the representation of all objects in a specific region around the player.
- a PlayerWorldModel which is the representation of all objects concerning the player in a specific region around the player (leveled monster, equipable item, pickable resource...)
- MapModels, InventoryModels, etc... representing objects concerning the player and formated for different Views (I also work with NGUI databinding)

I want my game to be playable in offline mode :
- The player picks, drop, sell, craft... items available in his LocalWorldModel
- Once online, the LocalWorldModel syncs with WorldServerModel to add the modification.

I also want my game to be playable in online mode :
- The player picks, drop, sell, craft... items available in his LocalWorldModel
- LocalWorldModel WorldServerModel syncs like any other online game.

Do you think TNET could be usable for the two cases ?

Regards

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNET for mobile MMO in offline mode
« Reply #1 on: September 13, 2014, 03:46:43 AM »
Sure, you can. I would suggest making good use of TNet's DataNode class. It can store any custom data in a hierarchical structure, easily retrievable and serializable in both text and binary formats.

What I do in Windward is this:

1. Player connects to the server.
2. First thing player does is requests its save file, for example "myplayer.dat" via TNManager.LoadFile.
3. Server loads this file for him and sends back the binary data if it's present.
4. Player loads the DataNode from that data, or if there isn't any -- creates a new DataNode.
5. Player sets TNManager.playerData to this dataNode and calls TNManager.Sync() so all players have access to it.
6. This data is now accessible via TNManager.playerDataNode (yours), as well as through player.dataNode (other players').
7. Whenever I modify something in that data tree, I just call TNManager.SyncPlayerData().
8. When it's time to save, I do TNManager.SaveFile, passing the same filename ("myplayer.dat").

All this functionality works seamlessly whether you're online or offline.