コード例 #1
0
ファイル: Log.cpp プロジェクト: genxinzou/svn-spring-archive
void Log::print(string message){
    if(message.empty() == true) return;
    string gtime;
    if(plaintext == true){
        gtime = GameTime() + GetSysTime() +FrameTime() + message + "\n";
    }else{
        gtime = "\n<tr><th width='8%' scope='row'><b>" + GameTime() + FrameTime() +"</b></th>\n<td width='92%'>" + message + "</td></tr>\n";
    }
    header(gtime);
}
コード例 #2
0
//-------------------------------------------------------------------------------------
ScriptID ScriptCallbacks::addCallback( float initialOffset, TimerHandler * pHandler )
{
	if (initialOffset < 0.f)
	{
		WARNING_MSG(boost::format("ScriptCallbacks::addTimer: Negative timer offset (%1%)\n") %
				initialOffset );

		initialOffset = 0.f;
	}

	int hertz = 0;
	
	if(g_componentType == BOTS_TYPE)
		hertz = g_kbeSrvConfig.gameUpdateHertz();
	else
		hertz = Config::getSingleton().gameUpdateHertz();

	int initialTicks = GameTime( g_kbetime +
			initialOffset * hertz );

	TimerHandle timerHandle = timers_.add(
			initialTicks, 0,
			pHandler, NULL );

	if (timerHandle.isSet())
	{
		int id = this->getNewID();

		map_[ id ] = timerHandle;

		return id;
	}

	return 0;
}
コード例 #3
0
ファイル: resource_manager.cpp プロジェクト: respu/grace-base
	Resource* ResourceManager::load_resource_in_fiber(ResourceLoaderID lid, ResourceID rid) {
		auto it = impl().resource_cache.find(rid);
		if (it != impl().resource_cache.end()) {
			return it->second;
		}
		
		if (impl().is_in_resource_loader_fiber) {
			impl().fiber_manager.launch([=]() {
				load_resource_impl(lid, rid);
			});
			Fiber::yield();
			auto loaded = impl().resource_cache.find(rid);
			if (loaded != impl().resource_cache.end()) {
				return loaded->second;
			}
			Error() << "Dependency '" << rid << "' failed to load.";
			return nullptr;
		} else {
			impl().is_in_resource_loader_fiber = true;
			impl().fiber_manager.launch([=]() {
				load_resource_impl(lid, rid);
			});
			impl().fiber_manager.update(GameTime());
			impl().is_in_resource_loader_fiber = false;
			auto loaded = impl().resource_cache.find(rid);
			if (loaded != impl().resource_cache.end()) {
				return loaded->second;
			}
			Error() << "Failed to load resource: " << rid;
			return nullptr;
		}
	}
コード例 #4
0
ファイル: Log.cpp プロジェクト: genxinzou/svn-spring-archive
void Log::Message(string msg, int player){
    if(plaintext == true){
        string m = "[" + PlayerNames[player] + "] " + GameTime() + FrameTime() +  " :: " + msg + "\n";
        header(m);
        return;
    }else{
        print("<span class='c'>" + msg + "</span>");
    }
}
コード例 #5
0
ファイル: Log.cpp プロジェクト: Tarendai/ntai
	void Log::print(std::string message){
		if(message.empty() == true) return;
		if (!G) {
			//NLOG(message);
			return;
		}
		std::string gtime;
		gtime = GameTime() + GetSysTime() +FrameTime() + message + "\n";
		header(gtime);
	}
