当前位置: 首页>>代码示例>>C++>>正文


C++ DataManager::get_sound方法代码示例

本文整理汇总了C++中DataManager::get_sound方法的典型用法代码示例。如果您正苦于以下问题:C++ DataManager::get_sound方法的具体用法?C++ DataManager::get_sound怎么用?C++ DataManager::get_sound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataManager的用法示例。


在下文中一共展示了DataManager::get_sound方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

MovableProducer::MovableProducer(DataManager &dm, const gamedata::unit_movable *um)
    :
    ObjectProducer(dm, um),
    unit_data(*um),
    on_move{dm.get_sound(this->unit_data.move_sound)},
    on_attack{dm.get_sound(this->unit_data.move_sound)},
    projectile{dm.get_type(this->unit_data.projectile_unit_id)} {

    // extra graphics if available
    // villagers have invalid attack and walk graphics
    // it seems these come from the command data instead
    auto walk = dm.get_unit_texture(this->unit_data.walking_graphics0);
    if (!walk) {

        // use standing instead
        walk = this->graphics[graphic_type::standing];
    }
    this->graphics[graphic_type::walking] = walk;

    // reuse as carry graphic if not already set
    if (this->graphics.count(graphic_type::carrying) == 0) {
        this->graphics[graphic_type::carrying] = walk;
    }

    auto attack = dm.get_unit_texture(this->unit_data.attack_graphic);
    if (attack && attack->is_valid()) {
        this->graphics[graphic_type::attack] = attack;
    }

    // extra abilities
    this->type_abilities.emplace_back(std::make_shared<MoveAbility>(this->on_move));
    this->type_abilities.emplace_back(std::make_shared<AttackAbility>(this->on_attack));
}
开发者ID:MrBeardy,项目名称:openage,代码行数:33,代码来源:producer.cpp

示例2: Error

ObjectProducer::ObjectProducer(DataManager &dm, const gamedata::unit_object *ud)
    :
    datamanager(dm),
    unit_data(*ud),
    terrain_outline{nullptr},
    default_tex{dm.get_unit_texture(ud->graphic_standing0)},
    dead_unit_producer{dm.get_type(ud->dead_unit_id)} {

    // for now just look for type names ending with "_D"
    this->decay = unit_data.name.substr(unit_data.name.length() - 2) == "_D";

    // find suitable sounds
    int creation_sound = this->unit_data.sound_creation0;
    int dying_sound = this->unit_data.sound_dying;
    if (creation_sound == -1) {
        creation_sound = this->unit_data.sound_creation1;
    }
    if (creation_sound == -1) {
        creation_sound = this->unit_data.sound_selection;
    }
    if (dying_sound == -1) {
        dying_sound = 323; //generic explosion sound
    }
    on_create = dm.get_sound(creation_sound);
    on_destroy = dm.get_sound(dying_sound);

    // convert the float to the discrete foundation size...
    this->foundation_size = {
        static_cast<int>(this->unit_data.radius_size0 * 2),
        static_cast<int>(this->unit_data.radius_size1 * 2),
    };

    // shape of the outline
    if (this->unit_data.selection_shape > 1) {
        this->terrain_outline = radial_outline(this->unit_data.radius_size0);
    }
    else {
        this->terrain_outline = square_outline(this->foundation_size);
    }

    // graphic set
    auto standing = dm.get_unit_texture(this->unit_data.graphic_standing0);
    if (!standing) {

        // indicates problems with data converion
        throw util::Error(MSG(err) << "Unit id " << this->unit_data.id0
            << " has invalid graphic data, try reconverting the data");
    }
    this->graphics[graphic_type::standing] = standing;
    auto dying_tex = dm.get_unit_texture(this->unit_data.graphic_dying0);
    if (dying_tex) {
        this->graphics[graphic_type::dying] = dying_tex;
    }

    // default extra graphics
    this->graphics[graphic_type::attack] = this->graphics[graphic_type::standing];
    this->graphics[graphic_type::work] = this->graphics[graphic_type::standing];

    // pull extra graphics from unit commands
    auto cmds = dm.get_command_data(this->unit_data.id0);
    for (auto cmd : cmds) {

        // same attack / work graphic
        if (cmd->action_graphic_id == -1 && cmd->proceed_graphic_id > 0) {
            auto task = dm.get_unit_texture(cmd->proceed_graphic_id);
            if (task) {
                this->graphics[graphic_type::work] = task;
                this->graphics[graphic_type::attack] = task;
            }
        }

        // seperate work and attack graphics
        if (cmd->action_graphic_id > 0 && cmd->proceed_graphic_id > 0 ) {
            auto attack = dm.get_unit_texture(cmd->proceed_graphic_id);
            auto work = dm.get_unit_texture(cmd->action_graphic_id);
            if (attack) {
                this->graphics[graphic_type::attack] = attack;
            }
            if (work) {
                this->graphics[graphic_type::work] = work;
            }
        }

        // villager carrying resources graphics
        if (cmd->carrying_graphic_id > 0) {
            auto carry = dm.get_unit_texture(cmd->carrying_graphic_id);
            this->graphics[graphic_type::carrying] = carry;
            if (carry) {

            }
        }
    }
}
开发者ID:MrBeardy,项目名称:openage,代码行数:93,代码来源:producer.cpp


注:本文中的DataManager::get_sound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。