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


C++ Boss::move方法代码示例

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


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

示例1: initializeBossPhases

std::vector<std::vector<Phase>> initializeBossPhases(World &world, Boss &boss)
{
    std::vector<std::vector<Phase>> data(Boss::TypeCount);

    // Welcome to one of the most un-readable code I've ever made :

    // Boss1 Phase1
    Phase b1p1(world, boss, sf::seconds(5.f));
    b1p1.addSkill(sf::seconds(0.f), [&](Boss& b, sf::Time){
        Player* player = world.getPlayerEntity();
        //world.shakeCameraFor(0.3f);
        boss.unsensible();
        if((b.getPosition().x-player->getPosition().x) > 40) {
            boss.move(Entity::Left);
        } else if((b.getPosition().x-player->getPosition().x) < 40) {
            boss.move(Entity::Right);
        } else {
            //boss.knock();
        }
    });
    data[Boss::Boss1].push_back(b1p1);
    // Boss1 Phase2
    Phase b1p2(world, boss, sf::seconds(3.f));
    b1p2.addSkill(sf::seconds(0.f), [&](Boss& b, sf::Time){
        b.sensible();
    });
    data[Boss::Boss1].push_back(b1p2);
    // Boss1 Phase3
    Phase b1p3(world, boss, sf::seconds(1.f));
    b1p3.addSkill(sf::seconds(0.9f), [&](Boss& b, sf::Time dt){
        if(randomInt(0,5) == 1) world.addMedkit(sf::Vector2f(randomFloat(10, 1270), 20));
    });
    data[Boss::Boss1].push_back(b1p3);
    // Boss1 Phase4
    Phase b1p4(world, boss, sf::seconds(1.f));
    b1p4.addSkill(sf::seconds(0.9f), [&](Boss& b, sf::Time dt){
        Player* player = world.getPlayerEntity();
        auto pos = player->getPosition();
        //world.addZombie(sf::Vector2f(pos.x, 100.f));
        //world.addZombie(sf::Vector2f(pos.x+50.f, 100.f));
        world.addZombie(sf::Vector2f(randomFloat(10, 1270), 100.f));
        b.playLocalSound(world.getCommandQueue(), Sounds::Boss1AddPop);
    });
    data[Boss::Boss1].push_back(b1p4);

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

    /*// Boss2 Phase2
    Phase b2p2(world, boss, sf::seconds(2.f));
    b2p2.addSkill(sf::seconds(0.90f), [&](Boss&, sf::Time){
    });
    data[Entity::Boss2].push_back(b2p2);
    // Boss2 Phase1
    Phase b2p1(world, boss, sf::seconds(1.2f));
    b2p1.addSkill(sf::seconds(0.5f), [&](Boss& b, sf::Time){
        PlayerEntity* player = world.player();
        if((b.getPosition().x-player->getPosition().x) > 0) {
            world.addCreature(2, 50.f);
        } else {
            world.addCreature(2, -50.f);
        }
    });
    data[Entity::Boss2].push_back(b2p1);
    // Boss2 Phase2
    data[Entity::Boss2].push_back(b2p2);
    data[Entity::Boss2].push_back(b2p1);
    data[Entity::Boss2].push_back(b2p2);
    data[Entity::Boss2].push_back(b2p1);
    // Boss1 Phase4
    Phase b2p3(world, boss, sf::seconds(0.f));
    b2p3.addSkill(sf::seconds(0.f), [&](Boss& b, sf::Time dt){
        PlayerEntity* player = world.player();
        if(b.getPosition().x < 512) {
            for(unsigned int i = 0; i < 5; ++i)
            {
                world.addCreature(2, 50.f + i*32.f);
            }
            world.addCreature(1, 380.f);
        } else {
            for(unsigned int i = 0; i < 5; ++i)
            {
                world.addCreature(2, -50.f - i*32.f);
            }
            world.addCreature(1, -380.f);
        }
    });
    data[Entity::Boss2].push_back(b2p3);
    // Boss2 Phase4
    Phase b2p4(world, boss, sf::seconds(4.f));
    b2p4.addSkill(sf::seconds(0.f), [&](Boss& b, sf::Time){
        PlayerEntity* player = world.player();
        if((b.getPosition().x-player->getPosition().x) > 0) {
            boss.move(Entity::Left);
        } else {
            boss.move(Entity::Right);
        }
    });
    data[Entity::Boss2].push_back(b2p4);
    // Boss2 Phase5
    Phase b2p5(world, boss, sf::seconds(2.f));
//.........这里部分代码省略.........
开发者ID:Lo-X,项目名称:ld32,代码行数:101,代码来源:datatables.cpp


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