当前位置: 首页>>代码示例>>C++>>正文


C++ Objective::IsUnit方法代码示例

本文整理汇总了C++中Objective::IsUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ Objective::IsUnit方法的具体用法?C++ Objective::IsUnit怎么用?C++ Objective::IsUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Objective的用法示例。


在下文中一共展示了Objective::IsUnit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandleInboundFlight

void HandleInboundFlight( ObjectiveClass *atc, Flight flight)
{
	if(!atc || !flight)
		return;

	Objective	o = (Objective)(flight->GetUnitAirbase());	// JBLOOK Added by M.N. for now to prevent CTD
	if (o && o->IsUnit())								// when user issues "Inbound" on a carrier
		return;
	
	int index, tod, time_in_minutes;
	FalconRadioChatterMessage *radioMessage = NULL;
	ATCBrain* atcBrain = atcBrain = atc->brain;
	AircraftClass *aircraft = (AircraftClass*)flight->GetComponentLead();
	int delay = 7 * CampaignSeconds;
	if (!PlayerOptions.PlayerRadioVoice)
	    delay = 500;
	atcBrain->AddInboundFlight(flight);

	index = atcBrain->FindBestLandingRunway( aircraft, TRUE);

	if(index)
	{
		int randNum = rand()%3;
		switch(randNum)
		{
		case 0:
			radioMessage = CreateCallFromATC(atc, aircraft, rcCONTINUEINBOUND1, FalconLocalGame);
			//M.N. changed to 32767 -> flexibly use randomized value of max available eval indexes
			radioMessage->dataBlock.edata[4]	= 32767;
			radioMessage->dataBlock.edata[5]	= (short)atcBrain->GetRunwayName(atcBrain->GetOppositeRunway(index));
			if(rand()%2)
				radioMessage->dataBlock.edata[6]	= 4;
			else
				radioMessage->dataBlock.edata[6]	= -1;
			break;

		case 1:
			radioMessage = CreateCallFromATC(atc, aircraft, rcCONTINUEINBOUND2, FalconLocalGame);

			if(rand()%2)
			{
				radioMessage->dataBlock.edata[3]	= (short)(rand()%3);
			}
			else
			{
				time_in_minutes =  TheCampaign.GetMinutesSinceMidnight();
				if (time_in_minutes < 180)//3am
					tod = 1;
				else if(time_in_minutes < 720 )//noon
					tod = 0;
				else if(time_in_minutes < 1020 ) //5pm
					tod = 2;
				else
					tod = 1;

				radioMessage->dataBlock.edata[3]	= (short)(3 + tod + (rand()%3)*3);
			}

			if(rand()%2)
				radioMessage->dataBlock.edata[4]	= 4;
			else
				radioMessage->dataBlock.edata[4]	= -1;
			break;

		case 2:
			radioMessage = CreateCallFromATC(atc, aircraft, rcCONTINUEINBOUND3, FalconLocalGame);
			radioMessage->dataBlock.edata[4]	= -1;
			radioMessage->dataBlock.edata[5]	= -1;
			radioMessage->dataBlock.edata[6]	= 32767;
			radioMessage->dataBlock.edata[7]	= (short)atcBrain->GetRunwayName(atcBrain->GetOppositeRunway(index));
			if(rand()%2)
				radioMessage->dataBlock.edata[8]	= 4;
			else
				radioMessage->dataBlock.edata[8]	= -1;
			break;
		}
		
		radioMessage->dataBlock.time_to_play= delay;
		FalconSendMessage(radioMessage, TRUE);
	}
	else
	{
		VuListIterator		flightIter(flight->GetComponents());

		aircraft = (AircraftClass*) flightIter.GetFirst();
		while(aircraft)
		{
			//all runways destroyed, divert 'em
			FalconATCCmdMessage* ATCCmdMessage = new FalconATCCmdMessage( aircraft->Id(), FalconLocalGame );
			ATCCmdMessage->dataBlock.from		= atc->Id();
			ATCCmdMessage->dataBlock.type		= FalconATCCmdMessage::Divert;
			ATCCmdMessage->dataBlock.rwindex	= 0;
			FalconSendMessage(ATCCmdMessage, FALSE);						// Send it
			aircraft = (AircraftClass*) flightIter.GetNext();
		}		
	}
}
开发者ID:FreeFalcon,项目名称:freefalcon-contrib,代码行数:97,代码来源:ATCMsg.cpp


注:本文中的Objective::IsUnit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。