• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Fire函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Fire函数的典型用法代码示例。如果您正苦于以下问题:C++ Fire函数的具体用法?C++ Fire怎么用?C++ Fire使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Fire函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: StudioFrameAdvance

//-----------------------------------------------------------------------------
// Make sure our target is still valid, and if so, fire at it
//-----------------------------------------------------------------------------
void CObjectSentrygun::Attack()
{
	StudioFrameAdvance( );

	if ( !FindTarget() )
	{
		m_iState.Set( SENTRY_STATE_SEARCHING );
		m_hEnemy = NULL;
		return;
	}

	// Track enemy
	Vector vecMid = EyePosition();
	Vector vecMidEnemy = m_hEnemy->WorldSpaceCenter();
	Vector vecDirToEnemy = vecMidEnemy - vecMid;

	QAngle angToTarget;
	VectorAngles( vecDirToEnemy, angToTarget );

	angToTarget.y = UTIL_AngleMod( angToTarget.y );
	if (angToTarget.x < -180)
		angToTarget.x += 360;
	if (angToTarget.x > 180)
		angToTarget.x -= 360;

	// now all numbers should be in [1...360]
	// pin to turret limitations to [-50...50]
	if (angToTarget.x > 50)
		angToTarget.x = 50;
	else if (angToTarget.x < -50)
		angToTarget.x = -50;
	m_vecGoalAngles.y = angToTarget.y;
	m_vecGoalAngles.x = angToTarget.x;

	MoveTurret();

	// Fire on the target if it's within 10 units of being aimed right at it
	if ( m_flNextAttack <= gpGlobals->curtime && (m_vecGoalAngles - m_vecCurAngles).Length() <= 10 )
	{
		Fire();

		if ( m_iUpgradeLevel == 1 )
		{
			// Level 1 sentries fire slower
			m_flNextAttack = gpGlobals->curtime + 0.2;
		}
		else
		{
			m_flNextAttack = gpGlobals->curtime + 0.1;
		}
	}
	else
	{
		// SetSentryAnim( TFTURRET_ANIM_SPIN );
	}
}
开发者ID:MrBoomer568,项目名称:TF2Classic,代码行数:59,代码来源:tf_obj_sentrygun.cpp


示例2: Fire

void CBaseMelee::SecondaryAttack( void )
{
	Fire();

#ifndef CLIENT_DLL
	MESSAGE_BEGIN( MSG_ONE, gmsgHintbox, NULL, m_pPlayer->pev );
        WRITE_SHORT(HINTBOX_MELEE2);
    MESSAGE_END();
#endif
}
开发者ID:BackupTheBerlios,项目名称:battlegrounds-svn,代码行数:10,代码来源:melee.cpp


示例3: AngleVectors

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CFuncTankMortar::ShootGun( void )
{
	Vector forward;
	AngleVectors( GetLocalAngles(), &forward );
	UpdateMatrix();
	forward = m_parentMatrix.ApplyRotation( forward );

	// use cached firing state
	Fire( 1, WorldBarrelPosition(), forward, m_pAttacker ); 
}
开发者ID:AgentAgrimar,项目名称:source-sdk-trilogy,代码行数:13,代码来源:hl1_func_tank.cpp


示例4: UTIL_MakeVectors

//=========================================================
// StartFire- since all of this code has to run and then 
// call Fire(), it was easier at this point to rip it out 
// of weaponidle() and make its own function then to try to
// merge this into Fire(), which has some identical variable names 
//=========================================================
void CGauss::StartFire( void )
{
	float flDamage;
	
	UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
	Vector vecAiming = gpGlobals->v_forward;
	Vector vecSrc = m_pPlayer->GetGunPosition( ); // + gpGlobals->v_up * -8 + gpGlobals->v_right * 8;
	
	if ( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() )
	{
		flDamage = 200;
	}
	else
	{
		flDamage = 200 * (( gpGlobals->time - m_pPlayer->m_flStartCharge) / GetFullChargeTime() );
	}

	if ( m_fPrimaryFire )
	{
		// fixed damage on primary attack
#ifdef CLIENT_DLL
		flDamage = 20;
#else 
		flDamage = gSkillData.plrDmgGauss;
#endif
	}

	if (m_fInAttack != 3)
	{
		//ALERT ( at_console, "Time:%f Damage:%f\n", gpGlobals->time - m_pPlayer->m_flStartCharge, flDamage );

#ifndef CLIENT_DLL
		float flZVel = m_pPlayer->pev->velocity.z;

		if ( !m_fPrimaryFire )
		{
			m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - gpGlobals->v_forward * flDamage * 5;
		}

		if ( !g_pGameRules->IsMultiplayer() )

		{
			// in deathmatch, gauss can pop you up into the air. Not in single play.
			m_pPlayer->pev->velocity.z = flZVel;
		}
#endif
		// player "shoot" animation
		m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
	}

	// time until aftershock 'static discharge' sound
	m_pPlayer->m_flPlayAftershock = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.3, 0.8 );

	Fire( vecSrc, vecAiming, flDamage );
}
开发者ID:Solexid,项目名称:halflife,代码行数:61,代码来源:gauss.cpp


