bool BaseGameLogic::Initialize(void) { m_pActorFactory = VCreateActorFactory(); /** // ZIP ResourceZipFile* ZipResource = WE_NEW ResourceZipFile(L"Assets.zip"); ZipResource->VOpen(); int ResourceCount = ZipResource->VGetNumResources(); //ResourceZipFile ZipResource("Assets.zip"); std::string Name1 = ZipResource->VGetResourceName(0); // Resource Loader ResCache* Cache = WE_NEW ResCache(10, ZipResource); if (Cache->Init()) { Resource TestRes("grid.dds"); shared_ptr<ResHandle> texture = Cache->GetHandle(&TestRes); int Size = texture->Size(); char* TextureBitmap = (char*) texture->Buffer(); } */ mat4x4 T = mat4x4(); T = translate(mat4x4(), vec3(1, 1, 1)); for (int i = 0; i < 1; i++) { VCreateActor("actors\\testactor.xml", NULL, &glm::mat4x4(), NULL); //m_pActorFactory->CreateActor("actors\\testactor.xml", NULL, &glm::mat4x4(), NULL); } VCreateActor("actors\\testactor.xml", NULL, &T, NULL); for (int i = 0; i < 3; i++) { //m_pActorFactory->CreateActor("actors\\testactor2.xml", NULL, &glm::mat4x4(), NULL); } //m_pActorFactory->CreateActor("actors\\testactor3.xml", NULL, &glm::mat4x4(), NULL); return true; }
// // TeapotWarsLogic::VChangeState // void TeapotWarsLogic::VChangeState(BaseGameState newState) { BaseGameLogic::VChangeState(newState); switch(newState) { case BGS_WaitingForPlayers: { // spawn all local players (should only be one, though we might support more in the future) GCC_ASSERT(m_ExpectedPlayers == 1); for (int i = 0; i < m_ExpectedPlayers; ++i) { shared_ptr<IGameView> playersView(GCC_NEW TeapotWarsHumanView(g_pApp->m_Renderer)); VAddView(playersView); if (m_bProxy) { // if we are a remote player, all we have to do is spawn our view - the server will do the rest. return; } } // spawn all remote player's views on the game for (int i = 0; i < m_ExpectedRemotePlayers; ++i) { shared_ptr<IGameView> remoteGameView(GCC_NEW NetworkGameView); VAddView(remoteGameView); } // spawn all AI's views on the game for (int i = 0; i < m_ExpectedAI; ++i) { shared_ptr<IGameView> aiView(GCC_NEW AITeapotView(m_pPathingGraph)); VAddView(aiView); } break; } case BGS_SpawningPlayersActors: { if (m_bProxy) { // only the server needs to do this. return; } for (auto it = m_gameViews.begin(); it != m_gameViews.end(); ++it) { shared_ptr<IGameView> pView = *it; if (pView->VGetType() == GameView_Human) { StrongActorPtr pActor = VCreateActor("actors\\player_teapot.xml", NULL); if (pActor) { shared_ptr<EvtData_New_Actor> pNewActorEvent(GCC_NEW EvtData_New_Actor(pActor->GetId(), pView->VGetId())); IEventManager::Get()->VTriggerEvent(pNewActorEvent); // [rez] This needs to happen asap because the constructor function for Lua (which is called in through VCreateActor()) queues an event that expects this event to have been handled } } else if (pView->VGetType() == GameView_Remote) { shared_ptr<NetworkGameView> pNetworkGameView = static_pointer_cast<NetworkGameView, IGameView>(pView); StrongActorPtr pActor = VCreateActor("actors\\remote_teapot.xml", NULL); if (pActor) { shared_ptr<EvtData_New_Actor> pNewActorEvent(GCC_NEW EvtData_New_Actor(pActor->GetId(), pNetworkGameView->VGetId())); IEventManager::Get()->VQueueEvent(pNewActorEvent); } } else if (pView->VGetType() == GameView_AI) { shared_ptr<AITeapotView> pAiView = static_pointer_cast<AITeapotView, IGameView>(pView); StrongActorPtr pActor = VCreateActor("actors\\ai_teapot.xml", NULL); if (pActor) { shared_ptr<EvtData_New_Actor> pNewActorEvent(GCC_NEW EvtData_New_Actor(pActor->GetId(), pAiView->VGetId())); IEventManager::Get()->VQueueEvent(pNewActorEvent); } } } break; } } }