本文整理汇总了C++中CSelectedUnits::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ CSelectedUnits::begin方法的具体用法?C++ CSelectedUnits::begin怎么用?C++ CSelectedUnits::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSelectedUnits
的用法示例。
在下文中一共展示了CSelectedUnits::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTooltip
std::string CSelectedUnits::GetTooltip(void)
{
std::string s;
if(selectedGroup!=-1 && grouphandler->groups[selectedGroup]->ai){
s="Group selected";
} else if(!selectedUnits.empty()){
// show the player name instead of unit name if it has FBI tag showPlayerName
if((*selectedUnits.begin())->unitDef->showPlayerName)
{
s=gs->players[gs->Team((*selectedUnits.begin())->team)->leader]->playerName.c_str();
} else {
s=(*selectedUnits.begin())->tooltip;
}
}
if(selectedUnits.empty()){
return s;
}
char tmp[500];
float maxHealth=0,curHealth=0,cost=0,exp=0,range=0,metalMake=0,metalUse=0,energyMake=0,energyUse=0,maxfuel=0,curfuel=0,numfuel=0;
for(set<CUnit*>::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
maxHealth+=(*ui)->maxHealth;
curHealth+=(*ui)->health;
exp+=(*ui)->experience;
cost+=(*ui)->metalCost+(*ui)->energyCost/60;
range+=(*ui)->maxRange;
metalMake+=(*ui)->metalMake;
metalUse+=(*ui)->metalUse;
energyMake+=(*ui)->energyMake;
energyUse+=(*ui)->energyUse;
maxfuel+=(*ui)->unitDef->maxFuel;
curfuel+=(*ui)->currentFuel;
if((*ui)->unitDef->maxFuel > 0)
numfuel++;
}
float num=selectedUnits.size();
sprintf(tmp,"\nHealth %.0f/%.0f",curHealth,maxHealth);
s+=tmp;
if(maxfuel>0){
sprintf(tmp," Fuel %.0f/%.0f",curfuel/numfuel,maxfuel/numfuel);
s+=tmp;
}
sprintf(tmp,"\nExperience %.2f Cost %.0f Range %.0f \n\xff\xd3\xdb\xffMetal: \xff\x50\xff\x50%.1f\xff\x90\x90\x90/\xff\xff\x50\x01-%.1f\xff\xd3\xdb\xff Energy: \xff\x50\xff\x50%.1f\xff\x90\x90\x90/\xff\xff\x50\x01-%.1f",
exp/num,cost,range/num, metalMake, metalUse, energyMake, energyUse);
s += tmp;
if (gs->cheatEnabled && (selectedUnits.size() == 1)) {
CUnit* unit = *selectedUnits.begin();
SNPRINTF(tmp, sizeof(tmp), "\xff\xc0\xc0\xff [TechLevel %i]",
unit->unitDef->techLevel);
s += tmp;
}
return s;
}
示例2: Draw
void CSelectedUnits::Draw()
{
glDisable(GL_DEPTH_TEST );
//glEnable(GL_BLEND);
//glColor4f(0,0.8f,0,0.4f);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor3f(0,1.0f,0);
set<CUnit*>::iterator ui;
glBegin(GL_QUADS);
if(selectedGroup!=-1){
for(ui=grouphandler->groups[selectedGroup]->units.begin();ui!=grouphandler->groups[selectedGroup]->units.end();++ui){
float3 pos((*ui)->pos+(*ui)->speed*gu->timeOffset);
glVertexf3(pos+float3((*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,-(*ui)->ysize*4));
glVertexf3(pos+float3((*ui)->xsize*4,0,-(*ui)->ysize*4));
}
} else {
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
float3 pos((*ui)->pos+(*ui)->speed*gu->timeOffset);
glVertexf3(pos+float3((*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,-(*ui)->ysize*4));
glVertexf3(pos+float3((*ui)->xsize*4,0,-(*ui)->ysize*4));
}
}
glEnd();
glEnable(GL_DEPTH_TEST );
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
//glDisable(GL_BLEND);
}
示例3: DrawCommands
void CSelectedUnits::DrawCommands(void)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
lineDrawer.Configure(cmdColors.UseColorRestarts(),
cmdColors.UseRestartColor(),
cmdColors.restart,
cmdColors.RestartAlpha());
glBlendFunc((GLenum)cmdColors.QueuedBlendSrc(),
(GLenum)cmdColors.QueuedBlendDst());
glEnable(GL_BLEND);
glLineWidth(cmdColors.QueuedLineWidth());
set<CUnit*>::iterator ui;
if(selectedGroup!=-1){
for(ui=grouphandler->groups[selectedGroup]->units.begin();ui!=grouphandler->groups[selectedGroup]->units.end();++ui){
(*ui)->commandAI->DrawCommands();
}
} else {
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->DrawCommands();
}
}
glLineWidth(1.0f);
glEnable(GL_DEPTH_TEST);
}
示例4: SetCommandPage
void CSelectedUnits::SetCommandPage(int page)
{
if(selectedGroup!=-1 && grouphandler->groups[selectedGroup]->ai){
grouphandler->groups[selectedGroup]->lastCommandPage=page;
}
if(!selectedUnits.empty())
(*selectedUnits.begin())->commandAI->lastSelectedCommandPage=page;
}
示例5: SetCommandPage
void CSelectedUnits::SetCommandPage(int page)
{
GML_RECMUTEX_LOCK(sel); // SetCommandPage - called from CGame::Draw --> RunLayoutCommand --> LayoutIcons --> RevertToCmdDesc
CUnitSet::iterator ui;
for (ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
(*ui)->commandAI->lastSelectedCommandPage = page;
}
}
示例6: SendSelection
void CSelectedUnits::SendSelection(void)
{
// first, convert CUnit* to unit IDs.
std::vector<short> selectedUnitIDs(selectedUnits.size());
std::vector<short>::iterator i = selectedUnitIDs.begin();
CUnitSet::const_iterator ui = selectedUnits.begin();
for(; ui != selectedUnits.end(); ++i, ++ui) *i = (*ui)->id;
net->Send(CBaseNetProtocol::Get().SendSelect(gu->myPlayerNum, selectedUnitIDs));
selectionChanged=false;
}
示例7: SendSelection
void CSelectedUnits::SendSelection(void)
{
// first, convert CUnit* to unit IDs.
std::vector<short> selectedUnitIDs(selectedUnits.size());
std::vector<short>::iterator i = selectedUnitIDs.begin();
std::set<CUnit*>::const_iterator ui = selectedUnits.begin();
for(; ui != selectedUnits.end(); ++i, ++ui) *i = (*ui)->id;
net->SendSTLData<unsigned char, std::vector<short> >(NETMSG_SELECT, gu->myPlayerNum, selectedUnitIDs);
selectionChanged=false;
}
示例8: SetCommandPage
void CSelectedUnits::SetCommandPage(int page)
{
if(selectedGroup!=-1 && grouphandlers[gu->myTeam]->groups[selectedGroup]->ai){
grouphandlers[gu->myTeam]->groups[selectedGroup]->lastCommandPage=page;
}
CUnitSet::iterator ui;
for (ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
(*ui)->commandAI->lastSelectedCommandPage = page;
}
}
示例9: ClearSelected
void CSelectedUnits::ClearSelected()
{
set<CUnit*>::iterator ui;
ENTER_MIXED;
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->selected=false;
DeleteDeathDependence(*ui);
}
ENTER_UNSYNCED;
selectedUnits.clear();
selectionChanged=true;
possibleCommandsChanged=true;
selectedGroup=-1;
}
示例10: ClearSelected
void CSelectedUnits::ClearSelected()
{
GML_RECMUTEX_LOCK(sel); // ClearSelected
CUnitSet::iterator ui;
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->selected=false;
DeleteDeathDependence(*ui);
}
selectedUnits.clear();
selectionChanged=true;
possibleCommandsChanged=true;
selectedGroup=-1;
}
示例11: DrawCommands
void CSelectedUnits::DrawCommands(void)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
set<CUnit*>::iterator ui;
if(selectedGroup!=-1){
for(ui=grouphandler->groups[selectedGroup]->units.begin();ui!=grouphandler->groups[selectedGroup]->units.end();++ui){
(*ui)->commandAI->DrawCommands();
}
} else {
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->DrawCommands();
}
}
glEnable(GL_DEPTH_TEST);
}
示例12: SendCommand
void CSelectedUnits::SendCommand(const Command& c)
{
if (selectionChanged) {
// send new selection
GML_RECMUTEX_LOCK(sel); // SendSelection
// first, convert CUnit* to unit IDs.
std::vector<short> selectedUnitIDs(selectedUnits.size());
std::vector<short>::iterator i = selectedUnitIDs.begin();
CUnitSet::const_iterator ui = selectedUnits.begin();
for(; ui != selectedUnits.end(); ++i, ++ui) {
*i = (*ui)->id;
}
net->Send(CBaseNetProtocol::Get().SendSelect(gu->myPlayerNum, selectedUnitIDs));
selectionChanged = false;
}
net->Send(CBaseNetProtocol::Get().SendCommand(gu->myPlayerNum, c.GetID(), c.options, c.params));
}
示例13: GetDefaultCmd
int CSelectedUnits::GetDefaultCmd(CUnit* unit, CFeature* feature)
{
// NOTE: the unitDef->aihint value is being ignored
int luaCmd;
if (eventHandler.DefaultCommand(unit, feature, luaCmd)) {
return luaCmd;
}
if ((selectedGroup != -1) && grouphandlers[gu->myTeam]->groups[selectedGroup]->ai) {
return grouphandlers[gu->myTeam]->groups[selectedGroup]->GetDefaultCmd(unit, feature);
}
// return the default if there are no units selected
CUnitSet::const_iterator ui = selectedUnits.begin();
if (ui == selectedUnits.end()) {
return CMD_STOP;
}
// setup the locals for IsBetterLeader()
targetUnit = unit;
targetFeature = feature;
if (targetUnit) {
targetIsEnemy = !gs->Ally(gu->myAllyTeam, targetUnit->allyteam);
}
// find the best leader to pick the command
const CUnit* leaderUnit = *ui;
const UnitDef* leaderDef = leaderUnit->unitDef;
for (++ui; ui != selectedUnits.end(); ++ui) {
const CUnit* testUnit = *ui;
const UnitDef* testDef = testUnit->unitDef;
if (testDef != leaderDef) {
if (IsBetterLeader(testDef, leaderDef)) {
leaderDef = testDef;
leaderUnit = testUnit;
}
}
}
return (leaderUnit->commandAI->GetDefaultCmd(unit, feature));
}
示例14: DrawCommands
// CALLINFO:
// CGame::Draw --> DrawCommands
// CMiniMap::DrawForReal --> DrawCommands
void CSelectedUnits::DrawCommands()
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
lineDrawer.Configure(cmdColors.UseColorRestarts(),
cmdColors.UseRestartColor(),
cmdColors.restart,
cmdColors.RestartAlpha());
lineDrawer.SetupLineStipple();
glEnable(GL_BLEND);
glBlendFunc((GLenum)cmdColors.QueuedBlendSrc(),
(GLenum)cmdColors.QueuedBlendDst());
glLineWidth(cmdColors.QueuedLineWidth());
GML_RECMUTEX_LOCK(sel); // DrawCommands
GML_RECMUTEX_LOCK(group); // DrawCommands
GML_STDMUTEX_LOCK(cai); // DrawCommands
CUnitSet::iterator ui;
if (selectedGroup != -1) {
CUnitSet& groupUnits = grouphandlers[gu->myTeam]->groups[selectedGroup]->units;
for(ui = groupUnits.begin(); ui != groupUnits.end(); ++ui) {
(*ui)->commandAI->DrawCommands();
}
} else {
for(ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
(*ui)->commandAI->DrawCommands();
}
}
// draw the commands from AIs
grouphandlers[gu->myTeam]->DrawCommands();
waitCommandsAI.DrawCommands();
glLineWidth(1.0f);
glEnable(GL_DEPTH_TEST);
}
示例15: GetDefaultCmd
int CSelectedUnits::GetDefaultCmd(CUnit *unit,CFeature* feature)
{
if(selectedGroup!=-1 && grouphandler->groups[selectedGroup]->ai){
return grouphandler->groups[selectedGroup]->GetDefaultCmd(unit,feature);
}
int cmd=CMD_STOP;
int lowestHint=10000;//find better way to decide
CUnit* selected=0;
int i = 0;
for(set<CUnit*>::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
if((!(*ui)->immobile || (i==selectedUnits.size() - 1 && lowestHint == 10000)) && (*ui)->aihint<lowestHint)
{
selected=*ui;
lowestHint=(*ui)->aihint;
}
i++;
}
if(selected)
cmd=selected->commandAI->GetDefaultCmd(unit,feature);
return cmd;
}