本文整理汇总了C++中Agent::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ Agent::GetType方法的具体用法?C++ Agent::GetType怎么用?C++ Agent::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Agent
的用法示例。
在下文中一共展示了Agent::GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ScoreTransportUtility
double Squad::ScoreTransportUtility(AiMain *ai, ArmyAgent *transport)
{
double max_score = BAD_UTILITY;
double tmp_score;
sint32 agent_idx, agent_num;
Agent *agent = NULL;
ArmyAgent *army_agent = NULL;
agent_num = my_agents.count;
for (agent_idx = agent_num-1; 0 <= agent_idx; agent_idx--)
{
agent = (Agent*)my_agents.Return_Data_By_Number(agent_idx);
if (agent->GetType() != AGENT_TYPE_ARMY)
continue;
army_agent = (ArmyAgent*) agent;
tmp_score = army_agent->EstimateTransportUtility(ai, transport);
if (tmp_score > max_score)
max_score = tmp_score;
}
return max_score;
}
示例2: UngroupAllArmies
void Squad::UngroupAllArmies(AiMain *ai)
{
sint32 agent_idx, agent_num;
Agent *agent = NULL;
ArmyAgent *army_agent = NULL;
BOOL is_unknown_id;
agent_num = my_agents.count;
for (agent_idx = agent_num-1; 0 <= agent_idx; agent_idx--)
{
agent = (Agent*)my_agents.Return_Data_By_Number(agent_idx);
if (agent->GetType() != AGENT_TYPE_ARMY)
continue;
army_agent = (ArmyAgent*) agent;
if ((army_agent->GetNUnits() > 1) &&
(army_agent->GetState() != AGENT_STATE_MARKED_DEAD))
{
Assert(army_agent->GetID().GetVal() != 0);
ai->m_player->ArmyUngroup(army_agent->GetID().GetVal(),
&is_unknown_id);
Assert(!is_unknown_id);
}
}
}
示例3: GetUsableTransport
sint32 Squad::GetUsableTransport(AiMain *ai)
{
sint32 agent_idx, agent_num;
Agent *agent = NULL;
ArmyAgent *army_agent = NULL;
sint32 total_empty = 0;
sint32 empty, full;
agent_num = my_agents.count;
for (agent_idx = agent_num-1; 0 <= agent_idx; agent_idx--)
{
agent = (Agent*)my_agents.Return_Data_By_Number(agent_idx);
if (agent->GetType() == AGENT_TYPE_ARMY)
{
army_agent = (ArmyAgent *) agent;
if (army_agent->GetMovePoints() >= MINIMUM_MOVEMENT_POINTS_TO_MOVE &&
!army_agent->IsWaitState())
{
if (army_agent->GetNumCargo(ai, full, empty))
total_empty += empty;
}
}
}
return total_empty;
}
示例4: GroupWithArmy
void Squad::GroupWithArmy(AiMain *ai, ArmyAgent *army_agent)
{
sint32 agent_idx, agent_num;
Agent *agent = NULL;
ArmyAgent *grouped_agent = NULL;
BOOL is_unknown_id;
MapPointData army_pos;
MapPointData grouped_pos;
agent_num = my_agents.count;
army_agent->GetPos(ai,army_pos);
Assert(army_agent->GetState() != AGENT_STATE_MARKED_DEAD);
if (army_agent->GetState() == AGENT_STATE_MARKED_DEAD)
return;
for (agent_idx = agent_num-1; 0 <= agent_idx; agent_idx--)
{
agent = (Agent*)my_agents.Return_Data_By_Number(agent_idx);
if (agent->GetType() == AGENT_TYPE_ARMY)
{
grouped_agent = (ArmyAgent *) agent;
Assert(grouped_agent->GetState() != AGENT_STATE_MARKED_DEAD);
if (grouped_agent->GetState() == AGENT_STATE_MARKED_DEAD)
continue;
grouped_agent->GetPos(ai,grouped_pos);
if (grouped_agent->GetID().GetVal() != army_agent->GetID().GetVal() &&
grouped_pos.x == army_pos.x &&
grouped_pos.y == army_pos.y &&
grouped_pos.z == army_pos.z)
{
Remove_Agent(grouped_agent);
ai->m_player->ArmyGroup(grouped_agent->GetID().GetVal(),
army_agent->GetID().GetVal(),
&is_unknown_id);
Assert(!is_unknown_id);
if (!is_unknown_id)
{
grouped_agent->m_has_been_executed = TRUE;
grouped_agent->SetState(AGENT_STATE_MARKED_DEAD);
}
}
}
}
}
示例5: Ok_To_Rally
BOOL Squad::Ok_To_Rally(AiMain *ai)
{
sint32 agent_idx, agent_num;
Agent *agent = NULL;
ArmyAgent *army_agent = NULL;
sint32 dest_cont;
BOOL dest_is_land;
MapPointData pos;
sint32 num_in_water = 0;
sint32 num_at_dest = 0;
agent_num = my_agents.count;
ArmyGoal *army_goal = (ArmyGoal*) my_strategic_goal;
army_goal->GetPos(pos);
if(pos.z == SPACE_Z) return TRUE;
BOOL r = ai->m_continents->GetContinent(ai, pos, dest_cont, dest_is_land);
Assert(r);
if (!dest_is_land)
return TRUE;
for (agent_idx = agent_num-1; 0 <= agent_idx; agent_idx--)
{
agent = (Agent*)my_agents.Return_Data_By_Number(agent_idx);
if (agent->GetType() != AGENT_TYPE_ARMY)
continue;
army_agent = (ArmyAgent*) agent;
if ((army_agent->GetNUnits() > 0) &&
(army_agent->GetState() != AGENT_STATE_MARKED_DEAD))
{
if ((army_agent->GetContinent() != dest_cont)
&& (army_agent->GetMyIsLand()))
return FALSE;
if (!army_agent->GetMyIsLand())
num_in_water++;
else if (army_agent->GetContinent() == dest_cont)
num_at_dest++;
}
}
return (agent_num == (num_in_water + num_at_dest));
}
示例6: GetTransportUnitsCount
sint32 Squad::GetTransportUnitsCount(AiMain *ai)
{
sint32 my_transports = 0;
Agent *agent;
for (sint32 i = 0; i < my_agents.count; i++)
{
agent = (Agent *) my_agents.Return_Data_By_Number( i );
if (agent->GetType() != AGENT_TYPE_CITY)
my_transports += ((ArmyAgent*) agent)->GetTransports(ai);
}
return my_transports;
}
示例7: Get_Totally_Complete
int Goal_Attack_Region::Get_Totally_Complete(AiMain *ai)
{
int i;
int completely_there_count = 0;
Agent *agent = NULL;
ArmyAgent *aa=NULL;
MapPointData army_pos;
if (attacking_squad == NULL) return false;
for (i=0; i < attacking_squad->my_agents.count; i++)
{
agent = (Agent *) attacking_squad->my_agents.Return_Data_By_Number(i);
if (agent->GetType() == AGENT_TYPE_ARMY)
{
aa = (ArmyAgent *) agent;
if (aa->GetState() == AGENT_STATE_MARKED_DEAD) {
continue;
}
aa->GetPos(ai, army_pos);
if ((m_pos->x == army_pos.x) &&
(m_pos->y == army_pos.y) &&
(m_pos->z == army_pos.z) )
{
completely_there_count++;
}
}
}
Set_Totally_Complete(completely_there_count == attacking_squad->my_agents.count);
return m_is_completed;
}
示例8: GetMoveTypes
uint32 Squad::GetMoveTypes(AiMain *ai)
{
if (m_moveType)
return m_moveType;
Agent *agent;
ArmyAgent *army_agent;
for (sint32 i = 0; i < my_agents.count; i++)
{
agent = (Agent *) my_agents.Return_Data_By_Number( i );
if (agent->GetType() != AGENT_TYPE_CITY)
{
army_agent = (ArmyAgent *)agent;
m_moveType |= army_agent->GetMoveIntersection(ai);
}
}
return m_moveType;
}
示例9: GetUsableDefense
double Squad::GetUsableDefense(AiMain *ai)
{
sint32 agent_idx, agent_num;
Agent *agent = NULL;
ArmyAgent *army_agent = NULL;
double total_defense = 0.0;
agent_num = my_agents.count;
for (agent_idx = agent_num-1; 0 <= agent_idx; agent_idx--)
{
agent = (Agent*)my_agents.Return_Data_By_Number(agent_idx);
if (agent->GetType() == AGENT_TYPE_ARMY)
{
army_agent = (ArmyAgent *) agent;
if (army_agent->GetMovePoints() >= MINIMUM_MOVEMENT_POINTS_TO_MOVE &&
!army_agent->IsWaitState())
total_defense += army_agent->GetDefenseStrength();
}
}
return total_defense;
}