本文整理汇总了C++中CArrayGet函数的典型用法代码示例。如果您正苦于以下问题:C++ CArrayGet函数的具体用法?C++ CArrayGet怎么用?C++ CArrayGet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CArrayGet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CanCompleteMission
int CanCompleteMission(struct MissionOptions *options)
{
int i;
// Death is the only escape from dogfights and quick play
if (gCampaign.Entry.Mode == CAMPAIGN_MODE_DOGFIGHT)
{
return GetNumPlayersAlive() <= 1;
}
else if (gCampaign.Entry.Mode == CAMPAIGN_MODE_QUICK_PLAY)
{
return GetNumPlayersAlive() == 0;
}
// Check all objective counts are enough
for (i = 0; i < (int)options->Objectives.size; i++)
{
struct Objective *o = CArrayGet(&options->Objectives, i);
MissionObjective *mobj =
CArrayGet(&options->missionData->Objectives, i);
if (o->done < mobj->Required)
{
return 0;
}
}
return 1;
}
示例2: HUDNumPopupsDrawObjective
void HUDNumPopupsDrawObjective(
const HUDNumPopups *popups, const int idx, const Vec2i pos)
{
const Objective *o = CArrayGet(&gMission.missionData->Objectives, idx);
const HUDNumPopup *p = CArrayGet(&popups->objective, idx);
DrawNumUpdate(p, "%d", o->done, pos, 0);
}
示例3: GetHitType
static HitType GetHitType(
const TTileItem *ti, const TMobileObject *bullet, int *targetUID)
{
*targetUID = -1;
HitType ht = HIT_NONE;
switch (ti->kind)
{
case KIND_CHARACTER:
ht = HIT_FLESH;
*targetUID = ((const TActor *)CArrayGet(&gActors, ti->id))->uid;
break;
case KIND_OBJECT:
ht = HIT_OBJECT;
*targetUID = ((const TObject *)CArrayGet(&gObjs, ti->id))->uid;
break;
default:
CASSERT(false, "cannot damage target kind");
break;
}
if (bullet->tileItem.SoundLock > 0 ||
!HasHitSound(
bullet->bulletClass->Power, bullet->flags, bullet->PlayerUID,
ti->kind, *targetUID, bullet->bulletClass->Special, true))
{
ht = HIT_NONE;
}
return ht;
}
示例4: DrawObjectiveHighlight
static void DrawObjectiveHighlight(
TTileItem *ti, Tile *tile, DrawBuffer *b, Vec2i offset)
{
color_t color;
if (ti->flags & TILEITEM_OBJECTIVE)
{
// Objective
const int objective = ObjectiveFromTileItem(ti->flags);
const Objective *o =
CArrayGet(&gMission.missionData->Objectives, objective);
if (o->Flags & OBJECTIVE_HIDDEN)
{
return;
}
if (!(o->Flags & OBJECTIVE_POSKNOWN) &&
(tile->flags & MAPTILE_OUT_OF_SIGHT))
{
return;
}
color = o->color;
}
else if (ti->kind == KIND_PICKUP)
{
// Gun pickup
const Pickup *p = CArrayGet(&gPickups, ti->id);
if (!PickupIsManual(p))
{
return;
}
color = colorDarker;
}
else
{
return;
}
const Vec2i pos = Vec2iNew(
ti->x - b->xTop + offset.x, ti->y - b->yTop + offset.y);
const int pulsePeriod = ConfigGetInt(&gConfig, "Game.FPS");
int alphaUnscaled =
(gMission.time % pulsePeriod) * 255 / (pulsePeriod / 2);
if (alphaUnscaled > 255)
{
alphaUnscaled = 255 * 2 - alphaUnscaled;
}
color.a = (Uint8)alphaUnscaled;
if (ti->getPicFunc != NULL)
{
Vec2i picOffset;
const Pic *pic = ti->getPicFunc(ti->id, &picOffset);
BlitPicHighlight(
&gGraphicsDevice, pic, Vec2iAdd(pos, picOffset), color);
}
else if (ti->kind == KIND_CHARACTER)
{
TActor *a = CArrayGet(&gActors, ti->id);
ActorPics pics = GetCharacterPicsFromActor(a);
DrawActorHighlight(&pics, pos, color);
}
}
示例5: DrawObjectiveInfo
static void DrawObjectiveInfo(
const struct MissionOptions *mo, const int idx, const Vec2i pos)
{
const MissionObjective *mobj =
CArrayGet(&mo->missionData->Objectives, idx);
const ObjectiveDef *o = CArrayGet(&mo->Objectives, idx);
const CharacterStore *store = &gCampaign.Setting.characters;
switch (mobj->Type)
{
case OBJECTIVE_KILL:
{
const Character *cd = CArrayGet(
&store->OtherChars, CharacterStoreGetSpecialId(store, 0));
const int i = cd->looks.face;
TOffsetPic pic;
pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
pic.dy = cHeadOffset[i][DIRECTION_DOWN].dy;
DrawTTPic(
pos.x + pic.dx, pos.y + pic.dy,
PicManagerGetOldPic(&gPicManager, pic.picIndex), &cd->table);
}
break;
case OBJECTIVE_RESCUE:
{
const Character *cd = CArrayGet(
&store->OtherChars, CharacterStoreGetPrisonerId(store, 0));
const int i = cd->looks.face;
TOffsetPic pic;
pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
pic.dy = cHeadOffset[i][DIRECTION_DOWN].dy;
DrawTTPic(
pos.x + pic.dx, pos.y + pic.dy,
PicManagerGetOldPic(&gPicManager, pic.picIndex), &cd->table);
}
break;
case OBJECTIVE_COLLECT:
{
const Pic *p = o->pickupClass->Pic;
Blit(&gGraphicsDevice, p, Vec2iAdd(pos, p->offset));
}
break;
case OBJECTIVE_DESTROY:
{
Vec2i picOffset;
const Pic *p =
MapObjectGetPic(IntMapObject(mobj->Index), &picOffset, false);
Blit(&gGraphicsDevice, p, Vec2iAdd(pos, picOffset));
}
break;
case OBJECTIVE_INVESTIGATE:
// Don't draw
return;
default:
CASSERT(false, "Unknown objective type");
return;
}
}
示例6: UIObjectDraw
void UIObjectDraw(
UIObject *o, GraphicsDevice *g, Vec2i pos, Vec2i mouse, CArray *drawObjs)
{
// Draw this UIObject and its children in BFS order
// Maintain a queue of UIObjects to draw
if (drawObjs->elemSize == 0)
{
CArrayInit(drawObjs, sizeof(UIObjectDrawContext));
UIObjectDrawContext c;
c.obj = o;
c.pos = pos;
CArrayPushBack(drawObjs, &c);
for (int i = 0; i < (int)drawObjs->size; i++)
{
UIObjectDrawContext *cPtr = CArrayGet(drawObjs, i);
UIObjectDrawAndAddChildren(
cPtr->obj, g, cPtr->pos, mouse, drawObjs);
}
}
else
{
for (int i = 0; i < (int)drawObjs->size; i++)
{
UIObjectDrawContext *cPtr = CArrayGet(drawObjs, i);
UIObjectDrawAndAddChildren(
cPtr->obj, g, cPtr->pos, mouse, NULL);
}
}
}
示例7: switch
TTileItem *ThingIdGetTileItem(ThingId *tid)
{
TTileItem *ti = NULL;
switch (tid->Kind)
{
case KIND_CHARACTER:
ti = &((TActor *)CArrayGet(&gActors, tid->Id))->tileItem;
break;
case KIND_PARTICLE:
ti = &((Particle *)CArrayGet(&gParticles, tid->Id))->tileItem;
break;
case KIND_MOBILEOBJECT:
ti = &((TMobileObject *)CArrayGet(
&gMobObjs, tid->Id))->tileItem;
break;
case KIND_OBJECT:
ti = &((TObject *)CArrayGet(&gObjs, tid->Id))->tileItem;
break;
case KIND_PICKUP:
ti = &((Pickup *)CArrayGet(&gPickups, tid->Id))->tileItem;
break;
default:
CASSERT(false, "unknown tile item to get");
break;
}
return ti;
}
示例8: SetupBadguysForMission
static void SetupBadguysForMission(Mission *mission)
{
int i;
CharacterStore *s = &gCampaign.Setting.characters;
CharacterStoreResetOthers(s);
if (s->OtherChars.size == 0)
{
return;
}
for (i = 0; i < (int)mission->Objectives.size; i++)
{
MissionObjective *mobj = CArrayGet(&mission->Objectives, i);
if (mobj->Type == OBJECTIVE_RESCUE)
{
CharacterStoreAddPrisoner(s, mobj->Index);
break; // TODO: multiple prisoners
}
}
for (i = 0; i < (int)mission->Enemies.size; i++)
{
CharacterStoreAddBaddie(s, *(int *)CArrayGet(&mission->Enemies, i));
}
for (i = 0; i < (int)mission->SpecialChars.size; i++)
{
CharacterStoreAddSpecial(
s, *(int *)CArrayGet(&mission->SpecialChars, i));
}
}
示例9: PlayerSelection
bool PlayerSelection(void)
{
PlayerSelectionData data;
memset(&data, 0, sizeof data);
data.IsOK = true;
GetDataFilePath(data.prefixes, "data/prefixes.txt");
GetDataFilePath(data.suffixes, "data/suffixes.txt");
GetDataFilePath(data.suffixnames, "data/suffixnames.txt");
NameGenInit(&data.g, data.prefixes, data.suffixes, data.suffixnames);
// Create selection menus for each local player
for (int i = 0, idx = 0; i < (int)gPlayerDatas.size; i++, idx++)
{
PlayerData *p = CArrayGet(&gPlayerDatas, i);
if (!p->IsLocal)
{
idx--;
continue;
}
PlayerSelectMenusCreate(
&data.menus[idx], GetNumPlayers(false, false, true), idx, i,
&gEventHandlers, &gGraphicsDevice, &data.g);
}
if (!gCampaign.IsClient)
{
NetServerOpen(&gNetServer);
}
GameLoopData gData = GameLoopDataNew(
&data, PlayerSelectionUpdate,
&data, PlayerSelectionDraw);
GameLoop(&gData);
if (data.IsOK)
{
for (int i = 0, idx = 0; i < (int)gPlayerDatas.size; i++, idx++)
{
PlayerData *p = CArrayGet(&gPlayerDatas, i);
if (!p->IsLocal)
{
idx--;
continue;
}
// For any player slots not picked, turn them into AIs
if (p->inputDevice == INPUT_DEVICE_UNSET)
{
PlayerSetInputDevice(p, INPUT_DEVICE_AI, 0);
}
}
}
for (int i = 0; i < GetNumPlayers(false, false, true); i++)
{
MenuSystemTerminate(&data.menus[i].ms);
}
NameGenTerminate(&data.g);
return data.IsOK;
}
示例10: DrawObjectiveHighlight
static void DrawObjectiveHighlight(
TTileItem *ti, Tile *tile, DrawBuffer *b, Vec2i offset)
{
if (!(ti->flags & TILEITEM_OBJECTIVE))
{
return;
}
int objective = ObjectiveFromTileItem(ti->flags);
MissionObjective *mo =
CArrayGet(&gMission.missionData->Objectives, objective);
if (mo->Flags & OBJECTIVE_HIDDEN)
{
return;
}
if (!(mo->Flags & OBJECTIVE_POSKNOWN) &&
(tile->flags & MAPTILE_OUT_OF_SIGHT))
{
return;
}
Vec2i pos = Vec2iNew(
ti->x - b->xTop + offset.x, ti->y - b->yTop + offset.y);
struct Objective *o =
CArrayGet(&gMission.Objectives, objective);
color_t color = o->color;
int pulsePeriod = FPS_FRAMELIMIT;
int alphaUnscaled =
(gMission.time % pulsePeriod) * 255 / (pulsePeriod / 2);
if (alphaUnscaled > 255)
{
alphaUnscaled = 255 * 2 - alphaUnscaled;
}
color.a = (Uint8)alphaUnscaled;
if (ti->getPicFunc != NULL)
{
Vec2i picOffset;
const Pic *pic = ti->getPicFunc(ti->id, &picOffset);
BlitPicHighlight(
&gGraphicsDevice, pic, Vec2iAdd(pos, picOffset), color);
}
else if (ti->getActorPicsFunc != NULL)
{
ActorPics pics = ti->getActorPicsFunc(ti->id);
// Do not highlight dead, dying or transparent characters
if (!pics.IsDead && !pics.IsTransparent)
{
for (int i = 0; i < 3; i++)
{
if (PicIsNotNone(&pics.Pics[i]))
{
BlitPicHighlight(
&gGraphicsDevice,
&pics.Pics[i], pos, color);
}
}
}
}
}
示例11: DogfightFinalScoresDraw
static void DogfightFinalScoresDraw(void *data)
{
UNUSED(data);
// This will only draw once
const int w = gGraphicsDevice.cachedConfig.Res.x;
const int h = gGraphicsDevice.cachedConfig.Res.y;
GraphicsBlitBkg(&gGraphicsDevice);
// Work out who's the winner, or if it's a tie
int maxScore = 0;
int playersWithMaxScore = 0;
for (int i = 0; i < (int)gPlayerDatas.size; i++)
{
const PlayerData *p = CArrayGet(&gPlayerDatas, i);
if (p->RoundsWon > maxScore)
{
maxScore = p->RoundsWon;
playersWithMaxScore = 1;
}
else if (p->RoundsWon == maxScore)
{
playersWithMaxScore++;
}
}
const bool isTie = playersWithMaxScore == (int)gPlayerDatas.size;
// Draw players and their names spread evenly around the screen.
// If it's a tie, display the message in the centre,
// otherwise display the winner just below the winning player
#define DRAW_TEXT "It's a draw!"
#define WINNER_TEXT "Winner!"
CASSERT(
gPlayerDatas.size >= 2 && gPlayerDatas.size <= 4,
"Unimplemented number of players for dogfight");
for (int i = 0; i < (int)gPlayerDatas.size; i++)
{
const Vec2i pos = Vec2iNew(
w / 4 + (i & 1) * w / 2,
gPlayerDatas.size == 2 ? h / 2 : h / 4 + (i / 2) * h / 2);
const PlayerData *p = CArrayGet(&gPlayerDatas, i);
DisplayCharacterAndName(pos, &p->Char, p->name);
ShowPlayerScore(pos, p->RoundsWon);
if (!isTie && maxScore == p->RoundsWon)
{
FontStrMask(
WINNER_TEXT,
Vec2iNew(pos.x - FontStrW(WINNER_TEXT) / 2, pos.y + 30),
colorGreen);
}
}
if (isTie)
{
FontStrCenter(DRAW_TEXT);
}
}
示例12: CArrayGet
Ammo *AmmoGetById(AmmoClasses *ammo, const int id)
{
if (id < (int)ammo->Ammo.size)
{
return CArrayGet(&ammo->Ammo, id);
}
else
{
return CArrayGet(&ammo->CustomAmmo, id - (int)ammo->Ammo.size);
}
}
示例13: ActionRun
static void ActionRun(Action *a, CArray *mapTriggers)
{
int i;
switch (a->action)
{
case ACTION_NULL:
return;
case ACTION_SOUND:
SoundPlayAt(&gSoundDevice, a->a.Sound, a->u.pos);
break;
case ACTION_SETTRIGGER:
for (i = 0; i < (int)mapTriggers->size; i++)
{
Trigger *tr = *(Trigger **)CArrayGet(mapTriggers, i);
if (tr->id == a->u.index)
{
tr->isActive = 1;
break;
}
}
break;
case ACTION_CLEARTRIGGER:
for (i = 0; i < (int)mapTriggers->size; i++)
{
Trigger *tr = *(Trigger **)CArrayGet(mapTriggers, i);
if (tr->id == a->u.index)
{
tr->isActive = 0;
break;
}
}
break;
case ACTION_CHANGETILE:
{
Tile *t= MapGetTile(&gMap, a->u.pos);
t->flags = a->a.tileFlags;
t->pic = a->tilePic;
t->picAlt = a->tilePicAlt;
}
break;
case ACTION_ACTIVATEWATCH:
ActivateWatch(a->u.index);
break;
case ACTION_DEACTIVATEWATCH:
DeactivateWatch(a->u.index);
break;
}
}
示例14: CASSERT
MapObject *IndexMapObject(const int i)
{
CASSERT(
i >= 0 &&
i < (int)gMapObjects.Classes.size + (int)gMapObjects.CustomClasses.size,
"Map object index out of bounds");
if (i < (int)gMapObjects.Classes.size)
{
return CArrayGet(&gMapObjects.Classes, i);
}
return CArrayGet(&gMapObjects.CustomClasses, i - gMapObjects.Classes.size);
}
示例15: ScreenMissionSummary
bool ScreenMissionSummary(CampaignOptions *c, struct MissionOptions *m)
{
// Save password
MissionSave ms;
MissionSaveInit(&ms);
ms.Campaign = c->Entry;
// Don't make password for next level if there is none
int passwordIndex = m->index + 1;
if (passwordIndex == c->Entry.NumMissions)
{
passwordIndex--;
}
strcpy(ms.Password, MakePassword(passwordIndex, 0));
ms.MissionsCompleted = m->index + 1;
AutosaveAddMission(&gAutosave, &ms, ms.Campaign.BuiltinIndex);
AutosaveSave(&gAutosave, GetConfigFilePath(AUTOSAVE_FILE));
// Calculate bonus scores
// Bonuses only apply if at least one player has lived
if (AreAnySurvived())
{
int bonus = 0;
// Objective bonuses
for (int i = 0; i < (int)m->missionData->Objectives.size; i++)
{
const struct Objective *o = CArrayGet(&m->Objectives, i);
const MissionObjective *mo = CArrayGet(&m->missionData->Objectives, i);
if (o->done == mo->Count && o->done > mo->Required)
{
// Perfect
bonus += PERFECT_BONUS;
}
}
bonus += GetAccessBonus(m);
bonus += GetTimeBonus(m, NULL);
for (int i = 0; i < (int)gPlayerDatas.size; i++)
{
PlayerData *p = CArrayGet(&gPlayerDatas, i);
ApplyBonuses(p, bonus);
}
}
GameLoopWaitForAnyKeyOrButtonData wData;
GameLoopData gData = GameLoopDataNew(
&wData, GameLoopWaitForAnyKeyOrButtonFunc,
m, MissionSummaryDraw);
GameLoop(&gData);
if (wData.IsOK)
{
SoundPlay(&gSoundDevice, StrSound("mg"));
}
return wData.IsOK;
}