本文整理汇总了C++中Guard::attachAi方法的典型用法代码示例。如果您正苦于以下问题:C++ Guard::attachAi方法的具体用法?C++ Guard::attachAi怎么用?C++ Guard::attachAi使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guard
的用法示例。
在下文中一共展示了Guard::attachAi方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void GameState::init()
{
if (m_xLevel != nullptr)
{
delete m_xLevel;
m_xLevel = nullptr;
}
m_xLevel = new Level("../resources/level/", m_xSpriteManager, m_xGameObjectManager);
m_xLevel->loadColorCodes("colorcodes.txt");
m_xLevel->loadFloorColorCodes("floorcolorcodes.txt");
m_xLevel->getRotationsPaths("rotate.txt");
m_xLevel->create("level.png", "patrol.txt");
m_xLevel->createFloor("FirstFloor.png");
sf::Clock *xTimer = new sf::Clock;
m_cClock = sf::Clock();
//m_xPlayer = m_xGameObjectManager->createPlayer(m_xSpriteManager->loadSprite("spy.txt"), sf::Vector2f(64 * 48, 64 * 8), m_xEngine->m_window, 1, m_xLevel, xTimer);
m_xPlayer = m_xGameObjectManager->createPlayer(new Animator(m_xSpriteManager, "../resources/Spritesheets/"), m_xSpriteManager->loadAnimatedSprite("Spy_walk.txt"), sf::Vector2f(64 * 48, 64 * 8), m_xEngine->m_window, 1, m_xLevel, xTimer, m_xStateManager);
m_vGameObjects[MAIN].push_back(m_xPlayer);
m_vGameObjects[MAIN].insert(m_vGameObjects[MAIN].end(), m_xLevel->getObjects()->begin(), m_xLevel->getObjects()->end());
m_xView = new sf::View();
//kommentar
m_xView->reset(sf::FloatRect(0, 0, 1920 * 1, 1080 * 1));
/*m_xPlayer->m_xWeapon = new Gun(true, 2, 1.f, 1.f, &m_vGameObjects[MAIN], m_xGameObjectManager, m_xSpriteManager);
m_xPlayer->m_xWeapon->setAttachedObject(m_xPlayer);*/
/*m_xPlayer->m_xWeapon = new Baton(true, 10, 1.f, 1.f, &m_vGameObjects[MAIN], m_xLevel, m_xGameObjectManager, m_xSpriteManager);
m_xPlayer->m_xWeapon->setAttachedObject(m_xPlayer);*/
m_xPlayer->m_xWeapon = new Garrote(1.f, 2.5f, &m_vGameObjects[MAIN]);
m_xPlayer->m_xWeapon->setAttachedObject(m_xPlayer);
SoundManager soundmanager("../resources/Music/");
m_sIngame = soundmanager.getMusic("Ingame.ogg");
m_sIngame->setVolume(40.0f);
m_sIngame->setLoop(true);
m_sIngame->play();
hud = new HUD(m_xView, m_xSpriteManager, m_xPlayer);
PathFind *path = new PathFind(m_xLevel);
for (auto obj : m_vGameObjects[MAIN])
{
if (obj->getType() == PATROLLINGGUARD || obj->getType() == STATIONARYGUARD)
{
Guard *guard = static_cast<Guard*>(obj);
guard->attachAi(new AIManager(guard, m_xLevel, m_xPlayer));
guard->attachAnimator(new Animator(m_xSpriteManager, "../resources/Spritesheets/"));
if (guard->getIsRotating())
guard->m_xAIManager->forceCurrentState(AIManager::STATIONARY);
else if (guard->getIsPatrolling())
guard->m_xAIManager->forceCurrentState(AIManager::PATROLLING);
}
}
m_xPlayer->setStateObjects(&m_vGameObjects[MAIN]);
}