RPG的类图示例(角色扮演游戏) [英] Class diagram examples for RPG (Role Playing Game)

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

问题描述

有没有人知道我在哪里可以找到RP图游戏开发的类图的例子?类似于这里的东西会非常有用。我不是在寻找可以slavishly复制的东西,而是为了不同的例子,图表的各种解决方案的问题,我发现,当我尝试和铅笔下来我自己的类。

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.

推荐答案

我知道来自GameDev.net的Emmanuel Deloget,但我不确定我会选择使用他在那里的层次结构!太多的继承,没有足够的灵活性。

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.

如果我正在写一个基于文本的RPG(如我在过去做的),它看起来有点像这样我没有时间为它绘制图表,可惜):

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):


  • 生物,房间和项目派生
    WorldEntity,与WorldEntity
    对象排列在一个Composite
    结构中,所以项目可以存在于
    其他项目,由生物携带,
    存在于房间内。实现
    WorldEntities
    的访问者模式可能工作良好。

  • CreatureType和ItemType类
    包含
    的'类'数据Creature和Item
    实例,它们返回它们的
    对应的'type'对象。 (例如,基础
    命中率和统计在前,
    当前命中点和瞬态效应
    在后者)。我可能实现这些作为
    原型列表的属性,将
    复制到Creature或Item实例时,
    他们被创建。你可以通过'parent'属性实现属性
    继承,以便
    a特定的goblin生物实例可以与
    'warrior goblin'CreatureType相关,它包含一个
    父引用'generic goblin'CreatureType。等等。

  • 由他们的房间拥有的退出,并且单程
    ,详细说明
    旅行的方向,各种通行条件等。

  • 区域,包含一组由一些逻辑组织连接
    的房间。

  • 一个Spawn类,用于指定Creature
    和Item实例(例如,哪个房间,
    或什么坐标),当它们被创建时,
    具有什么频率,以及从
    创建CreatureTypes和ItemTypes。

  • 法术,技能,能力等等。
    全部派生自基本动作类
    或指定前提
    (例如,当前位置,法力点,某些
    技能学习程度等)的界面。正常
    命令和动作也可以在这里,因为它们
    经常有一些要求太多
    (例如,一个'sleep'命令要求你不是
    已经睡眠。 )

  • 一个FutureEvent类,它本质上是一个
    回调,您推送到优先级队列
    以在将来执行。

  • 你可以使用哈希/地图/字典来计算战斗时间,你可以用
    计划战斗回合,拼写冷却时间,
    夜晚/ name-> value对,用于
    播放器和项目统计。不是类型安全,但
    你会欣赏的灵活性后。在我的
    经验使统计成员变量是
    可行但不灵活,并且专门化
    '属性'类在调试时变成一个复杂的
    噩梦。

  • 包含统计数据名称
    和修饰符值(例如+10,+ 15%)的修饰符类型。这些
    被添加到你的生物,因为他们使用的
    (例如通过法术效果,或挥舞
    一个魔法武器),并通过定时FutureEvent后剥离

  • 特定于游戏的类,如PlayerClass或
    PlayerRace,每个类描述玩家的类
    (例如战士,巫师,小偷)或种族(人类,精灵,
    矮人),并设置起始统计值和限制,
    技能可用性列表,特殊权力等。

  • 基本播放器界面类,将根据您的实际游戏类型而变化
    。你可能
    有一个图形游戏的渲染类,或
    在MUD中你可能有一个Connection类
    反映到播放器客户端的TCP连接。
    尝试保留所有游戏逻辑。

  • 脚本界面。大多数命令,法术,
    和生物AI可以更快地实现
    一个体面的脚本接口,它保持编译时间
    。它还允许一些伟大的游戏中调试
    和诊断功能。

  • Creatures, Rooms, and Items derived 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.
  • CreatureType and ItemType classes 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.
  • Exits that are owned by their Room, and are one way, and which detail the direction of travel, various conditions of passage, etc.
  • Areas, that contain groups of rooms connected by some logical organisation.
  • A Spawn class to dictate where Creature 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.
  • Spells, skills, abilities, etc. 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.)
  • A FutureEvent class which is essentially a 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.
  • A hash/map/dictionary of name->value pairs for 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.
  • A Modifier type which contains a stat name 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.
  • Game-specific classes such as PlayerClass or 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.
  • Basic player interface classes which will vary 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.
  • A scripting interface. Most of your commands, spells, 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.

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

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