请问精通设计模式的高手,webgame的基本模式有关问题
请教精通设计模式的高手,webgame的基本模式问题。
开发一个简单的网页游戏。所有对程序和对功能的要求,假定我们都能实现。现在的问题是对设计模式的选型和处理。
以下是我的初期设定:
基础分析:
一个虚拟玩家。 我的系统必须能提供UI,提供操作按钮。提供玩家属性、方法。
一个虚拟世界。 我的系统必须能构造一个比较完善的虚拟世界。有地图、城市、建筑、商店、住宅、物品、数值(资金、经验值、声望值、技能点)
、背包、装备等等。这一切基于php+mysql+javascript实现。
玩家交互。 我的系统要拥有玩家互相交互的功能。可以执行各种交互操作。短信息,邀请战斗,控制战斗,多人战斗,共同完成任务。等等。
玩家与虚拟世界交互。 我的系统要拥有玩家能够进行操作的功能。可以执行各种功能操作。
出生,学习,移动,工作,商业(买卖,交换(含物品与资金、物品),自定义任务。),交流,战斗(一系列功能),
做任务(一系列功能加上时间和奖励的集合)。物品处理。资金处理。
定义:
我个人将以上内容定义为:
User(玩家操作的部分) Trigger(执行事件时需要先通过触发,虚类) Action(如移动,工作等都是事件,虚类) AbstractItem(地图、城市、道具等,都属于虚拟物品,虚类)
方法:
User: display() doAction()
User仅仅只真实用户的操作。
Trigger:display()doAction()needTime()beginTime()endTime()
Trigger提供时间控制,Trigger的派生类,有立刻执行,倒计时执行,玩家交互执行。
Action:display()doAction()begin()Process()end()
Action提供事件的开始,过程,结束,Action的派生类,有移动,工作,战斗等等。
AbstractItem:display()get()lose()use()
AbstractItem构造了整个游戏中所有的虚拟物品。AbstractItem的派生类,如地图、城市等等,包括角色本身。
模式:
个人想法是User只是作为驱动。Trigger提供给User驱动的事件,并且控制Action的执行时间。AbstractItem提供所有Action相关的对应的对象。
这时候,User与Trigger好象是bridge模式,Action与AbstractItem也好象是brideg模式。Trigger与Action又象是Abstractfactory模式。
另外,需要有任务功能。个人认为任务就是一系列的Trigger组合。包括前续、后续等等。个人认为需要一个Task类,但不知道放Action里好,还是放Trigger里好,又或者是独立出来。
同时,由于是webgame,即时或半即时交互,通过ajax模拟。已经有专门的定时器(认为程序运行环境有这项功能)功能。
显示部分呢是web页面即UI包。可能需要语言包,和任务对话包。里面用到的图片也想做成图片包,当然图片包可能属于UI包。
问题:
1、最高层模式是什么模式或者选什么模式比较合理?
2、目前我自己认为的模式是否比较合理或者有更好的优化办法?
3、Task如何加入?
4、ajax与Trigger与定时器如何结合更好?(因为ajax属于纯功能了,但是Trigger又会用到。最关键的是一个是js,一个是php...)
5、UI包(可能会有多套UI)、语言包(可能需要多语种)、对话包等,如何合理的加入到游戏里?(数据库?填表?ini?)
请高手不吝赐教!不需要代码,只给思路即可。当然,有例子和代码更好。
------解决方案--------------------
没做过,ajax估计做不了
ajax是单项通信,连续请求量很大,看过用http长连接的
至于其他,你还是按面向对象思想来设计吧
对象 事件 属性 方法
------解决方案--------------------
说实话,我没看明白你的内容
和我对WEBGAME的想法不一样
还有,为什么一定要用设计模式呢?
我只引用一句话, 当您手中拿着一把锤子时,所有事物看上去都像钉子
------解决方案--------------------
我不否认模式的作用
只是,我认为要在理解模式下才去用,而不是死抠着用模式。。
------解决方案--------------------
个人觉得对话包作为action里比较好,作为atcion的属性或方法
action作为一个动作,触发时就给出或输出相关对话信息,这是系统级
用户级的直接输出就行了
------解决方案--------------------
关注...
------解决方案--------------------
学习,关注
------解决方案--------------------
服务端只需要保存各种对象状态即可.
其它的,就是JS架构的事.
别把MVC框架的那一套用过来. webgame 最重要的是执行效率,而不是开发效率....
------解决方案--------------------
MVC 只是我举的个例子.
对于webgame
JS 就当是内存了.
PHP就当是硬盘了.
AJAX就当是数据存储操作了.
继续讨论 设计模式.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



DJI has not confirmed any plans to introduce a new action camera yet. Instead, it seems that GoPro will get ahead of its rival this year, having teased that it will introduce two new action cameras on September 4. For context, these are expected to a

In Docker, the permission problem of the mounting directory can usually be solved by the following method: adding permission-related options when using the -v parameter to specify the mounting directory. You can specify the permissions of the mounted directory by adding: ro or :rw after the mounted directory, indicating read-only and read-write permissions respectively. For example: dockerrun-v/host/path:/container/path:roimage_name Define the USER directive in the Dockerfile to specify the user running in the container to ensure that operations inside the container comply with permission requirements. For example: FROMimage_name#CreateanewuserRUNuseradd-ms/bin/

Almost a year has passed since DJI released the Osmo Action 4 (curr. $299 on Amazon). Since then, the company has focused on its other divisions, including new RS camera gimbals. On top of that, it has introduced various drones as well like the Avata

In some cases, we want to perform some asynchronous operations in Vuex, such as network requests, which must be asynchronous. How to deal with this situation? Let me introduce to you the Action asynchronous operation of Vuex state management. I hope it will be helpful to friends in need. !

Insta360hasreleasedanewactioncamera,itssecondoftheyearaftertheInsta360X4(curr.$499.99onAmazon).Asexpected,thecompanyhasintroducedtheGo3S,anupgradedthatGo3thatadds4Kvideorecordingcapabilities.Specifically,whileInst

Define a Trigger to determine when a window (formed by a window allocator) is ready to be processed by a window function. Each WindowAssigner comes with a default value Trigger. If the default trigger doesn't suit your needs, you can use trigger(…). Trigger source code publicabstractclassTriggerimplementsSerializable{/**As long as an element falls into the current window, this method will be called*@paramelementThe element received*@paramtimestampThe arrival time of the element.*@paramwindowThe element belongs to

1. Basic concept A trigger is a special type of stored procedure. The trigger is triggered by an event and is executed. The trigger is similar to a js event. 1. The function is to forcefully check or convert the data before writing it to the data table (to ensure data security) When a trigger error occurs, the result of the change will be revoked (transaction safety). Some database management systems can use triggers for the data definition language DDL, called DDL triggers, which can replace the change instructions insteadof according to specific circumstances (mysql does not support ) 2. Advantages and Disadvantages of Triggers 2.1. Advantages Triggers can achieve cascading changes through related tables in the database (if the data in one table changes, triggers can be used to implement operations on other tables without the user knowing) Guaranteed

GoPro has now introduced its annual action camera refresh. Unlike in recent years, the company has decided to release two models. However, it has not returned to 360-degree cameras, despite teasing this time last year that it would replace the Max wi
