diff --git a/Content/Blueprints/GameModes/BP_BlasterGameMode.uasset b/Content/Blueprints/GameModes/BP_BlasterGameMode.uasset index aa6573f..8f02518 100644 Binary files a/Content/Blueprints/GameModes/BP_BlasterGameMode.uasset and b/Content/Blueprints/GameModes/BP_BlasterGameMode.uasset differ diff --git a/Source/Blaster/BlasterGameModeBase.cpp b/Source/Blaster/BlasterGameModeBase.cpp deleted file mode 100644 index eb97880..0000000 --- a/Source/Blaster/BlasterGameModeBase.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - - -#include "BlasterGameModeBase.h" - diff --git a/Source/Blaster/BlasterGameModeBase.h b/Source/Blaster/BlasterGameModeBase.h deleted file mode 100644 index 4bd8c29..0000000 --- a/Source/Blaster/BlasterGameModeBase.h +++ /dev/null @@ -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() - -}; diff --git a/Source/Blaster/Character/BlasterCharacter.cpp b/Source/Blaster/Character/BlasterCharacter.cpp index 3e5b036..30ee1bb 100644 --- a/Source/Blaster/Character/BlasterCharacter.cpp +++ b/Source/Blaster/Character/BlasterCharacter.cpp @@ -5,6 +5,7 @@ #include "Blaster/Blaster.h" #include "Blaster/Components/CombatComponent.h" +#include "Blaster/GameMode/BlasterGameMode.h" #include "Blaster/PlayerController/BlasterPlayerController.h" #include "Blaster/Weapon/Weapon.h" #include "Camera/CameraComponent.h" @@ -99,6 +100,11 @@ void ABlasterCharacter::PlayFireMontage(bool bAiming) } } +void ABlasterCharacter::Eliminated() +{ + +} + void ABlasterCharacter::PlayHitReactMontage() { if (Combat == nullptr || Combat->EquippedWeapon == nullptr) return; @@ -119,6 +125,17 @@ void ABlasterCharacter::ReceiveDamage(AActor* DamagedActor, float Damage, const UpdateHUDHealth(); PlayHitReactMontage(); + + if (Health == 0.f) + { + ABlasterGameMode* GameMode = GetWorld()->GetAuthGameMode(); + if (GameMode) + { + BlasterPlayerController = BlasterPlayerController == nullptr ? Cast(Controller) : BlasterPlayerController; + ABlasterPlayerController* AttackerController = Cast(InstigatorController); + GameMode->PlayerEliminated(this, BlasterPlayerController, AttackerController); + } + } } void ABlasterCharacter::Tick(float DeltaTime) @@ -421,7 +438,7 @@ void ABlasterCharacter::OnRep_Health() void ABlasterCharacter::UpdateHUDHealth() { - BlasterPlayerController = BlasterPlayerController == nullptr ?Cast(Controller) : BlasterPlayerController; + BlasterPlayerController = BlasterPlayerController == nullptr ? Cast(Controller) : BlasterPlayerController; if (BlasterPlayerController) { BlasterPlayerController->SetHUDHealth(Health, MaxHealth); diff --git a/Source/Blaster/Character/BlasterCharacter.h b/Source/Blaster/Character/BlasterCharacter.h index 8230de3..0ffdf25 100644 --- a/Source/Blaster/Character/BlasterCharacter.h +++ b/Source/Blaster/Character/BlasterCharacter.h @@ -21,6 +21,7 @@ public: virtual void PostInitializeComponents() override; virtual void OnRep_ReplicatedMovement() override; void PlayFireMontage(bool bAiming); + void Eliminated(); protected: virtual void BeginPlay() override; diff --git a/Source/Blaster/GameMode/BlasterGameMode.cpp b/Source/Blaster/GameMode/BlasterGameMode.cpp new file mode 100644 index 0000000..abdd53f --- /dev/null +++ b/Source/Blaster/GameMode/BlasterGameMode.cpp @@ -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) +{ + +} diff --git a/Source/Blaster/GameMode/BlasterGameMode.h b/Source/Blaster/GameMode/BlasterGameMode.h new file mode 100644 index 0000000..e5e8b31 --- /dev/null +++ b/Source/Blaster/GameMode/BlasterGameMode.h @@ -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); +};