有谁知道在哪里可以找到 RP 游戏开发的类图示例? 类似于这里的东西会非常有用。 我并不是在寻找可以盲目复制的东西,而是寻找不同的例子,这些例子描绘了我在尝试用铅笔记下自己的课程时发现的问题的各种解决方案。
Does anyone know where I can find examples of class diagrams for RP game development? Something similar to here would be quite useful. I'm not looking for things I can slavishly copy, but just for different examples that diagram various solutions to the problems I'm discovering as I try and pencil down my own classes.
发布评论
评论(7)
我从 GameDev.net 认识 Emmanuel Deloget,但我不确定我是否会选择使用他那里的层次结构! 继承太多,灵活性不够。
如果我正在编写一个基于文本的角色扮演游戏(就像我过去所做的那样),它看起来有点像这样(遗憾的是,我没有时间为它绘制图表):
来自 WorldEntity,与 WorldEntity
以组合方式排列的对象
结构,因此物品可以存在于其中
由生物携带的其他物品,
存在于房间内的人。 实施
WorldEntities 的访问者模式
可能会运作良好。
其中包含“类”数据
个体生物和物品
实例,引用回它们的
相应的“类型”对象。 (例如,基地
前者的生命值和统计数据,
当前生命值和瞬态效果
在后者)。 我可能会将这些实现为
得到的属性的原型列表
复制到生物或物品实例时
他们被创造了。 您可以实现属性
通过“父”属性继承,以便
特定的妖精生物实例可能与
‘战士妖精’CreatureType,其中包含
对“通用妖精”CreatureType 的父引用。 等等。
一种方式,并详细说明了方向
旅行、各种通行条件等。
通过某种逻辑组织。
并创建 Item 实例(例如哪个房间,
或在什么坐标),它们何时创建以及
以什么频率、从什么时间开始
其中 CreatureTypes 和 ItemTypes。 你可能有
这里有一些逻辑可以使事情随机化。
全部派生自 Action 基类
或指定先决条件的接口
(例如,当前位置、法力值、一些
技能的学习程度等)。 普通的
命令和操作也可以放在这里,因为它们
通常也有某种要求
(例如,“睡眠”命令要求您不
已经在睡觉了。)
您推送到优先级队列的回调
以便将来执行。 您可以使用这些来
安排战斗回合、法术冷却时间、
昼夜循环,随心所欲。
玩家和物品统计。 不是类型安全的,但是
稍后您会欣赏到这种灵活性。 在我的
制作 stats 成员变量的经验是
可行但不灵活,并且具有专业性
“属性”类变得复杂
调试时的噩梦。
和修饰符值(例如+10、+15%)。 这些
在使用时添加到您的生物中
(例如,通过法术效果,或通过挥舞
一件附魔武器)然后被脱掉
通过定时 FutureEvent 或其他一些事件,例如
作为正在执行的命令。
PlayerRace,每个描述一个玩家的职业
(例如战士、巫师、小偷)或种族(人类、精灵、
矮人)并设置起始统计值和限制,
可用技能列表、特殊能力等。
取决于您的实际游戏类型。 你可能会
有图形游戏的渲染类,或者
在 MUD 中你可能有一个 Connection 类
反映到玩家客户端的 TCP 连接。
尝试将所有游戏逻辑排除在外。
生物人工智能可以更快地实现
一个不错的脚本接口并且可以节省编译时间
也下来了。 它还允许进行一些很棒的游戏内调试
和诊断能力。
这将是我使用的基本高级结构。
I know Emmanuel Deloget from GameDev.net but I'm not sure I would choose to use the hierarchy he's got there! Too much inheritance, not enough flexibility.
If I was writing a text-based RPG (as I have done in the past) it would look a bit like this (though I've no time to draw up a diagram for it, sadly):
from WorldEntity, with WorldEntity
objects arranged in a Composite
structure, so items can live within
other items, carried by creatures,
who exist within rooms. Implementing
the Visitor pattern for WorldEntities
might work well.
which contain the 'class' data for
individual Creature and Item
instances, which refer back to their
corresponding 'type' object. (eg. base
hitpoints and stats in the former,
current hitpoints and transient effects
in the latter). I might implement these as
prototypical lists of properties that get
copied to Creature or Item instances when
they are created. You can implement property
inheritance via a 'parent' property so that
a specific goblin Creature instance may relate to the
'warrior goblin' CreatureType, which contains a
parent reference to the 'generic goblin' CreatureType. And so on.
one way, and which detail the direction of
travel, various conditions of passage, etc.
by some logical organisation.
and Item instances are created (eg. which room,
or at what coordinates), when they are created and
with what frequency, and from
which CreatureTypes and ItemTypes. You may have
some logic in here to randomise things a bit.
all derived from a base Action class
or interface that specifies prerequisites
(eg. current position, mana points, some
degree of learning of a skill, etc). Normal
commands and actions can go here too since they
often have some sort of requirements too
(eg. a 'sleep' command requires that you're not
already sleeping.)
callback that you push onto a priority queue
to execute in the future. You can use these to
schedule combat rounds, spell cool-down times,
night/day cycles, whatever you like.
player and item statistics. Not type-safe but
you'll appreciate the flexibility later. In my
experience making stats member variables is
workable but inflexible, and having specialise
'attribute' classes becomes a convoluted
nightmare when debugging.
and a modifier value (eg. +10, +15%). These
get added to your creatures as they are used
(eg. through a spell effect, or by wielding
an enchanted weapon) and get stripped off later
by a timed FutureEvent or some other event such
as a command being executed.
PlayerRace, each of which describe a player's class
(eg. warrior, wizard, thief) or race (human, elf,
dwarf) and set starting stat values and limits,
skill availability lists, special powers, etc.
depending on your actual game type. You might
have a rendering classes for a graphical game, or
in a MUD you might have a Connection class
reflecting the TCP connection to the player's client.
Try to keep all game logic out of these.
and creature AI can be realised more quickly with
a decent scripting interface and it keeps compile times
down too. It also allows for some great in-game debugging
and diagnostic capabilities.
That would be the basic high level structure I'd use.
您可能需要考虑组件实体系统而不是传统的继承层次结构; 它们往往对某些类型的更改更加灵活,使工具(例如世界编辑器)开发更加容易,并提供并行化的机会,否则这些并行化可能并不明显或容易。
许多现代游戏引擎正在从“整体类对象”(或类实体,等等)转向“组件包”方法。
周围有许多书籍和文章。 一般来说:
特别是(一些值得注意的的,谷歌“组件”和“实体”的各种组合以获取更多信息):
每篇文章都链接到更多文章。
尝试一下 kool-aid,你可能会喜欢它。 =)
You may want to consider a component entity system rather than a traditional inheritance hierarchy; they tend to be more flexible to certain types of change, make tool (e.g. world editor) development much easier, and present opportunities for parallelization that might not otherwise be obvious or easy.
Many modern game engines are moving away from the "monolithic class Object" (or class Entity, whatever) and toward a "bag of components" approach.
There are numerous books and articles around. Generally:
Specifically (some noteworthy ones, google "component" and "entity" in various combinations for more):
Each of these articles links to a few more.
Try the kool-aid, you might like it. =)
刚开始:
Just to start:
类似的事情怎么样:
替代文本 http://img217.imageshack.us/img217/4886/classwo0.png< /a>
以下是其他一些图表:
How about something of the sort :
alt text http://img217.imageshack.us/img217/4886/classwo0.png
Here are some other diagrams:
Steve Yegge 提出的非常不同的方法。
A very different approach by Steve Yegge.
请参阅 JADE 的 Javadoc 了解对复杂游戏的良好概述:)
Look at JADE's Javadoc for a good overview of a complex game :)
大胆一些,你的游戏不应该是砍伐式废话的克隆。
你的演员应该能够转换立场,采取主动
招募其他演员等等。否则,还有什么意义呢?
Be bold, your game shouldn't be a clone of hack and slash nonsense.
Your actors should be able to switch sides, take their own initiative
enlist other actors, etc. Otherwise, whats the point?