コード例 #6
0
//-------------------------------------------------------------------------------------
ScriptID ScriptTimers::addTimer( float initialOffset,
		float repeatOffset, int userArg, TimerHandler * pHandler )
{
	if (initialOffset < 0.f)
	{
		WARNING_MSG(boost::format("ScriptTimers::addTimer: Negative timer offset (%1%)\n") %
				initialOffset );

		initialOffset = 0.f;
	}

	KBE_ASSERT( g_pApp );

	int hertz = g_kbeSrvConfig.gameUpdateHertz();
	int initialTicks = GameTime( g_pApp->time() +
			initialOffset * hertz );
	int repeatTicks = 0;

	if (repeatOffset > 0.f)
	{
		repeatTicks = GameTime( repeatOffset * hertz );
		if (repeatTicks < 1)
		{
			repeatTicks = 1;
		}
	}

	TimerHandle timerHandle = g_pApp->timers().add(
			initialTicks, repeatTicks,
			pHandler, (void *)(intptr_t)userArg );

	if (timerHandle.isSet())
	{
		int id = this->getNewID();

		map_[ id ] = timerHandle;

		return id;
	}

	return 0;
}
コード例 #7
0
ファイル: Game.cpp プロジェクト: HanHangit/InputStream
Game::Game()
{
	window.create(sf::VideoMode(800, 600), "InputStream");
	window.setFramerateLimit(120);
	gTime = GameTime();
	running = true;
	//EinmaligerPointer der nur übergeben kann(perMove) -> Speicher wird gleich reserviert
	//ToDo switch states
	//CurrentState = std::move(std::unique_ptr<MainMenuState>(new MainMenuState));
	//CurrentState = std::move(std::unique_ptr<PlayState>(new PlayState));
}
コード例 #8
0
ファイル: Game.cpp プロジェクト: respu/XFXFramework
	Game::Game()
	{
		inRun = false;
		
		IsFixedTimeStep = true;

		Content = new ContentManager(&services);
		
		gameTime = GameTime(TimeSpan::Zero, TimeSpan::Zero);

		TargetElapsedTime = TimeSpan::FromTicks(0x28b0bL);
		inactiveSleepTime = TimeSpan::FromMilliseconds(20.0);

		isActive = true;
	}
コード例 #9
0
ファイル: Server.cpp プロジェクト: gamefreak/apollo
static void BadClient(unsigned int clientID) //deal with a bad message
{
	unsigned int currentTime = (unsigned int)GameTime();
    
    if(badMessageCount[clientID] > 1) 
    {
        if((currentTime - badMessage[clientID][badMessageCount[clientID]]) < 10)
        { // kick on 2nd in 10 seconds
            KillClient(clientID);
            return;
        }		
    }
    
    badMessageCount[clientID]++;
    badMessage[clientID][badMessageCount[clientID]] = currentTime;
}
コード例 #10
0
/*!
* @brief	アニメーションコントロール。
*/
void EnemyTest::AnimationControl()
{
	animation.Update(GameTime().GetFrameDeltaTime());
	if (Pad(0).IsPress(enButtonB)) {
		PlayAnimation(AnimationAttack);
	}else{
		if (state == enStateRun) {
			//歩きアニメーション。
			PlayAnimation(AnimationWalk);
		}
		else if (state == enStateStand) {
			//立ちアニメーションを流す。
			PlayAnimation(AnimationStand);
		}
	}
}
コード例 #11
0
    void ModelContainerView::doGraphics() {
        i_App->renderDevice->clear();
        RenderDevice *rd = i_App->renderDevice;

        rd->setProjectionAndCameraMatrix(i_App->debugCamera);

        LightingParameters lighting(GameTime(toSeconds(10, 00, AM)));
        //i_SkyRef->render(rd,lighting);
        rd->setAmbientLightColor(Color4(Color3::blue()));
        rd->enableLighting();

        GLight light =GLight::directional(i_App->debugController.getPosition() + i_App->debugController.getLookVector()*2,Color3::white());
        rd->setLight(0,light);


        Array<std::string > keys = iTriVarTable.getKeys();
        Array<std::string>::ConstIterator i = keys.begin();
        while(i != keys.end()) {
            VAR* var = iTriVarTable.get(*i);
            Array<int> indexArray = iTriIndexTable.get(*i);

            rd->beginIndexedPrimitives();
            rd->setVertexArray(*var);
            rd->sendIndices(RenderDevice::LINES, indexArray);
            rd->endIndexedPrimitives();
            ++i;
        }
        i_App->renderDevice->disableLighting();

        for(int i=0; i<gBoxArray.size(); ++i) {
            AABox b = gBoxArray[i];
            Draw::box(b,rd,Color3::red());
        }

        if(iDrawLine) {
            Draw::lineSegment(LineSegment::fromTwoPoints(iPos1, iPos2), rd, iColor, 3);

            if(myfound) {
                Draw::lineSegment(LineSegment::fromTwoPoints(p1, p2), rd, iColor, 3);
                Draw::lineSegment(LineSegment::fromTwoPoints(p2, p3), rd, iColor, 3);
                Draw::lineSegment(LineSegment::fromTwoPoints(p3, p1), rd, iColor, 3);
                Draw::sphere(Sphere(p4,0.5),rd, iColor);
                Draw::sphere(Sphere(p5,0.5),rd, Color3::green());
            }
        }
    }
