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

天行健 君子當自強而不息

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 閱讀(230) 評論(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>
            久久久久国产精品麻豆ai换脸| 久久综合综合久久综合| 亚洲精品在线免费| 欧美日韩高清在线播放| 一区二区日韩精品| 亚洲精品之草原avav久久| 欧美日韩精品一区二区| 亚洲一区二区精品在线| 午夜精品久久久| 一区二区三区在线观看视频| 欧美ab在线视频| 欧美理论电影在线播放| 亚洲综合视频1区| 久久av二区| 日韩一级大片| 亚洲欧美日韩国产一区二区三区| 国模吧视频一区| 亚洲激情午夜| 国产欧美精品va在线观看| 美女亚洲精品| 欧美日韩亚洲综合| 久久久夜夜夜| 欧美理论电影网| 久久久精品一区| 欧美另类女人| 久久九九热免费视频| 欧美成va人片在线观看| 欧美一级电影久久| 欧美韩日一区二区| 久久国产精品电影| 欧美日韩免费一区| 免费亚洲网站| 国产精品一区久久久| 亚洲欧洲日产国产网站| 国产日韩亚洲欧美综合| 亚洲伦理在线免费看| 激情校园亚洲| 亚洲欧美国产77777| 亚洲另类黄色| 浪潮色综合久久天堂| 久久精品国产欧美亚洲人人爽 | 欧美黄色成人网| 国产精品视频免费观看| 91久久精品国产91久久| 国产一区二区黄色| 亚洲免费中文| 亚洲午夜一区二区三区| 欧美二区视频| 免费国产自线拍一欧美视频| 国产精品嫩草影院av蜜臀| 亚洲人成网站在线播| 亚洲第一福利视频| 欧美一级在线视频| 小处雏高清一区二区三区| 欧美日本精品| 亚洲精品你懂的| 91久久精品一区二区别| 久久久亚洲午夜电影| 久久精品亚洲乱码伦伦中文| 国产精品白丝黑袜喷水久久久| 91久久精品国产91性色tv| 在线成人免费观看| 久久影音先锋| 嫩模写真一区二区三区三州| 在线观看欧美激情| 久久综合激情| 亚洲第一在线视频| 日韩午夜一区| 欧美人与性禽动交情品| 亚洲精品小视频| 亚洲手机视频| 国产精品视频自拍| 香蕉久久夜色| 老色鬼精品视频在线观看播放| 国产亚洲人成网站在线观看| 欧美亚洲在线播放| 久久久亚洲高清| 亚洲韩国青草视频| 欧美区一区二区三区| 日韩一区二区久久| 欧美一区二区三区在线观看| 国产日韩欧美不卡| 麻豆av福利av久久av| 亚洲国产一区二区三区高清| 一区二区成人精品| 国产精品扒开腿做爽爽爽软件| 亚洲一区二区精品| 久久人人97超碰人人澡爱香蕉| 亚洲国产精品电影| 欧美日韩免费| 欧美一区二区私人影院日本| 免费美女久久99| 一本久道综合久久精品| 国产精品理论片在线观看| 欧美一区二区在线视频| 欧美高清在线播放| 亚洲与欧洲av电影| 一色屋精品亚洲香蕉网站| 欧美黄色免费网站| 亚洲欧美日韩综合国产aⅴ| 欧美成人嫩草网站| 亚洲一区二区三区在线视频| 国模叶桐国产精品一区| 欧美精品xxxxbbbb| 欧美一进一出视频| 亚洲精品日韩久久| 久久久人成影片一区二区三区 | 国产欧美日韩综合精品二区| 欧美在线观看www| 亚洲人久久久| 另类专区欧美制服同性| 亚洲在线视频网站| 亚洲国产天堂久久综合| 国产美女精品| 欧美日韩1区| 久久久99精品免费观看不卡| 亚洲美女精品一区| 欧美成年人视频| 欧美一级午夜免费电影| 亚洲精品激情| 激情久久久久| 国产一区二区观看| 国产精品乱码一区二三区小蝌蚪 | 美女视频一区免费观看| 亚洲欧美日韩成人| 99国产精品久久久久久久成人热| 免费黄网站欧美| 久久av红桃一区二区小说| 中文无字幕一区二区三区| 亚洲国产高清在线| 在线成人黄色| 狠狠做深爱婷婷久久综合一区| 国产精品视频成人| 国产精品xxxxx| 欧美日韩精品一区视频| 麻豆精品传媒视频| 久久久久国产一区二区三区四区 | 欧美在线电影| 亚洲欧美日韩国产一区二区三区| 日韩视频不卡| 亚洲精品少妇30p| 亚洲精品女av网站| 欧美成人免费网站| 欧美1区2区| 欧美福利视频网站| 欧美freesex8一10精品| 久久亚洲欧美国产精品乐播| 久久久久久久国产| 久久亚洲精品一区| 欧美成人午夜激情在线| 欧美v亚洲v综合ⅴ国产v| 久久综合伊人77777麻豆| 久久综合精品国产一区二区三区| 久久嫩草精品久久久精品| 久久九九全国免费精品观看| 久久久久免费视频| 久久夜色精品国产| 欧美成人免费播放| 亚洲精品国产品国语在线app| 亚洲片在线观看| 在线一区二区三区做爰视频网站| 99视频精品免费观看| 亚洲一区日本| 久久久精品tv| 欧美精品一区二区三| 欧美日韩一区二区三区在线看| 国产精品成av人在线视午夜片| 国产精品美女久久福利网站| 国产一区香蕉久久| 亚洲国产精品久久人人爱蜜臀| 亚洲免费电影在线观看| 亚洲一二三区在线观看| 欧美中文字幕在线| 欧美激情欧美激情在线五月| 亚洲精选成人| 久久丁香综合五月国产三级网站| 欧美v国产在线一区二区三区| 欧美日韩国产美| 国产日韩精品电影| 亚洲精品欧美| 欧美在线视屏| 亚洲高清视频一区二区| 亚洲免费在线电影| 欧美aaaaaaaa牛牛影院| 国产精品裸体一区二区三区| 国内自拍一区| 亚洲在线视频免费观看| 久久综合国产精品| 野花国产精品入口| 久久婷婷综合激情| 欧美午夜三级| 亚洲国产色一区| 欧美一区二区三区播放老司机| 欧美激情精品久久久六区热门 | 美女精品在线| 国产欧美欧洲在线观看| 一区二区三区四区五区精品| 久久久久久久久蜜桃| 亚洲视频免费观看| 欧美精品在线网站|