完善战斗开始等待时间

This commit is contained in:
997146918 2025-09-09 16:13:56 +08:00
parent 5023885530
commit 9363b2b09d
16 changed files with 49 additions and 5 deletions

View File

@ -2,7 +2,7 @@
"BuildId": "37670630", "BuildId": "37670630",
"Modules": "Modules":
{ {
"ProjectFish": "UnrealEditor-ProjectFish.dll", "ProjectFish": "UnrealEditor-ProjectFish-0001.dll",
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor.dll" "ProjectFishEditor": "UnrealEditor-ProjectFishEditor-0001.dll"
} }
} }

View File

@ -3,6 +3,7 @@
#include "ProjectFishGameMode.h" #include "ProjectFishGameMode.h"
#include "ProjectFishPlayerController.h" #include "ProjectFishPlayerController.h"
#include "ProjectFishCharacter.h" #include "ProjectFishCharacter.h"
#include "Settings/GameConfigSettings.h"
#include "UObject/ConstructorHelpers.h" #include "UObject/ConstructorHelpers.h"
AProjectFishGameMode::AProjectFishGameMode() AProjectFishGameMode::AProjectFishGameMode()
@ -23,4 +24,22 @@ AProjectFishGameMode::AProjectFishGameMode()
{ {
PlayerControllerClass = PlayerControllerBPClass.Class; PlayerControllerClass = PlayerControllerBPClass.Class;
} }
}
void AProjectFishGameMode::BeginPlay()
{
Super::BeginPlay();
const UGameConfigSettings* ConfigSettings = GetDefault<UGameConfigSettings>();
FTimerHandle FishingTimerHandle;
GetWorld()->GetTimerManager().SetTimer(FishingTimerHandle, [this]()
{
this->bBattleIsBegin = true;
}, ConfigSettings->BattaleWatingTime, false);
}
bool AProjectFishGameMode::GetBattleIsBegin() const
{
return bBattleIsBegin;
} }

View File

@ -13,6 +13,13 @@ class AProjectFishGameMode : public AGameModeBase
public: public:
AProjectFishGameMode(); AProjectFishGameMode();
virtual void BeginPlay() override;
bool GetBattleIsBegin() const;
private:
bool bBattleIsBegin = false;
}; };

View File

@ -22,5 +22,7 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, config) UPROPERTY(EditAnywhere, BlueprintReadOnly, config)
float MaxWaitingTime; float MaxWaitingTime;
UPROPERTY(EditAnywhere, BlueprintReadOnly, config)
float BattaleWatingTime = 1.0f;
virtual FName GetCategoryName() const override; virtual FName GetCategoryName() const override;
}; };

View File

@ -3,9 +3,16 @@
#include "SkillManager.h" #include "SkillManager.h"
#include "Skill.h" #include "Skill.h"
#include "Kismet/GameplayStatics.h"
#include "ProjectFish/ProjectFishGameMode.h"
#include "ProjectFish/DataAsset/BagConfigAsset.h" #include "ProjectFish/DataAsset/BagConfigAsset.h"
#include "ProjectFish/DataAsset/BagShapeAsset.h" #include "ProjectFish/DataAsset/BagShapeAsset.h"
USkillManager::USkillManager()
{
}
void USkillManager::Tick(float DeltaTime) void USkillManager::Tick(float DeltaTime)
{ {
for (auto Skill : Skills) for (auto Skill : Skills)
@ -16,7 +23,7 @@ void USkillManager::Tick(float DeltaTime)
bool USkillManager::IsTickable() const bool USkillManager::IsTickable() const
{ {
return !bGameEnd; return !bGameEnd && IsValid(GameMode) && GameMode->GetBattleIsBegin();
} }
TStatId USkillManager::GetStatId() const TStatId USkillManager::GetStatId() const
@ -26,6 +33,10 @@ TStatId USkillManager::GetStatId() const
void USkillManager::AddPawn(class APawnWithSkill* Pawn, FIntPoint BagSize) void USkillManager::AddPawn(class APawnWithSkill* Pawn, FIntPoint BagSize)
{ {
if (!IsValid(GameMode))
{
GameMode = Cast<AProjectFishGameMode>(UGameplayStatics::GetGameMode(this));
}
PawnInfo.Add(Pawn, BagSize); PawnInfo.Add(Pawn, BagSize);
TMap<FIntPoint, int32> states; TMap<FIntPoint, int32> states;
for (int y = 0; y < BagSize.Y; y++) for (int y = 0; y < BagSize.Y; y++)

View File

@ -16,6 +16,8 @@ class PROJECTFISH_API USkillManager : public UObject, public FTickableGameObject
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
USkillManager();
virtual void Tick(float DeltaTime) override; virtual void Tick(float DeltaTime) override;
virtual bool IsTickable() const override; virtual bool IsTickable() const override;
virtual TStatId GetStatId() const override; virtual TStatId GetStatId() const override;
@ -72,6 +74,9 @@ protected:
bool bGameEnd = false; bool bGameEnd = false;
TMap<APawnWithSkill*, TMap<FIntPoint, int32>> PawnBagState; TMap<APawnWithSkill*, TMap<FIntPoint, int32>> PawnBagState;
private:
class AProjectFishGameMode* GameMode;
}; };