3D-03-牧师与魔鬼

本文是3D游戏编程与设计第三次作业的博客,内容为游戏“牧师与魔鬼(Priests and Devils)”的编程

游戏规则

游戏脚本

Priests and Devils Priests and Devils is a puzzle game in which you will help the Priests and Devils to cross the river within the time limit. There are 3 priests and 3 devils at one side of the river. They all want to get to the other side of this river, but there is only one boat and this boat can only carry two persons each time. And there must be one person steering the boat from one side to the other side. In the flash game, you can click on them to move them and click the go button to move the boat to the other direction. If the priests are out numbered by the devils on either side of the river, they get killed and the game is over. You can try it in many ways. Keep all priests alive! Good luck!

具体内容

现在有三位牧师与三个魔鬼在河岸,还有一只可以用来渡河的小船,现在需要让牧师们与魔鬼们渡河到对岸,有如下要求:

  • 小船上必须有一个以上的角色才能开动,且最多载两个角色
  • 当任一河岸的魔鬼数量大于牧师数量时(包括即将到岸的船上的角色),魔鬼就会杀死牧师,游戏失败
  • 当所有角色到达对岸时,游戏胜利

游戏设计

列出游戏中提及的事物(Objects)

牧师,魔鬼,船,河流,河岸

用表格列出玩家动作表(规则表)

动作 状态 响应
点击牧师或魔鬼 船在被点击角色的河岸 角色上船
点击船 船上至少有一个角色 船到对岸

制作对象预制

将角色用球体Sphere制作,牧师为白色,魔鬼为红色
将河流、河岸、船用立方体Cube制作
在这里插入图片描述

程序架构

游戏采用MVC架构,其中

  • Model:场景中所有的对象及其数据,如Boat.cs、Role.cs。
  • View:展示游戏结果,如UserGUI.cs、IUserAction.cs。
  • Controller:接受输入并调用Model和View去完成用户的需求,如Director.cs、FirstController.cs、SceneController.cs。

此外实现了两个辅助类:

  • Move.cs:检测鼠标点击,辅助对象移动的完成
  • Camera.cs:挂载在main camera上,调整main camera角度

代码展示

源代码较长,故仅依据程

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值