我需要为我在Unity C#中制作的简单游戏设置损失条件

发布于 2025-02-07 17:33:29 字数 322 浏览 3 评论 0原文

我正在制作一个简单的团结手机游戏。屏幕底部有一个大炮,您可以在屏幕顶部移动的平台上射出小子弹。对于我的失去状况,我需要按照“如果5个子弹在Y轴上超过5F”的方式说些什么,然后再进行游戏。

我知道如何在游戏结束时重新启动游戏,并且我尝试制作它,以便当您用完弹药并且并非所有平台都被破坏时,游戏结束了。但是问题是,如果您还剩一颗子弹,然后拍摄它,则在拍摄最后一颗子弹时就会触发游戏结束程序。因此,即使最后一个子弹击中了最后一个平台,游戏仍然结束并重新启动。在第一级,您有5个子弹,并且有一个平台。

我认为最好的方法是检查所有子弹是否在平台目标上方的Y轴上均高于5F。如果所有的5个子弹都高于此,则游戏结束。

I am working on a simple mobile game in Unity. There is a cannon at the bottom of the screen and you shoot small bullets at moving platforms at the top of the screen. For my lose condition I need to say something along the lines of "If 5 bullets are above 5f on y axis" then game over.

I know how to make the game restart when the game ends and I have tried making it so that when you run out of ammo and not all of the platforms are destroyed, the game ends. But the problem with this is that if you have one bullet left and you shoot it, the game end program gets triggered right when you shoot the last bullet. So even if the last bullet hits the last platform, the game still ends and restarts. On the first level you have 5 bullets and there is one platform.

I am thinking the best way to do it would be to check if all of the bullets fired are above 5f on y axis, which is above the platform target. If all 5 bullets fired are above this, then the game ends.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云淡风轻 2025-02-14 17:33:29

您的建议很有意义!看来您正在寻找场景,在这种情况下,玩家不再有实现目标的机会。因此,您的失落状态可能是两者:

  • 所有子弹都通过了“无返回点”(Y轴上的5F),并且:
  • 仍然至少剩下一个平台。

Your suggestion makes sense! It seems like you're looking for the scenario where the player no longer stands a chance of completing their goal. So, your lose condition might be if both:

  • all the bullets have passed the "point of no return" (above 5f on the y axis), and:
  • there is still at least one platform remaining.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文