示例5: BP_PreFire

// Pre Fire
void AWeapon::PreFire()
{
	// BP Pre Fire
	BP_PreFire();

	if (!ThePlayer)return;
	
	// If player stopped shooting stop event
	if (!bShooting )
	{
		ThePlayer->GetWorldTimerManager().ClearTimer(PreFireTimeHandle);
		return;
	}

	// Currently Equiping this weapon, delay a bit
	if (ThePlayer->IsAnimState(EAnimState::Equip))
	{
		// try after a small delay
		FTimerHandle MyHandle;
		ThePlayer->GetWorldTimerManager().SetTimer(MyHandle, this, &AWeapon::PreFire, 0.2, false);
		return;
	}

	// Wrong Weapon or Player Anim State
	if (!CanShoot())return;

	// Ammo Check
	if (!MainFire.CanFire())
	{
		//  BP No Ammo
		BP_NoAmmo();

		// if have ammo, start reloading
		if (CanReload())ReloadWeaponStart();
		return;
	}


	// The real fire event
	Fire();

	// Use Ammo
	if (bUseAmmo)UseMainFireAmmo();


	// Set Player Anim State
	ThePlayer->ServerSetAnimID(EAnimState::Fire);

	// Decrease move speed when shooting
	ThePlayer->ResetMoveSpeed();

	///	Stop Fire Anim
	FTimerHandle MyHandle;
	ThePlayer->GetWorldTimerManager().SetTimer(MyHandle, this, &AWeapon::StopFireAnim, 0.1, false);
}
开发者ID:MatrIsCool,项目名称:Rade,代码行数:56,代码来源:Weapon.cpp


示例6: AttackTime

void SlimeKingMiddle::MoodAttack(float dt)
{
	if (timer == kTimerUp)
	{
		timer = AttackTime();
		Animate("Stay", myEnum::kAction::kActionAttack);
		// fire a ball
		auto sp = this->getPosition();
		sp.y -= this->getContentSize().height;
		auto dp1 = Vec2(sp.x - CCRANDOM_MINUS1_1(), sp.y - 1);
		auto dp2 = Vec2(sp.x - CCRANDOM_MINUS1_1(), sp.y - 1);

		Fire(layer, sp, dp1);
		Fire(layer, sp, dp2);
	}
	else if (timer <= 0.0f)
	{
		ChooseMood();
	}
}
开发者ID:ilhaeYe,项目名称:MB,代码行数:20,代码来源:SlimeKingMiddle.cpp


示例7: SetNewFireTime

void cBoss::SpecificLogic(const cMap &map) {
    if (--fireTime <= 0) {
        SetNewFireTime();
        Fire();
    }
    if (--directionTime <= 0) {
        SetNewDirectionTime();
        SetNewDirection();
    }
    Move(map, direction, sceneX, sceneY);
}
开发者ID:afj176,项目名称:zelda,代码行数:11,代码来源:cBoss.cpp


示例8: Fire

void SpreadWeapon::Update(Vector2D location,Vector2D target)
{
	if(firing)
	{
		if(shotTimer.get_ticks() >= fireRate)
		{								
			Fire(location, target);
			shotTimer.start();
		}
	}
}
开发者ID:Chocken,项目名称:shmup,代码行数:11,代码来源:SpreadWeapon.cpp


示例9: Fire

void cgAircraftWeapon::Update( float fDeltaTime )
{
	if (!m_pkConfig)
		return ;

	m_fCD += fDeltaTime;
	if (m_fCD >= m_pkConfig->fFireCD)
	{
		m_fCD -= m_pkConfig->fFireCD;
		Fire();
	}
}
开发者ID:cgcoolgame,项目名称:cg,代码行数:12,代码来源:cgAircraftWeapon.cpp


示例10: vec3

