本文整理汇总了C++中GetUnit函数的典型用法代码示例。如果您正苦于以下问题:C++ GetUnit函数的具体用法?C++ GetUnit怎么用?C++ GetUnit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetUnit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetUnit
PSPower* PSProvince::GetOccupant(PSData* pData)
{
// Returns a pointer to the Power that occupies this province or NULL if it is empty.
if (!pData)
pData = TG.GetData();
PSUnit* pUnit = GetUnit(pData);
if (!pUnit)
return NULL;
return pUnit->GetOwner();
}
示例2: OnCombatStop
void OnCombatStop()
{
RemoveAIUpdateEvent();
// well, we are alive and our opponent ran away or died.
// notify twiggy and despawn
TwiggyFlatheadAI *twiggy = (TwiggyFlatheadAI *)GetLinkedCreature();
if(twiggy)
twiggy->OnBigWillSurvived();
GetUnit()->Despawn(1,0);
}
示例3: GetFloatValue
double nsCSSValue::GetAngleValueInRadians() const
{
double angle = GetFloatValue();
switch (GetUnit()) {
case eCSSUnit_Radian: return angle;
case eCSSUnit_Degree: return angle * M_PI / 180.0;
case eCSSUnit_Grad: return angle * M_PI / 200.0;
default:
NS_ABORT_IF_FALSE(false, "unrecognized angular unit");
return 0.0;
}
}
示例4: GetNextItem
void CUnitPane::OnRClick(wxListEvent& event)
{
wxMenu menu;
long idx = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
CUnit * pUnit = GetUnit(idx);
int x=0,y;
int width, height;
int nItems = GetSelectedItemCount();
wxDisplaySize(&width, &height);
y = event.GetPoint().y;
ClientToScreen(&x, &y);
if (height-y < 150)
y = height-150;
ScreenToClient(&x, &y);
if (nItems>1)
{
// multiple units
menu.Append(menu_Popup_IssueOrders , wxT("Issue orders"));
menu.Append(menu_Popup_UnitFlags , wxT("Set custom flags") );
menu.Append(menu_Popup_AddToTracking , wxT("Add to a tracking group"));
PopupMenu( &menu, event.GetPoint().x, y);
}
else
if (pUnit)
{
// single unit
if (pUnit->IsOurs)
{
menu.Append(menu_Popup_ShareSilv , wxT("Share SILV") );
menu.Append(menu_Popup_Teach , wxT("Teach") );
menu.Append(menu_Popup_Split , wxT("Split") );
menu.Append(menu_Popup_DiscardJunk , wxT("Discard junk items"));
menu.Append(menu_Popup_GiveEverything, wxT("Give everything") );
menu.Append(menu_Popup_DetectSpies , wxT("Detect spies") );
}
menu.Append(menu_Popup_UnitFlags , wxT("Set custom flags") );
menu.Append(menu_Popup_AddToTracking , wxT("Add to a tracking group"));
PopupMenu( &menu, event.GetPoint().x, y);
}
}
示例5: Start
// private stuff
bool Start()
{
if(active) return false;
// all is fine, lets start the affray
active = true;
phase = 0;
GetUnit()->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "The Affray has begun. Choperation. get ready to fight!");
// after 5 seconds, start
RegisterAIUpdateEvent(5000);
return true;
}
示例6: GetUnit
bool CAICheats::GetUnitResourceInfo(int unitId, UnitResourceInfo* unitResInf) const
{
bool fetchOk = false;
const CUnit* unit = GetUnit(unitId);
if (unit) {
unitResInf->energyMake = unit->resourcesMake.energy;
unitResInf->energyUse = unit->resourcesUse.energy;
unitResInf->metalMake = unit->resourcesMake.metal;
unitResInf->metalUse = unit->resourcesUse.metal;
fetchOk = true;
}
return fetchOk;
}
示例7: Allow
bool UnitContainer::Allow( const Unit *unit ) const {
if ( !Allow( unit->Type() ) ) return false;
int i;
for ( i = UnitCount() - 1; i >= 0; --i )
if ( GetUnit(i) == unit ) return true;
if ( unit->IsTransport() ) {
const Transport *t = static_cast<const Transport *>(unit);
if ( Crystals() + t->Crystals() > MaxCrystals() ) return false;
for ( i = t->UnitCount() - 1; i >= 0; --i )
if ( !Allow( t->GetUnit(i) ) ) return false;
}
return uc_slots >= uc_slots_full + unit->Weight();
}
示例8: GetAdjacentEnemyData
Enemies GetAdjacentEnemyData(Unit unit) {
Enemies enemies;
enemies.count = 0;
char color = GetUnitColor(unit);
Grids adjacentGrids = GetAdjacentGrids(*GetGrid(GetLocation(unit)));
for (unsigned int i = 0; i < adjacentGrids.count; i++) {
Grid grid = *adjacentGrids.grids[i];
if (isOccupied(grid) && !isOccupiedByAlly(grid, color)) {
Unit *enemy = GetUnit(grid);
enemies.enemy[enemies.count].unit = enemy;
enemies.enemy[enemies.count].canRetaliate = Retaliates(unit, *enemy);
++enemies.count;
}
}
return enemies;
}
示例9: COMMAND_INFO
void COMMAND_INFO() {
int x, y;
do {
printf("Enter the coordinate of the cell: ");
scanf("%d %d", &x, &y);
} while (!isValidCoordinate(x, y));
Grid *grid = GetGrid(MakePOINT(x, y));
Type type = GetType(*grid);
Player *gridOwner = GetOwner(*grid);
Unit *unit = GetUnit(*grid);
printf("== Cell Info ==\n");
if (type == Normal) {
printf("Normal\n");
} else if (type == Tower) {
printf("Tower\n");
} else if (type == Castle) {
printf("Castle\n");
} else if (type == Village) {
printf("Village\n");
}
printf("Owned by Player %d\n", GetPlayerIndex(*gridOwner));
if (unit) {
Player *unitOwner = GetPlayerFromColor(GetUnitColor(*unit));
char unitClassName[11];
UnitClassName(GetUnitClass(*unit), unitClassName);
printf("== Unit Info ==\n");
printf("%s\n", unitClassName);
printf("Owned by Player %d\n", GetPlayerIndex(*unitOwner));
printf("Health %d/%d | ATK %d\n",
GetHealth(*unit),
GetMaximumHealth(*unit),
GetAttack(*unit)
);
}
printf("\n");
}
示例10: MapAttributesIntoRule
static void
MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsRuleData* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
nsCSSValue* width = aData->ValueForWidth();
if (width->GetUnit() == eCSSUnit_Null) {
// width: int (html4 attribute == nav4 cols)
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (!value || value->Type() != nsAttrValue::eInteger) {
// cols: int (nav4 attribute)
value = aAttributes->GetAttr(nsGkAtoms::cols);
}
if (value && value->Type() == nsAttrValue::eInteger)
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Char);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
nsCSSValue* whiteSpace = aData->ValueForWhiteSpace();
if (whiteSpace->GetUnit() == eCSSUnit_Null) {
// wrap: empty
if (aAttributes->GetAttr(nsGkAtoms::wrap))
whiteSpace->SetIntValue(NS_STYLE_WHITESPACE_PRE_WRAP, eCSSUnit_Enumerated);
// width: int (html4 attribute == nav4 cols)
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (!value || value->Type() != nsAttrValue::eInteger) {
// cols: int (nav4 attribute)
value = aAttributes->GetAttr(nsGkAtoms::cols);
}
if (value && value->Type() == nsAttrValue::eInteger) {
// Force wrap property on since we want to wrap at a width
// boundary not just a newline.
whiteSpace->SetIntValue(NS_STYLE_WHITESPACE_PRE_WRAP, eCSSUnit_Enumerated);
}
}
}
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
}
示例11: WXUNUSED
void CUnitPane::OnPopupMenuDiscardJunk(wxCommandEvent& WXUNUSED(event))
{
long idx = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
CUnit * pUnit = GetUnit(idx);
CEditPane * pOrders;
if (pUnit)
{
pOrders = (CEditPane*)gpApp->m_Panes[AH_PANE_UNIT_COMMANDS];
if (pOrders)
pOrders->SaveModifications();
if (m_pCurLand)
m_pCurLand->guiUnit = pUnit->Id;
gpApp->SetOrdersChanged(gpApp->m_pAtlantis->DiscardJunkItems(pUnit, gpApp->GetConfig(SZ_SECT_UNITPROP_GROUPS, PRP_JUNK_ITEMS))
|| gpApp->GetOrdersChanged());
Update(m_pCurLand);
}
}
示例12: switch
bool CAICheats::GetProperty(int id, int property, void *data) const
{
bool fetchOk = false;
switch (property) {
case AIVAL_UNITDEF: {
const CUnit* unit = GetUnit(id);
if (unit) {
(*(const UnitDef**) data) = unit->unitDef;
fetchOk = true;
}
break;
}
default: {
fetchOk = false;
}
}
return fetchOk;
}
示例13: UnitData
//---------------------------------------------------------------------------
// --- Methods :: Unit --- //
//---------------------------------------------------------------------------
UnitData* UnitDatas::CreateUnit (INT32 nCol, INT32 nRow)
{
if (nCol >= _nCountCols || nRow >= _nCountRows)
{
return NULL;
}
UnitData newData = UnitData(nCol, nRow);
if (!IsExistsUnit(nCol, nRow))
{
_lstUnit.push_back(newData);
return GetUnit(nCol, nRow);
}
else
{
return NULL;
}
}
示例14: OnReachWP
void OnReachWP(uint32 iWaypointId, bool bForwards)
{
if( iWaypointId == 1 )
{
switch( RandomUInt(2) )
{
case 0: Emote( "Life from the lifelessness... death for you.", Text_Yell, 13961); break;
case 1: Emote( "Nothing is wasted in the process. You will see....", Text_Yell, 13962); break;
};
MoonScriptCreatureAI* pAnvil = GetNearestCreature( CN_VOLKHANS_ANVIL );
if( pAnvil )
_unit->CastSpell( pAnvil->GetUnit(), SPELL_TEMPER, true );
else
_unit->CastSpell( GetUnit(), SPELL_TEMPER, true );
SetCanEnterCombat( true );
_unit->GetAIInterface()->AttackReaction( GetNearestPlayer() , 1 ); // hackfix
};
};
示例15: sscanf
//---------------------------------------------------------------------------
void __fastcall TFMain_11011981::lbUnitsDblClick(TObject *Sender)
{
DWORD adr;
String item = lbUnits->Items->Strings[lbUnits->ItemIndex];
sscanf(item.c_str() + 1, "%lX", &adr);
PUnitRec recU = GetUnit(adr);
if (!CurUnitAdr || adr != CurUnitAdr)
{
CurUnitAdr = adr;
ShowUnitItems(recU, 0, -1);
}
else
{
ShowUnitItems(recU, lbUnitItems->TopIndex, lbUnitItems->ItemIndex);
}
CurUnitAdr = adr;
}