Skip to content

Commit

Permalink
Merge pull request #242 from kookmin-sw/dev
Browse files Browse the repository at this point in the history
CSS-359 [DevOps] 빌드_0.2.3
  • Loading branch information
autumn-na authored May 30, 2024
2 parents a497179 + 25d6ab2 commit 424ce8e
Show file tree
Hide file tree
Showing 25 changed files with 294 additions and 63 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified capstone_2024_20/Content/Level/Ingame.umap
Binary file not shown.
Binary file modified capstone_2024_20/Content/WidgetBlueprints/IngameWidget.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 15 additions & 3 deletions capstone_2024_20/Source/capstone_2024_20/Enemy/Enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

AEnemy::AEnemy(): SkeletalMesh(nullptr)
{
PrimaryActorTick.bCanEverTick = true;

// TODO@autumn - This is a temporary mesh, replace it with the actual mesh from data
SkeletalMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("SkeletalMesh"));
SkeletalMesh->SetSkeletalMesh(LoadObject<USkeletalMesh>(nullptr, TEXT("/Script/Engine.SkeletalMesh'/Game/GameObjects/Enemy/Base.Base'")));
Expand Down Expand Up @@ -40,9 +42,17 @@ void AEnemy::BeginPlay()

PopupEnemyWidget = Cast<UPopupEnemy>(PopupEnemyWidgetComponent->GetUserWidgetObject());
PopupEnemyWidget->SetHPProgressBarPercent(1);

AnimInstance = Cast<UEnemyAnimInstance>(SkeletalMesh->GetAnimInstance());
AnimInstance->OnGiveDamageDelegate.BindUObject(this, &AEnemy::GiveDamage);
}

// ReSharper disable once CppParameterMayBeConst
void AEnemy::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

if (const auto AnimInstance = Cast<UEnemyAnimInstance>(SkeletalMesh->GetAnimInstance()))
{
AnimInstance->OnGiveDamageDelegate.BindUObject(this, &AEnemy::GiveDamage);
}
}

void AEnemy::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
Expand Down Expand Up @@ -153,6 +163,7 @@ void AEnemy::ServerRPC_Attack_Implementation()

void AEnemy::MultiCastRPC_Attack_Implementation()
{
const auto AnimInstance = Cast<UEnemyAnimInstance>(SkeletalMesh->GetAnimInstance());
AnimInstance->bIsAttacking = true;
}

Expand Down Expand Up @@ -212,6 +223,7 @@ float AEnemy::GetDistanceToMyCharacter() const

bool AEnemy::CanMove() const
{
const auto AnimInstance = Cast<UEnemyAnimInstance>(SkeletalMesh->GetAnimInstance());
return !AnimInstance->bIsAttacking;
}

Expand Down
4 changes: 1 addition & 3 deletions capstone_2024_20/Source/capstone_2024_20/Enemy/Enemy.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class CAPSTONE_2024_20_API AEnemy : public AReplicatedCharacter, public IHP
public:
AEnemy();
virtual void BeginPlay() override;
virtual void Tick(float DeltaTime) override;

virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;

Expand Down Expand Up @@ -79,9 +80,6 @@ class CAPSTONE_2024_20_API AEnemy : public AReplicatedCharacter, public IHP
UPROPERTY()
UPopupEnemy* PopupEnemyWidget = nullptr;

UPROPERTY()
UEnemyAnimInstance* AnimInstance = nullptr;

const float MoveSpeed = 100.0f;
const float DistanceToMyCharacter = 200.0f;
const float AttackCooldown = 5.0f;
Expand Down
33 changes: 22 additions & 11 deletions capstone_2024_20/Source/capstone_2024_20/MyCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "MyPlayerController.h"
#include "Components/CapsuleComponent.h"
#include "Components/WidgetComponent.h"
#include "GameFramework/PlayerState.h"
#include "Net/UnrealNetwork.h"
#include "Enemy/Enemy.h"
#include "GameFramework/CharacterMovementComponent.h"
Expand Down Expand Up @@ -66,9 +65,6 @@ void AMyCharacter::BeginPlay()

CharacterChangerComponent->Change(GetGameInstance<UMyAudioInstance>()->GetCharacterType());

