游戏类图 [英] Game class diagram

查看:302
本文介绍了游戏类图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个游戏的类图的问题。
游戏发生的世界可以由字段表示。每个
字段由坐标x和y标识。该字段可以方便地到
建立和解或不。如果在现场有结算,只有
一个。每个字段都以位图形式链接到一个格局。在一些领域中,
可以是资源(例如煤,矿石)或不是专有的其他工件。
每个玩家是公国的统治者。可能属于许多
定居点的公国。国籍和公民身份指定
定居点卡车。定居者是公国的公民,通过属于b b b的公国到公国的一个定居点。然而,和解可能生活在不同的国家,其国籍不符合b $ b国籍。生活在村里的个别国家的特点是忠诚于bb b的公国,拥有村庄。对于定居者征收头税,
每周必须转移到公国。税收饲养公国的
库。税率过高降低了定居者的士气。
用于维护建筑物和b $ b军队的重要资金。
在村庄里,你可以放不同类型的建筑物。其中一些可以是
仅构建每个结算的单个副本(例如,沟渠),其他在更大的
数量(例如,植物毛皮)。对于沉积物在建筑物中,
的一部分,定居者必须作为建筑工人工作指定的小时数,并且必须为
提供适当的产品和原材料。 ¬
每天的沉淀物直径可以在其他职业中工作(例如
装甲,童子军)。对于定居者可以开展他们的工作,通常需要
适当的建筑物(例如锻造,锯木厂)。大多数工人b b b提供工件 - 制造产品(例如,铁匠,农夫)或b b b生产自然资源(例如,矿工,伐木工人)。某些工件可能需要制造
产品。然后,后工人,谁由
必要的小时数将工作在生产。作为定位器的结果而创建的工件
是一个产品。对于产品的最多
向后区域是Armor(例如,剑,链邮件)和食物
(例如面包,肉)。不是产品的最重要的工件类型是
自然资源。对于颗粒可以存储在工件more,
你必须建立一个仓库。

I have a problem with taking a class diagram for a game. The world in which the game takes place, can be represented by fields. Each field is identified by the coordinates x and y. The field may be convenient to establish a settlement or not. If there is a settlement on the field, the only one. Each field is linked to a landscape as a bitmap. In some fields, there may be resources (eg coal, ore), or other artifacts which are not proprietary. Each player is the ruler of a principality. May belong to the Duchy of many settlements. The Principality of nationality and citizenship designates settlements truck. The settlers are citizens of the duchy through belonging to one of the settlements of the principality. The settlement may, however, live in different nations, whose nationality does not coincide with citizenship. Individual nations living in village characterized by loyalty to the principality, which owns the village. For the settlers imposed a head tax, which every week has to be diverted to the principality. Taxes feed the treasury of the duchy. Too high taxes lowers the morale of the settlers. Collected funds for in importance to the maintenance of buildings and armies. In the villages you can put different types of buildings. Some of them can be built only a single copy of each settlement (eg, ditch), others in larger quantities (eg, plant furrier). To the sediment was in the building, part of the settlers must work as a builder of a specified number of hours and must be available appropriate products and raw materials for their construction. ¬ precipitate diameter of each day may work in other occupations (such as armorer, scouts). To the settlers could carry out their jobs, usually the appropriate buildings are required (such as a forge, sawmill). Most workers provide artifacts - manufactures products (eg, a blacksmith, a farmer) or producing natural resources (eg, a miner, a lumberjack). Manufacture of the product may be needed for some artifacts. Then, post workers, who by the requisite number of hours will work in production. The artifact, which was created as a result of the settlers, is a product. For the most backwards area of ​​the product to be Armor (eg, sword, chain mail) and food (eg bread, meat). The most important type of artifact that is not a product is a natural resource. To the pellet could be stored in the artifact more, you must build a warehouse.

我甚至不是问所有的任务 - 我知道是大和时间花费。
我只是想听到一些建议,什么放在抽象类,什么放在这里的接口。什么类应该建立一个建筑的操作?
预先感谢您的任何想法,事件简单的句子!

I'm not even asking about all the task - i know it is large and time spending. I just would like to hear some suggestions, what to put as abstract class, what to put as interface here. What class should have operations to build a building? Thanks in advance for any your idea, event single sentence!

推荐答案

您其实有一个非常良好的开端以分析模型。分析模型应该代表领域,在这种情况下是你的游戏的世界。如果将名词转换为类,并将动词转换为关联结束属性,则分析模型的第一个版本将会丢失。 (但是,要确保这些类的奇异的,不是复数)做这种转换的一种方法是使自然语言句子的符号列表,在两个方向上,如:

You actually have a pretty good start at an analysis model. An analysis model should represent the domain, which in this case is the world of your game. If you convert the nouns into classes and the verbs you already have into association-end properties, a first version of your analysis model will fall out. (But, make sure the classes are singular, not plural.) One way to do this conversion is to make a bullet list of natural-language sentences, in both directions, such as:


  • [一个或多个]字段代表的游戏

  • / em>包含在 [零或一个]字段中的字段
  • 字段 [零或一个]结算

  • 。 。 。

  • Game represented by [one or more] Fields
  • Field represents [one] Game
  • Field identified by [one] Coordinate
  • Coordinate identifies [one] Field
  • Settlement contained in [zero or one] Field
  • Field contains [zero or one] Settlement
  • . . .

(我认为接受超类,抽象类和接口可能为时过早,

(I think it may be premature for you to take on superclasses, abstract classes, and interfaces since you're asking about the basics here. Please ask another more specific question after you have more experience under your belt.)

然后,您可以将association-end-property名称转换为参与式短语以查看更正常在你的目标OO语言中,同时仍然保留语义。这些参与短语告诉读者你的代码的关联的目的,以及消除两个类之间的多个关联为不同的目的。下面是我所说的分词短语(用作形容词即动词短语),作为角色名称的意思是一些例子:

You can then convert the association-end-property names into participial phrases to look more normal in your target OO language, while still retaining semantics. These participial phrases tell the reader of your code the purpose of the association, as well as disambiguate multiple associations between two classes for different purposes. Here are some examples of what I mean by participial phrases (i.e., verb phrases used as adjectives), used as role names:


  • |游戏| -representedGame ----- representField- | Field |

  • | Field | - IdentifyingCoordinate- | Coordinate |

  • | Settlement | -containedSettlement ---- containsField- | Field |

  • 。 。

  • |Game| -representedGame-----representingField- |Field|
  • |Field| -identifiedField-----identifyingCoordinate- |Coordinate|
  • |Settlement| -containedSettlement----containingField- |Field|
  • . . .

此时,列出动词,代表您希望课程完成的事情。这些是你的操作。有时,显然哪个类应该负责操作;其他时候,你必须人格化。

At this point, make a list of verbs, representing the things you want your classes to accomplish. These are your operations. Sometimes it is obvious which class should be responsible for an operation; other times you have to anthropomorphize.

现在,使用这些操作代码的方法的图形和I / O库,你有自己的游戏!

Now, code methods for those operations using graphical and I/O libraries, and you have yourself a game!

有关更多信息,我强烈建议你阅读莱昂Starr的的如何建立口齿UML模型文章或HS Lahman的书,的基于模型的开发:应用程序

For more information, I highly recommend you read Leon Starr's How to Build Articulate UML Models article or H. S. Lahman's book, Model-Based Development: Applications.

这篇关于游戏类图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