コード例 #12
0
void PlayerHPBar::Update()
{
	//プレイヤーの残HPに応じてHPバーのサイズを変える。
	
	float hpRate = (float)g_player->GetHP() / (float)g_player->GetMaxHP();
	CVector2 size = hpBarMaxSize;
	size.x *= hpRate;
	m_hpBar.SetSize(size);
	switch (m_state) {
	case enState_DamageWait:
		m_timer += GameTime().GetFrameDeltaTime();
		if (m_timer > 0.5f) {
			//ダメージ演出開始。
			m_state = enState_Damage;
			m_timer = 0.0f;
		}
		break;
	case enState_Damage: {
		CVector2 sizeHPBack = m_hpBarBack.GetSize();
		sizeHPBack.x -= 1.5f;
		if (sizeHPBack.x < size.x) {
			m_state = enState_Normal;
			sizeHPBack.x = size.x;
		}
		m_hpBarBack.SetSize(sizeHPBack);
	}break;
	case enState_Normal:
		if (m_hpLastFrame > g_player->GetHP()) {
			//ダメージを受けた。
			m_state = enState_DamageWait;
			m_timer = 0.0f;
		}
		else if (m_hpLastFrame < g_player->GetHP()) {
			//回復している。
			m_hpBarBack.SetSize(size);
		}
		break;
	}
	m_hpLastFrame = g_player->GetHP();
}
コード例 #13
0
ファイル: SavedGame.cpp プロジェクト: UnkLegacy/OpenXcom
/**
 * Gets all the saves found in the user folder
 * and adds them to a text list.
 * @param list Text list.
 * @param lang Loaded language.
 */
