当前位置: 首页 > news >正文

沙坪坝网站开发天津做网站优化公司

沙坪坝网站开发,天津做网站优化公司,php网站开发背景介绍,中英文网站源码文章目录 3D游戏编程与设计 HW 3.5 牧师与恶魔1.游戏介绍2.题目要求3.MVC结构4.游戏对象表#xff0c;玩家动作表#xff0c;事件表5.类设计#xff08;一#xff09;Models① Boat② Coast③ Character #xff08;二#xff09;Views① UserGUI #xff08;三#xf… 文章目录 3D游戏编程与设计 HW 3.5 牧师与恶魔1.游戏介绍2.题目要求3.MVC结构4.游戏对象表玩家动作表事件表5.类设计一Models① Boat② Coast③ Character 二Views① UserGUI 三Controllers① Director② ISceneController③ IUserAction④ Moveable⑤ GameController⑥ FirstController 6.游戏结果展示一 游戏界面二游戏失败三游戏胜利 3D游戏编程与设计 HW 3.5 牧师与恶魔 完整游戏过程可见以下视频 https://www.bilibili.com/video/BV1Vk4y117J2/ 完整代码可见以下仓库 https://gitee.com/beilineili/game3-d 1.游戏介绍 牧师和恶魔是一款益智游戏你将帮助神父和恶魔在限定的时间内过河。河的一边有三个牧师和三个魔鬼。他们都想到河的另一边去但是只有一条船每次只能载两个人。必须有一个人把船从一边转向另一边。如果牧师们被河两岸的恶魔们打败在岸上的牧师数量少于恶魔他们就会被杀死游戏也就结束了。在游戏中你可以点击它们来移动它们点击go按钮来移动船到另一个方向。你可以用很多的方法来尝试。让所有的牧师活下去! 祝你好运 2.题目要求 3.MVC结构 MVC是模型(model)视图(view)控制器(controller)的缩写它是一种软件设计模式用一种业务逻辑、数据、界面显示分离的方法组织代码将业务逻辑聚集到一个部件里面在改进和个性化定制界面及用户交互的同时不需要重新编写业务逻辑。MVC基本结构图 在牧师与恶魔游戏设计中可以分为 ① SSDirector整个结构的管理者控制各个场景的切换协调 ② ISceneController抽象每个场景的管理者是Director用来向场景控制器传递要求的接口 ③ IUserAction抽象负责管理行为之间的交互对于玩家的每个动作产生相应的响应结果通过这样基于职责的设计实现了赋予不同对象特定的职责使游戏程序的结构更加清晰、可复用性更高。 4.游戏对象表玩家动作表事件表 游戏对象对象类型Priest 牧师CubeDevil 魔鬼SphereBoat 船CubeRiver 河流CubeCoast 河岸Cube 动作触发事件点击 Character 人物人物上船下船点击 Boat 船只船只过河 事件结果其中一边恶魔数量大于牧师包括船上和岸上的玩家失败所有牧师和恶魔都到了另一岸玩家成功 5.类设计 基于职责设计使用面向对象技术设计游戏。 项目的程序代码采用MVC结构根据功能将代码文件分别放入Controllers, Models, Views文件夹中。 一Models ① Boat 有 location船位置坐标属性有起点和终点此外还需要维护船上的空位坐标以及角色信息 ② Coast 同 Boat需要维护岸上的空位坐标和角色信息 ③ Character 有 namelocation 和 isOnBoard 属性其中 name 用于区分角色是牧师还是恶魔IsOnBoat 用于区分是否在船上 二Views ① UserGUI Start 函数通过获得 Director 的单例初始化获得当前场记 CurrentSecnController // 得到 GameControllervoid Start () {status 0;action Director.GetInstance().CurrentSecnController as IUserAction;}OnGUI 函数渲染游戏界面 void OnGUI () {textStyle new GUIStyle {fontSize 40,alignment TextAnchor.MiddleCenter};hintStyle new GUIStyle {fontSize 15,fontStyle FontStyle.Normal};btnStyle new GUIStyle(button) {fontSize 30};// 打印标题和规则提示信息GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 195, 100, 50), Priest And Devil, textStyle);GUI.Label(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 125, 100, 50), White Cube: Periest\n Red Sphere: Devil\n\n rule, hintStyle);// 打印游戏结果和重开游戏的按钮if (status 1) {// LoseGUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 85, 100, 50), You Lose!, textStyle);if (GUI.Button(new Rect(Screen.width / 2 - 70, Screen.height / 2, 140, 70), Restart, btnStyle)) {status 0;action.Restart();}} else if (status 2) {// WinGUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 85, 100, 50), You Win!, textStyle);if (GUI.Button(new Rect(Screen.width / 2 - 70, Screen.height / 2, 140, 70), Restart, btnStyle)) {status 0;action.Restart();}}}OnMouseDown 函数监听捕捉用户的点击动作转至 Controller 处理 void OnMouseDown() {if (gameObject.name boat) {action.MoveBoat();} else {action.CharacterClicked(characterCtrl);}}三Controllers ① Director 获取当前游戏的场景管理游戏全局状态 public class Director : System.Object{// Singlton instance.private static Director instance;public ISceneController CurrentSecnController { get; set; }// get instance anytime anywhere!public static Director GetInstance(){if (instance null){instance new Director();}return instance;}public int getFPS(){return Application.targetFrameRate;}public void setFPS(int fps){Application.targetFrameRate fps;}}② ISceneController 场记 GameController 与导演 Director 交互的接口 public interface ISceneController{void LoadResources();}③ IUserAction 玩家与 GameController 互动的用户交互接口 public interface IUserAction {void MoveBoat();void CharacterClicked(CharacterController characterCtrl);void Restart();}④ Moveable SetDestination 用于控制对应游戏对象的运动 public void SetDestination(Vector3 pos) {destination pos;middle pos;if (pos.y transform.position.y) { // 移动船status 2;} else if (pos.y transform.position.y) { // 将角色从岸上移到船上middle.y transform.position.y;} else { // 将角色从船上移到岸上middle.x transform.position.x;}status 1;}⑤ GameController CoastController GetEmptyIndex岸上空位的下标 GetEmptyPosition岸上空位的坐标 GetOnCoast上岸 GetOffCoast离岸 GetCharacterNum计算岸上角色的数量BoatController Move移动船 GetEmptyIndex船上空位的下标 IsEmpty船是否有空位 GetEmptyPosition船上空位的坐标 GetOnBoat当玩家点击牧师或魔鬼使之上船时被调用。 GetOffBoat当玩家点击牧师或魔鬼使之上岸时被调用。 GetCharacterNum计算船上角色的数量CharacterController 配合 CoastController 和 BoatController ⑥ FirstController 在场景被加载唤醒awake时它会自动注入导演设置当前场景 void Awake() {Director director Director.GetInstance();director.CurrentSecnController this;userGUI gameObject.AddComponentUserGUI() as UserGUI;characters new MyNamespace.CharacterController[6];LoadResources();}CheckGameOver 判断游戏胜负 private int CheckGameOver() {int rightPriest 0;int rightDevil 0;int leftPriest 0;int leftDevil 0;int status 0;rightPriest rightCoastCtrl.GetCharacterNum()[0];rightDevil rightCoastCtrl.GetCharacterNum()[1];leftPriest leftCoastCtrl.GetCharacterNum()[0];leftDevil leftCoastCtrl.GetCharacterNum()[1];// Winif (leftPriest leftDevil 6) {status 2; }if (boatCtrl.boat.Location Location.right) {rightPriest boatCtrl.GetCharacterNum()[0];rightDevil boatCtrl.GetCharacterNum()[1];} else {leftPriest boatCtrl.GetCharacterNum()[0];leftDevil boatCtrl.GetCharacterNum()[1];}// Loseif ((rightPriest rightDevil rightPriest 0) ||(leftPriest leftDevil leftPriest 0)) {status 1;}return status;}6.游戏结果展示 完整游戏过程可见以下视频 https://www.bilibili.com/video/BV1Vk4y117J2/ 一 游戏界面 二游戏失败 三游戏胜利
http://www.hkea.cn/news/14334008/

