98 - Blaster Game Mode

This commit is contained in:
Kingsmedia 2022-05-07 17:11:53 +02:00
parent 835069d362
commit 9999ef2d37
7 changed files with 49 additions and 23 deletions

View File

@ -1,5 +0,0 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "BlasterGameModeBase.h"

View File

@ -1,17 +0,0 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "BlasterGameModeBase.generated.h"
/**
*
*/
UCLASS()
class BLASTER_API ABlasterGameModeBase : public AGameModeBase
{
GENERATED_BODY()
};

View File

@ -5,6 +5,7 @@
#include "Blaster/Blaster.h" #include "Blaster/Blaster.h"
#include "Blaster/Components/CombatComponent.h" #include "Blaster/Components/CombatComponent.h"
#include "Blaster/GameMode/BlasterGameMode.h"
#include "Blaster/PlayerController/BlasterPlayerController.h" #include "Blaster/PlayerController/BlasterPlayerController.h"
#include "Blaster/Weapon/Weapon.h" #include "Blaster/Weapon/Weapon.h"
#include "Camera/CameraComponent.h" #include "Camera/CameraComponent.h"
@ -99,6 +100,11 @@ void ABlasterCharacter::PlayFireMontage(bool bAiming)
} }
} }
void ABlasterCharacter::Eliminated()
{
}
void ABlasterCharacter::PlayHitReactMontage() void ABlasterCharacter::PlayHitReactMontage()
{ {
if (Combat == nullptr || Combat->EquippedWeapon == nullptr) return; if (Combat == nullptr || Combat->EquippedWeapon == nullptr) return;
@ -119,6 +125,17 @@ void ABlasterCharacter::ReceiveDamage(AActor* DamagedActor, float Damage, const
UpdateHUDHealth(); UpdateHUDHealth();
PlayHitReactMontage(); PlayHitReactMontage();
if (Health == 0.f)
{
ABlasterGameMode* GameMode = GetWorld()->GetAuthGameMode<ABlasterGameMode>();
if (GameMode)
{
BlasterPlayerController = BlasterPlayerController == nullptr ? Cast<ABlasterPlayerController>(Controller) : BlasterPlayerController;
ABlasterPlayerController* AttackerController = Cast<ABlasterPlayerController>(InstigatorController);
GameMode->PlayerEliminated(this, BlasterPlayerController, AttackerController);
}
}
} }
void ABlasterCharacter::Tick(float DeltaTime) void ABlasterCharacter::Tick(float DeltaTime)

View File

@ -21,6 +21,7 @@ public:
virtual void PostInitializeComponents() override; virtual void PostInitializeComponents() override;
virtual void OnRep_ReplicatedMovement() override; virtual void OnRep_ReplicatedMovement() override;
void PlayFireMontage(bool bAiming); void PlayFireMontage(bool bAiming);
void Eliminated();
protected: protected:
virtual void BeginPlay() override; virtual void BeginPlay() override;

View File

@ -0,0 +1,10 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BlasterGameMode.h"
void ABlasterGameMode::PlayerEliminated(ABlasterCharacter* ElimmedCharacter, ABlasterPlayerController* VictimController,
ABlasterPlayerController* AttackerController)
{
}

View File

@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameMode.h"
#include "BlasterGameMode.generated.h"
/**
*
*/
UCLASS()
class BLASTER_API ABlasterGameMode : public AGameMode
{
GENERATED_BODY()
public:
virtual void PlayerEliminated(class ABlasterCharacter* ElimmedCharacter, class ABlasterPlayerController* VictimController, class ABlasterPlayerController* AttackerController);
};