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

天行健 君子當自強而不息

游戲中物件的定義與使用(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>
            欧美日韩免费观看一区| 亚洲精选久久| 久久精品国产免费| 性久久久久久久久久久久| 正在播放亚洲一区| 正在播放欧美视频| 亚洲香蕉视频| 羞羞色国产精品| 欧美在线观看www| 玖玖国产精品视频| 欧美日韩成人在线播放| 欧美视频免费看| 国产精品入口尤物| 精品二区久久| 一区二区三区视频在线| 篠田优中文在线播放第一区| 久久国产欧美| 亚洲人午夜精品免费| 亚洲国产成人av在线| aⅴ色国产欧美| 久久国产一区| 欧美精品色网| 狠狠色2019综合网| 一本一道久久综合狠狠老精东影业 | 欧美高清在线视频| 欧美丝袜一区二区三区| 国产免费成人在线视频| 亚洲人成毛片在线播放女女| 亚洲欧美日韩另类精品一区二区三区| 久久成人综合视频| 亚洲国产美女精品久久久久∴| 亚洲美女免费视频| 久久国产精品99精品国产| 欧美日韩国产经典色站一区二区三区| 国产丝袜美腿一区二区三区| 亚洲日本理论电影| 久久蜜臀精品av| 亚洲一区二区三区视频播放| 欧美国产精品v| 在线免费不卡视频| 亚洲欧美另类中文字幕| 亚洲电影有码| 久久精品欧洲| 国产女人18毛片水18精品| 一本久道久久综合婷婷鲸鱼| 男女精品视频| 久久精品国产精品| 国产精品嫩草99a| 亚洲私人黄色宅男| 亚洲日本欧美在线| 欧美成人中文| 国产主播一区二区| 久久精品在线| 一区二区三区四区蜜桃| 欧美国产日韩精品| 91久久久国产精品| 欧美v日韩v国产v| 欧美一区二区三区免费观看视频| 国产精品久久久久一区| 亚洲素人在线| 一本高清dvd不卡在线观看| 欧美伦理在线观看| 夜夜嗨av一区二区三区| 亚洲国产婷婷香蕉久久久久久| 久久久精彩视频| 尤物yw午夜国产精品视频明星| 久久久伊人欧美| 久久精品国产在热久久 | 麻豆久久久9性大片| 欧美在线观看视频一区二区三区| 国产日本欧洲亚洲| 久久久国产精品一区二区三区| 性伦欧美刺激片在线观看| 国精品一区二区| 美女免费视频一区| 蜜桃伊人久久| 一本久道久久综合中文字幕| 亚洲视频中文| 国产亚洲午夜| 欧美电影免费观看高清| 欧美精品久久久久久| 亚洲婷婷综合久久一本伊一区| 亚洲午夜久久久久久久久电影院| 国产精品一区二区欧美| 欧美xart系列在线观看| 欧美日韩美女在线| 久久精品亚洲精品| 欧美激情综合在线| 欧美在线观看视频在线| 蜜臀a∨国产成人精品| 亚洲午夜精品一区二区三区他趣| 欧美一级午夜免费电影| 亚洲精品女人| 亚洲欧美国产高清va在线播| 黄色成人av网站| 在线视频欧美日韩精品| 亚洲成人在线观看视频| 亚洲视频一区在线| 在线观看不卡| 99视频在线观看一区三区| 国产亚洲欧美一区在线观看| 日韩视频在线一区二区三区| 国产一区二区欧美日韩| 亚洲精品网址在线观看| 国内免费精品永久在线视频| 一区二区三区成人精品| 精品二区久久| 午夜一区在线| 亚洲一区三区在线观看| 美女露胸一区二区三区| 午夜综合激情| 猛干欧美女孩| 亚洲免费在线| 99精品视频免费观看| 欧美与欧洲交xxxx免费观看| 一本色道久久88综合亚洲精品ⅰ| 欧美影院成人| 亚洲欧美一区二区在线观看| 嫩草影视亚洲| 久久伊伊香蕉| 国产午夜亚洲精品理论片色戒| 亚洲欧洲精品一区二区| 尤物99国产成人精品视频| 午夜一区二区三视频在线观看| 亚洲宅男天堂在线观看无病毒| 女人天堂亚洲aⅴ在线观看| 久久久久国产精品一区| 欧美午夜www高清视频| 欧美激情视频一区二区三区免费 | 久久精品日韩一区二区三区| 欧美无乱码久久久免费午夜一区| 亚洲东热激情| 亚洲福利视频一区| 久久精品伊人| 久久午夜视频| 黄色影院成人| 久久婷婷色综合| 免费成人高清| 黄色精品一二区| 欧美一区二区三区免费观看 | 亚洲一区二区三区乱码aⅴ| 欧美精品色网| 一区二区日韩精品| 亚洲私人影院| 国产精品资源| 久久成人综合视频| 久久综合网络一区二区| 黄色成人在线网站| 老司机aⅴ在线精品导航| 欧美a级一区二区| 亚洲成人资源| 欧美精品免费看| 正在播放亚洲| 久久精品国产成人| 国产午夜精品全部视频在线播放| 亚洲欧美日韩天堂一区二区| 欧美一区二区视频在线| 国产日韩欧美一区| 久久本道综合色狠狠五月| 男女精品网站| 一区二区三区日韩在线观看| 国产精品视频免费在线观看| 午夜精品免费在线| 欧美阿v一级看视频| 亚洲日本一区二区三区| 一区二区三区四区五区视频 | 美日韩在线观看| 亚洲精品乱码久久久久久久久| 欧美日韩天堂| 欧美影院成人| 日韩亚洲欧美成人| 久久精品国产精品亚洲精品| 免费看的黄色欧美网站| 一区二区三区日韩欧美| 国产精品久久久一区麻豆最新章节| 亚洲尤物视频在线| 性欧美xxxx视频在线观看| 久久久99免费视频| 99视频精品全部免费在线| 国产精品一区二区久久国产| 免费成人激情视频| 亚洲综合成人婷婷小说| 欧美成人一品| 欧美一级电影久久| 日韩系列欧美系列| 国产视频一区二区在线观看| 欧美国产先锋| 久久精品91久久久久久再现| 日韩一区二区免费高清| 久久一区视频| 亚洲欧美精品一区| 亚洲免费观看在线视频| 国内精品一区二区| 国产精品一区二区久久精品| 欧美经典一区二区| 久久久综合免费视频| 香港久久久电影| 亚洲一区二区视频| 日韩视频一区二区| 亚洲黄色大片|