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


C++ Mission::Do方法代码示例

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


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

示例1: Step

void SpaceportPanel::Step()
{
	if(GetUI()->IsTop(this))
	{
		Mission *mission = player.MissionToOffer(Mission::SPACEPORT);
		if(mission)
			mission->Do(Mission::OFFER, player, GetUI());
		else
			player.HandleBlockedMissions(Mission::SPACEPORT, GetUI());
	}
}
开发者ID:AJMansfield,项目名称:endless-sky,代码行数:11,代码来源:SpaceportPanel.cpp

示例2: Step

void PlanetPanel::Step()
{
	// If the previous mission callback resulted in a "launch", take off now.
	if(player.ShouldLaunch())
	{
		DoKey('d');
		return;
	}
	if(GetUI()->IsTop(this))
	{
		Mission *mission = player.MissionToOffer(Mission::LANDING);
		if(mission)
			mission->Do(Mission::OFFER, player, GetUI());
		else
			player.HandleBlockedMissions(Mission::LANDING, GetUI());
	}
}
开发者ID:eflyon,项目名称:endless-sky,代码行数:17,代码来源:PlanetPanel.cpp

示例3: RemoveMission

// Mark a mission for removal, either because it was completed, or it failed,
// or because the player aborted it.
void PlayerInfo::RemoveMission(Mission::Trigger trigger, const Mission &mission, UI *ui)
{
	for(auto it = missions.begin(); it != missions.end(); ++it)
		if(&*it == &mission)
		{
			// Don't delete the mission yet, because the conversation or dialog
			// panel may still be showing. Instead, just mark it as done. Doing
			// this first avoids the possibility of an infinite loop, e.g. if a
			// mission's "on fail" fails the mission itself.
			doneMissions.splice(doneMissions.end(), missions, it);
			
			mission.Do(trigger, *this, ui);
			cargo.RemoveMissionCargo(&mission);
			for(shared_ptr<Ship> &ship : ships)
				ship->Cargo().RemoveMissionCargo(&mission);
			return;
		}
}
开发者ID:Danteyxw,项目名称:endless-sky,代码行数:20,代码来源:PlayerInfo.cpp

示例4: Step

void PlanetPanel::Step()
{
	// If the previous mission callback resulted in a "launch", take off now.
	if(player.ShouldLaunch())
	{
		DoKey('d');
		return;
	}
	// If the player starts a new game, exits the shipyard without buying
	// anything, clicks to the bank, then returns to the shipyard and buys a
	// ship, make sure they are shown an intro mission.
	if(GetUI()->IsTop(this) || GetUI()->IsTop(bank.get()))
	{
		Mission *mission = player.MissionToOffer(Mission::LANDING);
		if(mission)
			mission->Do(Mission::OFFER, player, GetUI());
		else
			player.HandleBlockedMissions(Mission::LANDING, GetUI());
	}
}
开发者ID:DingusShingleton,项目名称:endless-sky,代码行数:20,代码来源:PlanetPanel.cpp

示例5: Step

