コード例 #1
0
//moves the player down and changes his stamina
void Player::MoveDown()
{
	if (Stamina > 0)
	{
		ChangeStamina(-1);
	}
	else
	{
		ChangeHealth(-2);
	}
	yLocation++;
}
コード例 #2
0
//moves the player up and changes his stamina
void Player::MoveUp()
{
	if (Stamina > 0)
	{
		ChangeStamina(-1);
	}
	else
	{
		ChangeHealth(-2);
	}
	yLocation--;
}
コード例 #3
0
//moves the player right and changes his stamina
void Player::MoveRight()
{
	if (Stamina > 0)
	{
		ChangeStamina(-1);
	}
	else
	{
		ChangeHealth(-2);
	}
	xLocation++;
}
コード例 #4
0
//uses Gatorade to restore the player's stamina
string Player::Drink()
{
	if (Gatorade == 0)
	{
		return "You're out of Gatorade!";
	}
	else
	{
		Gatorade--;
		ChangeStamina(15);
		return "Your stamina has been restored!";
	}
}
コード例 #5
0
void ARoguelikeChar::CharacterJump()
{
	if (bIsDead)return;

	if (bIsAiming || PlayerAnimationInstance->bIsReloading)
		return;

	if (bIsSprinting && !PlayerAnimationInstance->bHasJumped)
	{
		ChangeStamina(-20);
	}

	Jump();
	PlayerAnimationInstance->bHasJumped = true;
}
コード例 #6
0
void ARoguelikeChar::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	if (bIsDead)
	{
		DeathCameraMovement(DeltaTime);
	}
	else
	{

		PlayerCamera->PostProcessSettings.SceneColorTint = FLinearColor(1.f, CurrentHealth / MaxHealth, CurrentHealth / MaxHealth);

		// Reset Jump Check
		if (PlayerAnimationInstance->bHasJumped)
		{
			PlayerAnimationInstance->bIsGrounded = GetCharacterMovement()->IsMovingOnGround();
			if (PlayerAnimationInstance->bIsGrounded)PlayerAnimationInstance->bHasJumped = false;
		}

		// Aiming Mechanic
		if (bIsAiming)
		{
			if (PlayerCamera->FieldOfView > FOVLowLimit)
			{
				PlayerCamera->FieldOfView -= FOVDropRate * DeltaTime;
			}
		}
		else
		{
			if (PlayerCamera->FieldOfView < FOVHighLimit)
			{
				PlayerCamera->FieldOfView += FOVDropRate * DeltaTime;
			}
		}

		// Sprinting Mechanics
		ChangeStamina(StaminaRate * DeltaTime);


		// Laser-Specific Code
		if (bIsAiming)
			GenerateLaserBeam();


	}
}
コード例 #7
0
//restores the player's health and stamina when he sleeps in a bed
void Player::Sleep()
{
	ChangeHealth(40);
	ChangeStamina(20);
}