예제 #1
0
void Avatar::Update( float aDeltaTime, Collision* aCollisionChecker )
{
    myInvulnerabilityTime -= aDeltaTime;

    if( !IsInAir() )
    {
        const float fDecelerationFactor = 800.f;
        float fNewLength = CU::Macro::Max( 0.0f, myExternalVelocities.Length() - fDecelerationFactor * aDeltaTime );
        myExternalVelocities = myExternalVelocities.Normalize() * fNewLength;
    }
    // movement update
    myMovement.myY += (9.82f) * 40.f * aDeltaTime;
    Vector2f change = Vector2f( 0, ( myExternalVelocities.myY + myMovement.myY ) * aDeltaTime );
    if( !aCollisionChecker->IsValidMoveFat( myCollisionObject.myPosition, change, 7.f ) )
    {
        myMovement.myY = 0;
        myExternalVelocities.myY = 0;
    }
    change = ( myExternalVelocities + myMovement ) * aDeltaTime;
    if( !aCollisionChecker->IsValidMoveFat( myCollisionObject.myPosition, change, 7.f ) )
    {
        change.myX = 0;
    }
    if( change.myX > 0 )
        myLastMovementDirection = 1.0f;
    else if( change.myX < 0 )
        myLastMovementDirection = -1.f;
    myCollisionObject.myPosition += change;
    // alignSprites
    myHitbox.GetHitbox().myPosition = GetPosition();
    mySprite.SetPosition( myCollisionObject.GetMinPosition() );
    debugsprite.SetPosition( myCollisionObject.GetMinPosition() );
    // attacking
    myAttackComponent.Update( aDeltaTime, myCollisionObject.myPosition, myLastMovementDirection );
}
예제 #2
0
void KMovableObject::AfterProcessMoveZ()
{
    if (IsInAir())
    {
        // 悬空状态向下加速
        m_nVelocityZ -= GetCurrentGravity();
    }
}
예제 #3
0
void KMovableObject::OnIdle(int nCurLoop)
{
    if(IsInAir() || m_nVelocityX != 0 || m_nVelocityY != 0 || m_nVelocityZ != 0)
    {
        TurnToMoveType(mosFree);
        OnFree(nCurLoop);
    }

Exit1:
    return;
}
예제 #4
0
// Called when the character jumps
void AMurphysLawCharacter::Jump()
{
	// Only jump when the character has enough stamina or isn't already in the air
	if (GetCurrentStaminaLevel() - JumpStaminaDecayAmount <= 0.f
		|| IsInAir()) return;

	// Stop the character from running first
	SetIsRunning(false);

	Super::Jump();

	UpdateStaminaLevel(-JumpStaminaDecayAmount);
}
예제 #5
0
void KMovableObject::OnFree(int nCurLoop)
{
    assert(m_eMoveType == mosFree);
    if (m_nVelocityX == 0 && m_nVelocityY == 0 && m_nVelocityZ == 0 && !IsInAir())
    {
        TurnToMoveType(mosIdle);
        OnTurnedToIdle();
        goto Exit0;
    }

    ProcessMove();

Exit0:
    return;
}
예제 #6
0
bool PoweredUnitClass::PowerDown()
{
	auto const pTechno = this->Techno;

	if(EMPulse::IsDeactivationAdvisable(pTechno)) {
		// destroy if EMP.Threshold would crash this unit when in air
		auto const pType = pTechno->GetTechnoType();
		auto const pExt = TechnoTypeExt::ExtMap.Find(pType);

		if(EMPulse::EnableEMPEffect2(pTechno)
			|| (pExt->EMP_Threshold && pTechno->IsInAir()))
		{
			return false;
		}
	}

	return true;
}
예제 #7
0
void JetPack::Refresh()
{
  if (active) {
    Point2d F(0.0, 0.0);
    const UDMoveIntention * ud_move_intention = ActiveCharacter().GetLastUDMoveIntention();
    if (ud_move_intention && ud_move_intention->GetDirection() == DIRECTION_UP) {
      F.y = -(ActiveCharacter().GetMass() * GameMode::GetInstance()->gravity + JETPACK_FORCE);
    }
    const LRMoveIntention * lr_move_intention = ActiveCharacter().GetLastLRMoveIntention();
    if (lr_move_intention && IsInAir()) {
      LRDirection direction = lr_move_intention->GetDirection();
      if (direction == DIRECTION_LEFT)
        F.x = -JETPACK_FORCE;
      else
        F.x = JETPACK_FORCE;
      ActiveCharacter().SetDirection(direction);
    }

    if (F.IsNull() && m_flying)
      StopFlying();
    else if (!F.IsNull() && !m_flying)
      StartFlying();

    ActiveCharacter().SetExternForceXY(F);

    if (!F.IsNull()) {
      // We are using fuel !!!
      uint current = GameTime::GetInstance()->Read() ;
      int64_t delta = current - m_last_fuel_down;

      while (delta >= DELTA_FUEL_DOWN) {
        if (EnoughAmmoUnit()) {
          UseAmmoUnit();
          m_last_fuel_down += DELTA_FUEL_DOWN ;
          delta -= DELTA_FUEL_DOWN ;
        } else {
          p_Deselect();
          break;
        }
      }

    }
  }
}
예제 #8
0
bool JetPack::IsPreventingJumps()
{
  return IsInAir();
}
예제 #9
0
bool JetPack::IsPreventingLRMovement()
{
  return IsInAir();
}
예제 #10
0
void Avatar::Jump()
{
    if( !IsInAir() )
        myMovement.myY = -200.f;
}