本文整理汇总了C++中PlayerInfo::Missions方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerInfo::Missions方法的具体用法?C++ PlayerInfo::Missions怎么用?C++ PlayerInfo::Missions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerInfo
的用法示例。
在下文中一共展示了PlayerInfo::Missions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
MissionPanel::MissionPanel(PlayerInfo &player)
: MapPanel(player),
available(player.AvailableJobs()),
accepted(player.Missions()),
availableIt(player.AvailableJobs().begin()),
acceptedIt(player.AvailableJobs().empty() ? accepted.begin() : accepted.end())
{
while(acceptedIt != accepted.end() && !acceptedIt->IsVisible())
++acceptedIt;
wrap.SetWrapWidth(380);
wrap.SetFont(FontSet::Get(14));
wrap.SetAlignment(WrappedText::JUSTIFIED);
// Select the first available or accepted mission in the currently selected
// system, or along the travel plan.
if(!FindMissionForSystem(selectedSystem) && player.HasTravelPlan())
{
const auto &tp = player.TravelPlan();
for(auto it = tp.crbegin(); it != tp.crend(); ++it)
if(FindMissionForSystem(*it))
break;
}
// Auto select the destination system for the current mission.
if(availableIt != available.end())
selectedSystem = availableIt->Destination()->GetSystem();
else if(acceptedIt != accepted.end())
selectedSystem = acceptedIt->Destination()->GetSystem();
// Center the system slightly above the center of the screen because the
// lower panel is taking up more space than the upper one.
center = Point(0., -80.) - selectedSystem->Position();
}
示例2: player
HailPanel::HailPanel(PlayerInfo &player, const StellarObject *object)
: player(player), planet(object->GetPlanet()),
sprite(object->GetSprite().GetSprite()), unit(object->Position().Unit())
{
SetInterruptible(false);
const Government *gov = player.GetSystem()->GetGovernment();
if(planet)
header = gov->GetName() + " " + planet->Noun() + " \"" + planet->Name() + "\":";
if(planet && player.Flagship())
{
for(const Mission &mission : player.Missions())
if(mission.HasClearance(planet) && mission.ClearanceMessage() != "auto"
&& mission.HasFullClearance())
{
planet->Bribe();
message = mission.ClearanceMessage();
return;
}
if(planet->CanLand())
message = "You are cleared to land, " + player.Flagship()->Name() + ".";
else
{
SetBribe(planet->GetBribeFraction());
if(bribe)
message = "If you want to land here, it'll cost you "
+ Format::Number(bribe) + " credits.";
else
message = "I'm afraid we can't permit you to land here.";
}
}
}
示例3: MapPanel
MissionPanel::MissionPanel(PlayerInfo &player)
: MapPanel(player, -4),
available(player.AvailableJobs()),
accepted(player.Missions()),
availableIt(player.AvailableJobs().begin()),
acceptedIt(player.AvailableJobs().empty() ? accepted.begin() : accepted.end())
{
while(acceptedIt != accepted.end() && !acceptedIt->IsVisible())
++acceptedIt;
// Center the system slightly above the center of the screen because the
// lower panel is taking up more space than the upper one.
center = Point(0., -80.) - selectedSystem->Position();
wrap.SetWrapWidth(380);
wrap.SetFont(FontSet::Get(14));
wrap.SetAlignment(WrappedText::JUSTIFIED);
}
示例4: MovePlayer
void AI::MovePlayer(Ship &ship, const PlayerInfo &player, const list<shared_ptr<Ship>> &ships)
{
Command command;
if(player.HasTravelPlan())
{
const System *system = player.TravelPlan().back();
ship.SetTargetSystem(system);
// Check if there's a particular planet there we want to visit.
for(const Mission &mission : player.Missions())
if(mission.Destination() && mission.Destination()->GetSystem() == system)
{
ship.SetDestination(mission.Destination());
break;
}
}
if(keyDown.Has(Command::NEAREST))
{
double closest = numeric_limits<double>::infinity();
int closeState = 0;
for(const shared_ptr<Ship> &other : ships)
if(other.get() != &ship && other->IsTargetable())
{
// Sort ships into one of three priority states:
// 0 = friendly, 1 = disabled enemy, 2 = active enemy.
int state = other->GetGovernment()->IsEnemy(ship.GetGovernment());
// Do not let "target nearest" select a friendly ship, so that
// if the player is repeatedly targeting nearest to, say, target
// a bunch of fighters, they won't start firing on friendly
// ships as soon as the last one is gone.
if((!state && !shift) || other->GetGovernment()->IsPlayer())
continue;
state += state * !other->IsDisabled();
double d = other->Position().Distance(ship.Position());
if(state > closeState || (state == closeState && d < closest))
{
ship.SetTargetShip(other);
closest = d;
closeState = state;
}
}
}
else if(keyDown.Has(Command::TARGET))
{
shared_ptr<const Ship> target = ship.GetTargetShip();
bool selectNext = !target || !target->IsTargetable();
for(const shared_ptr<Ship> &other : ships)
{
bool isPlayer = other->GetGovernment()->IsPlayer() || other->GetPersonality().IsEscort();
if(other == target)
selectNext = true;
else if(other.get() != &ship && selectNext && other->IsTargetable() && isPlayer == shift)
{
ship.SetTargetShip(other);
selectNext = false;
break;
}
}
if(selectNext)
ship.SetTargetShip(shared_ptr<Ship>());
}
else if(keyDown.Has(Command::BOARD))
{
shared_ptr<const Ship> target = ship.GetTargetShip();
if(!target || !target->IsDisabled() || target->IsDestroyed() || target->GetSystem() != ship.GetSystem())
{
double closest = numeric_limits<double>::infinity();
bool foundEnemy = false;
bool foundAnything = false;
for(const shared_ptr<Ship> &other : ships)
if(other->IsTargetable() && other->IsDisabled() && !other->IsDestroyed())
{
bool isEnemy = other->GetGovernment()->IsEnemy(ship.GetGovernment());
double d = other->Position().Distance(ship.Position());
if((isEnemy && !foundEnemy) || d < closest)
{
closest = d;
foundEnemy = isEnemy;
foundAnything = true;
ship.SetTargetShip(other);
}
}
if(!foundAnything)
keyDown.Clear(Command::BOARD);
}
}
else if(keyDown.Has(Command::LAND))
{
// If the player is right over an uninhabited planet, display a message
// explaining why they cannot land there.
string message;
for(const StellarObject &object : ship.GetSystem()->Objects())
if(!object.GetPlanet() && !object.GetSprite().IsEmpty())
{
double distance = ship.Position().Distance(object.Position());
if(distance < object.Radius())
//.........这里部分代码省略.........
示例5: Do
void MissionAction::Do(PlayerInfo &player, UI *ui, const System *destination) const
{
bool isOffer = (trigger == "offer");
if(!conversation.IsEmpty() && ui)
{
ConversationPanel *panel = new ConversationPanel(player, conversation, destination);
if(isOffer)
panel->SetCallback(&player, &PlayerInfo::MissionCallback);
ui->Push(panel);
}
else if(!dialogText.empty() && ui)
{
map<string, string> subs;
subs["<first>"] = player.FirstName();
subs["<last>"] = player.LastName();
if(player.Flagship())
subs["<ship>"] = player.Flagship()->Name();
string text = Format::Replace(dialogText, subs);
if(isOffer)
ui->Push(new Dialog(text, player, destination));
else
ui->Push(new Dialog(text));
}
else if(isOffer && ui)
player.MissionCallback(Conversation::ACCEPT);
// If multiple outfits are being transferred, first remove them before
// adding any new ones.
for(const auto &it : gifts)
if(it.second < 0)
DoGift(player, it.first, it.second, ui);
for(const auto &it : gifts)
if(it.second > 0)
DoGift(player, it.first, it.second, ui);
if(payment)
player.Accounts().AddCredits(payment);
for(const auto &it : events)
player.AddEvent(*GameData::Events().Get(it.first), player.GetDate() + it.second);
if(!fail.empty())
{
// Failing missions invalidates iterators into the player's mission list,
// but does not immediately delete those missions. So, the safe way to
// iterate over all missions is to make a copy of the list before we
// begin to remove items from it.
vector<const Mission *> failedMissions;
for(const Mission &mission : player.Missions())
if(fail.count(mission.Identifier()))
failedMissions.push_back(&mission);
for(const Mission *mission : failedMissions)
player.RemoveMission(Mission::FAIL, *mission, ui);
}
// Check if applying the conditions changes the player's reputations.
player.SetReputationConditions();
conditions.Apply(player.Conditions());
player.CheckReputationConditions();
}