青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

游戲中物件的定義與使用(5)

 

本篇是游戲中物件的定義與使用(4)的續篇。

 

使用物品清單系統管理物件

物件被分散在四處,玩家們找到這些物件只不過是一個時間問題。對于這種情況,玩家需要運用一種方法去管理物件,包括使用物品清單控制系統(inventory control system,ICS)來進行分類整理。

請不要誤解,一個ICS并不只適用于玩家,它同樣適用于整個游戲世界。物件可以屬于一張地圖,一個角色,甚至是另一個物件(例如背包,有一些其他的物件在它里面),那就意味著物件需要指定它的所有者(ownership)。除此之外,一個所有者可以擁有一個物件的多個實例(multiple instance),例如貨幣。

所有者的物件收藏稱之為物件清單列表(inventory list),任何物件都可以歸屬到這個列表中去(也包括物件的眾多實例)。所有者,物件清單列表,以及數量之間的關系如下表所示:


 

ICS和MIL相互協調工作,MIL只保存了世界中每個物件惟一的實例,而ICS則使用了物件的眾多實例。每當ICS需要一個物件的信息時,它可以引用MIL。以這種方式,可以僅使用ICS保存MIL中的物件引用編號(如下圖所示),以節省大量內存。

For your game’s maps and levels, a simple ICS (called a map ICS) consists of only a
list of items and their locations within the map, which is just fine because you can
place objects throughout—ready for characters to pick them up. The real problem
comes when those characters pick them up and add them to their inventory.
Multiple instances pile up, new items are added, and other items are used or
dropped. Things quickly become a real jumble. Handling a collection of character’s
objects is the job of a character ICS, which is a little more complicated than its map
counterpart.

 

開發一個地圖ICS

The map ICS tracks items that are placed within levels, including items that are
contained within other items—a sword contained within a treasure chest, for
example. The type of map you use determines how you position items within the
map. In 3-D maps, you use three coordinates for positioning an item—the X-, Y-,
and Z- coordinates. Because each map is also unique (each part of the world has
different maps), you can track each map’s items in separate files.

You can represent the map ICS with a structure and a class:

//==================================================================================
// This structure contains map item information list.
//==================================================================================
typedef struct sMapItem
{
    
long    item_index;             // MIL item index
    long    quantity;               // quantity of item (ie coins)
    float   x_pos, y_pos, z_pos;    // map coordinates

    sMapItem*   prev;
    sMapItem*   next;

    
long    index;          // map item index
    long    owner_index;

    sMapItem*   parent;     
// parent of a contained item
    
    sMapItem()
    {
        memset(
this, 0, sizeof(*this));
        owner_index = -1;
    }

    ~sMapItem()
    {
        delete next;   
    }
} *sMapItemPtr;

//==================================================================================
// This class encapsulate map inventory contrl system.
//==================================================================================
typedef class cMapIcs
{
private:
    
long        m_num_items;
    sMapItemPtr m_root_item;

private:
    
long    get_next_long(FILE* fp);
    
float   get_next_float(FILE* fp);

public:
    cMapIcs();
    ~cMapIcs();

    
bool load(const char* filename);
    
bool save(const char* filename);
    
void free();

    
void add(long item_index, long quantity,
             
float x_pos, float y_pos, float z_pos,
             sMapItemPtr owner_item);

    
void remove(sMapItemPtr item);

    
long get_num_items();
    sMapItemPtr get_root_item();
    sMapItemPtr get_item(
long index);
} *cMapIcsPtr;

First, you see the sMapItem structure, which holds the information for every item in
the map. item_index is the MIL item reference number (which ranges from 0 to 1,023
if you used the MILEdit program), and quantity is the number of item_index (to allow
things like a horde of coins to be represented as a single object). Then you see the
item’s map coordinates x_pos, y_pos, and z_pos.

Next comes the prev and next pointers. You insert them to track a linked list of
sMapItem structures. The next couple of variables, index and owner_index, are used when
loading and saving the items in a map. Index stores the current index number of
an item in the linked list. If an item is owned by another item, the Owner variable
holds the index number of the parent object (otherwise, Owner is set to -1). When
loading (or adding) an object, you set the final variable in sMapItem (parent) to point
to the actual owner item’s structure. You can see the sMapItem structure link list concept
illustrated in Figure 15.8.

The sMapItem uses both a constructor and destructor function called whenever a
structure instance is allocated or reallocated. Both functions ensure that the linked
list pointers are in check, and whenever a structure is deleted, all subsequent
sMapItem structures in the linked list are deleted as well.

CAUTION
If you’re removing only a single instance of sMapItem from the linked list, you first have to
set the instance’s Next variable to NULL. Doing so ensures that all subsequent instances in the
linked list are not deleted as well.

The cMapICS class has two private functions (get_next_long and get_next_float) used to read
in text and convert it into a long or float value. The cMapICS class also has eight usable
public functions. Take a closer look at those public functions.


