本文整理汇总了C++中Town::set_nation方法的典型用法代码示例。如果您正苦于以下问题:C++ Town::set_nation方法的具体用法?C++ Town::set_nation怎么用?C++ Town::set_nation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Town
的用法示例。
在下文中一共展示了Town::set_nation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CampaignEastWest::plot_d2_create_game()
{
// find a non-own nation
int srcNation;
for( srcNation = nation_array.size(); srcNation > 0; --srcNation)
{
if( !nation_array.is_deleted(srcNation)
&& !nation_array[srcNation]->is_own() )
{
break;
}
}
//
int unitId;
short kingXLoc = -1, kingYLoc;
if(srcNation)
{
Nation *nationPtr = nation_array[srcNation];
if( nationPtr->is_human() )
unitId = race_res[nationPtr->race_id]->infantry_unit_id;
else
unitId = monster_res[nationPtr->monster_id()]->unit_id;
if( nationPtr->king_unit_recno )
{
unit_array[nationPtr->king_unit_recno]->get_cur_loc( kingXLoc, kingYLoc);
}
}
else
unitId = 0;
Town *targetTown;
// find a town and turn it independent
int count = 1;
for(int townRecno = 1; townRecno <= town_array.size() && count > 0; ++townRecno )
{
if( town_array.is_deleted(townRecno) )
continue;
targetTown = town_array[townRecno];
if( targetTown->is_own() )
{
targetTown->set_nation(0);
// ----- create a monster next to town -------//
if( unitId && kingXLoc >= 0)
{
int unitRecno = targetTown->create_unit(unitId);
if( unitRecno )
{
unit_array[unitRecno]->betray(srcNation);
unit_array[unitRecno]->move(kingXLoc, kingYLoc, true);
}
}
--count;
}
}
}
示例2: use_manually
//.........这里部分代码省略.........
// change unit to my nation
Unit *targetUnit;
if( !base_obj_array.is_deleted(targetBaseObjRecno)
&& (targetUnit = base_obj_array[targetBaseObjRecno]->cast_to_Unit() )
&& targetUnit->is_visible()
&& targetUnit->rank_id != RANK_KING
&& targetUnit->nation_recno != 0 && unitPtr->nation_recno != 0
&& !targetUnit->is_nation(unitPtr->nation_recno)
&& unitPtr->area_distance(targetUnit) <= 8
&& targetUnit->betray(unitPtr->nation_recno) )
{
use_now(item);
}
else
{
if( unitPtr->is_own() ) // failed
{
// failed sound effect
se_ctrl.immediate_sound("TURN_OFF");
}
}
}
break;
case ITEM_TOWN_CHANGE_NATION:
{
// change town to our nation
Town *targetTown;
if( !base_obj_array.is_deleted(targetBaseObjRecno)
&& (targetTown = base_obj_array[targetBaseObjRecno]->cast_to_Town() )
&& !targetTown->under_construction
&& unitPtr->nation_recno != 0
&& targetTown->nation_recno != unitPtr->nation_recno
&& unitPtr->area_distance(targetTown) <= 8
&& (targetTown->surrender(unitPtr->nation_recno), targetTown->nation_recno == unitPtr->nation_recno) )
{
use_now(item);
}
else
{
if( unitPtr->is_own() )
{
// failed sound effect
se_ctrl.immediate_sound("TURN_OFF");
}
}
}
break;
case ITEM_TOWN_FREE:
{
// change town to independent nation
Town *targetTown;
if( !base_obj_array.is_deleted(targetBaseObjRecno)
&& (targetTown = base_obj_array[targetBaseObjRecno]->cast_to_Town() )
&& !targetTown->under_construction
&& targetTown->nation_recno != 0
&& unitPtr->area_distance(targetTown) <= 8
&& (targetTown->set_nation(0), targetTown->nation_recno == 0) )
{
use_now(item);
}
else
{
if( unitPtr->is_own() )
{
// failed sound effect
se_ctrl.immediate_sound("TURN_OFF");
}
}
}
break;
case ITEM_TELEPORT:
{
// targetBaseObjRecno is xLoc,
// para2 is yLoc
if( unitPtr->teleport( targetBaseObjRecno, para2 ) )
{
use_now(item);
}
else
{
if( unitPtr->is_own() )
{
// failed sound effect
se_ctrl.immediate_sound("TURN_OFF");
}
}
}
break;
default:
err_here();
}
}
}