本文整理汇总了C++中Town::surrender方法的典型用法代码示例。如果您正苦于以下问题:C++ Town::surrender方法的具体用法?C++ Town::surrender怎么用?C++ Town::surrender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Town
的用法示例。
在下文中一共展示了Town::surrender方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
}