posted on 2007-11-07 18:31 lovedday 閱讀(250) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久九九久久九九| 一区二区三区视频免费在线观看 | 国产日韩欧美在线观看| 欧美日韩福利在线观看| 欧美暴力喷水在线| 欧美日韩免费一区二区三区视频| 欧美大片在线看| 欧美日韩一区二区三区在线看| 麻豆精品传媒视频| 欧美日韩国产美| 国产精品一区在线观看| 国产精品亚洲人在线观看| 国内精品久久久久久影视8| 亚洲高清免费视频| 日韩午夜免费视频| 亚洲欧美日韩国产| 久久精品av麻豆的观看方式 | 最新亚洲激情| 亚洲在线视频一区| 久久亚洲精品欧美| 91久久精品国产| 最新日韩欧美| 欧美一二三区精品| 欧美国产三区| 国产一区二区丝袜高跟鞋图片| 亚洲国产小视频在线观看| 一区二区三区产品免费精品久久75| 欧美一级久久久| 亚洲国产三级网| 欧美专区在线播放| 国产精品www色诱视频| 在线免费观看日本一区| 午夜久久福利| 亚洲精品日产精品乱码不卡| 欧美在线视频一区二区三区| 欧美网站大全在线观看| 91久久精品美女| 欧美一区二区三区的| 欧美日韩一区二区三区在线| 亚洲日本成人| 麻豆国产精品va在线观看不卡| 中文日韩在线视频| 欧美激情视频一区二区三区免费 | 黄色精品网站| 午夜久久美女| 一区二区三区高清不卡| 欧美高清影院| 亚洲国产欧美另类丝袜| 老色批av在线精品| 久久精品一区二区| 黄色成人免费网站| 麻豆久久婷婷| 久久综合精品国产一区二区三区| 狠狠色丁香婷婷综合| 久久国产日韩欧美| 欧美一区精品| 狠狠色丁香婷婷综合| 美女精品视频一区| 美国十次成人| 亚洲理伦在线| 亚洲精品视频中文字幕| 欧美精品videossex性护士| 亚洲人在线视频| 亚洲乱码精品一二三四区日韩在线| 欧美黄色成人网| 一本久道久久综合婷婷鲸鱼| 亚洲日韩中文字幕在线播放| 欧美激情小视频| 一本大道久久a久久综合婷婷| 日韩午夜在线观看视频| 国产精品视频男人的天堂| 久久成人综合视频| 久久免费精品视频| 亚洲精品久久视频| 亚洲美女色禁图| 国产精品久久久久久妇女6080 | 麻豆精品一区二区综合av| 久久久久久国产精品mv| 亚洲国产精品一区二区第四页av| 欧美国产精品人人做人人爱| 欧美激情精品| 欧美在线免费| 免费久久精品视频| 夜夜嗨av一区二区三区四季av| 亚洲最新合集| 国内外成人在线| 最新日韩av| 国产视频欧美| 国产精品成人午夜| 欧美一区二区高清| 久久久青草婷婷精品综合日韩 | 免费视频亚洲| 欧美日韩午夜剧场| 久久在线播放| 欧美性猛交xxxx乱大交退制版| 久久九九热免费视频| 欧美精品一区二区在线观看 | 欧美一区二区| 亚洲精品日产精品乱码不卡| 亚洲午夜激情| 亚洲精品日韩综合观看成人91| 亚洲视频在线二区| 亚洲成色www8888| 在线综合视频| 亚洲乱码国产乱码精品精天堂| 欧美一级视频| 一区二区三区.www| 麻豆视频一区二区| 久久精品99国产精品日本 | 欧美一区午夜精品| 99精品国产高清一区二区| 久久国产乱子精品免费女| 亚洲午夜性刺激影院| 久久久久久成人| 亚洲中字黄色| 欧美—级a级欧美特级ar全黄| 午夜精品久久久久久久久久久| 久久乐国产精品| 久久理论片午夜琪琪电影网| 欧美日韩亚洲成人| 亚洲高清资源| 久久精品国产精品亚洲精品| 欧美一区二区精美| 欧美韩国日本一区| 久久久久91| 国产精品自拍网站| 亚洲尤物在线| 午夜亚洲视频| 国产精品高潮呻吟久久av无限| 日韩一二三区视频| 亚洲免费观看高清在线观看| 欧美xart系列高清| 麻豆成人在线观看| 狠狠综合久久av一区二区小说| 亚洲免费网址| 亚洲免费人成在线视频观看| 欧美视频一区二区三区四区| 亚洲国产视频a| 99精品国产99久久久久久福利| 欧美国产精品一区| 亚洲黄色精品| 亚洲美女黄色片| 欧美片网站免费| 日韩一级片网址| 亚洲桃花岛网站| 欧美日韩中文字幕精品| 亚洲精品午夜| 亚洲欧美激情精品一区二区| 欧美一级日韩一级| 欧美片网站免费| 99在线|亚洲一区二区| 亚洲精品在线电影| 欧美视频官网| 99re66热这里只有精品4| 在线不卡a资源高清| 欧美成人精品一区二区| 亚洲视频观看| 久久手机精品视频| 欧美另类女人| 亚洲经典一区| 一本久久综合| 欧美视频在线观看免费| 亚洲第一搞黄网站| 亚洲人成在线观看| 欧美日韩精品一区二区三区四区| 亚洲美女毛片| 亚洲免费影视第一页| 国产精品私人影院| 久久精品亚洲国产奇米99| 欧美成人第一页| 亚洲视频自拍偷拍| 国产欧美一区二区精品性| 欧美一区二区高清在线观看| 欧美成人综合| 亚洲欧美日韩综合一区| 狠狠色狠狠色综合日日91app| 久久在线视频| 一区二区三区久久网| 鲁大师影院一区二区三区| 日韩视频一区二区| 国产无一区二区| 男人插女人欧美| 一本色道久久综合亚洲精品婷婷| 久久精品亚洲热| 亚洲精品国产精品乱码不99| 国产精品a久久久久久| 久久精品视频在线观看| 一本一本a久久| 麻豆成人综合网| 一区二区黄色| 亚洲国产成人av好男人在线观看| 国产精品啊v在线| 久久久一区二区三区| 一区二区免费在线观看| 欧美成人福利视频| 久久婷婷一区| 99re视频这里只有精品| 男女精品视频| 久久久久久日产精品| 亚洲性感美女99在线|