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


C++ Status::aquire_item方法代码示例

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


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

示例1: move

Area* Shop::move(int key)
{
    Area *area = 0;
    void *data = 0;
    bool rejected = false;

    int input = get_input_keydown(key);
    if (input & PRESS_DOWN) {
        data = m_menu->advance_pointer(Menu::DirectionDown);
        m_media->play_sound("advance.wav");
    }
    else if (input & PRESS_UP) {
        data = m_menu->advance_pointer(Menu::DirectionUp);
        m_media->play_sound("advance.wav");
    }
    else if (input & PRESS_ENTER) {
        if (m_menu->get_option() == 4) {
            m_media->play_sound("select.wav");
            area = new Area(m_src.c_str(), m_sx, m_sy);
        }
        else {
            Item *item = (Item *) m_menu->get_data();
            if (item) {
                Status *status = m_db->get_status();
                if (status->pay_gold(item->get_attribute("price"))) {
                    m_menu->replace_option("Sold out!");
                    item->aquire(m_db);
                    status->aquire_item(item);
                    m_media->play_sound("select.wav");
                }
                else {
                    m_media->play_sound("reject.wav");
                    rejected = true;
                }
            }
            else {
                m_media->play_sound("reject.wav");
                rejected = true;
            }
        }
    }

    if (data) {
        Item *item = (Item *) data;
        static char str[12];
        Color color;
        sprintf(str, "%06d Gold", item->get_attribute("price"));
        Status *status = m_db->get_status();
        if (status->get_gold() < item->get_attribute("price")) {
            color.set_named(Color::Red);
        }
        else {
            color.set_named(Color::White);
        }
        m_price_text->replace_line(str, color);
    }
    else if (!rejected) {
        static char str[12];
        Color color(Color::White);
        sprintf(str, "000000 Gold");
        m_price_text->replace_line(str, color);
    }

    return area;
}
开发者ID:surdeg,项目名称:dragonscurse,代码行数:65,代码来源:shop.cpp

示例2: move


//.........这里部分代码省略.........
                    }
                }
            }

            // Handle monster object
            else if (object_type == Object::TypeMonster) {
                Monster *monster = (Monster *) object;

                monster->move(m_map);
                monster->set_reference(player->get_front(), player->get_y());
                if (player->check_collision(monster) ||
                    monster->attack_object(player)) {
                    if (!monster->get_invisible()) {
                        player->set_hit(monster, m_db->get_status());
                    }
                }
                if (player->attack_object(monster)) {
                    monster->set_hit(player, m_db->get_status());
                }
                if (monster->get_action() == Actor::HitPerished) {
                    perished.push_back(monster);
                }
            }

            // Handle item objects
            else if (object_type == Object::TypeItem) {
                Item *item = (Item *) object;

                item->move(m_map);

                // Check if player picked up item
                if (player->check_collision(item)) {
                    Status *status = m_db->get_status();
                    status->aquire_item(item);
                    item->aquire(this);
                    item->set_reused(true);
                    perished.push_back(item);
                }
            }

            // Handle collectable objects
            else if (object_type == Object::TypeCollectable) {
                Collectable *collectable = (Collectable *) object;

                collectable->move(m_map);

                // Check if player picked up the collectable
                if (player->check_collision(collectable)) {
                    Status *status = m_db->get_status();
                    status->aquire_collectable(collectable);
                    perished.push_back(collectable);
                }
            }

            // Handle curse objects
            else if (object_type == Object::TypeCurse) {
                Curse *curse = (Curse *) object;

                curse->move(m_map);
                if (player->check_collision(curse)) {
                    player->set_morph(new Morph("human_to_salamander.xml",
                                                m_media,
                                                player->get_x(),
                                                player->get_y(),
                                                player->get_dir()));
                    player->set_warp(new Area(curse));
开发者ID:baijkal,项目名称:dragonscurse,代码行数:67,代码来源:world.cpp


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