简体   繁体   English

高效的视频游戏服务器数据存储?

[英]Efficient video game server data storage?

I'm currently developing a multiplayer iOS video game where I want the players data to be stored in the cloud. 我目前正在开发一款多人iOS视频游戏,希望将玩家数据存储在云中。 In the game the player creates an area by placing items, planting trees etc which other players can then visit and walk around in realtime. 在游戏中,玩家通过放置物品,种植树木等来创建区域,其他玩家随后可以实时访问并走动。

From the game map side what needs to be stored is: 从游戏地图的角度来看,需要存储的是:

  • A 50x50 tile grid - The type of tile (grass etc) and the height of the tile 50x50的瓦片网格-瓦片的类型(草等)和瓦片的高度
  • All of the placed items and any associated item specific data (A tree for example would store when it was planted) 所有放置的物品以及任何相关的物品特定数据(例如,一棵树将在种植时存储)

On the player side I need to store their: 在播放器方面,我需要存储以下内容:

  • Character customisation 角色定制
  • Inventory 库存

The information would need to be read fairly infrequently (every time a client connects to the area) but would need to be written back to fairly regularly (every time an item is placed etc) so that any future connecting client would be reading the correct data. 信息将需要很少被读取(每次客户连接到该区域时),但需要被相当定期地写回(每次放置物品等),以便将来的任何连接客户都将读取正确的数据。 。

My question really is where to start with regards to storing this data in an efficient way for the server? 我的问题确实是从服务器的高效存储方式开始呢? I considered using several XML files to store different portions of the map and then storing each of the other parts (Inventory, Character etc) in their own XML file. 我考虑过使用几个XML文件存储地图的不同部分,然后将其他每个部分(库存,角色等)存储在各自的XML文件中。 But is this the most efficient way of doing it from the servers perspective? 但这是从服务器角度来看最有效的方法吗? I want to minimise the amount of data it has to write back when the client updates :) 我想最小化客户端更新时必须回写的数据量:)

TL;DR: Use a database and the Unity plugin for said database. TL; DR:使用数据库和用于该数据库的Unity插件。

Managing an XML file via server is just going to cause a bunch of file locking/synchronization problems that you shouldn't be dealing with manually (unless, this is the focus of your project/research). 通过服务器管理XML文件只会引起一系列文件锁定/同步问题,您不应该手动处理这些问题(除非这是您的项目/研究重点)。

There are plenty of database backends that you can use, and that work well with Unity. 您可以使用很多数据库后端,并且它们可以与Unity很好地协同工作。 A few I can think of off-hand: 我能想到的一些辅助功能:

• Parse.com --- they have a Unity plugin •Parse.com ---他们有一个Unity插件

• Write your own HTTP-based web server (in PHP/MySQL, JavaScript, Ruby, whatever) and then use a REST interface library (a bunch on the Unity Asset Store) to talk to it and store your data. •编写您自己的基于HTTP的Web服务器(使用PHP / MySQL,JavaScript,Ruby,等等),然后使用REST接口库(Unity Asset Store上的一堆)与之对话并存储您的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM