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

天行健 君子當自強而不息

Controlling Players and Characters(35)

You're coming to the end of the long haul. You’ve finished the private data and
functions, and the public functions are left:

public:
    cCharController()
    {
        ZeroMemory(
thissizeof(*this));
    }

    ~cCharController()
    {
        shutdown();
    }

    
void free()
    {
        delete m_root_char;
        m_root_char = NULL;

        m_num_char = 0;
    }

    
void shutdown()
    {
        free();

        delete[] m_mesh_anim;
        m_mesh_anim = NULL;
        m_num_mesh_anim = 0;

        delete[] m_char_anim;
        m_char_anim = NULL;
        m_num_char_anim = 0;

        m_spell_controller    = NULL;
        m_def_file[0]         = '\0';
        m_weapon_mesh_path[0] = '\0';
        m_texture_path[0]     = '\0';
    }
///////////////////////////////////////////////////////////////////////////////////////////////////

void cCharController::init(ID3DXFont* font, PCSTR def_file,
                           sItem* mil, sSpell* msl,
                           
long num_mesh_anim, PCSTR* mesh_names,
                           PCSTR weapon_mesh_path, PCSTR texture_path,
                           
long num_char_anim, sCharAnimInfo* char_anims)
{
    free();

    
if(mesh_names == NULL || def_file == NULL)
        
return;

    m_font = font;

    strcpy(m_def_file, def_file);

    m_mil = mil;
    m_msl = msl;

    
// copy over mesh path and texture path (or set default)
    strcpy(m_weapon_mesh_path, weapon_mesh_path ? weapon_mesh_path : ".\\");
    strcpy(m_texture_path, texture_path ? texture_path : ".\\");

    
// get mesh names
    if((m_num_mesh_anim = num_mesh_anim) != 0)
    {
        m_mesh_anim = 
new sMeshAnim[num_mesh_anim];

        
for(long i = 0; i < m_num_mesh_anim; i++)
            strcpy(m_mesh_anim[i].filename, mesh_names[i]);
    }

    
// get animation data
    if((m_num_char_anim = num_char_anim) != 0)
    {
        m_char_anim = 
new sCharAnimInfo[m_num_char_anim];

        
for(long i = 0; i < m_num_char_anim; i++)
            memcpy(&m_char_anim[i], &char_anims[i], 
sizeof(sCharAnimInfo));
    }
}

In addition to the typical class constructor and destructor are the init and shutdown pair
of functions. For the controller to operate, it must first be initialized with a call to init.
When you’re done with the character controller class, a call to shutdown is in order.

Somewhat similar in nature to shutdown, the free function completely
removes all characters in the list of active characters. This function is useful for
clearing the list when a character leaves a level and a whole new set of characters
need to be added to the list.

Speaking of adding characters to the list, here comes the function that does it all.

With the add_char function, you need to provide a unique identification number, the MCL
character definition number to use, the character’s type to assign (CHAR_PC, CHAR_NPC,
or CHAR_MONSTER), the artificial intelligence to use, and the character’s coordinates and
Y-axis angle used to point the character in a specific direction.

Following add_char are two functions that remove a character in the list. The remove function
takes a character’s unique identification number as an argument,
and the remove_char function takes a pointer to the character structure.

///////////////////////////////////////////////////////////////////////////////////////////////////

bool cCharController::add_char(long id, long def, long type, long ai,
                               
float pos_x, float pos_y, float pos_z,
                               
float direction)
{
    FILE* fp;
    
if((fp = fopen(m_def_file, "rb")) == NULL)
        
return false;

    sCharacter* character = 
new sCharacter;

    character->def           = def;
    character->id            = id;
    character->type          = type;
    character->ai            = ai;
    character->pos_x         = pos_x;
    character->pos_y         = pos_y;
    character->pos_z         = pos_z;
    character->direction     = direction;
    character->update_enable = 
true;
    character->charge        = rand()%101;

    sCharDef& char_def = character->char_def;

    fseek(fp, 
sizeof(sCharDef) * def, SEEK_SET);
    fread(&char_def, 1, 
sizeof(sCharDef), fp);
    fclose(fp);

    character->health_points = char_def.health_points;
    character->mana_points   = char_def.mana_points;

    
// load character ics
    if(char_def.item_filename)
    {
        character->char_ics = 
new cCharIcs;
        character->char_ics->load(char_def.item_filename);
    }

    sMeshAnim& mesh_anim = m_mesh_anim[char_def.mesh_index];

    
// load mesh and animation if needed
    if(mesh_anim.count == 0)
    {
        mesh_anim.mesh.load(mesh_anim.filename, m_texture_path);
        mesh_anim.anim.load(mesh_anim.filename, &mesh_anim.mesh);
        
        
for(long i = 0; i < m_num_char_anim; i++)
            mesh_anim.anim.set_loop(m_char_anim[i].is_loop, m_char_anim[i].name);
    }

    character->
object.create(&mesh_anim.mesh);
    mesh_anim.count++;

    
// load and configure weapon (if any)
    if(m_mil && char_def.weapon != -1 && m_mil[char_def.weapon].mesh_filename)
    {
        
char path[MAX_PATH];
        sprintf(path, "%s%s", m_weapon_mesh_path, m_mil[char_def.weapon].mesh_filename);
        character->weapon_mesh.load(path, m_texture_path);

        character->weapon_object.create(&character->weapon_mesh);
        character->weapon_object.attach_to_object(&character->
object, "WeaponHand");
    }

    
// link into head of list
    if(m_root_char)
        m_root_char->prev = character;

    character->next = m_root_char;
    m_root_char = character;

    
return true;
}

///////////////////////////////////////////////////////////////////////////////////////////////////

void cCharController::remove_char(sCharacter* character)
{
    
if(character == NULL)
        
return;

    
// decrease mesh count and release if no more

    sMeshAnim& mesh_anim = m_mesh_anim[character->char_def.mesh_index];

    
if(--mesh_anim.count == 0)
    {
        mesh_anim.mesh.free();
        mesh_anim.anim.free();
    }

    
// remove from list
    if(character->prev)
        character->prev->next = character->next;
    
else
        m_root_char = character->next;

    
if(character->next)
        character->next->prev = character->prev;

    character->prev = character->next = NULL;
    delete character;
}

///////////////////////////////////////////////////////////////////////////////////////////////////

void remove(long char_id)
{
     
return remove_char(get_char(char_id));
}

posted on 2007-12-04 17:27 lovedday 閱讀(226) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(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>
            一色屋精品亚洲香蕉网站| 国产亚洲欧洲| 亚洲视频在线看| 99国产麻豆精品| 国产精品日本一区二区| 欧美一区免费| 久久伊人精品天天| 亚洲日韩第九十九页| 亚洲精品色婷婷福利天堂| 国产精品qvod| 久久久一区二区| 欧美大色视频| 亚洲综合国产激情另类一区| 亚洲欧美在线一区| 亚洲成人资源网| 日韩亚洲欧美在线观看| 国产精品女人久久久久久| 美国十次成人| 欧美三级不卡| 国产精品久久久久久影院8一贰佰| 亚洲在线1234| 久久久五月天| 亚洲欧美日韩精品久久奇米色影视| 欧美一区二区三区四区夜夜大片| 亚洲国产成人av在线| 亚洲免费在线视频| 国产精品久久久久久久久动漫| 久久gogo国模啪啪人体图| 毛片一区二区| 欧美在线观看www| 欧美激情精品久久久久久黑人| 欧美在线国产| 欧美激情bt| 浪潮色综合久久天堂| 欧美视频精品一区| 亚洲国产精品久久久久秋霞蜜臀 | 亚洲一区二区三区乱码aⅴ| 亚洲高清不卡一区| 亚洲在线一区二区| 亚洲精品欧美日韩专区| 欧美在线啊v| 午夜免费在线观看精品视频| 欧美第一黄网免费网站| 久久久精彩视频| 国产精品日韩高清| 99在线观看免费视频精品观看| 在线不卡免费欧美| 欧美与欧洲交xxxx免费观看 | 亚洲美女中文字幕| 久久三级福利| 欧美 日韩 国产精品免费观看| 国产精品嫩草99a| 一区二区三区日韩在线观看| 亚洲裸体在线观看| 免费在线一区二区| 欧美高清视频在线观看| 一色屋精品视频在线观看网站| 欧美亚洲日本国产| 久久精品91久久香蕉加勒比| 国产精品色婷婷| 亚洲免费视频成人| 欧美一区二区日韩一区二区| 欧美午夜精品一区二区三区| 夜夜嗨网站十八久久| 亚洲视频1区2区| 欧美网站大全在线观看| 一本到12不卡视频在线dvd| 在线视频亚洲一区| 国产精品久久久久毛片软件| 亚洲少妇自拍| 欧美在线观看你懂的| 国产在线国偷精品产拍免费yy| 小辣椒精品导航| 久久这里有精品视频| 亚洲第一精品夜夜躁人人爽| 免费观看日韩av| 亚洲精选国产| 午夜日韩在线| 狠狠色丁香久久婷婷综合丁香| 久久九九免费| 欧美夫妇交换俱乐部在线观看| 亚洲国产精品999| 欧美精品aa| 亚洲综合第一页| 免费在线亚洲| 中文日韩在线视频| 国产欧美日韩在线| 免费看精品久久片| 亚洲精品久久久久久一区二区 | 精品96久久久久久中文字幕无| 浪潮色综合久久天堂| 亚洲精品乱码| 欧美中文在线观看| 亚洲娇小video精品| 欧美视频精品在线| 久久久亚洲成人| 99视频超级精品| 榴莲视频成人在线观看| 一区二区三区日韩| 黄色一区二区在线| 欧美日韩亚洲高清一区二区| 午夜在线精品偷拍| 亚洲精品欧洲精品| 久久婷婷蜜乳一本欲蜜臀| 一区二区三区www| 一区二区三区亚洲| 欧美午夜剧场| 免费亚洲电影在线| 欧美一区二视频| 一区二区三区精品| 欧美二区不卡| 久久久精品五月天| 亚洲综合不卡| 亚洲精品乱码久久久久久黑人| 国产日韩欧美精品一区| 欧美激情视频在线播放| 久久激情视频| 亚洲一区二区三区免费观看| 亚洲国产精品福利| 久久中文字幕导航| 欧美制服第一页| 亚洲免费视频一区二区| 日韩午夜激情| 亚洲国产片色| 1000部国产精品成人观看| 国产欧美日韩另类视频免费观看 | 欧美一区二区三区在线观看视频| 亚洲久色影视| 亚洲啪啪91| 亚洲国产成人av在线| 麻豆精品在线观看| 久久免费视频在线| 久久久久久久999| 久久高清免费观看| 亚欧美中日韩视频| 午夜亚洲精品| 亚洲欧美久久久| 亚洲男人av电影| 午夜国产精品视频| 亚洲欧洲av一区二区三区久久| 亚洲一区二区欧美| 亚洲免费视频成人| 亚洲欧美日韩国产一区| 亚洲欧美激情四射在线日 | 亚洲欧美精品伊人久久| 亚洲综合日本| 欧美一区二区在线免费播放| 亚洲欧美中文字幕| 久久超碰97中文字幕| 久久久久国产精品午夜一区| 久久精品一本| 欧美大片在线观看| 亚洲精品麻豆| 亚洲一区二区三区乱码aⅴ蜜桃女 亚洲一区二区三区乱码aⅴ | 亚洲欧美日韩精品久久久| 午夜精品免费视频| 久久久久久久综合日本| 麻豆成人综合网| 亚洲高清影视| 最新国产乱人伦偷精品免费网站| 亚洲精选一区二区| 亚洲一区二区免费| 久久久.com| 欧美—级在线免费片| 国产精品久久久久久亚洲毛片| 国产精品人人爽人人做我的可爱| 国产一区二区三区四区hd| 伊人成人在线| 中文亚洲欧美| 久久久久免费视频| 亚洲激情第一页| 亚洲一级在线| 久久一二三四| 国产精品久久毛片a| 狠狠色综合播放一区二区| 日韩视频―中文字幕| 欧美一区2区三区4区公司二百| 麻豆免费精品视频| 一区二区三区精品视频| 欧美一区二区三区成人| 欧美黑人在线播放| 国产日韩精品一区二区三区在线 | 国产欧美日韩精品a在线观看| 亚洲福利国产精品| 欧美一区二区三区四区高清 | 午夜免费电影一区在线观看 | 亚洲免费在线观看视频| 女生裸体视频一区二区三区| 一区二区三区日韩精品| 久久免费精品视频| 国产精品日韩欧美一区二区三区| 亚洲国产日韩欧美在线动漫 | 亚洲激情国产精品| 欧美一区午夜视频在线观看| 欧美激情一区在线观看| 欧美伊人精品成人久久综合97| 欧美日韩激情小视频| 1204国产成人精品视频| 欧美中文字幕在线播放| 夜夜夜久久久|