void clSpaceShip::Update( float dt )
{
	iActor::Update( dt );

//	printf("vv = %f\n", g_ScreenJoystick->GetAxisValue(0));

	if ( g_Game->IsKeyPressed( SDLK_LEFT ) )
	{
		m_Angle += dt;
	}

	if ( g_Game->IsKeyPressed( SDLK_RIGHT ) )
	{
		m_Angle -= dt;
	}

	bool Accel = g_Game->IsKeyPressed( SDLK_UP );
	bool Decel = g_Game->IsKeyPressed( SDLK_DOWN );
	m_Accel = vec3( 0.0f );

	if ( Accel )
	{
		m_Accel = GetDirection();
	}

	if ( Decel )
	{
		m_Accel += -GetDirection();
	}

	if ( g_Game->IsKeyPressed( SDLK_SPACE ) )
	{
		Fire();
	}

	m_Pos = g_Game->ClampToLevel( m_Pos );
	m_Vel *= 0.99f;
	const float MaxVel = 1.1f;

	if ( m_Vel.Length() > MaxVel ) { m_Vel = ( m_Vel / m_Vel.Length() ) * MaxVel; }

	m_FireTime -= dt;

	if ( m_FireTime < 0 ) { m_FireTime = 0.0f; }

	mat4 ScaleFix = mat4::GetScaleMatrix( vec3( 0.1f ) );
	mat4 RotFix = mat4::GetRotateMatrixAxis( 90.0f * Math::DTOR, vec3( 0, 0, 1 ) );

	mat4 Pos = mat4::GetTranslateMatrix( m_Pos );
	mat4 Rot = mat4::GetRotateMatrixAxis( m_Angle, vec3( 0, 0, 1 ) );

	if ( m_Node ) { m_Node->SetLocalTransform( ScaleFix * RotFix * Rot * Pos ); }
}
开发者ID:adarash,项目名称:Mastering-Android-NDK,代码行数:53,代码来源:Actors.cpp


示例11: Execute

			void Execute()
			{
				auto projectile = mWeapon->GetProjectile()->Clone();
				projectile->SetPosition(mPosition);
				projectile->SetVelocity(sf::Vector2f(projectile->GetSpeed(), 0.0f));
				projectile->SetRotation(0.0f);
				projectile->SetZOrder(50);
				projectile->SetCurrentAimpoint(mCurrAim);
				projectile->SetFinalAimpoint(mFinalAim);
				projectile->Fire();
				mDrawNode->Add(projectile);
			}
开发者ID:MysteriousMilk,项目名称:ProjectOrion,代码行数:12,代码来源:FireProjectileEvent.hpp


示例12: CalculateStreamTime

//----------------------------------------------------------------------------
//              
//	ROUTINE:	CAIHumanStrategyShootStream::UpdateAiming()
//              
//	PURPOSE:	
//              
//----------------------------------------------------------------------------
/*virtual*/ void CAIHumanStrategyShootStream::UpdateAiming(HOBJECT hTarget)
{
	if ( m_flStreamTime < g_pLTServer->GetTime() )
	{
		// Don't calculate new stream time until finished firing animation.
		if( !GetAnimationContext()->IsLocked() )
		{
			CalculateStreamTime();
		}

		Aim();
	}
	else
	{
		// We're done waiting, fire if we're at a reasonable angle

		if ( m_bIgnoreFOV )
		{
			Fire();
		}
		else
		{
			LTVector vTargetPos;
			g_pLTServer->GetObjectPos(hTarget, &vTargetPos);

			LTVector vDir = vTargetPos - GetAI()->GetPosition();
			vDir.y = 0.0f;
			vDir.Normalize();

			if ( vDir.Dot(GetAI()->GetTorsoForward()) < 0.70f )
			{
				Aim();
			}
			else
			{
				Fire();
			}
		}
	}
}
开发者ID:rickyharis39,项目名称:nolf2,代码行数:47,代码来源:AIHumanStrategyShootStream.cpp


示例13: fabs

void CASW_Sentry_Top::CheckFiring()
{
	if ( gpGlobals->curtime > m_fNextFireTime && HasAmmo() && ( m_bHasHysteresis || m_hEnemy.Get() ) )
	{
		float flDist = fabs(m_fGoalYaw - m_fCurrentYaw);
		flDist = fsel( flDist - 180, 360 - flDist, flDist );

		if ( (flDist < ASW_SENTRY_FIRE_ANGLE_THRESHOLD) || ( m_bHasHysteresis && !m_hEnemy ) )
		{
			Fire();
		}	
	}
}
开发者ID:Nightgunner5,项目名称:Jastian-Summer,代码行数:13,代码来源:asw_sentry_top.cpp


示例14: GetPosition

void RPG_Projectile::Fire(hkvVec3 position, VisBaseEntity_cl* target, bool trackTarget, float speed)
{
  if(trackTarget)
  {
    m_targetToTrack = target;
  }

  hkvVec3 directionToTarget = target->GetPosition() - GetPosition();
  if(directionToTarget.normalizeIfNotZero() == HKV_SUCCESS)
  {
    Fire(position, directionToTarget, speed);
  }
}
开发者ID:Arpit007,项目名称:projectanarchy,代码行数:13,代码来源:Projectile.cpp