相关文章:

  • 温州网站建设服务中心购物网站有哪些模块
  • 创意 国外 网站泰安网站建设课程报告
  • 展示型网站建设流程图怎么样百度能搜到自己的网站
  • phpcms v9网站地图开源商城
  • 社旗微网站开发荆门网站制作公司
  • 站长之家alexa排名怎么看晋城网站建设公司
  • 国际交流中心网站建设与管理制度wordpress移动端seo优化
  • 佛山网站建设企业报价商学院网站建设建议
  • 淘宝客cms建站教程公司用什么邮箱好
  • 企业网站seo多少钱wordpress主题好看的
  • 韩国风格网站模板下载wordpress哪个php版本好
  • 西安网站建设 至诚有了网站源码如何做网页
  • 郑州教育培训机构网站建设微营销平台系统
  • 网站开发发展趋势2018淘宝客可以做返利网站吗
  • 上海网站开发公司哪家好网站后台查找软件
  • 钉钉网站建设服务协议建站如何赚钱
  • 网站制作400哪家好中国国防新闻
  • 有没有做京东客好的网站推荐建网站的公司赚钱吗
  • 做网站哪个公司好 快选宁陵建站宝电商设计网站有哪些功能模块
  • php完整电商网站开发源码刷关键词优化排名
  • 滨河网站建设成都的做网站公司
  • 医疗器械网站建设策划书四川网站建设贴吧
  • 企业门户网站系统wordpress中文目录
  • 通化市网站建设沅江网站开发
  • 网站页面设计特点浏览器网址导航
  • 用什么软件做网站好网站建设需要懂什么语言
  • 企业网站设计建设工程机械职业技能鉴定
  • pc网站建设和推广学校网站建设的背景
  • 怎么夸一个网站开发公司wordpress安装500错误
  • 如何查询网站接入商机房建设网站模板