Skip to content

Commit 28c99f6

Browse files
committed
Tide up codes
1 parent b7bee5c commit 28c99f6

14 files changed

+9
-32
lines changed
Binary file not shown.
29.2 KB
Binary file not shown.
23.4 KB
Binary file not shown.
-6 Bytes
Binary file not shown.
-20.8 KB
Binary file not shown.
-14.8 KB
Binary file not shown.

Source/Immortal/Private/BaseCharacter.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright J&J.
22

33
#include "BaseCharacter.h"
4-
#include "BaseHealthBarWidget.h"
54
#include "PaperFlipbookComponent.h"
6-
#include "BaseHealthBarWidgetComponent.h"
75
#include "Components/CapsuleComponent.h"
86
#include "Components/InputComponent.h"
97
#include "GameFramework/CharacterMovementComponent.h"
@@ -66,9 +64,6 @@ ABaseCharacter::ABaseCharacter()
6664
SideViewCameraComponent->OrthoWidth = 2048.0f;
6765
SideViewCameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
6866

69-
// Create a health bar widget component
70-
//HealthBarWidgetComponent = CreateDefaultSubobject<UBaseHealthBarWidgetComponent>(TEXT("HealthBarWidget"));
71-
7267
// Setup Character
7368
StartingHealth = 10;
7469
CurrentHealth = StartingHealth;

Source/Immortal/Private/BaseHealthBarWidget.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
void UBaseHealthBarWidget::SetParentCharacter(class ABaseCharacter* InCharacter)
66
{
77
ParentCharacter = InCharacter;
8-
UE_LOG(LogTemp, Warning, TEXT("Parent Character: %s"), *ParentCharacter->GetName());
98
}
109

1110
float UBaseHealthBarWidget::GetHealthPercent() const
1211
{
1312
if (!ParentCharacter) { return 0.f; }
1413
return ParentCharacter->GetHealthPercent();
15-
}
14+
}

Source/Immortal/Private/BaseHealthBarWidgetComponent.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ UBaseHealthBarWidgetComponent::UBaseHealthBarWidgetComponent()
1111
if (HealthBarWidgetObj.Succeeded())
1212
{
1313
SetWidgetClass(HealthBarWidgetObj.Class);
14-
UE_LOG(LogTemp, Warning, TEXT("Called"));
1514
}
1615

17-
1816
SetWidgetSpace(EWidgetSpace::Screen);
1917
SetRelativeLocation(FVector(0.f, 0.f, 150.f));
2018
SetDrawAtDesiredSize(true);
@@ -26,7 +24,6 @@ void UBaseHealthBarWidgetComponent::BeginPlay()
2624

2725
if (Cast<UBaseHealthBarWidget>(Widget))
2826
{
29-
UE_LOG(LogTemp, Warning, TEXT("Found"));
3027
auto ParentCharacter = Cast<ABaseCharacter>(GetOwner());
3128
if (ParentCharacter)
3229
{

Source/Immortal/Private/Character1.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ ACharacter1::ACharacter1()
77

88
}
99

10-
void ACharacter1::Fire()
11-
{
12-
}
10+
//void ACharacter1::Fire()
11+
//{
12+
//}

Source/Immortal/Private/ImmortalPlayerController.cpp

+1-11
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ void AImmortalPlayerController::SetupInputComponent()
2525

2626
}
2727

28-
29-
void AImmortalPlayerController::BeginPlay()
30-
{
31-
Super::BeginPlay();
32-
if (!ControlledCharacter) { return; }
33-
34-
UE_LOG(LogTemp, Warning, TEXT("PlayerController is controlling: %s"), *ControlledCharacter->GetName());
35-
}
36-
3728
void AImmortalPlayerController::Tick(float DeltaSeconds)
3829
{
3930
Super::Tick(DeltaSeconds);
@@ -44,14 +35,12 @@ void AImmortalPlayerController::SwapCharacter()
4435
{
4536
ABaseCharacter* ClosestCharacter = Cast<ABaseCharacter>(GetClosestPawn());
4637
if (!ClosestCharacter) { return; }
47-
UE_LOG(LogTemp, Warning, TEXT("Closest pawn: %s"), *ClosestCharacter->GetName());
4838
if (ClosestCharacter->GetHealthPercent() <= 0 && ControlledCharacter->GetHealthPercent() > 0)
4939
{
5040
UnPossess();
5141
ControlledCharacter->OnDeath.RemoveDynamic(this, &AImmortalPlayerController::OnCharacterDeath);
5242
Possess(ClosestCharacter);
5343
SetPawn(ClosestCharacter);
54-
UE_LOG(LogTemp, Warning, TEXT("Player pawn now is: %s"), *ControlledCharacter->GetName());
5544

5645
ClosestCharacter->ResetCharacter();
5746
}
@@ -61,6 +50,7 @@ void AImmortalPlayerController::QuitGame()
6150
{
6251
ConsoleCommand("quit");
6352
}
53+
6454
void AImmortalPlayerController::OnCharacterDeath()
6555
{
6656
UE_LOG(LogTemp, Warning, TEXT("Player Character Died"));

Source/Immortal/Public/BaseCharacter.h

-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ class ABaseCharacter : public APaperCharacter
4444
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
4545
class UCameraComponent* SideViewCameraComponent;
4646

47-
//UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
48-
//class UBaseHealthBarWidgetComponent* HealthBarWidgetComponent;
49-
5047
/** Called to choose the correct animation to play based on the character's movement state */
5148
void UpdateAnimation();
5249

Source/Immortal/Public/Character1.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ class IMMORTAL_API ACharacter1 : public ABaseCharacter
2020
//virtual void Tick(float DeltaSeconds) override;
2121

2222
protected:
23-
virtual void Fire() override;
23+
//virtual void Fire() override;
2424

2525
};

Source/Immortal/Public/ImmortalPlayerController.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#include "ImmortalPlayerController.generated.h"
88

99
/**
10-
*
10+
* This class is the player controller class for Immortal.
11+
* It is Responsible for swapping characters (player's persist ability) and controlling UI.
1112
*/
12-
class ABaseCharacter;
1313

1414
UCLASS()
1515
class IMMORTAL_API AImmortalPlayerController : public APlayerController
@@ -19,7 +19,6 @@ class IMMORTAL_API AImmortalPlayerController : public APlayerController
1919
public:
2020

2121
virtual void SetPawn(APawn* InPawn) override;
22-
virtual void BeginPlay() override;
2322
virtual void Tick(float DeltaSeconds) override;
2423

2524
UFUNCTION(BlueprintCallable, Category = "Swap")
@@ -37,7 +36,7 @@ class IMMORTAL_API AImmortalPlayerController : public APlayerController
3736
/** Returns the closest pawn other than possessed pawn within the swap radius */
3837
APawn* GetClosestPawn();
3938

40-
ABaseCharacter* ControlledCharacter = nullptr;
39+
class ABaseCharacter* ControlledCharacter = nullptr;
4140

4241
UPROPERTY(EditAnywhere, Category = CharacterSetup)
4342
float SwapRadius = 200;

0 commit comments

Comments
 (0)