本文整理汇总了C++中CGameObject::addController方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameObject::addController方法的具体用法?C++ CGameObject::addController怎么用?C++ CGameObject::addController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameObject
的用法示例。
在下文中一共展示了CGameObject::addController方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
bool CGamePlayState::update(float dtime)
{
m_enemyTime -= dtime;
if (m_enemyCount > 0.f && m_enemyTime <= 0.f)
{
m_enemyTime = 2.f;
m_enemyId++;
// Create new enemy
CGameObject* enemy = new CGameObject();
if (m_enemyId == 1) {
enemy->setPosition(glm::vec3(-50.f, 30.f, 50.f));
enemy->setRotation(glm::vec3(0.f));
enemy->setScale(glm::vec3(0.5f));
enemy->addController(std::make_shared<CRestrictPositionController>(glm::vec2(-100.f, -100.f), glm::vec2(100.f, 100.f)));
enemy->addController(std::make_shared<CLinearMovementController>(enemy->getForward(), 15.f));
enemy->addController(std::make_shared<CHealthController>(100.f));
enemy->addController(std::make_shared<CRemoveOnDeathController>(this));
}
if (m_enemyId == 2) {
enemy->setPosition(glm::vec3(0.f, 45.f, -50.f));
enemy->setRotation(glm::vec3(0.f));
enemy->setScale(glm::vec3(0.5f));
enemy->addController(std::make_shared<CRestrictPositionController>(glm::vec2(-100.f, -100.f), glm::vec2(100.f, 100.f)));
enemy->addController(std::make_shared<CLinearMovementController>(enemy->getForward(), 15.f));
enemy->addController(std::make_shared<CHealthController>(100.f));
enemy->addController(std::make_shared<CRemoveOnDeathController>(this));
}
if (m_enemyId == 3) {
enemy->setPosition(glm::vec3(50.f, 20.f, 0.f));
enemy->setRotation(glm::vec3(0.f));
enemy->setScale(glm::vec3(0.5f));
enemy->addController(std::make_shared<CRestrictPositionController>(glm::vec2(-100.f, -100.f), glm::vec2(100.f, 100.f)));
enemy->addController(std::make_shared<CLinearMovementController>(enemy->getForward(), 15.f));
enemy->addController(std::make_shared<CHealthController>(100.f));
enemy->addController(std::make_shared<CRemoveOnDeathController>(this));
}
if (m_enemyId == 4) {
enemy->setPosition(glm::vec3(50.f, 25.f, 0.f));
enemy->setRotation(glm::vec3(0.f, 92.6,0.f));
enemy->setScale(glm::vec3(0.5f));
enemy->addController(std::make_shared<CRestrictPositionController>(glm::vec2(-100.f, -100.f), glm::vec2(100.f, 100.f)));
enemy->addController(std::make_shared<CSimpleWaypointController>(glm::vec3(-101.f, 25.f, 0.f), 15.f, this));
enemy->addController(std::make_shared<CHealthController>(100.f));
enemy->addController(std::make_shared<CRemoveOnDeathController>(this));
}
if (m_enemyId == 5) {
enemy->setPosition(glm::vec3(0.f, 40.f, -50.f));
enemy->setRotation(glm::vec3(0.f, 92.6, 0.f));
enemy->setScale(glm::vec3(0.5f));
enemy->addController(std::make_shared<CRestrictPositionController>(glm::vec2(-100.f, -100.f), glm::vec2(100.f, 100.f)));
enemy->addController(std::make_shared<CSimpleWaypointController>(glm::vec3(-101.f, 40.f, -50.f), 15.f, this));
enemy->addController(std::make_shared<CHealthController>(100.f));
enemy->addController(std::make_shared<CRemoveOnDeathController>(this));
}
if (m_enemyId == 6) {
enemy->setPosition(glm::vec3(-50.f, 50.f, 50.f));
enemy->setRotation(glm::vec3(0.f, 92.6, 0.f));
enemy->setScale(glm::vec3(0.5f));
enemy->addController(std::make_shared<CRestrictPositionController>(glm::vec2(-100.f, -100.f), glm::vec2(100.f, 100.f)));
enemy->addController(std::make_shared<CSimpleWaypointController>(glm::vec3(-101.f, 50.f, 50.f), 15.f, this));
enemy->addController(std::make_shared<CHealthController>(100.f));
enemy->addController(std::make_shared<CRemoveOnDeathController>(this));
}
// Player collidable added to player collision group
std::vector<float> enemyVertices;
std::vector<unsigned int> enemyIndices;
std::vector<float> enemyNormals;
std::vector<float> enemyUvs;
EPrimitiveType enemyType;
m_resourceManager->getMesh(enemyShip, enemyVertices, enemyIndices, enemyNormals, enemyUvs, enemyType);
enemy->setCollidable(m_collisionSystem->add(CAABBox::create(enemyVertices), m_enemyGroup));
// Create scene object
CSceneObjectProxy* enemySceneObject = new CSceneObjectProxy(m_scene, m_scene->createObject(enemyShip, enemyShipMaterial, glm::vec3(m_enemyXPosition, 25.f, 0.f), glm::quat(0.f, 0.f, 0.f, 0.f), glm::vec3(0.5f)));
enemy->setSceneObject(enemySceneObject);
// Add enemy
getGameWorld().addObject(enemy);
m_enemyCount -= 1;
m_enemyXPosition += 25.f;
}
m_ring->setRotation(glm::vec3(m_ring->getRotation().x, m_ring->getRotation().y, m_ring->getRotation().z + dtime));
if (m_inputProvider->isKeyPressed(GLFW_KEY_P))
{
return false;
}
if (m_inputProvider->isKeyPressed(GLFW_KEY_O))
{
//.........这里部分代码省略.........