void SavedGame::getList(TextList *list, Language *lang)
{
	DIR *dp = opendir(USER_DIR);
    if (dp == 0)
	{
        throw Exception("Failed to open saves directory");
    }
	
    struct dirent *dirp;
    while ((dirp = readdir(dp)) != 0)
	{
		std::string file = dirp->d_name;
		// Check if it's a valid save
		if (file.find(".sav") == std::string::npos)
		{
			continue;
		}
		std::string fullname = USER_DIR + file;
		std::ifstream fin(fullname.c_str());
		if (!fin)
		{
			throw Exception("Failed to load savegame");
		}
		YAML::Parser parser(fin);
		YAML::Node doc;
		
		parser.GetNextDocument(doc);
		GameTime time = GameTime(6, 1, 1, 1999, 12, 0, 0);
		time.load(doc["time"]);
		std::stringstream saveTime;
		std::wstringstream saveDay, saveMonth, saveYear;
		saveTime << time.getHour() << ":" << std::setfill('0') << std::setw(2) << time.getMinute();
		saveDay << time.getDay() << lang->getString(time.getDayString());
		saveMonth << lang->getString(time.getMonthString());
		saveYear << time.getYear();
		list->addRow(5, Language::utf8ToWstr(file.substr(0, file.length()-4)).c_str(), Language::utf8ToWstr(saveTime.str()).c_str(), saveDay.str().c_str(), saveMonth.str().c_str(), saveYear.str().c_str());
		fin.close();
    }
    closedir(dp);
}
コード例 #14
0
//--------------------------------------------------------------------------------------
// Render the scene using the D3D11 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D11FrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext,
								  double fTime, float fElapsedTime, void* pUserContext )
{
	// Clear render target and the depth stencil 
	float ClearColor[4] = { 0.176f, 0.196f, 0.667f, 0.0f };
	ID3D11RenderTargetView* pRTV = DXUTGetD3D11RenderTargetView();
	ID3D11DepthStencilView* pDSV = DXUTGetD3D11DepthStencilView();
	pd3dImmediateContext->ClearRenderTargetView( pRTV, ClearColor );
	pd3dImmediateContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0 );

	vegetationRendering->draw(pd3dDevice, GameTime(fElapsedTime, fTime));

	std::wstringstream ws;

	ws << DXUTGetFPS();
	
	textHelper.Begin();
	textHelper.SetInsertionPos(5, 5);
	textHelper.SetForegroundColor(vegetationRendering->isInCaptureMode() ? D3DXCOLOR(1,0,0,1) : D3DXCOLOR(1, 1, 0, 1));
	textHelper.DrawTextLine(ws.str().c_str());
	textHelper.End();
}
コード例 #15
0
	void CEngine::RunGameLoop()
	{
		// Enter the message loop
		MSG msg;
		ZeroMemory(&msg, sizeof(msg));
#ifdef USE_DISP_FPS
		char text[256] = {"\0"};
#endif
		while (msg.message != WM_QUIT)
		{
			if (PeekMessage(&msg, nullptr, 0U, 0U, PM_REMOVE))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			else {
#ifdef USE_DISP_FPS
				CStopwatch sw;
				sw.Start();
#endif
				GameTime().Update();
				//キー入力を更新。
				m_keyInput.Update();

				m_skinModelDataResources.Update();

				m_physicsWorld.Update();

				CRenderContext& topRenderContext = m_renderContextArray[0];
				CRenderContext& lastRenderContext = m_renderContextArray[m_numRenderContext - 1];

				topRenderContext.SetRenderTarget(0, &m_mainRenderTarget[m_currentMainRenderTarget]);
				//topRenderContext.SetRenderTarget(0, &m_backBufferRT);
				topRenderContext.SetRenderTarget(1, NULL);
				
				CGameObjectManager& goMgr = CGameObjectManager::Instance();
				goMgr.Execute(
					m_renderContextArray.get(), 
					m_numRenderContext, 
					m_renderContextMap.get(),
					m_preRender,
					m_postEffect
				);
				lastRenderContext.SetRenderTarget(0, &m_backBufferRT);
				lastRenderContext.Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
					D3DCOLOR_RGBA(0, 0, 0, 0), 1.0f, 0
				);
				CopyMainRenderTargetToBackBuffer(lastRenderContext);

				m_pD3DDevice->BeginScene();
				//レンダリングコマンドのサブミット
				for( int i = 0; i < m_numRenderContext; i++ ){
					m_renderContextArray[i].SubmitCommandBuffer();
				}
				// 描画

#ifdef USE_DISP_FPS
				m_fpsFont.Draw(text, 0, 0);
#endif
				m_pD3DDevice->EndScene();
				m_pD3DDevice->Present(nullptr, nullptr, nullptr, nullptr);
				
				//
#ifdef USE_DISP_FPS
				sw.Stop();
				sprintf(text, "fps = %lf\n", 1.0f / sw.GetElapsed());
#endif


			}
		}
	}
コード例 #16
0
ファイル: resource_manager.cpp プロジェクト: respu/grace-base
		GameTime now() const { return GameTime(); }
