本文整理汇总了C++中Projectile::SetOwner方法的典型用法代码示例。如果您正苦于以下问题:C++ Projectile::SetOwner方法的具体用法?C++ Projectile::SetOwner怎么用?C++ Projectile::SetOwner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projectile
的用法示例。
在下文中一共展示了Projectile::SetOwner方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void Projectile::Update()
{
++mTicks;
if( (mPos.x <0) ||
(mPos.x>960)||
(mPos.y<0)||
(mPos.y>540))
{
mbIsDead = true;
}
switch(mpData->GetType())
{
case PT_Vector:
case PT_VectorGrenade:
mPos = mPos + mVector*mpData->GetSpeed();
break;
case PT_Custom:
break;
}
if(PT_VectorGrenade == mpData->GetType())
{
if(mTicks>mpData->GetFuse())
{
mbIsDead=true;
for(int it = 0; it<8;++it)
{
Projectile *pProjectile = ModContentManager::Instance().SpawnProjectile(mpData->GetShrapnelName());
Math::Vector2f refPosition = mPos;
int vec = 0+45*it;
refPosition += Math::Vector2f::GetVectorFromDeg(vec)*mpData->GetRadius();
pProjectile->SetPosition(refPosition);
pProjectile->SetVector(vec);
pProjectile->SetOwner(GetOwner());
if(PO_Enemy==GetOwner())
{
Game::Instance().QueueProjectile(pProjectile);
}
else if(PO_Player==GetOwner())
{
Game::Instance().QueueProjectile(pProjectile);
}
}
}
}
}
示例2: Update
void Player::Update()
{
mPosition += InputManager::Instance().GetDirection()*mSpeed;
if(mPosition.x<0){mPosition.x = 0;}
if(mPosition.y<0){mPosition.y = 0;}
if(mPosition.x>960){mPosition.x = 960;}
if(mPosition.y>540){mPosition.y = 540;}
// shoot
++ticks;
if(0==(ticks%rateOfFire))
{
Projectile *pProjectile = ModContentManager::Instance().SpawnProjectile("player_bullet");
Math::Vector2f refPosition = mPosition;
refPosition.x += 32;
pProjectile->SetPosition(refPosition);
pProjectile->SetVector(Math::Vector2f(1.f,0.f));
pProjectile->SetOwner(PO_Player);
Game::Instance().AddPlayerProjectile(pProjectile);
}
}
示例3: Shoot
void Ship::Shoot(const Vector2D &direction,
const Resource_Projectile_t &projectile, Vector2D offset)
{
Projectile *p = (Projectile*)GetGameContext()->CreateEntityNoSpawn("projectile");
Q_ASSERT(p != nullptr);
float volume = IsPlayer() ? 0.5f : 0.3f;
offset.Rotate(GetAngle());
p->SetOwner(this);
p->Teleport(GetOrigin() + offset);
p->SetAngle(direction.Angle());
p->Init(projectile, IsPlayer());
p->Launch(direction, volume);
if (projectile.fire_rate > 0.0f)
shootDelay = GetGameContext()->GetGameTime() + 1.0f / projectile.fire_rate;
GetGameContext()->SpawnEntity(p);
}
示例4: ReleaseAttack
void Player::ReleaseAttack()
{
if (IsDead())
{
return;
}
if (IsBow())
{
if (m_bIsChargingAttack == true)
{
UnloadWeapon(false);
Projectile* pProjectile = m_pProjectileManager->CreateProjectile(m_chargeSpawnPosition, m_chargeSpawnVelocity, 0.0f, "media/gamedata/items/Arrow/Arrow.item", 0.08f);
pProjectile->SetProjectileType(true, false, false);
pProjectile->SetOwner(this, NULL, NULL);
m_bIsChargingAttack = false;
m_chargeAmount = 0.0f;
m_bowAttackDelay = 0.125f;
if (m_bIsIdle)
{
m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_FullBody, false, AnimationSections_FullBody, "BindPose", 0.2f);
}
else
{
m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Head_Body, false, AnimationSections_Head_Body, "BindPose", 0.2f);
m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Left_Arm_Hand, false, AnimationSections_Left_Arm_Hand, "BindPose", 0.2f);
m_pVoxelCharacter->BlendIntoAnimation(AnimationSections_Right_Arm_Hand, false, AnimationSections_Right_Arm_Hand, "BindPose", 0.2f);
}
VoxGame::GetInstance()->PlaySoundEffect(eSoundEffect_ArrowRelease);
}
}
}
示例5: AttackAnimationTimerFinished
void Player::AttackAnimationTimerFinished()
{
if (IsBow())
{
}
else if (IsBoomerang())
{
vec3 boomerangSpawnPosition = GetCenter() + (m_forward*0.75f) + (GetRightVector()*-0.4f) + (GetUpVector()*0.5f);
float cameraModification = (m_cameraForward.y*17.5f);
if (m_cameraForward.y < 0.0f)
{
cameraModification = (m_cameraForward.y*5.0f);
}
vec3 boomerangTarget = boomerangSpawnPosition + m_forward*15.0f + (vec3(0.0f, 1.0f, 0.0f) * cameraModification);
if (m_pTargetEnemy != NULL)
{
boomerangTarget = m_pTargetEnemy->GetProjectileHitboxCenter();
if (m_pTargetEnemy->IsMoving())
{
boomerangTarget += m_pTargetEnemy->GetForwardVector() * (m_pTargetEnemy->GetMovementSpeed() / 3.0f);
}
}
float curveTime = length(boomerangTarget - boomerangSpawnPosition) / 15.0f;
if (curveTime <= 0.4f)
curveTime = 0.4f;
Projectile* pProjectile = m_pProjectileManager->CreateProjectile(boomerangSpawnPosition, vec3(0.0f, 0.0f, 0.0f), 0.0f, "media/gamedata/weapons/Boomerang/BoomerangThrown.weapon", 0.05f);
pProjectile->SetProjectileType(true, false, false);
pProjectile->SetOwner(this, NULL, NULL);
pProjectile->SetGravityMultiplier(0.0f);
pProjectile->SetReturnToPlayer(true);
pProjectile->SetProjectileCurveParams(m_forward, boomerangTarget, curveTime);
pProjectile->SetWorldCollisionEnabled(true);
m_pVoxelCharacter->SetRenderRightWeapon(false);
}
else if (IsStaff())
{
float powerAmount = 25.0f;
float cameraMultiplier = 25.0f;
vec3 spellSpawnPosition = GetCenter() + (m_forward*1.25f) + (GetUpVector()*0.25f);
if (VoxGame::GetInstance()->GetCameraMode() == CameraMode_FirstPerson)
{
cameraMultiplier = 30.0f;
spellSpawnPosition.y += 0.75f;
}
vec3 spellSpawnVelocity = m_forward * powerAmount + vec3(0.0f, 1.0f, 0.0f) * (m_cameraForward.y*cameraMultiplier);
if (m_pTargetEnemy != NULL)
{
vec3 toTarget = m_pTargetEnemy->GetProjectileHitboxCenter() - GetCenter();
spellSpawnVelocity = (normalize(toTarget) * powerAmount);
}
Projectile* pProjectile = m_pProjectileManager->CreateProjectile(spellSpawnPosition, spellSpawnVelocity, 0.0f, "media/gamedata/items/Fireball/Fireball.item", 0.05f);
pProjectile->SetProjectileType(true, false, false);
pProjectile->SetOwner(this, NULL, NULL);
pProjectile->SetGravityMultiplier(0.0f);
}
else if (IsWand())
{
}
else if (IsBomb())
{
vec3 bombSpawnPosition = GetCenter() + (m_forward*0.75f) + (GetUpVector()*0.5f);
float liftAmount = 8.0f;
float powerAmount = 30.0f;
float cameraMultiplier = 25.0f;
if (VoxGame::GetInstance()->GetCameraMode() == CameraMode_FirstPerson)
{
cameraMultiplier = 30.0f;
}
vec3 bombSpawnVelocity;
if (m_pTargetEnemy)
{
// Enemy target
vec3 toTarget = m_pTargetEnemy->GetCenter() - GetCenter();
float toTargetDistance = length(toTarget);
liftAmount += toTargetDistance * 0.04f;
bombSpawnVelocity = (normalize(toTarget) * powerAmount) + vec3(0.0f, liftAmount, 0.0f);
}
else
{
bombSpawnVelocity = (m_forward * powerAmount) + (GetUpVector() * liftAmount) + vec3(0.0f, 1.0f, 0.0f) * (m_cameraForward.y*cameraMultiplier);
}
Projectile* pProjectile = m_pProjectileManager->CreateProjectile(bombSpawnPosition, bombSpawnVelocity, 0.0f, "media/gamedata/items/Bomb/BombThrown.item", 0.05f);
pProjectile->SetProjectileType(true, false, false);
pProjectile->SetOwner(this, NULL, NULL);
pProjectile->SetGravityMultiplier(3.5f);
float explodeRadius = 3.5f - (GetRandomNumber(-150, 0, 2) * 0.01f);
//.........这里部分代码省略.........
示例6: AttackAnimationTimerFinished_Alternative
void Player::AttackAnimationTimerFinished_Alternative()
{
if (IsBow())
{
}
else if (IsBoomerang())
{
}
else if (IsStaff())
{
}
else if (IsWand())
{
}
else if (IsBomb())
{
}
else if (IsConsumable())
{
}
else if (IsDagger())
{
}
else if (IsHammer())
{
}
else if (IsMace())
{
}
else if (IsSickle())
{
}
else if (IsPickaxe())
{
}
else if (IsAxe())
{
}
else if (Is2HandedSword())
{
}
else if (IsSword())
{
}
else if (IsBlockPlacing())
{
}
else if (IsItemPlacing())
{
}
else if (IsSceneryPlacing())
{
}
else if (IsSpellHands())
{
float powerAmount = 25.0f;
float cameraMultiplier = 25.0f;
vec3 spellSpawnPosition = GetCenter() + (m_forward*0.5f) + (GetUpVector()*0.0f);
// For left hand
spellSpawnPosition += (GetRightVector()*0.4f);
if (VoxGame::GetInstance()->GetCameraMode() == CameraMode_FirstPerson)
{
cameraMultiplier = 30.0f;
spellSpawnPosition.y += 0.75f;
}
vec3 spellSpawnVelocity = m_forward * powerAmount + vec3(0.0f, 1.0f, 0.0f) * (m_cameraForward.y*cameraMultiplier);
if (m_pTargetEnemy != NULL)
{
vec3 toTarget = m_pTargetEnemy->GetProjectileHitboxCenter() - GetCenter();
spellSpawnVelocity = (normalize(toTarget) * powerAmount);
}
Projectile* pProjectile = m_pProjectileManager->CreateProjectile(spellSpawnPosition, spellSpawnVelocity, 0.0f, "media/gamedata/items/Fireball/FireballBlue.item", 0.05f);
pProjectile->SetProjectileType(true, false, false);
pProjectile->SetOwner(this, NULL, NULL);
pProjectile->SetGravityMultiplier(0.0f);
}
else if (IsShield())
{
}
else if (IsTorch())
{
}
}
示例7: Update
//.........这里部分代码省略.........
{
p->SetTarget(sTarget);
}
}
}
}
}
break;
case ID_UPDATE_PROJECTILE:
{
int id, damage, owner, target;
Projectile::PROJECTILE_TYPE type;
float x, y, vel_x, vel_y, speed;
bool active;
bs.Read(id);
Projectile* p = FindProjectileByID(id);
if (p)
{
bs.Read(active);
bs.Read(type);
bs.Read(x);
bs.Read(y);
bs.Read(vel_x);
bs.Read(vel_y);
bs.Read(speed);
bs.Read(damage);
bs.Read(owner);
bs.Read(target);
Ship* sOwner = FindShipByID(owner);
if (sOwner)
{
p->SetOwner(sOwner);
p->SetType(type);
p->SetX(x);
p->SetY(y);
p->SetActive(active);
p->SetVelocityX(vel_x);
p->SetVelocityY(vel_y);
p->SetSpeed(speed);
p->SetDamage(damage);
if (target != -1)
{
Enemy* sTarget = FindEnemyByID(target);
if (sTarget)
{
p->SetTarget(sTarget);
}
}
}
}
}
break;
case ID_DESTROY_PROJECTILE:
{
int id;
bs.Read(id);
Projectile* p = FindProjectileByID(id);
if (p && p->GetActive())
{
// Reset projectile
//DestroyProjectile(p);
p->Reset();
}
}