From 579100f45cd02c884fd3d740c398575ffbfde316 Mon Sep 17 00:00:00 2001 From: Oleg Petruny Date: Sun, 17 Nov 2024 22:20:05 +0100 Subject: [PATCH] Minigame without AI --- .../Lost_Edge/Config/DefaultEngine.ini | 1 + .../Blueprints/Items/BP_CompanionCube.uasset | 4 +- .../AgeOfWar/BP_Minigame_AgeOfWar.uasset | 4 +- .../AgeOfWar/UI_Minigame_AgeOfWar.uasset | 4 +- .../BP_Minigame_AgeOfWarUnit_Base.uasset | 4 +- ...BP_Minigame_AgeOfWarUnit_FirstMelee.uasset | 4 +- ...BP_Minigame_AgeOfWarUnit_FirstRange.uasset | 4 +- .../BP_Minigame_AgeOfWarUnit_FirstTank.uasset | 4 +- .../Lost_Edge/Content/Levels/Test/L_Test.umap | 4 +- .../Private/Interactable/Interactable.cpp | 24 +++++----- .../Private/Interactable/Interactable.h | 2 +- .../Minigame/AgeOfWar/AgeOfWarManager.cpp | 35 +++++++++++--- .../Minigame/AgeOfWar/AgeOfWarManager.h | 18 +++---- .../Minigame/AgeOfWar/AgeOfWarUnit.cpp | 47 +++++++++++++------ .../Private/Minigame/AgeOfWar/AgeOfWarUnit.h | 25 +++++++--- .../Minigame/CrossyRoad/CrossyRoadManager.cpp | 6 +-- .../Minigame/SubwaySurf/SubwaySurfManager.cpp | 6 +-- 17 files changed, 122 insertions(+), 74 deletions(-) diff --git a/UnrealProject/Lost_Edge/Config/DefaultEngine.ini b/UnrealProject/Lost_Edge/Config/DefaultEngine.ini index fbd6426..369b66a 100644 --- a/UnrealProject/Lost_Edge/Config/DefaultEngine.ini +++ b/UnrealProject/Lost_Edge/Config/DefaultEngine.ini @@ -139,6 +139,7 @@ ManualIPAddress= +Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.") +Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility"),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") +Profiles=(Name="Interactable",CollisionEnabled=QueryAndPhysics,bCanModify=True,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Interactable")),HelpMessage="WorldDynamic objects derived from AInteractable.") ++Profiles=(Name="AgeOfWarUnit",CollisionEnabled=QueryOnly,bCanModify=True,ObjectTypeName="Vehicle",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Minigame object") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="Interactable") -ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall") -ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn") diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Items/BP_CompanionCube.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Items/BP_CompanionCube.uasset index b8610db..ba9951d 100644 --- a/UnrealProject/Lost_Edge/Content/Blueprints/Items/BP_CompanionCube.uasset +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Items/BP_CompanionCube.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2b9660bb6e1de93ac49a75a29779ac8bbac2f4230b1aec0f7eca4604a8f79467 -size 23557 +oid sha256:1195d0ee2ffdfd23b58c5b83519c0c26bf91b3df3a623d52411462876b9d9848 +size 25381 diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/BP_Minigame_AgeOfWar.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/BP_Minigame_AgeOfWar.uasset index 895e73b..35f9a4f 100644 --- a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/BP_Minigame_AgeOfWar.uasset +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/BP_Minigame_AgeOfWar.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bfba9f57eeadaeb16c2816753739eddb5d4998c706c1d37265019f3d367bf8db -size 117797 +oid sha256:eb79e9917fe826eb430ee33c9f2f3899bab8a193eb230ce24017fb13c4179e7f +size 366061 diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/UI_Minigame_AgeOfWar.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/UI_Minigame_AgeOfWar.uasset index 3ff9b75..71b6ab2 100644 --- a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/UI_Minigame_AgeOfWar.uasset +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/UI_Minigame_AgeOfWar.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:af517d6e39525d50ced0a91902c5c66cee5ccd9163f437b383490274c8f10e24 -size 152299 +oid sha256:48d61e4adb9f190548560d1e42f2d07c60564a988ba877f70e528c204e544709 +size 181823 diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_Base.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_Base.uasset index 8a670fd..d0c20a2 100644 --- a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_Base.uasset +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_Base.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc5241f0309901748105c0db83cf1816e1967ed59b581585fc2d30592a891ade -size 21133 +oid sha256:12a1a84218555e73e3f9ef1f3db30bf3e1ca2b427a041839128f111e97d80263 +size 23941 diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstMelee.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstMelee.uasset index 179cd0e..aaadec9 100644 --- a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstMelee.uasset +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstMelee.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e97530e0d19c9723523efe8e89dc6041bb2d402d66077f62603271811148d857 -size 20500 +oid sha256:905f95b9ba7239185a27a95f0dc44c394705c7ae7c1edf38274a29cb8d5eeed7 +size 23343 diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstRange.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstRange.uasset index 716efd6..1766f2a 100644 --- a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstRange.uasset +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstRange.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8c8ca38d1d4d1e8df6ce890237d4ec03c3a28fcd9caaf9ca5743943132710b79 -size 22390 +oid sha256:685d868675c82a533270e268390749c68bd14f8d1d08059ee090a24748e2998d +size 26335 diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstTank.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstTank.uasset index 85233d4..8e12740 100644 --- a/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstTank.uasset +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_FirstTank.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:47e26221cdcd59092d748bcf7aac3c452cd4a0426d5f1c9a2fc1213e96b52b68 -size 21087 +oid sha256:8202a38d55de0cc6f348780d036e2c08fcc2d0860e28ce6649346ec71989f49a +size 23930 diff --git a/UnrealProject/Lost_Edge/Content/Levels/Test/L_Test.umap b/UnrealProject/Lost_Edge/Content/Levels/Test/L_Test.umap index 278e2c4..435c279 100644 --- a/UnrealProject/Lost_Edge/Content/Levels/Test/L_Test.umap +++ b/UnrealProject/Lost_Edge/Content/Levels/Test/L_Test.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:26ba9021d327e31a02433e566da5b6428681e17f2ae92ad100200f30c073dea3 -size 2257698 +oid sha256:bdd549e2cfccd08d1cf7a9347d806405311dbd11d371bb8677428ef5aba7f9ed +size 2265093 diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.cpp index 832cae8..1094c03 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.cpp @@ -55,25 +55,25 @@ void AInteractable::BeginPlay() } } - GetComponents(meshes); - for(auto mesh : meshes) + GetComponents(collisions, true); + for(auto collision : collisions) { if(activatorTypes) { - mesh->SetCollisionProfileName(TEXT("Interactable")); + collision->SetCollisionProfileName(TEXT("Interactable")); } if(activatorTypes & static_cast(EActivatorType::Saw)) { - mesh->CustomDepthStencilValue = 128; - mesh->CustomDepthStencilWriteMask = ERendererStencilMask::ERSM_Default; - mesh->SetRenderCustomDepth(true); + collision->CustomDepthStencilValue = 128; + collision->CustomDepthStencilWriteMask = ERendererStencilMask::ERSM_Default; + collision->SetRenderCustomDepth(true); } if(activatorTypes & static_cast(EActivatorType::Use)) { - mesh->CustomDepthStencilWriteMask = ERendererStencilMask::ERSM_Default; - mesh->SetRenderCustomDepth(true); + collision->CustomDepthStencilWriteMask = ERendererStencilMask::ERSM_Default; + collision->SetRenderCustomDepth(true); } } @@ -120,8 +120,8 @@ void AInteractable::_Activate(EActivatorType type) if(activated & static_cast(EActivatorType::Use)) { - for(auto mesh : meshes) - mesh->SetCustomDepthStencilValue(132); + for(auto collision : collisions) + collision->SetCustomDepthStencilValue(132); } Activate(type); @@ -155,8 +155,8 @@ void AInteractable::_Deactivate(EActivatorType type) if(!(activated & static_cast(EActivatorType::Use))) { - for(auto mesh : meshes) - mesh->SetCustomDepthStencilValue(0); + for(auto collision : collisions) + collision->SetCustomDepthStencilValue(0); } Deactivate(type); diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.h index 33d4358..1b84e93 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.h @@ -58,7 +58,7 @@ protected: TMap modificators; class APlayerBase* player = nullptr; - TArray meshes; + TArray collisions; }; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.cpp index 9b01484..7f566a9 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.cpp @@ -4,6 +4,7 @@ #include "AgeOfWarManager.h" #include "Camera/CameraComponent.h" +#include "Components/ChildActorComponent.h" #include "AgeOfWarUnit.h" #include "MainGameModeBase.h" @@ -13,6 +14,8 @@ TMap AAgeOfWarManager::unitStats = {}; const FAgeOfWarUnitStats& AAgeOfWarManager::UnitGetStats(TSubclassOf unitClass) { + check(unitStats.Contains(*unitClass)); + return unitStats[unitClass]; } @@ -21,10 +24,7 @@ AAgeOfWarManager::AAgeOfWarManager() auto root = CreateDefaultSubobject(TEXT("Scene")); camera = CreateDefaultSubobject(TEXT("Camera")); - camera->AttachToComponent(root, FAttachmentTransformRules::KeepRelativeTransform); - - basePlayer = static_cast(CreateDefaultSubobject(TEXT("BasePlayer"), AAgeOfWarUnit::StaticClass(), baseClass, true, false)); - baseComputer = static_cast(CreateDefaultSubobject(TEXT("BaseComputer"), AAgeOfWarUnit::StaticClass(), baseClass, true, false)); + camera->SetupAttachment(root); } void AAgeOfWarManager::Start(APlayerBase* playerPawn, FMinigameEndCallback delegate) @@ -38,6 +38,16 @@ void AAgeOfWarManager::Start(APlayerBase* playerPawn, FMinigameEndCallback deleg player->SwitchToView(this); FillUnitStats(); + TArray units; + GetComponents(units); + for(auto& unit : units) + { + if(auto proxy = Cast(unit->GetChildActor())) + { + proxy->manager = this; + proxy->UpdateStats(); + } + } } void AAgeOfWarManager::End() @@ -50,10 +60,21 @@ void AAgeOfWarManager::End() AMinigame::End(); } -void AAgeOfWarManager::UnitKill(AAgeOfWarUnit* unit) -{} - void AAgeOfWarManager::AddUnitStats(TSubclassOf unitClass, FAgeOfWarUnitStats stats) { unitStats.Add(unitClass, stats); } + +FAgeOfWarUnitStats AAgeOfWarManager::GetUnitStats(TSubclassOf unitClass) +{ + return UnitGetStats(unitClass); +} + +void AAgeOfWarManager::SpawnUnit(TSubclassOf unitClass, FTransform transform, bool computer) +{ + FActorSpawnParameters spawnParams{}; + spawnParams.Owner = this; + auto unit = GetWorld()->SpawnActor(*unitClass, transform, spawnParams); + unit->team = computer ? UnitTeam::AI : UnitTeam::Player; + unit->manager = this; +} diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.h index 0f9a842..099e729 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarManager.h @@ -19,27 +19,23 @@ public: virtual void Start(class APlayerBase* playerPawn, FMinigameEndCallback delegate) override; virtual void End() override; - void UnitKill(class AAgeOfWarUnit* unit); + UFUNCTION(BlueprintImplementableEvent) + void OnUnitKill(class AAgeOfWarUnit* unit); protected: UFUNCTION(BlueprintImplementableEvent) void FillUnitStats(); - UFUNCTION(BlueprintCallable) static void AddUnitStats(TSubclassOf unitClass, struct FAgeOfWarUnitStats stats); + UFUNCTION(BlueprintPure) + static struct FAgeOfWarUnitStats GetUnitStats(TSubclassOf unitClass); + + UFUNCTION(BlueprintCallable) + void SpawnUnit(TSubclassOf unitClass, FTransform transform, bool computer = false); static TMap unitStats; UPROPERTY(EditAnywhere) class UCameraComponent* camera; - UPROPERTY(EditDefaultsOnly) - class TSubclassOf baseClass; - UPROPERTY(EditAnywhere) - class AAgeOfWarUnit* basePlayer; - UPROPERTY(EditAnywhere) - class AAgeOfWarUnit* baseComputer; - - - }; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.cpp index 17ff2bd..efb92fb 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.cpp @@ -3,39 +3,55 @@ #include "AgeOfWarUnit.h" +#include "Components/StaticMeshComponent.h" + #include "AgeOfWarManager.h" +#include const FAgeOfWarUnitStats& AAgeOfWarUnit::GetStats() { if(!stats) stats = &AAgeOfWarManager::UnitGetStats(GetClass()); - if(ensureAlways(stats)) - { - auto errorMsg = FString::Printf(TEXT("AgeOfWarManager instance doesn't contain %s class stats... Destroying actor"), &GetClass()->GetName()); - UE_LOG(LogTemp, Log, TEXT("%s"), *errorMsg); - GEngine->AddOnScreenDebugMessage(-1, 20.0f, FColor::Red, errorMsg); - static FAgeOfWarUnitStats s{}; - stats = &s; - Destroy(); - } - return *stats; } -void AAgeOfWarUnit::BeginPlay() +void AAgeOfWarUnit::UpdateStats() { health = GetStats().health; } +void AAgeOfWarUnit::BeginPlay() +{ + if(manager) + { + UpdateStats(); + } + + Super::BeginPlay(); +} + void AAgeOfWarUnit::EndPlay(const EEndPlayReason::Type EndPlayReason) -{} +{ + Super::EndPlay(EndPlayReason); +} + +AAgeOfWarUnit::AAgeOfWarUnit() +{ + //auto root = CreateDefaultSubobject(TEXT("Scene")); + // + //collision = CreateDefaultSubobject(TEXT("Collision")); + //collision->SetCollisionProfileName(TEXT("AgeOfWarUnit")); + + PrimaryActorTick.bCanEverTick = true; + PrimaryActorTick.bStartWithTickEnabled = true; +} void AAgeOfWarUnit::Tick(float deltaTime) { Super::Tick(deltaTime); - if(GetStats().moveSpeed <= 0) + if(!manager || GetStats().moveSpeed <= 0) return; // move unit forward @@ -68,17 +84,20 @@ void AAgeOfWarUnit::Tick(float deltaTime) lastAttackTimestamp = FPlatformTime::Seconds(); forwardUnit->Damage(GetStats().attackDamage); } + GEngine->AddOnScreenDebugMessage(4, 5.0f, FColor::Yellow, FString::Printf(TEXT("Time %f"), lastAttackTimestamp + GetStats().attackRate - FPlatformTime::Seconds())); } void AAgeOfWarUnit::Damage(const int32 damage) { + GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, FString::Printf(TEXT("Damage %d taken by %s"), damage, *GetClass()->GetName())); + health -= damage; if(health > 0) return; if(IsValid(manager)) - manager->UnitKill(this); + manager->OnUnitKill(this); else Destroy(); } diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.h index 84f45c8..d1652d5 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/AgeOfWar/AgeOfWarUnit.h @@ -37,35 +37,46 @@ struct FAgeOfWarUnitStats }; +UENUM(BlueprintType) +enum class UnitTeam : uint8 +{ + Player, + AI +}; + UCLASS(Blueprintable, MinimalAPI, Abstract) class AAgeOfWarUnit : public AActor { GENERATED_BODY() public: - enum class UnitTeam - { - Player, - AI - }; + AAgeOfWarUnit(); + virtual void Tick(float deltaTime) override; UFUNCTION(BlueprintPure) const FAgeOfWarUnitStats& GetStats(); - class AAgeOfWarManager* manager = nullptr; + UFUNCTION(BlueprintCallable) + void UpdateStats(); + const FAgeOfWarUnitStats* stats = nullptr; + class AAgeOfWarManager* manager = nullptr; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) UnitTeam team; protected: virtual void BeginPlay() override; virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; - virtual void Tick(float deltaTime) override; void Damage(const int32 damage); AAgeOfWarUnit* forwardUnit = nullptr; private: + UPROPERTY(EditAnywhere) + class UBoxComponent* collision; + int32 health; FTimerHandle attackTimer; double lastAttackTimestamp = 0; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadManager.cpp index 1c6a8e7..c7794e6 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/CrossyRoad/CrossyRoadManager.cpp @@ -24,13 +24,13 @@ ACrossyRoadManager::ACrossyRoadManager() auto root = CreateDefaultSubobject(TEXT("Scene")); playerPos = CreateDefaultSubobject(TEXT("PlayerPos")); - playerPos->AttachToComponent(root, FAttachmentTransformRules::KeepRelativeTransform); + playerPos->SetupAttachment(root); camera = CreateDefaultSubobject(TEXT("Camera")); - camera->AttachToComponent(root, FAttachmentTransformRules::KeepRelativeTransform); + camera->SetupAttachment(root); mannequin = CreateDefaultSubobject(TEXT("Mannequin")); - mannequin->AttachToComponent(root, FAttachmentTransformRules::KeepRelativeTransform); + mannequin->SetupAttachment(root); } void ACrossyRoadManager::Start(APlayerBase* playerPawn, FMinigameEndCallback delegate) diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfManager.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfManager.cpp index 16b8f00..9b0746a 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfManager.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Minigame/SubwaySurf/SubwaySurfManager.cpp @@ -24,13 +24,13 @@ ASubwaySurfManager::ASubwaySurfManager() auto root = CreateDefaultSubobject(TEXT("Scene")); playerPos = CreateDefaultSubobject(TEXT("PlayerPos")); - playerPos->AttachToComponent(root, FAttachmentTransformRules::KeepRelativeTransform); + playerPos->SetupAttachment(root); camera = CreateDefaultSubobject(TEXT("Camera")); - camera->AttachToComponent(root, FAttachmentTransformRules::KeepRelativeTransform); + camera->SetupAttachment(root); mannequin = CreateDefaultSubobject(TEXT("Mannequin")); - mannequin->AttachToComponent(root, FAttachmentTransformRules::KeepRelativeTransform); + mannequin->SetupAttachment(root); } void ASubwaySurfManager::Start(APlayerBase* playerPawn, FMinigameEndCallback delegate)