コード例 #17
0
void EnemyTest::Update()
{
	CVector3 nextPosition = position;
	const float MOVE_SPEED = 5.0f;
	if (state == enStateRun || state == enStateStand) {
		if (Pad(0).IsTrigger(enButtonRB3)) {
			isPointLightOn = !isPointLightOn;
		}
		if (Pad(0).IsPress(enButtonA)) {
			//Aボタンが押された。
			//車との距離を調べる。
			CVector3 diff = g_car->GetPosition();
			diff.Subtract(position);
			if (diff.Length() < 2.0f) {
				//車との距離が2m以内。
				state = enState_RideOnCar;
				skinModel.SetShadowReceiverFlag(false);
				skinModel.SetShadowCasterFlag(false);
				g_car->SetRideOnFlag(true);
				g_camera->SetCar(g_car);
				return;
			}
			else if(!isJump){
				//車との距離が離れていたらジャンプ。
				moveSpeed.y = 8.0f;
				isJump = true;
			}
		}
		//走りか立ち状態の時。
		CVector3 moveDirLocal;
		moveDirLocal.y = 0.0f;
		moveDirLocal.x = Pad(0).GetLStickXF();
		moveDirLocal.z = Pad(0).GetLStickYF();
		const CMatrix& mViewInv = g_camera->GetCamera().GetViewMatrixInv();
		//カメラ空間から見た奥方向のベクトルを取得。
		CVector3 cameraZ;
		cameraZ.x = mViewInv.m[2][0];
		cameraZ.y = 0.0f;		//Y軸いらない。
		cameraZ.z = mViewInv.m[2][2];
		cameraZ.Normalize();	//Y軸を打ち消しているので正規化する。
								//カメラから見た横方向のベクトルを取得。
		CVector3 cameraX;
		cameraX.x = mViewInv.m[0][0];
		cameraX.y = 0.0f;		//Y軸はいらない。
		cameraX.z = mViewInv.m[0][2];
		cameraX.Normalize();	//Y軸を打ち消しているので正規化する。

		CVector3 moveDir;
		moveDir.x = cameraX.x * moveDirLocal.x + cameraZ.x * moveDirLocal.z;
		moveDir.y = 0.0f;	//Y軸はいらない。
		moveDir.z = cameraX.z * moveDirLocal.x + cameraZ.z * moveDirLocal.z;

		moveSpeed.x = moveDir.x * MOVE_SPEED;
		moveSpeed.z = moveDir.z * MOVE_SPEED;
		
		//Y方向には重力落下を加える。
		const float GRAVITY = -18.8f;
		moveSpeed.y += GRAVITY * GameTime().GetFrameDeltaTime();
		CVector3 addPos = moveSpeed;
		addPos.Scale(GameTime().GetFrameDeltaTime());
		nextPosition.Add(addPos);
		if (moveDir.LengthSq() > 0.0001f) {
			rotation.SetRotation(CVector3::Up, atan2f(moveDir.x, moveDir.z));
			//走り状態に遷移。
			state = enStateRun;
		}
		else {
			//立ち状態。
			state = enStateStand;
		}
		
		ShadowMap().SetLightTarget(position);
		CVector3 lightPos;
		lightPos.Add(position, toLightPos);
		ShadowMap().SetLightPosition(lightPos);
		//コリジョン検出と解決を行う。
		CollisionDetectAndResolve(nextPosition);
	}
	else if (state == enState_RideOnCar) {
		ShadowMap().SetLightTarget(g_car->GetPosition());
		CVector3 lightPos;
		lightPos.Add(g_car->GetPosition(), toLightPos);
		ShadowMap().SetLightPosition(lightPos);
		if (g_car->GetMoveSpeed().Length() < 0.1f) {
			//車が停止状態。
			if (Pad(0).IsPress(enButtonB)) {
				//降車。
				g_camera->SetCar(NULL);
				g_car->SetRideOnFlag(false);
				skinModel.SetShadowReceiverFlag(true);
				skinModel.SetShadowCasterFlag(true);
				position = g_car->GetPosition();
				state = enStateStand;
			}
		}
	}
	
	skinModel.Update(position, rotation, CVector3::One);
	
	//ポイントライトの位置を更新。
	UpdatePointLightPosition();
	//アニメーションコントロール。
	AnimationControl();
	lastFrameState = state;
}
コード例 #18
0
ファイル: Log.cpp プロジェクト: genxinzou/svn-spring-archive
void Log::iprint(string message){
    string gtime = GameTime() + message;
    G->cb->SendTextMsg(gtime.c_str(), 1);
    print(message);
}
コード例 #19
0
//--------------------------------------------------------------------------------------
// Handle updates to the scene.  This is called regardless of which D3D API is used
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext )
{
	vegetationRendering->update(GameTime(fElapsedTime, fTime));
}
コード例 #20
0
ファイル: OverlordThread.cpp プロジェクト: dmead/sc2bot
void OverlordThread::Reset()
{
    _WakeUpTime = GameTime() + 5.0;
    _Priority = 2;
    _Name = "Overlord";
}
コード例 #21
0
ProgramResultType ProgramProduceUnitExtractor::ExecuteStep()
{
    UnitEntry *Entry = g_Context->Managers.Knowledge.ExtractorUnit();
    FrameHUDManager &FrameHUD = g_Context->Managers.FrameHUD;
    FrameUnitManager &FrameUnit = g_Context->Managers.FrameUnit;
    const String ActionButtonName = GetRaceTypeString(Entry->Race) + String("BuildBasicStructure");
    if(_CurState == ProgProduceUnitExtractorSelectWorkers)
    {
        LogThreadEvent("Selecting Workers", LogStep);
        g_Context->Managers.KeyboardMouse.SendKey(KEY_0 + g_Context->Managers.ControlGroup.FindControlGroupIndex(ControlGroupWorkerMineral));
        _CurState = ProgProduceUnitExtractorMoveToBuildingSite;
        return ProgramResultStillExecuting;
    }
    if(_CurState == ProgProduceUnitExtractorMoveToBuildingSite)
    {
        ActionButtonStateType State;
        if(!FrameHUD.ActionButtonPresent(ActionButtonName, State))
        {
            LogThreadEvent("BuildBasicStructure not present", LogError);
            return ProgramResultFail;
        }
        if(State != ActionButtonStateNormal)
        {
            LogThreadEvent("BuildBasicStructure is in an invalid state", LogError);
            return ProgramResultFail;
        }
        Vec2f MinimapExtractorLocation;
        bool Success = g_Context->Managers.Knowledge.RandomExtractorSite(MinimapExtractorLocation);
        if(!Success)
        {
            LogThreadEvent("RandomExtractorSite failed", LogError);
            return ProgramResultFail;
        }
        const Vec2i ScreenCoord = g_Context->Constants.MinimapCoordToScreenCoord(MinimapExtractorLocation);
        LogThreadEvent(String("MoveToBuildingSite: ") + ScreenCoord.CommaSeparatedString(), LogStep);
        g_Context->Managers.KeyboardMouse.Click(ScreenCoord, MouseButtonLeft, ModifierNone);
        _CurState = ProgProduceUnitExtractorSelectBuildStructure;
        return ProgramResultStillExecuting;
    }
    if(_CurState == ProgProduceUnitExtractorSelectBuildStructure)
    {
        ActionButtonStateType State;
        if(!FrameHUD.ActionButtonPresent(ActionButtonName, State))
        {
            LogThreadEvent("BuildBasicStructure not present", LogError);
            return ProgramResultFail;
        }
        if(State != ActionButtonStateNormal)
        {
            LogThreadEvent("BuildBasicStructure is in an invalid state", LogError);
            return ProgramResultFail;
        }
        g_Context->Managers.KeyboardMouse.SendKey(KEY_B);
        LogThreadEvent("Selecting BuildBasicStructure", LogStep);
        _CurState = ProgProduceUnitExtractorSelectBuilding;
        return ProgramResultStillExecuting;
    }
    if(_CurState == ProgProduceUnitExtractorSelectBuilding)
    {
        ActionButtonStateType State;
        if(!FrameHUD.ActionButtonPresent(Entry->Name, State))
        {
            LogThreadEvent(Entry->Name + String(" not present"), LogError);
            return ProgramResultFail;
        }
        if(State != ActionButtonStateNormal)
        {
            LogThreadEvent(Entry->Name + String(" is in an invalid state"), LogError);
            return ProgramResultFail;
        }
        g_Context->Managers.KeyboardMouse.SendKey(KEY_A + (Entry->Hotkey - 'a'));
        LogThreadEvent(String("Selecting building: ") + String(Entry->Hotkey), LogStep);
        _CurState = ProgProduceUnitExtractorFindBuildingPlacement;
        _TimeoutTime0 = GameTime() + 1.0;
    }
    if(_CurState == ProgProduceUnitExtractorFindBuildingPlacement)
    {
        ActionButtonStateType State;
        if(FrameHUD.ActionButtonPresent(ActionButtonName, State))
        {
            if(_AttemptsMade == 0)
            {
                LogThreadEvent("BuildBasicStructure present but no attempts made", LogError);
                return ProgramResultFail;
            }
            _TimeoutTime1 = GameTime() + 1.5;
            _CurState = ProgProduceUnitExtractorWaitForSuccess;
            return ProgramResultStillExecuting;
        }
        if(!FrameHUD.ActionButtonPresent("Cancel", State))
        {
            LogThreadEvent("Cancel not present", LogError);
            return ProgramResultFail;
        }
        if(GameTime() > _TimeoutTime0)
        {
            LogThreadEvent("Timed out searching for building location", LogError);
            return ProgramResultFail;
        }
        Vector<const FrameUnitInfo*> AllGeysers;
        for(UINT UnitIndex = 0; UnitIndex < FrameUnit.UnitsThisFrame().Length(); UnitIndex++)
        {
            const FrameUnitInfo &CurUnit = *FrameUnit.UnitsThisFrame()[UnitIndex];
            if(CurUnit.Owner == PlayerInvalid && CurUnit.Entry->Name == "VespeneGeyser" && CurUnit.Clickable())
            {
                AllGeysers.PushEnd(&CurUnit);
            }
        }
        if(AllGeysers.Length() == 0)
        {
            LogThreadEvent("No clickable geysers", LogError);
            return ProgramResultFail;
        }
        
        Vec2i ScreenCoord = AllGeysers.RandomElement()->ScreenBound.Center().RoundToVec2i();
        LogThreadEvent(String("GeyserPoint: ") + ScreenCoord.CommaSeparatedString(), LogStep);
        g_Context->Managers.KeyboardMouse.Click(ScreenCoord, MouseButtonLeft, ModifierNone);
        _AttemptsMade++;
        return ProgramResultStillExecuting;
    }
    if(_CurState == ProgProduceUnitExtractorWaitForSuccess)
    {
        if(GameTime() > _TimeoutTime1)
        {
            LogThreadEvent("Timed out waiting for building success", LogError);
            return ProgramResultFail;
        }
        ActionButtonStateType State;
        if(FrameHUD.ActionButtonPresent(ActionButtonName, State))
        {
            if(State == ActionButtonStateSelected)
            {
                LogThreadEvent("BuildBasicStructure selected, success", LogDone);
                g_Context->ReportAction(Entry->Name, RGBColor::Green);
                g_Context->Managers.Knowledge.RecordUnitInProduction(Entry, GameTime());
                return ProgramResultSuccess;
            }
            else
            {
                LogThreadEvent("BuildBasicStructure is in an invalid state", LogStep);
                return ProgramResultStillExecuting;
            }
        }
    }
    HANDLE_CRITICAL_FAILURE;
}
コード例 #22
0
ファイル: SearchThread.cpp プロジェクト: dmead/sc2bot
void SearchThread::ProgramFailed()
{
    _WakeUpTime = GameTime() + 0.01f;
}
コード例 #23
0
ファイル: Log.cpp プロジェクト: Tarendai/ntai
	void Log::Message(std::string msg, int player){
		std::string m = "[" + PlayerNames[player] + "] " + GameTime() + FrameTime() +  " :: " + msg + "\n";
		header(m);
		return;
	}
