当前位置: 首页>>代码示例>>C++>>正文


C++ AWeapon::GetClass方法代码示例

本文整理汇总了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);
		}
	}
}
开发者ID:rcktscnc,项目名称:unreal-project,代码行数:25,代码来源:MainCharacter.cpp

示例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;
	}
}
开发者ID:Jayman2000,项目名称:zdoom-pull,代码行数:26,代码来源:a_weapons.cpp

示例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;
	}
}
开发者ID:WChrisK,项目名称:Zandronum,代码行数:90,代码来源:chat.cpp

示例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;
	}
//.........这里部分代码省略.........
开发者ID:doomtech,项目名称:zdoom-old,代码行数:101,代码来源:ct_chat.cpp


注:本文中的AWeapon::GetClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。