PirateAnimInstance = Cast<UPirateAnimInstance>(GetMesh()->GetAnimInstance());
PirateAnimInstance->OnPirateGiveDamageDelegate.BindUObject(this, &AMyCharacter::GiveDamage);

SetMaxHP(10);
SetCurrentHP(10);
}
Expand All @@ -80,6 +76,13 @@ void AMyCharacter::Tick(float DeltaTime)

// ! 캐릭터에 Attach한 UI가 Movement에 따라 움직이는 문제가 있어, Tick에서 위치를 업데이트
TextWidget->SetWorldLocation(GetActorLocation() + FVector(0.0f, 0.0f, -200.0f));

PirateAnimInstance = Cast<UPirateAnimInstance>(GetMesh()->GetAnimInstance());
if (PirateAnimInstance)
{
PirateAnimInstance->OnPirateGiveDamageDelegate.BindUObject(this, &AMyCharacter::GiveDamage);
PirateAnimInstance->OnPirateAttackEndDelegate.BindUObject(this, &AMyCharacter::AttackEnd);
}
}

void AMyCharacter::BeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
Expand Down Expand Up @@ -276,9 +279,11 @@ bool AMyCharacter::CanRevive() const
return CurrentReviveCooldown <= 0.0f;
}

bool AMyCharacter::IsAttacking() const
// Blueprint에서 실행 흐름을 제어하기 위함
// ReSharper disable once CppUE4BlueprintCallableFunctionMayBeConst
bool AMyCharacter::IsAttacking()
{
return PirateAnimInstance->bIsAttacking;
return bIsAttacking;
}

// ReSharper disable once CppParameterMayBeConst
Expand All @@ -305,6 +310,7 @@ void AMyCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLife
DOREPLIFETIME(AMyCharacter, CurrentHP);
DOREPLIFETIME(AMyCharacter, CurrentPlayerState);
DOREPLIFETIME(AMyCharacter, CurrentReviveCooldown);
DOREPLIFETIME(AMyCharacter, bIsAttacking);
}

void AMyCharacter::SetNamePlate() const
Expand Down Expand Up @@ -461,15 +467,20 @@ void AMyCharacter::Attack()
ServerRPC_Attack();
}

void AMyCharacter::ServerRPC_Attack_Implementation()
void AMyCharacter::AttackEnd()
{
CurrentAttackCooldown = AttackCooldown;
MulticastRPC_Attack();
if (!HasAuthority())
{
return;
}

bIsAttacking = false;
}

void AMyCharacter::MulticastRPC_Attack_Implementation() const
void AMyCharacter::ServerRPC_Attack_Implementation()
{
PirateAnimInstance->bIsAttacking = true;
CurrentAttackCooldown = AttackCooldown;
bIsAttacking = true;
}

float AMyCharacter::GetHPPercent() const
Expand Down
13 changes: 8 additions & 5 deletions capstone_2024_20/Source/capstone_2024_20/MyCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CAPSTONE_2024_20_API AMyCharacter : public ACharacter, public IHP

UPROPERTY(VisibleAnywhere)
UCharacterChangerComponent* CharacterChangerComponent;

protected:
bool bIsOverlap = false;

Expand Down Expand Up @@ -114,6 +114,9 @@ class CAPSTONE_2024_20_API AMyCharacter : public ACharacter, public IHP
UPROPERTY()
UPirateAnimInstance* PirateAnimInstance = nullptr;

UPROPERTY(Replicated)
bool bIsAttacking = false;

public:
// [begin] IHP interface
virtual int32 GetMaxHP() const override;
Expand Down Expand Up @@ -211,13 +214,11 @@ class CAPSTONE_2024_20_API AMyCharacter : public ACharacter, public IHP
void DropObject(AActor* Ship) const;

void Attack();
void AttackEnd();

UFUNCTION(Server, Reliable)
void ServerRPC_Attack();

UFUNCTION(NetMulticast, Reliable)
void MulticastRPC_Attack() const;

UFUNCTION(BlueprintPure)
float GetHPPercent() const;

Expand All @@ -228,7 +229,9 @@ class CAPSTONE_2024_20_API AMyCharacter : public ACharacter, public IHP

bool CanRevive() const;