コード例 #24
0
ファイル: SearchThread.cpp プロジェクト: dmead/sc2bot
void SearchThread::ProgramSucceeded()
{
    _WakeUpTime = GameTime() + 0.01f;
}
コード例 #25
0
ファイル: OverlordThread.cpp プロジェクト: dmead/sc2bot
void OverlordThread::ProgramFailed()
{
    _WakeUpTime = GameTime() + 5.0;
}
コード例 #26
0
ProgramResultType ProgramProduceUnitLarvae::ExecuteStep()
{
    FrameHUDManager &FrameHUD = g_Context->Managers.FrameHUD;
    if(_CurState == ProgProduceUnitLarvaeSelectHatcheries)
    {
        LogThreadEvent("Selecting Hatcheries", LogStep);
        g_Context->Managers.KeyboardMouse.SendKey(KEY_0 + g_Context->Managers.ControlGroup.FindControlGroupIndex(ControlGroupBuildingMain));
        _CurState = ProgProduceUnitLarvaeSelectLarvae;
        return ProgramResultStillExecuting;
    }
    if(_CurState == ProgProduceUnitLarvaeSelectLarvae)
    {
        ActionButtonStateType State;
        if(!FrameHUD.ActionButtonPresent("Larvae", State))
        {
            LogThreadEvent("Larvae button not found", LogError);
            return ProgramResultFail;
        }
        if(State != ActionButtonStateNormal)
        {
            LogThreadEvent("Larvae button in invalid state", LogError);
            return ProgramResultFail;
        }
        LogThreadEvent("Selecting Larvae", LogStep);
        g_Context->Managers.KeyboardMouse.SendKey(KEY_S);
        _CurState = ProgProduceUnitLarvaeOrderUnit;
        return ProgramResultStillExecuting;
    }
    if(_CurState == ProgProduceUnitLarvaeOrderUnit)
    {
        if(!FrameHUD.ValidateSingleUnit("Larvae"))
        {
            LogThreadEvent("Larvae selection failed", LogError, RGBColor::Orange);
            return ProgramResultFail;
        }
        if(_Entry->Hotkey >= 'a' && _Entry->Hotkey <= 'z')
        {
            g_Context->Managers.KeyboardMouse.SendKey(KEY_A + (_Entry->Hotkey - 'a'));
            LogThreadEvent(String("Ordering larvae: ") + String(_Entry->Hotkey), LogStep);
            _TimeoutTime = GameTime() + 1.0;
            _CurState = ProgProduceUnitLarvaeWaitForCocoon;
            return ProgramResultStillExecuting;
        }
        else
        {
            LogThreadEvent("Invalid unit hotkey", LogError);
            return ProgramResultFail;
        }
    }
    if(_CurState == ProgProduceUnitLarvaeWaitForCocoon)
    {
        if(GameTime() > _TimeoutTime)
        {
            LogThreadEvent("Timed out waiting for cocoon", LogError);
            return ProgramResultFail;
        }
        if(FrameHUD.CountUnitsWithName("ZergCocoon") > 0)
        {
            LogThreadEvent("ZergCocoon found", LogDone);
            g_Context->ReportAction(_Entry->Name, RGBColor::Green);
            g_Context->Managers.Knowledge.RecordUnitInProduction(_Entry, GameTime());
            if(_Entry->Name == "Zergling")
            {
                g_Context->Managers.Knowledge.RecordUnitInProduction(_Entry, GameTime());
            }
            return ProgramResultSuccess;
        }
        else
        {
            LogThreadEvent("Waiting for ZergCocoon", LogStep);
            return ProgramResultStillExecuting;
        }
    }
    HANDLE_CRITICAL_FAILURE;
}
コード例 #27
0
ファイル: OverlordThread.cpp プロジェクト: dmead/sc2bot
void OverlordThread::ProgramSucceeded()
{
    _WakeUpTime = GameTime() + 5.0;
}
コード例 #28
0
ファイル: gametime.cpp プロジェクト: JonnyH/OpenApoc
GameTime GameTime::midday() { return GameTime(TICKS_PER_HOUR * 12); }