摘要本文主要阐述网络回合制战斗系统的实现,包括回合制战斗系统的整个流程(战斗开始、玩家下达战斗指令、战斗动画、战斗结束),和网络回合制战斗系统常见的主要功能(攻击、使用技能、使用物品)的实现,并且在游戏项目《PKer》中进行实践和测试。在开发环境方面,服务器采用国内IOCP高性能开源框架“HP-Socket”(Windows平台),并且连接到Mysql数据库,客户端采用近年比较火热的强大跨平台引擎Unity3D(2D,C#)并且使用Sqlite作为嵌入式数据库。除此以外,本文还对战斗系统实现所涉及到的相关技术如Unity引擎的协同程序、单例设计模式和分包算法进行简要介绍。
关键词回合制战斗系统, 网络游戏,Unity3D,协同程序,游戏编程
ABSTRACT This article mainly expounds the implementation work turn-bat system, including the whole process of turn-bat system (battle begins, the players fighting instructions, combat animation, battle ends), and the main function mon (attack, using skills, using items) implementation, and in the game "PKer" in practice and test of the project. In the aspect of development environment, C++ IOCP server with Windows platform and connect to the Mysql database, the client uses Unity3D (2D, C#) and uses Sqlite as an embedded database. In addition to this, this article also involved bat system related technologies such as the Unity engine coroutines, singleton design pattern and the subcontract algorithm are briefly introduced.
KEYWORDS Turn-bat system, online game, Unity3D, Coroutine, Singleton design pattern
目录
前言 1
第1章绪论 2
回合制游戏简介 2
广义上的回合制游戏 2
狭义上的回合制游戏 2
回合制战斗系统简介 2
实践项目《PKer》简介 2
第2章开发环境和部分涉及技术简介 4
开发环境简介 4
Unity协同程序 4
Unity协同程序简介 4
Unity协同程序的运用 4
单例设计模式 5
单例设计模式 5
单例设计模式的运用 6
单例设计模式在Unity中的运用 7
分包算法 7
分包的原因 7
环形缓冲区(Circular Buffer) 7
分包算法流程图 9
第3章战斗动画实现方案的研究与对比 11
研究背景 11
实现方案一:有限状态机 11
实现方案二:协同程序(Coroutine) 12
方案抉择结论 13
第4章回合制网游战斗系统设计 14
回合制网游战斗系统设计 14
回合制网游战斗系统服务器实现思路 15
回合制网游战斗系统客户端实现思路 15
战斗系统框架结构(以实践项目《PKer》为例) 16
第5章回合制战斗系统实现 18
战斗系统相关消息结构体的定义 18
服务器战斗系统的实现 20
服务器战斗系统相关结构体 20
初始化一个战局 23
接收客户端的战斗指令消息 23
处理战斗指令并发送动画消息 24
说明 27
客户端战斗系统的实现 27
客户端战斗系统功能模块 28
客户端战斗系统相关数据类型 28
进入战斗后初始化战斗角色 29
下达战斗指令并发送战斗指令消息 29
基于unity的回合制网游战斗系统的研究与实现 来自淘豆网www.taodocs.com转载请标明出处.