17. Photon Network Engineの概要
Exit Gamesが開発した
高速でスケーラブルなネットワークエンジン
Photon Server is the fastest and easiest to use on-premise
Network Engine to build scalable MMOGs, FPS or any other
multiplayer game and application for PC, Mac, Browser,
Mobile, Console and Cross-Platform. (公式Webより)
要するにすごいらしい
•
•
•
18. .NET CLR (C#)
Photon Network Engineの概要
Photon Core (C/C++)
Reliable UDP Websockets Binary TCP
Server
Application
Server
Application
Server
Application
サーバー クライアント
Photon SDK
(for each platforms)
Client
Application
52. Photon Server
(Master Server)
Photon Server
(Game Server)
Photon Server
(Game Server)
Photon Server
(Game Server)
ダンゴル Client
ダンゴル Client
ダンゴルのPhotonサーバー構成
ダンゴルクライアントからはまずはMaster Serverに接続される
マスターサーバーが負荷状況によりどのGame Serverを使うか判断する
53. Photon Server
(Master Server)
Photon Server
(Game Server)
Photon Server
(Game Server)
Photon Server
(Game Server)
ダンゴル Client
ダンゴル Client
ダンゴルのPhotonサーバー構成
Game Serverが決まったら、クライアント同士の通信は
Game Serverを介して行われる
54. Photon Server
(Master Server)
Photon Server
(Game Server)
Photon Server
(Game Server)
Photon Server
(Game Server)
ダンゴルClient
ダンゴルAPIサーバー
ダンゴルのPhotonサーバー構成
ダンゴルではユーザーマッチング時に外部サーバーと連携する
必要があり、一部SDKに手が入っています
69. 入室処理
function InstantiateLocalPlayer()
{
var prefabName : String = “Birdie”; //prefab name in Resource Folder.
var position : Vector3 = Vector3.zero;
var rotation : Quaternion = Quaternion.identity;
PhotonNetwork.Instantiate(prefabName, position, rotation, 0);
}
74. namespace Photon
{
public class MonoBehaviour : UnityEngine.MonoBehaviour
{
public PhotonView photonView
{
get
{
return PhotonView.Get(this);
}
}
new public PhotonView networkView
{
get
{
return PhotonView.Get(this);
}
}
}
}
RPCの実装
75. public function OnShot(status : ShotStatus)
{
var json : String = JsonMapper.ToJson(status);
photonView.RPC("RpcPlayerShot", PhotonTargets.Others, json);
}
@RPC
function RpcPlayerShot(json : String)
{
var shotStatus : ShotStatus = JsonMapper.ToObject.<ShotStatus>(json);
var player : PlayerController = GetComponent.<PlayerController>();
player.Shot(shotStatus);
}
RPCの実装