bool IsAttacking() const;
UFUNCTION(BlueprintCallable)
bool IsAttacking();

void ReduceAttackCooldown(float DeltaTime);
bool CanAttack() const;
};
47 changes: 47 additions & 0 deletions capstone_2024_20/Source/capstone_2024_20/MyIngameHUD.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include "MyIngameHUD.h"
#include "Components/ProgressBar.h"
#include "Components/TextBlock.h"
#include "Upgrade/UpgradeWidgetElement.h"
#include "WidgetBlueprint/PopupDead.h"
#include "WidgetBlueprint/PopupCaution.h"
#include "WidgetBlueprint/PopupEnemyShip.h"
#include "WidgetBlueprint/PopupGameOver.h"
#include "WidgetBlueprint/PopupClear.h"

void AMyIngameHUD::BeginPlay()
{
Expand Down Expand Up @@ -32,6 +35,16 @@ void AMyIngameHUD::BeginPlay()
PopupCaution = CreateWidget<UPopupCaution>(GetWorld(), PopupCautionClass);
PopupCaution->AddToViewport();
PopupCaution->SetVisibility(ESlateVisibility::Hidden);

PopupGameOverClass = LoadClass<UPopupGameOver>(nullptr, TEXT("/Script/UMGEditor.WidgetBlueprint'/Game/WidgetBlueprints/StageFailPopUpWidget.StageFailPopUpWidget_C'"));
PopupGameOver = CreateWidget<UPopupGameOver>(GetWorld(), PopupGameOverClass);
PopupGameOver->AddToViewport();
PopupGameOver->SetVisibility(ESlateVisibility::Hidden);

PopupClearClass = LoadClass<UPopupClear>(nullptr, TEXT("/Script/UMGEditor.WidgetBlueprint'/Game/WidgetBlueprints/StageClearPopUpWidget.StageClearPopUpWidget_C'"));
PopupClear = CreateWidget<UPopupClear>(GetWorld(), PopupClearClass);
PopupClear->AddToViewport();
PopupClear->SetVisibility(ESlateVisibility::Hidden);

bIsCalledBeginPlay = true;
}
Expand Down Expand Up @@ -88,3 +101,37 @@ void AMyIngameHUD::ShowPopupCaution(const FText& Text) const
PopupCaution->SetVisibility(ESlateVisibility::Hidden);
}, 3.0f, false);
}

void AMyIngameHUD::ShowPopupGameOver(const bool bHasAuthority) const
{
PopupGameOver->SetVisibility(ESlateVisibility::Visible);
PopupGameOver->Initialize(bHasAuthority);

APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
PlayerController->bShowMouseCursor = true;
}

void AMyIngameHUD::ShowPopupClear(const bool bHasAuthority) const
{
PopupClear->SetVisibility(ESlateVisibility::Visible);
PopupClear->Initialize(bHasAuthority);

APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
PlayerController->bShowMouseCursor = true;
}

void AMyIngameHUD::SetCurrency(const int32 Amount) const
{
if (!InGameWidget)
{
return;
}

UTextBlock* TextBlock = Cast<UTextBlock>(InGameWidget->GetWidgetFromName(TEXT("TextBlock_205")));
if (!TextBlock)
{
return;
}

TextBlock->SetText(FText::FromString(FString::FromInt(Amount)));
}
21 changes: 21 additions & 0 deletions capstone_2024_20/Source/capstone_2024_20/MyIngameHUD.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "Upgrade/UpgradeWidget.h"
#include "MyIngameHUD.generated.h"

class UPopupClear;
class UPopupGameOver;
class UPopupEnemyShip;
class UPopupCaution;
class UProgressBar;
Expand Down Expand Up @@ -39,6 +41,16 @@ class CAPSTONE_2024_20_API AMyIngameHUD : public AHUD
void ShowPopupCaution(const FText& Text) const;
// [end] PopupCaution

// [begin] PopupGameOver
void ShowPopupGameOver(bool bHasAuthority) const;
// [end] PopupGameOver

// [begin] PopupClear
void ShowPopupClear(const bool bHasAuthority) const;
// [end] PopupClear

void SetCurrency(int32 Amount) const;