示例15: timerEvent

void ODeferrer :: timerEvent (QTimerEvent *pQTimerEvent )
{

  killTimer(timerid);
  
  if ( parent() ) 
    setParent(NULL);
    
  Fire();
  delete this;


}
开发者ID:BackupTheBerlios,项目名称:openaqua-svn,代码行数:13,代码来源:ODeferrer.cpp


示例16: GetWorld

void ABaseWeapon::HandleFiring()
{
	const float GameTime = GetWorld()->GetTimeSeconds();

	if (LastFireTime > 0 && WeaponConfig.TimeBetweenShots > 0 && LastFireTime + WeaponConfig.TimeBetweenShots > GameTime)
	{
		GetWorldTimerManager().SetTimer(time_handler, this, &ABaseWeapon::Fire, LastFireTime + WeaponConfig.TimeBetweenShots - GameTime, false);
	}
	else
	{
		Fire();
	}
}
开发者ID:ZerosGames,项目名称:FightKillWin,代码行数:13,代码来源:BaseWeapon.cpp


示例17: Fire

///
/// TRANSITIONNODE DEFINITIONS ///
///
void TransitionNode::UpdateKey(unsigned int n)
{
	_fireCounter++;
	// how do we erase one 1? it has to omit any value present in both.
	// bitwise XOR to update key state
	_firekey ^= n;
	// if all 1's are gone
	if((_firekey&0xffffffff)==0)
	{
		_isActivated = true;
		Fire();
	}
}
开发者ID:stumposs,项目名称:DP,代码行数:16,代码来源:PetriNet.cpp


示例18: Fire

Kylin::Factor* Kylin::ActionDispatcher::Fire( KUINT uGID,KUINT uTarget )
{
	Kylin::Entity* pEnt = KylinRoot::GetSingletonPtr()->GetEntity(uTarget);
	if (pEnt)
	{
		Factor* pFactor = Fire(uGID);
		SAFE_CALL(pFactor,SetTarget(uTarget));

		return pFactor;
	}
	
	return NULL;
}
开发者ID:dzw,项目名称:kylin001v,代码行数:13,代码来源:ActionDispatcher.cpp


示例19: Reload

/*void Weapon::FixedUpdate(float timeStep)
{
    Actor::FixedUpdate(timeStep);
    //something
    //SetLeftHandOffset();
}*/
void Weapon::Update(Controls& ctrl, float timeStep)
{
    lefthand_target_=node_->GetWorldTransform()*lefthand_off_;
    //node_->SetPosition(Vector3(0.2f, 0.2f, 0.2f));//objectNode
    //this is called from the pawn controlling it, fron thier fixed update, like a state
    if(reloading_)
        Reload(timeStep);

    if (ctrl.IsDown(CTRL_FIRE))
        Fire(timeStep);
    else
        ReleaseFire();
}
开发者ID:ghidra,项目名称:urho_framework,代码行数:19,代码来源:Weapon.cpp


示例20: GetOverlappingActors

void ALightningStorm::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	TArray<AActor*> OverlappingActors;
	GetOverlappingActors(OverlappingActors, ASwoim::StaticClass());

	int FireCounter = 0;


	TArray<ASwoim*> HitSwoimers;
	for (auto& first : OverlappingActors) {
		for (auto& second : OverlappingActors) {
			float d = FVector::Dist(first->GetActorLocation(), second->GetActorLocation());
			if (d > 0 && d < ArcDistance)
			{
				HitSwoimers.Add(Cast<ASwoim>(second));
			}
		}
	}

	if (HitSwoimers.Num() > 1) {
		int32 CurInt = FMath::RandRange(0, HitSwoimers.Num() - 1);
		int32 NextInt = FMath::RandRange(0, HitSwoimers.Num() - 1);
		for (int i = LightiningsArray.Num(); i < FMath::Min(HitSwoimers.Num(), NumOfLights); i++) {
			LightiningsArray.Add(Fire(HitSwoimers[CurInt], HitSwoimers[NextInt]));
			CurInt = NextInt;
			NextInt = FMath::RandRange(0, HitSwoimers.Num() - 1);

		}
	}
	
		
	

	UE_LOG(LogTemp, Warning, TEXT("LightiningsArray %d"), LightiningsArray.Num());

	bool IsCompeleted = true;
	for (auto& Lightining : LightiningsArray) {
		if (!Lightining->HasCompleted())
		{
			IsCompeleted = false;
		}
	}
	if (IsCompeleted)
	{
		LightiningsArray.Empty();
	}


}
开发者ID:TeAhTimEh,项目名称:Swoimz,代码行数:51,代码来源:LightningStorm.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FireBullets函数代码示例发布时间:2022-05-30
下一篇:
C++ FinishCommand函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap