void ParticleEmitterData::CreateInputLayout() { HRESULT hr; D3DX11_PASS_DESC passDesc; hr = myEffect->GetTechnique()->GetPassByIndex(0)->GetDesc(&passDesc); DL_ASSERT_EXP(!FAILED(hr), "[ParticleEmitterData](CreateInputLayout) : Failed to get Pass Description!"); const D3D11_INPUT_ELEMENT_DESC VertexParticleLayout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "ALPHA", 0, DXGI_FORMAT_R32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "SIZE", 0, DXGI_FORMAT_R32_FLOAT, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TIME", 0, DXGI_FORMAT_R32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "ROTATION", 0, DXGI_FORMAT_R32_FLOAT, 0, 36, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; UINT size = ARRAYSIZE(VertexParticleLayout); hr = Engine::GetInstance()->GetDevice()->CreateInputLayout(VertexParticleLayout , size , passDesc.pIAInputSignature , passDesc.IAInputSignatureSize , &myInputLayout); DL_ASSERT_EXP(!FAILED(hr), "[ParticleEmitterData](CreateInputLayout) : Failed to Create InputLayout!"); Engine::GetInstance()->SetDebugName(myInputLayout, "ParticleEmitterData::myInputLayout"); }
void StateStack::PushSubGameState(GameState* aSubGameState) { DL_ASSERT_EXP(myGameStates.Size() > 0, "Can't push sub game state, no main game state present."); DL_ASSERT_EXP(myMainIndex < 20 && mySubIndex < 20, "Can't add more than 20 states, it's unreasonable!"); myGameStates[myMainIndex].Add(aSubGameState); aSubGameState->InitState(myStateStackProxy); mySubIndex = myGameStates[myMainIndex].Size() - 1; }
void Cube3D::InitVertexBuffer() { myVertexBuffer = new VertexBufferWrapper(); HRESULT hr; if (myInputLayout == nullptr) { D3DX11_PASS_DESC passDesc; hr = myEffect->GetTechnique()->GetPassByIndex(0)->GetDesc(&passDesc); DL_ASSERT_EXP(!FAILED(hr), "[Cube3D](CreateInputLayout) : Failed to get Pass Description!"); const D3D11_INPUT_ELEMENT_DESC Cube3DRendererLayout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; UINT size = ARRAYSIZE(Cube3DRendererLayout); hr = Engine::GetInstance()->GetDevice()->CreateInputLayout(Cube3DRendererLayout , size , passDesc.pIAInputSignature , passDesc.IAInputSignatureSize , &myInputLayout); DL_ASSERT_EXP(!FAILED(hr), "[Cube3D](CreateInputLayout) : Failed to Create InputLayout!"); Engine::GetInstance()->SetDebugName(myInputLayout, "Cube3D::myInputLayout"); } D3D11_BUFFER_DESC vertexBufferDescription; vertexBufferDescription.Usage = D3D11_USAGE_DYNAMIC; vertexBufferDescription.ByteWidth = myVertexBaseData->mySize; vertexBufferDescription.BindFlags = D3D11_BIND_VERTEX_BUFFER; vertexBufferDescription.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; vertexBufferDescription.MiscFlags = 0; vertexBufferDescription.StructureByteStride = 0; D3D11_SUBRESOURCE_DATA vertexBufferInitData; vertexBufferInitData.pSysMem = myVertexBaseData->myVertexData; // Set vertex buffer hr = Engine::GetInstance()->GetDevice()->CreateBuffer(&vertexBufferDescription, &vertexBufferInitData , &myVertexBuffer->myVertexBuffer); if (FAILED(hr)) { DL_ASSERT("Failed to create vertexbuffer in CUBE3D"); } Engine::GetInstance()->SetDebugName(myVertexBuffer->myVertexBuffer, "Cube3D::myVertexBuffer"); }
void LevelFactory::LoadDifficults() { XMLReader reader; reader.OpenDocument("Data/Setting/SET_difficulty.xml"); tinyxml2::XMLElement* rootElement = reader.ForceFindFirstChild("root"); int index = 0; for (tinyxml2::XMLElement* e = reader.ForceFindFirstChild(rootElement); e != nullptr; e = reader.FindNextElement(e)) { DL_ASSERT_EXP(index < static_cast<int>(eDifficult::_COUNT), "You are trying to add more difficults than there should be."); if (std::strcmp(e->Name(), "Difficult") == 0) { Difficult newDifficult; std::string diffType; reader.ForceReadAttribute(e, "type", diffType); reader.ForceReadAttribute(e, "multiplier", newDifficult.myMultiplier); reader.ForceReadAttribute(e, "defendHealthMulitplier", newDifficult.myHealthMultiplier); if (diffType == "Easy") { newDifficult.myType = eDifficult::EASY; } else if (diffType == "Normal") { newDifficult.myType = eDifficult::NORMAL; } else if (diffType == "Hard") { newDifficult.myType = eDifficult::HARD; } myDifficults.Insert(index++,newDifficult); } } reader.CloseDocument(); }
void ParticleEmitterInstance::Initiate(ParticleEmitterData* someData, bool anAllowManyParticles) { myParticleEmitterData = someData; myEmitterPath = myParticleEmitterData->myFileName; int particleCount = static_cast<int>(myParticleEmitterData->myParticlesPerEmitt * myParticleEmitterData->myParticlesLifeTime / myParticleEmitterData->myEmissionRate) + 1; DL_DEBUG(("Loading :" + myEmitterPath).c_str()); DL_ASSERT_EXP(anAllowManyParticles == true || particleCount <= 201, "Can't have more than 201 particles in an emitter!"); myGraphicalParticles.Init(particleCount); myLogicalParticles.Init(particleCount); myEmissionTime = myParticleEmitterData->myEmissionRate; myDiffColor = (myParticleEmitterData->myData.myEndColor - myParticleEmitterData->myData.myStartColor) / myParticleEmitterData->myParticlesLifeTime; for (int i = 0; i < particleCount; ++i) { GraphicalParticle tempGraphics; myGraphicalParticles.Add(tempGraphics); LogicalParticle tempLogic; myLogicalParticles.Add(tempLogic); } myIsActive = myParticleEmitterData->myIsActiveAtStart; myShouldLive = myParticleEmitterData->myIsActiveAtStart; myEmitterLife = myParticleEmitterData->myEmitterLifeTime; CreateVertexBuffer(); }
void ParticleEmitterInstance::CreateVertexBuffer() { myVertexWrapper = new VertexBufferWrapper(); myVertexWrapper->myStride = sizeof(GraphicalParticle); myVertexWrapper->myByteOffset = 0; myVertexWrapper->myStartSlot = 0; myVertexWrapper->myNumberOfBuffers = 1; HRESULT hr; D3D11_BUFFER_DESC vertexBufferDesc; ZeroMemory(&vertexBufferDesc, sizeof(vertexBufferDesc)); vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC; vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; vertexBufferDesc.MiscFlags = 0; vertexBufferDesc.StructureByteStride = 0; if (myVertexWrapper->myVertexBuffer != nullptr) { myVertexWrapper->myVertexBuffer->Release(); } vertexBufferDesc.ByteWidth = sizeof(GraphicalParticle) * myGraphicalParticles.Size(); hr = Engine::GetInstance()->GetDevice()->CreateBuffer(&vertexBufferDesc, nullptr, &myVertexWrapper->myVertexBuffer); DL_ASSERT_EXP(hr == S_OK, "[ParticleEmitterInstance](CreateVertexBuffer) : Failed to create VertexBuffer"); Engine::GetInstance()->SetDebugName(myVertexWrapper->myVertexBuffer , "ParticleEmitterInstance::myVertexWrapper->myVertexBuffer"); }
bool Prism::Surface::SetTexture(const std::string& aResourceName, Texture* aTexture) { DL_ASSERT_EXP(aTexture != nullptr , CU::Concatenate("Shader resource ( %s ) tried to use invalid texture", aResourceName.c_str())); ID3DX11EffectShaderResourceVariable* shaderVar = myEffect->GetEffect()->GetVariableByName(aResourceName.c_str())->AsShaderResource(); if (shaderVar->IsValid() == false) { //DL_MESSAGE_BOX("Failed to get ShaderResource", "Surface Error", MB_ICONWARNING); RESOURCE_LOG("Failed to get ShaderResource"); return false; } if (aResourceName == "EmissiveTexture") { myEmissive = true; } myTextures.Add(aTexture); myShaderResources.Add(aTexture->GetShaderView()); myShaderResourceViews.Add(shaderVar); myShaderResourceNames.Add(aResourceName); return true; }
bool Prism::Surface::SetTexture(const std::string& aResourceName, const std::string& aFileName, bool aUseSRGB) { aUseSRGB; DL_ASSERT_EXP(aFileName != "" , CU::Concatenate("Shader resource ( %s ) tried to use invalid filePath", aResourceName.c_str())); Texture* tex = Engine::GetInstance()->GetTextureContainer()->GetTexture(aFileName); ID3DX11EffectShaderResourceVariable* shaderVar = myEffect->GetEffect()->GetVariableByName(aResourceName.c_str())->AsShaderResource(); if (shaderVar->IsValid() == false) { std::string errorMsg = "Failed to get ShaderResource: " + aResourceName; //DL_MESSAGE_BOX(errorMsg.c_str(), "Surface Error", MB_ICONWARNING); RESOURCE_LOG(errorMsg.c_str()); return false; } if (aResourceName == "EmissiveTexture") { myEmissive = true; } myTextures.Add(tex); myShaderResources.Add(tex->GetShaderView()); myShaderResourceViews.Add(shaderVar); myFilePaths.Add(aFileName); myShaderResourceNames.Add(aResourceName); return true; }
void MissionManager::Update(float aDeltaTime, bool aForceNextMission) { DL_ASSERT_EXP(myCurrentMission < myMissions.Size(), "CurrentMission out of bounds!"); std::stringstream ss; ss << myCurrentMission; Prism::Engine::GetInstance()->PrintText(ss.str(), { 400, -370 }, Prism::eTextType::DEBUG_TEXT); if (aForceNextMission == true || myEndEventsActive == false && myMissions[myCurrentMission]->Update(aDeltaTime, -1, eMissionCategory::DUMMY) == true) { myAllowedToStartNextMission = !myMissions[myCurrentMission]->EventsEnd(); myEndEventsActive = true; } if (myEndEventsActive == true && myAllowedToStartNextMission == true) { myMissions[myCurrentMission]->End(); Prism::Audio::AudioInterface::GetInstance()->PostEvent("Play_MissionCompleted", 0); ++myCurrentMission; if (myCurrentMission == myMissions.Size()) { myLevel.CompleteLevel(); } else { myMissions[myCurrentMission]->EventsStart(); myMissions[myCurrentMission]->Start(); myAllowedToStartNextMission = false; myEndEventsActive = false; } } }
bool DeliverWaterAction::Update(float /*aDelta*/) { StockpileComponent* stockpile = myStockpileToDeliverTo->GetComponent<StockpileComponent>(); DL_ASSERT_EXP(stockpile != nullptr, "Tried to Deliver Water to a non-stockpile entity"); stockpile->PlaceResource(WATER); return true; }
void Renderer::BeginScene() { DL_ASSERT_EXP(mySceneIndex < MAX_NUMBER_OF_SCENES, "Tried to Begin to many Scenes"); SceneData& data = mySceneData[mySceneIndex]; ID3D11RenderTargetView* renderTarget = data.myScene->GetRenderTargetView(); ID3D11DepthStencilView* depth = data.myScene->GetDepthStencilView(); myEngine->GetContex()->ClearRenderTargetView(renderTarget, myClearColor); myEngine->GetContex()->ClearDepthStencilView(depth, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); myEngine->GetContex()->OMSetRenderTargets(1, &renderTarget, depth); }
void Renderer::EndScene(int aEffect) { DL_ASSERT_EXP(mySceneIndex < MAX_NUMBER_OF_SCENES, "Tried to Begin to many Scenes"); SceneData& data = mySceneData[mySceneIndex]; ID3D11RenderTargetView* renderTarget = data.myFinished->GetRenderTargetView(); myEngine->GetContex()->ClearRenderTargetView(renderTarget, myClearColor); myFullScreenHelper->Process(data.myScene, data.myFinished, aEffect); ++mySceneIndex; }
void GPUData::SetupIndexBuffer(int aIndexCount, char* aIndexData) { if (myIndexBuffer->myIndexBuffer != nullptr) { SAFE_RELEASE(myIndexBuffer->myIndexBuffer); } myIndexBuffer->myBufferDesc->ByteWidth = sizeof(UINT) * aIndexCount; D3D11_SUBRESOURCE_DATA initData; initData.pSysMem = aIndexData; DL_ASSERT_EXP(SUCCEEDED(Engine::GetInstance()->GetDevice()->CreateBuffer(myIndexBuffer->myBufferDesc, &initData, &myIndexBuffer->myIndexBuffer)) == TRUE, "GPUData::SetupIndexBuffer: Failed to SetupIndexBuffer"); }
void GPUData::SetupVertexBuffer(int aVertexCount, char* aVertexData, GPUContext& aGPUContext) { if (myVertexBuffer->myVertexBuffer != nullptr) { SAFE_RELEASE(myVertexBuffer->myVertexBuffer); } myVertexBuffer->myBufferDesc->ByteWidth = myVertexBuffer->myStride * aVertexCount; D3D11_SUBRESOURCE_DATA initData; initData.pSysMem = aVertexData; DL_ASSERT_EXP(SUCCEEDED(aGPUContext.GetDevice()->CreateBuffer(myVertexBuffer->myBufferDesc, &initData , &myVertexBuffer->myVertexBuffer)) == TRUE, "GPUData::SetupVertexBuffer: Failed to SetupVertexBuffer"); }
void Prism::Effect::SetPosAndScale(const CU::Vector2<float>& aPos , const CU::Vector2<float>& aScale) { DL_ASSERT_EXP(mySpritePosAndScale != nullptr , "Effect2D: Tried to SetPosAndScale but mySpritePosAndScale is nullptr"); mySpritePosAndScaleVector.x = aPos.x; mySpritePosAndScaleVector.y = aPos.y; mySpritePosAndScaleVector.z = aScale.x; mySpritePosAndScaleVector.w = aScale.y; mySpritePosAndScale->SetFloatVector(&mySpritePosAndScaleVector.x); }
bool DeliverWaterAction::IsInRange() { DL_ASSERT_EXP(myStockpileToDeliverTo != nullptr, "Invalid TargetEntity"); CU::Vector2<float> ownPosition = myEntity.GetPosition(); CU::Vector2<float> otherPosition = GetTargetPosition(); CU::Vector2<float> direction = otherPosition - ownPosition; float distance = CU::Length(direction); if (distance < 10.f) return true; return false; }
void StateStack::PopSubGameState() { DL_ASSERT_EXP(myGameStates.Size() > 0, "Can't pop an empty stack."); myGameStates[myMainIndex][mySubIndex]->EndState(); myGameStates[myMainIndex].DeleteCyclicAtIndex(mySubIndex); --mySubIndex; if (mySubIndex >= 0) { myGameStates[myMainIndex][mySubIndex]->ResumeState(); } }
void ParticleEmitterInstance::UpdateVertexBuffer() { D3D11_MAPPED_SUBRESOURCE mappedResource; Engine::GetInstance()->GetContex()->Map(myVertexWrapper->myVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); if (mappedResource.pData != nullptr) { GraphicalParticle *data = (GraphicalParticle*)mappedResource.pData; bool isSafe = sizeof(GraphicalParticle) == sizeof(myGraphicalParticles[0]); DL_ASSERT_EXP(isSafe, "[ParticleEmitter](UpdateVertexBuffer) : Not safe to copy."); memcpy(data, &myGraphicalParticles[0], sizeof(GraphicalParticle)* myGraphicalParticles.Size()); } Engine::GetInstance()->GetContex()->Unmap(myVertexWrapper->myVertexBuffer, 0); }
void MissionContainer::SortCopy(CU::GrowingArray<Mission*>& someOut, const CU::GrowingArray<Mission*>& someIn) const { int currentIndex = 0; while (someOut.Size() != someIn.Size()) { int prevIndex = currentIndex; for (int i = 0; i < someIn.Size(); ++i) { if (someIn[i]->GetIndex() == currentIndex) { ++currentIndex; someOut.Add(someIn[i]); break; } } DL_ASSERT_EXP(prevIndex == currentIndex - 1, "Mission index " + std::to_string(currentIndex) + " not found."); } }
MissionManager::MissionManager(Level& aLevel, Entity& aPlayer, const std::string& aFileToReadFrom) : myLevel(aLevel) , myPlayer(aPlayer) , myMissions(16) , myCurrentMission(0) , myMissionsNotOrder(16) , myAllowedToStartNextMission(true) , myEndEventsActive(false) { PostMaster::GetInstance()->Subscribe(eMessageType::EVENT_QUEUE_EMPTY, this); XMLReader reader; reader.OpenDocument(aFileToReadFrom); tinyxml2::XMLElement* element = reader.ForceFindFirstChild("root"); for (element = reader.ForceFindFirstChild(element, "missionContainer"); element != nullptr; element = reader.FindNextElement(element, "missionContainer")) { int missionIndex = -1; reader.ForceReadAttribute(element, "index", missionIndex); MissionContainer* mission = new MissionContainer(myLevel, myPlayer, reader, element); mission->SetIndex(missionIndex); myMissionsNotOrder.Add(mission); } reader.CloseDocument(); int currentIndex = 0; while (myMissions.Size() != myMissionsNotOrder.Size()) { int prevIndex = currentIndex; for (int i = 0; i < myMissionsNotOrder.Size(); ++i) { if (myMissionsNotOrder[i]->GetIndex() == currentIndex) { ++currentIndex; myMissions.Add(myMissionsNotOrder[i]); break; } } DL_ASSERT_EXP(prevIndex == currentIndex - 1, "Mission index " + std::to_string(currentIndex) + " not found."); } }
void Prism::Scene::AddInstance(Instance* aInstance) { #ifdef SCENE_USE_OCTREE if (aInstance->GetOctreeType() == eOctreeType::PLAYER) { DL_ASSERT_EXP(myPlayerInstance == nullptr, "Tried to add Player twice to Scene"); myPlayerInstance = aInstance; } else if (aInstance->GetOctreeType() == eOctreeType::DYNAMIC) { myDynamicInstances.Add(aInstance); } else { myOctree->Add(aInstance); } #else myInstances.Add(aInstance); #endif }
void LevelFactory::FillDataPropOrDefendable(XMLReader& aReader, tinyxml2::XMLElement* aLevelElement, Entity* aEntityToCreate) { tinyxml2::XMLElement* propElement = aReader.ForceFindFirstChild(aLevelElement, "position"); CU::Vector3<float> propPosition; aReader.ForceReadAttribute(propElement, "X", propPosition.x); aReader.ForceReadAttribute(propElement, "Y", propPosition.y); aReader.ForceReadAttribute(propElement, "Z", propPosition.z); aEntityToCreate->myOriginalOrientation.SetPos(propPosition*10.f); propElement = aReader.ForceFindFirstChild(aLevelElement, "rotation"); CU::Vector3<float> propRotation; aReader.ForceReadAttribute(propElement, "X", propRotation.x); aReader.ForceReadAttribute(propElement, "Y", propRotation.y); aReader.ForceReadAttribute(propElement, "Z", propRotation.z); aEntityToCreate->myOriginalOrientation = CU::GetOrientation(aEntityToCreate->myOriginalOrientation, propRotation); //if (aEntityToCreate->GetType() == eEntityType::PROP) //{ // int health = 30; // aEntityToCreate->AddComponent<HealthComponent>()->Init(health); //} #ifdef _DEBUG //REMOVE THIS STUFF WHEN HENRIK HAS UPDATED Entities if (aEntityToCreate->GetComponent<HealthComponent>() == nullptr) { int health = 30; aEntityToCreate->AddComponent<HealthComponent>()->Init(health); } #endif DL_ASSERT_EXP(aEntityToCreate->GetComponent<HealthComponent>() != nullptr, aEntityToCreate->GetName() + ": Prop without healthcomponent has been loaded."); aEntityToCreate->myOrientation = aEntityToCreate->myOriginalOrientation; myCurrentLevel->myEntities.Add(aEntityToCreate); myCurrentLevel->myCollisionManager->Add(myCurrentLevel->myEntities.GetLast()->GetComponent<CollisionComponent>(), aEntityToCreate->GetType()); }
void Prism::Octree::Add(Instance* aInstance) { DL_ASSERT_EXP(aInstance->GetOctreeType() != eOctreeType::NOT_IN_OCTREE, "Can't add NOT_IN_OCTREE object to octree."); myRoot->InsertObjectDown(aInstance); }
void BulletManager::ActivateBullet(BulletData* aWeaponData, const CU::Matrix44<float>& anOrientation , eEntityType aEntityType, const CU::Vector3<float>& aEnitityVelocity, const CU::Vector3<float>& aDirection , Entity* aHomingTarget, float aHomingTurnRateModifier) { Entity* bullet = nullptr; if (aEntityType == eEntityType::PLAYER || aEntityType == eEntityType::ALLY) { bullet = aWeaponData->myPlayerBullets[aWeaponData->myPlayerBulletCounter]; } else if (aEntityType == eEntityType::ENEMY) { bullet = aWeaponData->myEnemyBullets[aWeaponData->myEnemyBulletCounter]; } DL_ASSERT_EXP(bullet != nullptr, "Non Player/Enemy cant activate bullets!"); bullet->GetComponent<BulletComponent>()->SetOwner(aEntityType); if (bullet->GetComponent<BulletComponent>()->GetActive() == false) { if (aEntityType == eEntityType::PLAYER || aEntityType == eEntityType::ALLY) { myCollisionManager.Add(bullet->GetComponent<CollisionComponent>(), eEntityType::PLAYER_BULLET); } else if (aEntityType == eEntityType::ENEMY) { myCollisionManager.Add(bullet->GetComponent<CollisionComponent>(), eEntityType::ENEMY_BULLET); } } if (bullet->GetComponent<BulletAIComponent>() != nullptr) { bullet->RemoveComponent<BulletAIComponent>(); } if (aEntityType == eEntityType::PLAYER) { bullet->GetComponent<PhysicsComponent>()->Init(anOrientation, (anOrientation.GetForward() * (aWeaponData->mySpeed)) + aEnitityVelocity); } else if (aEntityType == eEntityType::ENEMY || aEntityType == eEntityType::ALLY) { bullet->GetComponent<PhysicsComponent>()->Init(anOrientation, (aDirection * (aWeaponData->mySpeed)) + aEnitityVelocity); } bullet->GetComponent<BulletComponent>()->SetActive(true); bullet->GetComponent<CollisionComponent>()->Update(0.5f); if (bullet->GetComponent<StreakEmitterComponent>() != nullptr) { bullet->GetComponent<StreakEmitterComponent>()->Reset(); } if (aHomingTarget != nullptr) { bullet->AddComponent<BulletAIComponent>()->Init((CU::Length((anOrientation.GetForward() * (aWeaponData->mySpeed)) + aEnitityVelocity) / 2.f) , aHomingTurnRateModifier, &myCollisionManager); bullet->GetComponent<BulletAIComponent>()->SetEntityToFollow(aHomingTarget, aHomingTarget); } if (aEntityType == eEntityType::PLAYER || aEntityType == eEntityType::ALLY) { aWeaponData->myPlayerBulletCounter++; if (aWeaponData->myPlayerBulletCounter >= aWeaponData->myMaxBullet) { aWeaponData->myPlayerBulletCounter = 0; } } else if (aEntityType == eEntityType::ENEMY) { aWeaponData->myEnemyBulletCounter++; if (aWeaponData->myEnemyBulletCounter >= aWeaponData->myMaxBullet) { aWeaponData->myEnemyBulletCounter = 0; } } }
MissionContainer::MissionContainer(Level& aLevel, Entity& aPlayer, XMLReader& aReader, tinyxml2::XMLElement* aElement) : Mission(aReader, aElement) , myRequiredMissions(8) , myOptionalMissions(8) , myRequiredActiveMissions(8) , myOptionalActiveMissions(8) , myEndingMissions(8) { PostMaster::GetInstance()->Subscribe(eMessageType::EVENT_QUEUE_EMPTY, this); CU::GrowingArray<Mission*> unorderedRequiredMissions(8); CU::GrowingArray<Mission*> unorderedOptionalMissions(8); for (tinyxml2::XMLElement* element = aReader.ForceFindFirstChild(aElement, "mission"); element != nullptr; element = aReader.FindNextElement(element, "mission")) { std::string type; aReader.ForceReadAttribute(element, "type", type); type = CU::ToLower(type); int missionIndex = -1; aReader.ForceReadAttribute(element, "index", missionIndex); bool required; aReader.ForceReadAttribute(element, "required", required); Mission* mission = nullptr; if (type == "waypoint") { mission = new WaypointMission(aLevel, aPlayer, aReader, element); } else if (type == "killx") { mission = new KillXEnemiesMission(aLevel, aReader, element); } else if (type == "killxabort") { mission = new KillXEnemiesAbortMission(aLevel, aReader, element); } else if (type == "killall") { mission = new KillAllMission(aLevel, aReader, element); } else if (type == "killallabort") { mission = new KillAllAbortMission(aLevel, aReader, element); } else if (type == "survival") { mission = new SurvivalMission(aReader, element); } else if (type == "survivalabort") { mission = new SurvivalAbortMission(aReader, element); } else if (type == "defend") { mission = new DefendMission(aReader, element, false); } else if (type == "defendabort") { mission = new DefendMission(aReader, element, true); } else if (type == "killstructures") { mission = new KillStructureMission(aReader, element); } DL_ASSERT_EXP(mission != nullptr, "Missiontype not recognized: " + type); mission->SetIndex(missionIndex); if (required == true) { unorderedRequiredMissions.Add(mission); } else { unorderedOptionalMissions.Add(mission); PostMaster::GetInstance()->SendMessage<LevelScoreMessage>(LevelScoreMessage(eLevelScoreMessageType::OPTIONAL_MISSION_ADDED)); } } DL_ASSERT_EXP(unorderedRequiredMissions.Size() > 0, "Need a required mission in missioncontainer"); SortCopy(myRequiredMissions, unorderedRequiredMissions); SortCopy(myOptionalMissions, unorderedOptionalMissions); for (int i = 0; i < myRequiredMissions.Size(); ++i) { myRequiredActiveMissions.Add(myRequiredMissions[i]); } for (int i = 0; i < myOptionalMissions.Size(); ++i) { myOptionalActiveMissions.Add(myOptionalMissions[i]); } }
Event::Event(const std::string& aName, const CU::GrowingArray<Action*>& someActions) : myName(aName) , myActions(someActions) { DL_ASSERT_EXP(myActions.Size() > 0, "Can't create event with zero actions."); }
bool Prism::Surface::VerifyTextures(const std::string& aModelPath) { if (aModelPath.find("skySphere") != std::string::npos) { return true; } bool diffuse = false; bool albedo = false; bool normal = false; bool roughness = false; bool metal = false; bool ao = false; bool emissiveness = false; for (int i = 0; i < myShaderResourceNames.Size(); ++i) { if (myShaderResourceNames[i] == "DiffiuseTexture") { diffuse = true; } else if (myShaderResourceNames[i] == "AlbedoTexture") { albedo = true; } else if (myShaderResourceNames[i] == "NormalTexture") { normal = true; } else if (myShaderResourceNames[i] == "RoughnessTexture") { roughness = true; } else if (myShaderResourceNames[i] == "MetalnessTexture") { metal = true; } else if (myShaderResourceNames[i] == "AOTexture") { ao = true; } else if (myShaderResourceNames[i] == "EmissiveTexture") { emissiveness = true; } } if (diffuse == true) return true; #ifndef _DEBUG DL_ASSERT_EXP(albedo == true, CU::Concatenate("Albedo missing from %s", aModelPath.c_str())); DL_ASSERT_EXP(normal == true, CU::Concatenate("NormalMap missing from %s", aModelPath.c_str())); DL_ASSERT_EXP(roughness == true, CU::Concatenate("Roughness missing from %s", aModelPath.c_str())); DL_ASSERT_EXP(metal == true, CU::Concatenate("Metalness missing from %s", aModelPath.c_str())); DL_ASSERT_EXP(ao == true, CU::Concatenate("AmbientOcclusion missing from %s", aModelPath.c_str())); DL_ASSERT_EXP(emissiveness == true, CU::Concatenate("Emissiveness missing from %s", aModelPath.c_str())); #endif return true; }
void StateStack::RenderCurrentState() { DL_ASSERT_EXP(myGameStates.Size() > 0, "Can't render, no gamestate present."); RenderStateAtIndex(mySubIndex); }
void Prism::Sprite::CopyFromD3DTexture(ID3D11Texture2D* aTexture) { DL_ASSERT_EXP(myTexture != nullptr, "Tried to CopyFromD3DTexture on a sprite that was created from file"); Engine::GetInstance()->GetContex()->CopyResource(myTexture, aTexture); }