本文整理汇总了C++中AWeapon::GetClass方法的典型用法代码示例。如果您正苦于以下问题:C++ AWeapon::GetClass方法的具体用法?C++ AWeapon::GetClass怎么用?C++ AWeapon::GetClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AWeapon
的用法示例。
在下文中一共展示了AWeapon::GetClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCollision
void AMainCharacter::OnCollision(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
AWeapon* CollidedWeapon = Cast<AWeapon>(OtherActor);
if (CollidedWeapon)
{
if (CollidedWeapon->Config.Name == TEXT("Glock") && Inventory[0] == NULL)
{
Inventory[0] = CollidedWeapon->GetClass();
CollidedWeapon->Destroy();
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, "Weapon picked up: " + CollidedWeapon->Config.Name);
}
if (CollidedWeapon->Config.Name == TEXT("M4A1") && Inventory[1] == NULL)
{
Inventory[1] = CollidedWeapon->GetClass();
CollidedWeapon->Destroy();
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, "Weapon picked up: " + CollidedWeapon->Config.Name);
}
if (CollidedWeapon->Config.Name == TEXT("Shotgun") && Inventory[2] == NULL)
{
Inventory[2] = CollidedWeapon->GetClass();
CollidedWeapon->Destroy();
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, "Weapon picked up: " + CollidedWeapon->Config.Name);
}
}
}
示例2: FindMostRecentWeapon
static bool FindMostRecentWeapon(player_t *player, int *slot, int *index)
{
if (player->PendingWeapon != WP_NOCHANGE)
{
return player->weapons.LocateWeapon(player->PendingWeapon->GetClass(), slot, index);
}
else if (player->ReadyWeapon != NULL)
{
AWeapon *weap = player->ReadyWeapon;
if (!player->weapons.LocateWeapon(weap->GetClass(), slot, index))
{
// If the current weapon wasn't found and is powered up,
// look for its non-powered up version.
if (weap->WeaponFlags & WIF_POWERED_UP && weap->SisterWeaponType != NULL)
{
return player->weapons.LocateWeapon(weap->SisterWeaponType, slot, index);
}
return false;
}
return true;
}
else
{
return false;
}
}
示例3: chat_DoSubstitution
//*****************************************************************************
//
// [CW]
void chat_DoSubstitution( FString &Input )
{
player_t *pPlayer = &players[consoleplayer];
AWeapon *pReadyWeapon = pPlayer->ReadyWeapon;
if ( chat_substitution )
{
FString Output;
const char *pszString = Input.GetChars( );
for ( ; *pszString != 0; pszString++ )
{
if ( !strncmp( pszString, "$ammocount", 10 ))
{
if ( pReadyWeapon && pReadyWeapon->Ammo1 )
{
Output.AppendFormat( "%d", pReadyWeapon->Ammo1->Amount );
if ( pReadyWeapon->Ammo2 )
Output.AppendFormat( "/%d", pReadyWeapon->Ammo2->Amount );
}
else
{
Output.AppendFormat( "no ammo" );
}
pszString += 9;
}
else if ( !strncmp( pszString, "$ammo", 5 ))
{
if ( pReadyWeapon && pReadyWeapon->Ammo1 )
{
Output.AppendFormat( "%s", pReadyWeapon->Ammo1->GetClass( )->TypeName.GetChars( ) );
if ( pReadyWeapon->Ammo2 )
{
Output.AppendFormat( "/%s", pReadyWeapon->Ammo2->GetClass( )->TypeName.GetChars( ));
}
}
else
{
Output.AppendFormat( "no ammo" );
}
pszString += 4;
}
else if ( !strncmp( pszString, "$armor", 6 ))
{
AInventory *pArmor = pPlayer->mo->FindInventory<ABasicArmor>( );
int iArmorCount = 0;
if ( pArmor )
iArmorCount = pArmor->Amount;
Output.AppendFormat( "%d", iArmorCount );
pszString += 5;
}
else if ( !strncmp( pszString, "$health", 7 ))
{
Output.AppendFormat ("%d", pPlayer->health);
pszString += 6;
}
else if ( !strncmp( pszString, "$weapon", 7 ))
{
if ( pReadyWeapon )
Output.AppendFormat( "%s", pReadyWeapon->GetClass( )->TypeName.GetChars( ) );
else
Output.AppendFormat( "no weapon" );
pszString += 6;
}
else if ( !strncmp( pszString, "$location", 9 ))
{
Output += SECTINFO_GetPlayerLocation( consoleplayer );
pszString += 8;
}
else
{
Output.AppendCStrPart( pszString, 1 );
}
}
Input = Output;
}
}
示例4: DoSubstitution
static bool DoSubstitution (char *out, const char *in)
{
player_t *player = &players[consoleplayer];
AWeapon *weapon = player->ReadyWeapon;
const char *a, *b;
a = in;
while ((b = strchr (a, '$')))
{
strncpy (out, a, b - a);
out += b - a;
a = ++b;
while (*b && isalpha (*b))
{
++b;
}
ptrdiff_t len = b - a;
if (len == 6)
{
if (strnicmp (a, "health", 6) == 0)
{
out += sprintf (out, "%d", player->health);
}
else if (strnicmp (a, "weapon", 6) == 0)
{
if (weapon == NULL)
{
out += sprintf (out, "no weapon");
}
else
{
out += sprintf (out, "%s", weapon->GetClass()->Name+1);
}
}
}
else if (len == 5)
{
if (strnicmp (a, "armor", 5) == 0)
{
AInventory *armor = player->mo->FindInventory<ABasicArmor>();
int armorpoints = armor != NULL ? armor->Amount : 0;
out += sprintf (out, "%d", armorpoints);
}
}
else if (len == 9)
{
if (strnicmp (a, "ammocount", 9) == 0)
{
if (weapon == NULL)
{
out += sprintf (out, "0");
}
else
{
out += sprintf (out, "%d", weapon->Ammo1 != NULL ? weapon->Ammo1->Amount : 0);
if (weapon->Ammo2 != NULL)
{
out += sprintf (out, "/%d", weapon->Ammo2->Amount);
}
}
}
}
else if (len == 4)
{
if (strnicmp (a, "ammo", 4) == 0)
{
if (weapon == NULL || weapon->Ammo1 == NULL)
{
out += sprintf (out, "no ammo");
}
else
{
out += sprintf (out, "%s", weapon->Ammo1->GetClass()->Name+1);
if (weapon->Ammo2 != NULL)
{
out += sprintf (out, "/%s", weapon->Ammo2->GetClass()->Name+1);
}
}
}
}
else if (len == 0)
{
*out++ = '$';
*out = 0;
if (*b == '$')
{
b++;
}
}
else
{
*out++ = '$';
strncpy (out, a, len);
out += len;
}
a = b;
}
//.........这里部分代码省略.........