3D游戏编程实践——Priests and Devils(动作分离版)

本文介绍了3D游戏Priests and Devils的编程实践,重点在于实现动作分离,通过动作管理器处理角色和船只的运动。游戏目标是帮助牧师和魔鬼过河,保持牧师安全。文章详细讲解了动作管理器的设计,包括动作基类、组合动作实现和牧师魔鬼的具体动作,并提到了裁判类用于判断游戏状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

编程实践——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!

  • 游戏中提及的事物有:河岸Coast(包括起始河岸和目的河岸),河River,3个牧师Priests,3个魔鬼Devils,船。

  • 玩家动作表:

    事物
    牧师/魔鬼 从河岸上船
    牧师/魔鬼 从船上河岸
    从河岸行驶到另一河岸
  • 预制游戏中的对象:

在这里插入图片描述

  • 在 GameObjects 中创建 长方形、正方形、球 及其色彩代表游戏中的对象:

    我用金色的方块代表牧师,红色的球代表恶魔,蓝色的细长长方体代表河流,带有纹理的方块代表河岸,方块代表船,游戏效果图如下:
    在这里插入图片描述

本次实践依然是采用MVC结构实现,与上一次无动作分离版的区别在于,之前对于动作的管理是实现了一个动作类,当鼠标点击船或是人物时,相当于是控制器让船或人物的实例调用动作类来实现运动。这次实践中将船或人物与动作分离开来,单独实现了一个动作管理器,鼠标点击船或是人物时,相当于是控制器直接将动作请求传给动作管理器,动作管理器来实现船或人物的运动。

接下来介绍动作管理器的实现:
  • SSActionManager(动作管理基类)
    管理SequenceActionSSAction,可以给它们传递游戏对象,让游戏对象做动作或是一连串的动作,控制动作的切换。SSActionManager继承了ISSActionCall

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值