Photon (v4)的基本框架。开发框架主要Photon和游戏逻辑(C#)两个部分,如下图最新的Photon v4支持的4种底层协议,游戏开发逻辑Photon目前主要划分为Load Balancing 和MMO(大型多人同时在线游戏)。
一、Photon服务端示例
1、服务端开发
新建解决方案TestPhotonServer并新建类库项目MyPhotonServer,类库添加Photon引用(可在photon安装目录的lib里找到)
Photon.SocketServer.dll
PhotonHostRuntimeInterfaces.dll
为什么新建类库项目呢?所有的Photon的服务端程序都是先编译成dll,再由PhotonControl.exe通过配置文件调用运行的。
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Photon.SocketServer; namespace MyPhotonServer { public class MyServerApplication:ApplicationBase { protected override PeerBase CreatePeer(InitRequest initRequest) { return new MyServerPeer(initRequest); } protected override void Setup() { //初始化 } protected override void TearDown() { //关闭 } } }