在 ASP.NET 中编写游戏大厅代码

发布于 2024-11-11 17:35:11 字数 667 浏览 3 评论 0原文

我有一个在线 3D 多人游戏,它使用插件将自身嵌入到网页中,我正在尝试找出如何在不使用 Flash 的情况下为其创建一个基于 Web 的大厅。

这个想法是,登录的玩家在页面上选择游戏类型,然后自动进入一个最多可容纳 x 名玩家的开放大厅。大厅是一个网页,用户可以在其中选择他们的皮肤和升级。一旦第 x 个玩家加入,大厅就应该开始倒计时,成功完成后会将所有用户重定向到另一个页面,加载嵌入式游戏并将这些用户一起带入同一服务器。

如果用户在计时器结束之前退出大厅/页面,则倒计时需要停止,并且大厅必须等待房间再次满员。我不确定如何执行这部分,因为我似乎需要一些服务器端计时器对象来了解玩家何时离开。我正在考虑使用 WebSync 与大厅页面中的每个用户沟通有多少玩家目前在大厅中,我假设我还可以使用它发送命令,在成功的计时器倒计时后将用户引导到新页面。我还想象我可以使用 WebSync 或其他东西让我的服务器知道有人离开大厅以停止倒计时。

如何创建此服务器端计时器以及如何与其交互?我正在考虑使用 Quartz.Net 来访问调度程序或其他东西,但我还不确定。

有什么想法吗?

I have an online 3D multiplayer game that uses a plugin to embed itself into a web page and I'm trying to figure out how to make a web based lobby for it without turning to Flash.

The idea is that signed in players choose a game type on a page and are automatically taken to an open Lobby that accepts up to x players. The lobby is a web page where the user can choose their skin and upgrades. As soon as the x'th player joins, the lobby should begin a countdown, which upon it's successful completion redirects all users to another page that loads the embedded game up and takes those users into the same server together.

If a user backs out of the lobby/page before the timer ends, the countdown needs to stop and the lobby must wait for the room to become full again. I'm not sure how to do this part as it seems like I'd need some server side timer object that is aware of when a player leaves. I'm looking at using WebSync to communicate with each user in a lobby page as to how many players are currently in the lobby, and I'm assuming I can also use this to send down a command to boot users to a new page upon successful timer countdown. I also imagine I can use WebSync or something else to let my server know when someone leaves the lobby in order to stop the countdown.

How do I create this server side timer and how do I interact with it? I'm thinking of using Quartz.Net to access the scheduler or something, but I'm not sure yet.

Any Ideas?

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

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

发布评论

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

评论(1

淤浪 2024-11-18 17:35:11

您可以选择使用 WebSockets 吗?您将能够(或多或少立即)监视状态更改并根据事件更新客户端和服务器。

您可以在预定义的时间从服务器发送大量数据,并在客户端上运行 javascript 将用户踢到新页面/在计时器结束(或玩家离开或加入游戏)时执行某些操作。

(插件:我和一个朋友编写了一个 C# 库,其中包含一个有效的实时聊天示例,可在此处找到:https:/ /github.com/Olivine-Labs/Alchemy-Websockets

Do you have the option of using WebSockets? You'd be able to (more or less instantly) watch for state change and update both the client and server upon events.

You can send down a chunk of data from the server at a predefined time, and run javascript on the client to kick the user to the new page / do something when the timer ends (or a player leaves or joins the game.)

(Plug: a friend and I wrote a C# library, with a working live chat example, found here: https://github.com/Olivine-Labs/Alchemy-Websockets)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文