void MainPanel::Step()
{
	engine.Wait();
	
	bool isActive = GetUI()->IsTop(this);
	
	if(show.Has(Command::MAP))
	{
		GetUI()->Push(new MapDetailPanel(player));
		isActive = false;
	}
	else if(show.Has(Command::INFO))
	{
		GetUI()->Push(new InfoPanel(player));
		isActive = false;
	}
	else if(show.Has(Command::HAIL))
	{
		ShowHailPanel();
		isActive = false;
	}
	show = Command::NONE;
	
	// If the player just landed, pop up the planet panel. When it closes, it
	// will call this object's OnCallback() function;
	if(isActive && player.GetPlanet() && !player.GetPlanet()->IsWormhole())
	{
		GetUI()->Push(new PlanetPanel(player, bind(&MainPanel::OnCallback, this)));
		player.Land(GetUI());
		isActive = false;
	}
	if(isActive && player.Flagship() && player.Flagship()->IsTargetable()
			&& !Preferences::Has("help: navigation"))
	{
		Preferences::Set("help: navigation");
		ostringstream out;
		out << "Welcome to the sky! To travel to another star system, press \""
			<< Command::MAP.KeyName() << "\" to view your map, "
			<< "and click on the system you want to travel to. "
			<< "Your hyperdrive can only travel along the \"links\" shown on your map. "
			<< "After selecting a destination, close your map and press \""
			<< Command::JUMP.KeyName() << "\" to jump to that system.\n"
			<< "\tYour ship does not jump until you release the jump key. Once you have escorts, "
			<< "you can hold the key to get them ready to jump, "
			<< "then release it to have them all jump simultaneously.\n"
			<< "\tWhen you reach a new system, you can press \""
			<< Command::LAND.KeyName() << "\" to land on any inhabited planets that are there.\n"
			<< "\tAlso, don't worry about crashing into asteroids or other ships; "
			<< "your ship will fly safely below or above them.";
		GetUI()->Push(new Dialog(out.str()));
		isActive = false;
	}
	if(isActive && player.Flagship() && player.Flagship()->IsDestroyed()
			&& !Preferences::Has("help: dead"))
	{
		Preferences::Set("help: dead");
		ostringstream out;
		out << "Uh-oh! You just died. The universe can a dangerous place for new captains!\n"
			<< "\tFortunately, your game is automatically saved every time you leave a planet. "
			<< "To load your most recent saved game, press \"" + Command::MENU.KeyName()
			<< "\" to return to the main menu, then click on \"Load / Save\" and \"Enter Ship.\"";
		GetUI()->Push(new Dialog(out.str()));
		isActive = false;
	}
	if(isActive && player.Flagship() && player.Flagship()->IsDisabled()
			&& !player.Flagship()->IsDestroyed() && !Preferences::Has("help: disabled"))
	{
		Preferences::Set("help: disabled");
		ostringstream out;
		out << "Your ship just got disabled! "
				<< "Before an enemy ship finishes you off, you should find someone to help you.\n\tPress \""
				<< Command::TARGET.KeyName() << "\" to cycle through all the ships in this system. "
				<< "When you have a friendly one selected, press \""
				<< Command::HAIL.KeyName() << "\" to hail it. "
				<< "You can then ask for help, and the ship will come over and patch you up."
				<< "\n\tIf the ship that disabled you is still hanging around, "
				<< "you might need to hail them first and bribe them to leave you alone.";
		GetUI()->Push(new Dialog(out.str()));
		isActive = false;
	}
	
	engine.Step(isActive);
	
	for(const ShipEvent &event : engine.Events())
	{
		const Government *actor = event.ActorGovernment();
		
		player.HandleEvent(event, GetUI());
		if((event.Type() & (ShipEvent::BOARD | ShipEvent::ASSIST)) && isActive && actor->IsPlayer())
		{
			Mission *mission = player.BoardingMission(event.Target());
			if(mission)
				mission->Do(Mission::OFFER, player, GetUI());
			else if(event.Type() == ShipEvent::BOARD)
			{
				GetUI()->Push(new BoardingPanel(player, event.Target()));
				isActive = false;
			}
		}
		if(event.Type() & (ShipEvent::SCAN_CARGO | ShipEvent::SCAN_OUTFITS))
//.........这里部分代码省略.........
开发者ID:AJMansfield,项目名称:endless-sky,代码行数:101,代码来源:MainPanel.cpp

示例6: TakeOffIfReady

void PlanetPanel::TakeOffIfReady()
{
	// If we're currently showing a conversation or dialog, wait for it to close.
	if(!GetUI()->IsTop(this) && !GetUI()->IsTop(trading.get()) && !GetUI()->IsTop(bank.get())
			&& !GetUI()->IsTop(spaceport.get()) && !GetUI()->IsTop(hiring.get()))
		return;
	
	// If something happens here that cancels the order to take off, don't try
	// to take off until the button is clicked again.
	requestedLaunch = false;
	
	// Check for any landing missions that have not been offered.
	Mission *mission = player.MissionToOffer(Mission::LANDING);
	if(mission)
	{
		mission->Do(Mission::OFFER, player, GetUI());
		return;
	}
	
	// Check whether the player should be warned before taking off.
	if(player.ShouldLaunch())
	{
		TakeOff();
		return;
	}
	
	// Check if any of the player's ships are configured in such a way that they
	// will be impossible to fly.
	for(const shared_ptr<Ship> &ship : player.Ships())
	{
		if(ship->GetSystem() != &system || ship->IsDisabled() || ship->IsParked())
			continue;
		
		string check = ship->FlightCheck();
		if(!check.empty() && check.back() == '!')
		{
			GetUI()->Push(new ConversationPanel(player,
				*GameData::Conversations().Get("flight check: " + check), nullptr, ship));
			return;
		}
	}
	
	// The checks that follow are typically caused by parking or selling
	// ships or changing outfits.
	const Ship *flagship = player.Flagship();
	
	// Are you overbooked? Don't count fireable flagship crew. If your
	// ship can't hold the required crew, count it as having no fireable
	// crew rather than a negative number.
	const CargoHold &cargo = player.Cargo();
	int overbooked = -cargo.BunksFree() - max(0, flagship->Crew() - flagship->RequiredCrew());
	int missionCargoToSell = cargo.MissionCargoSize() - cargo.Size();
	// Will you have to sell something other than regular cargo?
	int cargoToSell = -(cargo.Free() + cargo.CommoditiesSize());
	int droneCount = 0;
	int fighterCount = 0;
	for(const auto &it : player.Ships())
		if(!it->IsParked() && !it->IsDisabled() && it->GetSystem() == &system)
		{
			const string &category = it->Attributes().Category();
			droneCount += (category == "Drone") - it->BaysFree(false);
			fighterCount += (category == "Fighter") - it->BaysFree(true);
		}
	
	if(fighterCount > 0 || droneCount > 0 || cargoToSell > 0 || overbooked > 0)
	{
		ostringstream out;
		if(missionCargoToSell > 0 || overbooked > 0)
		{
			bool both = ((cargoToSell > 0 && cargo.MissionCargoSize()) && overbooked > 0);
			out << "If you take off now you will fail a mission due to not having enough ";

			if(overbooked > 0)
			{
				out << "bunks available for " << overbooked;
				out << (overbooked > 1 ? " of the passengers" : " passenger");
				out << (both ? " and not having enough " : ".");
			}

			if(missionCargoToSell > 0)
			{
				out << "cargo space to hold " << missionCargoToSell;
				out << (missionCargoToSell > 1 ? " tons" : " ton");
				out << " of your mission cargo.";
			}
		}
		else
		{
			out << "If you take off now you will have to sell ";
			bool triple = (fighterCount > 0 && droneCount > 0 && cargoToSell > 0);

			if(fighterCount == 1)
				out << "a fighter";
			else if(fighterCount > 0)
				out << fighterCount << " fighters";
			if(fighterCount > 0 && (droneCount > 0 || cargoToSell > 0))
				out << (triple ? ", " : " and ");
		
			if(droneCount == 1)
				out << "a drone";
//.........这里部分代码省略.........
开发者ID:Amazinite,项目名称:endless-sky,代码行数:101,代码来源:PlanetPanel.cpp

示例7: StepEvents

// Handle ShipEvents from this and previous Engine::Step calls. Start with the
// oldest and then process events until any create a new UI element.
void MainPanel::StepEvents(bool &isActive)
{
	while(isActive && !eventQueue.empty())
	{
		const ShipEvent &event = eventQueue.front();
		const Government *actor = event.ActorGovernment();
		
		// Pass this event to the player, to update conditions and make
		// any new UI elements (e.g. an "on enter" dialog) from their
		// active missions.
		if(!handledFront)
			player.HandleEvent(event, GetUI());
		handledFront = true;
		isActive = (GetUI()->Top().get() == this);
		
		// If we can't safely display a new UI element (i.e. an active
		// mission created a UI element), then stop processing events
		// until the current Conversation or Dialog is resolved. This
		// will keep the current event in the queue, so we can still
		// check it for various special cases involving the player.
		if(!isActive)
			break;
		
		// Handle boarding events.
		// 1. Boarding an NPC may "complete" it (i.e. "npc board"). Any UI element that
		// completion created has now closed, possibly destroying the event target.
		// 2. Boarding an NPC may create a mission (e.g. it thanks you for the repair/refuel,
		// asks you to complete a quest, bribes you into leaving it alone, or silently spawns
		// hostile ships). If boarding creates a mission with an "on offer" conversation, the
		// ConversationPanel will only let the player plunder a hostile NPC if the mission is
		// declined or deferred - an "accept" is assumed to have bought the NPC its life.
		// 3. Boarding a hostile NPC that does not display a mission UI element will display
		// the BoardingPanel, allowing the player to plunder it.
		const Ship *flagship = player.Flagship();
		if((event.Type() & (ShipEvent::BOARD | ShipEvent::ASSIST)) && actor->IsPlayer()
				&& !event.Target()->IsDestroyed() && flagship && event.Actor().get() == flagship)
		{
			Mission *mission = player.BoardingMission(event.Target());
			if(mission && mission->HasSpace(*flagship))
				mission->Do(Mission::OFFER, player, GetUI());
			else if(mission)
				player.HandleBlockedMissions((event.Type() & ShipEvent::BOARD)
						? Mission::BOARDING : Mission::ASSISTING, GetUI());
			// Determine if a Dialog or ConversationPanel is being drawn next frame.
			isActive = (GetUI()->Top().get() == this);
			
			// Confirm that this event's target is not destroyed and still an
			// enemy before showing the BoardingPanel (as a mission NPC's
			// completion conversation may have allowed it to be destroyed or
			// captured).
			// TODO: This BoardingPanel should not be displayed if a mission NPC
			// completion conversation creates a BoardingPanel for it, or if the
			// NPC completion conversation ends via `accept,` even if the ship is
			// still hostile.
			if(isActive && (event.Type() == ShipEvent::BOARD) && !event.Target()->IsDestroyed()
					&& event.Target()->GetGovernment()->IsEnemy())
			{
				// Either no mission activated, or the one that did was "silent."
				GetUI()->Push(new BoardingPanel(player, event.Target()));
				isActive = false;
			}
		}
		
		// Handle scan events of or by the player.
		if(event.Type() & (ShipEvent::SCAN_CARGO | ShipEvent::SCAN_OUTFITS))
		{
			if(actor->IsPlayer())
			{
				ShowScanDialog(event);
				isActive = false;
			}
			else if(event.TargetGovernment()->IsPlayer())
			{
				string message = actor->Fine(player, event.Type(), &*event.Target());
				if(!message.empty())
				{
					GetUI()->Push(new Dialog(message));
					isActive = false;
				}
			}
		}
		
		// Remove the fully-handled event.
		eventQueue.pop_front();
		handledFront = false;
	}
}
开发者ID:Amazinite,项目名称:endless-sky,代码行数:89,代码来源:MainPanel.cpp


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