本文整理汇总了C++中Objective::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ Objective::GetType方法的具体用法?C++ Objective::GetType怎么用?C++ Objective::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Objective
的用法示例。
在下文中一共展示了Objective::GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendSupply
// This sends supply from s to d, subtracting from losses and adding to it's supply traffic field
// Updates values to amount which actually made it. returns 0 if none made it.
int SendSupply (Objective s, Objective d, int *supply, int *fuel)
{
Objective c;
PathClass path;
int i,l,n,loss,type;
if (!*supply && !*fuel)
return 0;
if (GetObjectivePath(&path,s,d,Foot,s->GetTeam(),PATH_MARINE) < 1)
return 0;
c = s;
loss = 0;
AddSupply(s,*supply/10,*fuel/10);
for (i=0; i<path.GetLength(); i++)
{
n = path.GetDirection(i);
c = c->GetNeighbor(n);
type = c->GetType();
if (type == TYPE_ROAD || type == TYPE_INTERSECT || type == TYPE_RAILROAD || type == TYPE_BRIDGE)
{
AddSupply(c,*supply/10,*fuel/10);
l = c->GetObjectiveSupplyLosses() + 2; // Automatic loss rate of 2% per objective
*supply = *supply*(100-l)/100;
*fuel = *fuel*(100-l)/100;
}
if (!*supply && !*fuel)
return 0;
}
return 1;
}
示例2: MoveUnit
int TaskForceClass::MoveUnit (CampaignTime time)
{
GridIndex x = 0, y = 0;
GridIndex nx = 0, ny = 0;
GridIndex ox = 0, oy = 0;
WayPoint w = NULL, ow = NULL;
Objective o = NULL;
int moving = 1;
CampaignHeading h = 0;
// RV - Biker
// Naval units now have three modes:
// (a) Sit still in harbor
// (b) Do a 20 km track (repeating waypoints)
// (c) Followy WPs
GetLocation(&x,&y);
w = ResetCurrentWP(this);
FindNearestUnit(x, y, NULL);
// Check for mode a
o = FindNearestObjective(x, y, NULL, 1);
// RV - Biker - If we are in port and have no WPs do nothing
if (o && o->GetType() == TYPE_PORT && !w) {
return TRUE;
}
// If not in port and no WPs... create a repeating path 20 km north and back
if (!w) {
DisposeWayPoints();
w = AddUnitWP(x, y, 0, 60, TheCampaign.CurrentTime + (rand()%15), 0, 0);
w->SetWPFlags(WPF_REPEAT);
// This should prevent naval units to run into ground
if (GetCover(x, y+20) == Water) {
w = AddUnitWP(x, y+20, 0, 60, TheCampaign.CurrentTime + (15+(rand()%15))*CampaignMinutes, 0, 0);
}
else {
w = AddUnitWP(x, y, 0, 60, TheCampaign.CurrentTime + 15*CampaignMinutes, 0, 0);
}
w->SetWPFlags(WPF_REPEAT);
w = AddUnitWP(x, y, 0, 60, TheCampaign.CurrentTime + (30+(rand()%15))*CampaignMinutes, 0xffffffff, 0);
w->SetWPFlags(WPF_REPEAT);
SetCurrentWaypoint (1);
w = GetCurrentUnitWP();
}
w->GetWPLocation(&nx, &ny);
// RV - Biker - Wait for departure
if (Camp_GetCurrentTime() < w->GetWPDepartureTime()) {
SetUnitLastMove(Camp_GetCurrentTime());
return 0;
}
// Move, if we're not at destination
if (x!=nx || y!=ny)
{
if (w)
ow = w->GetPrevWP();
if (ow)
ow->GetWPLocation(&ox, &oy);
else
GetLocation(&ox, &oy);
while (moving) {
h = DirectionTo(ox, oy, nx, ny, x, y);
if (h > 7) {
moving = 0;
h = Here;
}
// This is kinda hacky - basically, limit change in direction to 45 deg per move
if (h > last_direction) {
if (h - last_direction < 5)
h = (last_direction+1) & 0x07;
else
h = (last_direction+7) & 0x07;
}
else if (h < last_direction) {
if (last_direction - h < 5)
h = (last_direction+7) & 0x07;
else
h = (last_direction+1) & 0x07;
}
//this moves the unit
if (ChangeUnitLocation(h) > 0) {
last_direction = h;
}
else {
moving = 0;
}
//.........这里部分代码省略.........