protected:
// ! Set on blueprint
UPROPERTY(BlueprintReadWrite, Category = "UI")
Expand All @@ -56,6 +68,9 @@ class CAPSTONE_2024_20_API AMyIngameHUD : public AHUD
TSubclassOf<UPopupCaution> PopupCautionClass;
TSubclassOf<UPopupEnemyShip> PopupEnemyShipClass;

TSubclassOf<UPopupGameOver> PopupGameOverClass;
TSubclassOf<UPopupClear> PopupClearClass;

private:
UPROPERTY()
UUserWidget* InGameWidget;
Expand All @@ -72,6 +87,12 @@ class CAPSTONE_2024_20_API AMyIngameHUD : public AHUD
UPROPERTY()
UPopupCaution* PopupCaution;

UPROPERTY()
UPopupGameOver* PopupGameOver;

UPROPERTY()
UPopupClear* PopupClear;

// ! 일부 클래스에서, HUD의 BeginPlay가 늦게 호출되는 경우가 있어 해당 클래스에서는 BeginPlay를 직접 호출.
// ! 이때, BeginPlay가 이미 호출된 경우에는 다시 호출하지 않도록 예외 처리하기 위한 변수
bool bIsCalledBeginPlay = false;
Expand Down
6 changes: 4 additions & 2 deletions capstone_2024_20/Source/capstone_2024_20/MyShip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ void AMyShip::BeginPlay()
Super::BeginPlay();

// Todo@autumn replace with data table
SetMaxHP(5);
SetCurrentHP(5);
SetMaxHP(20);
SetCurrentHP(20);
FindMyCannons();
FindEnemySpawnPoints();
FindEventSpawnPoints();
Expand All @@ -48,6 +48,8 @@ void AMyShip::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeP
DOREPLIFETIME(AMyShip, TargetRotation);
DOREPLIFETIME(AMyShip, MaxHP);
DOREPLIFETIME(AMyShip, CurrentHP);
DOREPLIFETIME(AMyShip, MoveSpeed);
DOREPLIFETIME(AMyShip, RotationAcceleration);
}

void AMyShip::UpgradeMoveSpeed()
Expand Down
1 change: 1 addition & 0 deletions capstone_2024_20/Source/capstone_2024_20/MyShip.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CAPSTONE_2024_20_API AMyShip : public APawn, public IHP
UPROPERTY(Replicated)
float MoveSpeed = 600.0f;

UPROPERTY(Replicated)
float RotationAcceleration = 1.0f;

UPROPERTY(BlueprintReadWrite,EditAnywhere)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#include "PirateAnimInstance.h"
#include "Net/UnrealNetwork.h"

void UPirateAnimInstance::OnAttackEnd()
void UPirateAnimInstance::OnAttackEnd() const
{
bIsAttacking = false;
if (OnPirateAttackEndDelegate.IsBound())
{
OnPirateAttackEndDelegate.Execute();
}
}

// ! 사이드 이펙트를 막기 위함
// ReSharper disable once CppUE4BlueprintCallableFunctionMayBeConst
void UPirateAnimInstance::OnGiveDamage()
{
OnPirateGiveDamageDelegate.Execute();
}

void UPirateAnimInstance::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(UPirateAnimInstance, bIsAttacking);
if (OnPirateGiveDamageDelegate.IsBound())
{
OnPirateGiveDamageDelegate.Execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Animation/AnimInstance.h"
#include "PirateAnimInstance.generated.h"

DECLARE_DELEGATE(FOnPirateAttackEndDelegate);
DECLARE_DELEGATE(FOnPirateGiveDamageDelegate);

UCLASS()
Expand All @@ -13,16 +14,11 @@ class CAPSTONE_2024_20_API UPirateAnimInstance : public UAnimInstance

public:
UFUNCTION(BlueprintCallable)
void OnAttackEnd();
void OnAttackEnd() const;

UFUNCTION(BlueprintCallable)
void OnGiveDamage();

UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated)
bool bIsAttacking;

FOnPirateAttackEndDelegate OnPirateAttackEndDelegate;
FOnPirateGiveDamageDelegate OnPirateGiveDamageDelegate;

private:
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
};
Loading

0 comments on commit 424ce8e

Please sign in to comment.