a practical architecture design for mmo casual game

36
A Practical Architecture Design For MMO Casual Game Ngô Thái An

Upload: actionvn

Post on 10-May-2015

4.375 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: A Practical Architecture Design for MMO Casual Game

A Practical Architecture Design For MMO Casual Game

Ngô Thái An

Page 2: A Practical Architecture Design for MMO Casual Game

Content

• Happy Me• Architecture Overview• Architecture Detail

Object Management SystemServer-Client Data SynchronizationNetwork Message Dispatching System

Page 3: A Practical Architecture Design for MMO Casual Game

Happy Me

Page 4: A Practical Architecture Design for MMO Casual Game

Happy Me

• MMO casual game• Room-based active server• Web-based Unity3D client• Run on social platform

Page 5: A Practical Architecture Design for MMO Casual Game

In-game screenshots

Page 6: A Practical Architecture Design for MMO Casual Game

About technical team

• 3 system and framework developers• 4 game developers• 12 months of development

Page 7: A Practical Architecture Design for MMO Casual Game

Architecture Overview

Page 8: A Practical Architecture Design for MMO Casual Game

MMO game physical architecture

Database

Game Servers

Client

Internet

Page 9: A Practical Architecture Design for MMO Casual Game

Game data, logic, presentation

Server Side Client Side

Game Logic

PresentationOf A Player

PlayerData

PlayerData

PlayerData

PresentationOf A Room

Page 10: A Practical Architecture Design for MMO Casual Game

MODEL

CONTRO-LLERVIEW

Which design to adapt ?

Page 11: A Practical Architecture Design for MMO Casual Game

A minimalist game system

Object Management

System

Network Message

Dispatching System

Auto Synchronization Framework

REQUIRE

REQUIRE

MAKE OUR LIFE EASIER

Page 12: A Practical Architecture Design for MMO Casual Game

Initial requirements

• Object management system MVC design pattern Dynamic data

• Auto synchronization framework Truly automatic («Set» and forget style) Synchronize the delta difference only

• Network message dispatching system Custom structure message Easy to register messages and invoke

handlers

Page 13: A Practical Architecture Design for MMO Casual Game

Object Management System(MVC Design)

Page 14: A Practical Architecture Design for MMO Casual Game

Overview diagram

Model

View

Controller

(gameplay logic)

Database

Network Message

s

View

Controller

(graphic logic)

Server Side

Client Side

Unity3D

3D Models

Database

Model

Page 15: A Practical Architecture Design for MMO Casual Game

MVC objects mapping

Model

View

Controller

Game Objects

Object Views

Game Logic

Modules

Rooms

Page 16: A Practical Architecture Design for MMO Casual Game

Detail diagram

Game Objects

Object Views

Game Logic

No-SQL(Storage)

Network Message

s

Object Views

Graphic Logic

Server Side

Client Side

SQL(Ranking,

Log)

Database

Game Objects

Modules Modules

Rooms Rooms

Page 17: A Practical Architecture Design for MMO Casual Game

General purpose base object

Object

Rooms

ObjectViews

ModulesGame

Objects

Page 18: A Practical Architecture Design for MMO Casual Game

The “Object” requirements

• A container of properties• Serialize to and deserialize from JSON• Hierarchy relationship (parent-child)

Page 19: A Practical Architecture Design for MMO Casual Game

Object dynamic properties

Object

Guid

Property 1Property 2

Property Meta Data

• Tags• Persistent• Client transfer

• Type• Long

• Name• “property 2”

• Version• 568

Page 20: A Practical Architecture Design for MMO Casual Game

Define the properties

Page 21: A Practical Architecture Design for MMO Casual Game

The object tree

Object

Unit

GameObject

DataObject

Player

DecoItem

Pet

UseItem

ClothItem

Item

Quest

Job

PlayerView

DecoView PetView

ObjectView

Module

MainGame

Authen

HomeDeco

SyncData

Room

Lobby Public Personal

Object Manager

Page 22: A Practical Architecture Design for MMO Casual Game

ResultPros• MVC design pattern practice• Fully customizable property system• Manage game world into one single

system

Cons• Challenge to manage huge number

of objects

Page 23: A Practical Architecture Design for MMO Casual Game

Auto Synchronization Framework(Server <-> Client)

Page 24: A Practical Architecture Design for MMO Casual Game

Synchronization concept

ServerRoomPlayer.Position = (10,

20)

Player.OnUpdatePosition(10, 20){ model.MoveTo(10, 20);}

Client

Page 25: A Practical Architecture Design for MMO Casual Game

Duties of a room

SynchronizationScheduler

OtherScheduler

s

MessageProcessor

ROOM

• Process messages from clients

• Send or broadcast messages to clients

• Synchronize data changes between server and clients

• Update status• Other duties…

Page 26: A Practical Architecture Design for MMO Casual Game

Thread pool workers

Personal Room

Coffee Room

Downtown Room

Sync

Other

Sync

Thread Pool

Other

Sync

Other

Sync

Sync

Other

ROOMS

TASK QUEUE

S

WORKERS

Page 27: A Practical Architecture Design for MMO Casual Game

Thread

Schedulers 1 second

SYNCHRONIZATIONSCHEDULER

OTHERS SCHEDULER

1/10 second

Other Task

Sync Task

Sync Task

Other Task

Sync Task

Other Task

TASK QUEUE

WORKER

Page 28: A Practical Architecture Design for MMO Casual Game

Object change-set

ObjectPosition

Energy

Gold

Change Set

SYNCHRONIZATIONSCHEDULER

SetProperty(Position, (1, 2))

Sync Task

Page 29: A Practical Architecture Design for MMO Casual Game

ResultPros• Automatic synchronization property

changes• Optimal data transfer• Best use for active server game

Cons• Overhead to determine what has

changed since last sync.

Page 30: A Practical Architecture Design for MMO Casual Game

Network Message Dispatching System

Page 31: A Practical Architecture Design for MMO Casual Game

Custom message structureLogin- Usernam

e- Password

Synchronize- Type- Propertie

s

Buy Item- ItemType- Quantity

Chat- Message

RequestFriend- FriendGuid

Serializer(Thrift, Protobuf, Json,

XML)

Network package

Encryption

Page 32: A Practical Architecture Design for MMO Casual Game

Message factory

Server

Send

Client

Receive

Serialize

Deserialize

Login- Username- Password

Login- Username- Password

OnAuthen

OnMove

OnRun

LoginAuthenMoveRun

Message Handlers

OnLogin

Page 33: A Practical Architecture Design for MMO Casual Game

ResultPros• Meaningful message by define

custom structure• Familiar usage as common GUI

system (MFC, WinForm)• Share message definition between

server and client• Easy to apply encryptionCons• Unknown

Page 34: A Practical Architecture Design for MMO Casual Game

Conclusion

• Seamless MVC framework across server and client

• Address the most common difficulty in design active server : the synchronization

• Base framework environment for adapting any gameplay

Page 35: A Practical Architecture Design for MMO Casual Game

Q&A

Page 36: A Practical Architecture Design for MMO Casual Game