本文整理汇总了C++中CCharacter::GiveBlock方法的典型用法代码示例。如果您正苦于以下问题:C++ CCharacter::GiveBlock方法的具体用法?C++ CCharacter::GiveBlock怎么用?C++ CCharacter::GiveBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCharacter
的用法示例。
在下文中一共展示了CCharacter::GiveBlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Tick
void CPickup::Tick()
{
// MineTee: wait for destroy
if (m_DestroyTick > 0)
{
if (Server()->Tick() > m_DestroyTick)
{
GameWorld()->DestroyEntity(this);
return;
}
}
// wait for respawn
if(m_SpawnTick > 0)
{
if(Server()->Tick() > m_SpawnTick)
{
// respawn
m_SpawnTick = -1;
if(m_Type == POWERUP_WEAPON)
GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SPAWN);
}
else
return;
}
// MineTee
CCharacter *pChr = 0x0;
if (m_Type == POWERUP_DROPITEM)
{
CCharacter *pChrAttraction = GameServer()->m_World.ClosestCharacter(m_Pos, 60.0f, 0);
if (pChrAttraction && Server()->Tick()-m_TimerOwnerTake > Server()->TickSpeed()*2.5f)
{
float d = distance(m_Pos, pChrAttraction->m_Pos);
float v = abs((100.0f-d)*5.5f/100.0f);
m_Vel += normalize(pChrAttraction->m_Pos - m_Pos) * v;
}
GameServer()->Collision()->MoveBox(&m_Pos, &m_Vel, vec2(32.0f, 32.0f), 0.5f);
m_Vel.y += GameServer()->m_World.m_Core.m_Tuning.m_Gravity;
m_Vel.x += (m_Vel.x < 0.0f)?0.05f:-0.05f;
if (Server()->Tick()-m_TimerOwnerTake > Server()->TickSpeed()*2.5f)
pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
else if (GameServer()->m_apPlayers[m_Owner] && GameServer()->m_apPlayers[m_Owner]->GetCharacter() && GameServer()->m_apPlayers[m_Owner]->GetCharacter()->IsAlive())
pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, GameServer()->m_apPlayers[m_Owner]->GetCharacter());
}
else if (m_Type == POWERUP_BLOCK)
{
CCharacter *pChrAttraction = GameServer()->m_World.ClosestCharacter(m_Pos, 96.0f, 0);
if (pChrAttraction)
{
float d = distance(m_Pos, pChrAttraction->m_Pos);
float v = abs((100.0f-d)*5.5f/100.0f);
m_Pos += normalize(pChrAttraction->m_Pos - m_Pos) * v;
}
pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
}
else
pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
//
// Check if a player intersected us
if(pChr && pChr->IsAlive())
{
// player picked us up, is someone was hooking us, let them go
int RespawnTime = -1;
switch (m_Type)
{
// MineTee
case POWERUP_DROPITEM:
if (m_Subtype >= NUM_WEAPONS-CBlockManager::MAX_BLOCKS)
{
if (pChr->GiveBlock(m_Subtype, m_Amount))
{
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_BLOCK);
GameWorld()->DestroyEntity(this);
return;
}
}
else
{
if(pChr->GiveWeapon(m_Subtype, m_Amount))
{
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
if(m_Subtype == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
else if(m_Subtype == WEAPON_SHOTGUN)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
else if(m_Subtype == WEAPON_RIFLE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
if(pChr->GetPlayer())
GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
}
}
break;
case POWERUP_BLOCK:
//.........这里部分代码省略.........