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

天行健 君子當自強而不息

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

 

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

 

使用物品清單系統(tǒng)管理物件

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

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

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


 

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

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.

 

開發(fā)一個地圖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)  編輯 收藏 引用


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


公告

導航

統(tǒng)計

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美一区二区在线看| 欧美激情第二页| 亚洲盗摄视频| 在线观看国产欧美| 亚洲国产精品久久91精品| 亚洲高清视频一区二区| 亚洲精品一二三| 日韩亚洲欧美成人一区| 一本久久综合亚洲鲁鲁五月天| 一本久道久久综合婷婷鲸鱼| 亚洲欧美在线网| 久久综合久久综合久久综合| 欧美国产亚洲精品久久久8v| 亚洲精品久久久久久久久久久| av不卡在线| 亚洲欧美日韩中文播放| 久久青草欧美一区二区三区| 欧美日韩成人综合| 欧美在线一级视频| 亚洲精品一二| 国内精品嫩模av私拍在线观看| 国模吧视频一区| 亚洲二区视频| 亚洲欧美美女| 欧美1区视频| 99国产精品私拍| 欧美影院午夜播放| 欧美日韩国产黄| 亚洲第一久久影院| 亚洲欧美三级在线| 亚洲国产精品精华液2区45| 宅男噜噜噜66国产日韩在线观看| 欧美在线视频一区| 国产精品久久99| 亚洲日产国产精品| 久久夜精品va视频免费观看| 亚洲毛片在线| 浪潮色综合久久天堂| 国产精品一区久久久| 亚洲美女毛片| 欧美成人在线网站| 欧美在线网址| 国产日韩综合| 亚洲免费视频在线观看| 亚洲激情第一区| 久久综合九色欧美综合狠狠| 国产欧美日韩亚洲一区二区三区| 99ri日韩精品视频| 亚洲第一成人在线| 美女网站久久| 又紧又大又爽精品一区二区| 欧美伊人精品成人久久综合97| 日韩午夜激情| 欧美日本中文字幕| 日韩午夜中文字幕| 欧美成人精品激情在线观看| 欧美中文字幕在线视频| 国产女人18毛片水18精品| 亚洲欧美国产高清va在线播| 亚洲视频福利| 国产精品激情偷乱一区二区∴| 日韩香蕉视频| 夜夜嗨av色综合久久久综合网| 欧美精品在线网站| 一区二区三区久久精品| 夜夜狂射影院欧美极品| 国产精品白丝黑袜喷水久久久| 夜夜嗨av一区二区三区四季av| 91久久午夜| 欧美三级电影一区| 亚洲一区免费视频| 午夜久久资源| 国产一区成人| 免费视频一区二区三区在线观看| 久久久久久久久久久久久久一区 | 国产专区欧美专区| 欧美专区福利在线| 久久av红桃一区二区小说| 国内一区二区在线视频观看 | aa成人免费视频| 一区二区三区精品视频在线观看| 欧美日韩中文字幕在线| 香港成人在线视频| 久久精品日产第一区二区| 伊人久久大香线蕉av超碰演员| 欧美sm视频| 欧美日韩不卡| 久久精品夜色噜噜亚洲a∨| 久久av在线| 亚洲另类黄色| 亚洲欧美另类国产| 1000部精品久久久久久久久| 亚洲国产精品成人一区二区 | 欧美高清视频一区二区三区在线观看 | 久久精品一区蜜桃臀影院| 久久久国产一区二区三区| 亚洲欧洲精品一区二区三区不卡 | 曰韩精品一区二区| 亚洲激情电影在线| 国产精品一区视频网站| 美国成人直播| 欧美色精品在线视频| 久久精品伊人| 欧美日韩日本国产亚洲在线| 久久久亚洲国产天美传媒修理工 | 亚洲精品中文字幕有码专区| 亚洲午夜电影在线观看| 亚洲电影免费| 午夜精品久久久久久久白皮肤 | 欧美中文字幕久久| 亚洲视频axxx| 久久综合中文字幕| 欧美中文字幕久久| 欧美日韩亚洲免费| 欧美成人一区二免费视频软件| 欧美视频在线观看 亚洲欧| 国产综合第一页| 亚洲欧美日韩天堂一区二区| 久久精品免费观看| 亚洲在线成人| 欧美精品一卡| 欧美成人综合一区| 国内视频一区| 亚欧美中日韩视频| 午夜欧美大尺度福利影院在线看| 欧美黄色片免费观看| 欧美福利一区二区| 在线日韩中文| 狂野欧美一区| 欧美成人自拍| 亚洲韩日在线| 理论片一区二区在线| 久久男人av资源网站| 国产偷久久久精品专区| 亚洲一区二区免费| 午夜精品久久一牛影视| 国产精品成人观看视频国产奇米| 亚洲国产欧美一区| 亚洲人成在线观看一区二区| 久久天天躁狠狠躁夜夜爽蜜月| 久久久久国产精品人| 国产在线观看一区| 久久er精品视频| 久久综合给合久久狠狠色| 国产日韩欧美一二三区| 校园春色国产精品| 久久青青草原一区二区| 国产一区日韩欧美| 久久久久久亚洲精品杨幂换脸| 久久精品欧洲| 精品福利免费观看| 老色批av在线精品| 亚洲人精品午夜| 99国产精品久久| 国产精品久久综合| 小黄鸭精品密入口导航| 美脚丝袜一区二区三区在线观看 | 羞羞漫画18久久大片| 国产精品专区一| 久久精品亚洲乱码伦伦中文 | 先锋影音久久久| 国产中文一区二区| 快射av在线播放一区| 亚洲精品美女在线| 亚洲欧美视频在线观看| 国产自产高清不卡| 欧美激情精品久久久久久黑人| 亚洲神马久久| 牛牛影视久久网| 中国成人黄色视屏| 国产一区二区电影在线观看| 老司机一区二区三区| 亚洲性线免费观看视频成熟| 久久久久久久综合狠狠综合| 亚洲精品在线看| 国产精品入口夜色视频大尺度| 校园春色国产精品| 最近中文字幕日韩精品| 欧美一级一区| 日韩一区二区精品视频| 99re66热这里只有精品3直播| 红桃视频欧美| 欧美午夜无遮挡| 久久精品国产一区二区三| 亚洲欧洲精品一区二区三区波多野1战4| 亚洲婷婷综合色高清在线| 国产一区二区三区不卡在线观看| 欧美福利专区| 久久精品一区四区| 亚洲天堂成人| 91久久香蕉国产日韩欧美9色| 欧美怡红院视频| 一区二区三区四区精品| 在线视频观看日韩| 国产亚洲成av人在线观看导航| 欧美日韩亚洲一区二区| 欧美91视频| 久久综合免费视频影院| 欧美亚洲综合在线| 一区二区三区精品久久久|