Fishing, RythmClick minigames, bugfixes

This commit is contained in:
Oleg Petruny 2024-09-21 22:01:25 +02:00
parent 9c03eee1d5
commit 7c1610534c
65 changed files with 348 additions and 72 deletions

Binary file not shown.

BIN
Content/Audio/Music/Minigames/SW_Minigame_RythmClick.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Input/Minigame/Actions/IA_Minigame_Fishing.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Input/Minigame/IMC_Minigame_Fishing.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Input/Minigame/IMC_Minigame_SubwaySurf.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

BIN
Content/Levels/Test/Actors/Minigame/BP_Test_AgeOfWar.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

BIN
Content/Levels/Test/L_Test.umap (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -29,9 +29,9 @@ UCutsceneManager::UCutsceneManager()
}
}
void UCutsceneManager::EnqueueSequence(TSoftObjectPtr<class ULevelSequence> sequence, FCutsceneEndCallback endCallback)
void UCutsceneManager::EnqueueSequence(ULevelSequence* sequence, FCutsceneEndCallback endCallback)
{
if(!sequence.LoadSynchronous())
if(!sequence)
return;
FScopeLock lock1(&_sequencesLock);
@ -81,9 +81,9 @@ void UCutsceneManager::PlayNextSequence()
FScopeLock lock(&_sequencesLock);
TSoftObjectPtr<ULevelSequence> sequence;
ULevelSequence* sequence;
_nextSequences.Dequeue(sequence);
_sequencePlayer = ULevelSequencePlayer::CreateLevelSequencePlayer(GetWorld(), sequence.LoadSynchronous(), FMovieSceneSequencePlaybackSettings{}, _sequencePlayerActor);
_sequencePlayer = ULevelSequencePlayer::CreateLevelSequencePlayer(GetWorld(), sequence, FMovieSceneSequencePlaybackSettings{}, _sequencePlayerActor);
_sequencePlayer->OnStop.AddDynamic(this, &UCutsceneManager::OnSequenceEnd);
_sequencePlayer->Play();
}

View File

@ -17,7 +17,7 @@ public:
UCutsceneManager();
UFUNCTION(BlueprintCallable)
void EnqueueSequence(TSoftObjectPtr<class ULevelSequence> sequence, FCutsceneEndCallback endCallback);
void EnqueueSequence(class ULevelSequence* sequence, FCutsceneEndCallback endCallback);
UFUNCTION(BlueprintCallable)
void SkipSequence();
@ -38,7 +38,7 @@ private:
class ULevelSequencePlayer* _sequencePlayer = nullptr;
class ALevelSequenceActor* _sequencePlayerActor = nullptr;
TQueue<TSoftObjectPtr<class ULevelSequence>> _nextSequences;
TQueue<class ULevelSequence*> _nextSequences;
FCriticalSection _sequencesLock;
TQueue<FCutsceneEndCallback> _endCallbacks;
FCriticalSection _callbacksLock;

View File

@ -284,5 +284,5 @@ void UInteractableScreenCapturer::Process()
running = false;
}
);
}
}
}
}

View File

@ -0,0 +1,27 @@
// Oleg Petruny proprietary.
#include "AgeOfWarManager.h"
#include "MainGameModeBase.h"
#include "PlayerBase.h"
AAgeOfWarManager::AAgeOfWarManager()
{}
void AAgeOfWarManager::Start(APlayerBase* playerPawn, FMinigameEndCallback delegate)
{
if(!playerPawn)
return;
AMinigame::Start(playerPawn, delegate);
player->LockPlayer(FPlayerLock::All());
}
void AAgeOfWarManager::End()
{
player->UnlockPlayer(FPlayerLock::All());
AMinigame::End();
}

View File

@ -0,0 +1,19 @@
// Oleg Petruny proprietary.
#pragma once
#include "Minigame/Minigame.h"
#include "AgeOfWarManager.generated.h"
UCLASS(Blueprintable, BlueprintType, MinimalAPI)
class AAgeOfWarManager : public AMinigame
{
GENERATED_BODY()
public:
AAgeOfWarManager();
virtual void Start(class APlayerBase* playerPawn, FMinigameEndCallback delegate) override;
virtual void End() override;
};

View File

@ -0,0 +1,27 @@
// Oleg Petruny proprietary.
#include "CrossyRoadManager.h"
#include "MainGameModeBase.h"
#include "PlayerBase.h"
ACrossyRoadManager::ACrossyRoadManager()
{}
void ACrossyRoadManager::Start(APlayerBase* playerPawn, FMinigameEndCallback delegate)
{
if(!playerPawn)
return;
AMinigame::Start(playerPawn, delegate);
player->LockPlayer(FPlayerLock::All());
}
void ACrossyRoadManager::End()
{
player->UnlockPlayer(FPlayerLock::All());
AMinigame::End();
}

View File

@ -0,0 +1,19 @@
// Oleg Petruny proprietary.
#pragma once
#include "Minigame/Minigame.h"
#include "CrossyRoadManager.generated.h"
UCLASS(Blueprintable, BlueprintType, MinimalAPI)
class ACrossyRoadManager : public AMinigame
{
GENERATED_BODY()
public:
ACrossyRoadManager();
virtual void Start(class APlayerBase* playerPawn, FMinigameEndCallback delegate) override;
virtual void End() override;
};

View File

@ -0,0 +1,30 @@
// Oleg Petruny proprietary.
#include "FishingManager.h"
#include "MainGameModeBase.h"
#include "PlayerBase.h"
AFishingManager::AFishingManager()
{
static ConstructorHelpers::FObjectFinder<UInputMappingContext> asset{ TEXT("/Script/EnhancedInput.InputMappingContext'/Game/Input/Minigame/IMC_Minigame_Fishing.IMC_Minigame_Fishing'") };
input = asset.Object;
}
void AFishingManager::Start(APlayerBase* playerPawn, FMinigameEndCallback delegate)
{
if(!playerPawn)
return;
AMinigame::Start(playerPawn, delegate);
player->LockPlayer(FPlayerLock::All());
}
void AFishingManager::End()
{
player->UnlockPlayer(FPlayerLock::All());
AMinigame::End();
}

View File

@ -0,0 +1,46 @@
// Oleg Petruny proprietary.
#pragma once
#include "Minigame/Minigame.h"
#include "FishingManager.generated.h"
USTRUCT(BlueprintType)
struct FFishVariation
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float difficulty;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float size;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float duration;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 price;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FLinearColor color;
};
UCLASS(Blueprintable, BlueprintType, MinimalAPI)
class AFishingManager : public AMinigame
{
GENERATED_BODY()
public:
AFishingManager();
virtual void Start(class APlayerBase* playerPawn, FMinigameEndCallback delegate) override;
virtual void End() override;
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
void CatchSucceed(int32 price);
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
void CatchFailed();
};

View File

@ -3,17 +3,24 @@
#include "Minigame.h"
#include "EnhancedInputSubsystems.h"
#include "InputMappingContext.h"
#include "PlayerBase.h"
AMinigame::AMinigame()
: AActor()
{
PrimaryActorTick.bStartWithTickEnabled = false;
PrimaryActorTick.bCanEverTick = true;
}
void AMinigame::End()
{}
{
if(callback.IsBound())
callback.Execute(result, score);
OnEnd();
}
void AMinigame::Restart()
{}
@ -23,8 +30,15 @@ UInputMappingContext* AMinigame::GetInputMappings()
return input.LoadSynchronous();
}
void AMinigame::Start(class APlayerBase* playerPawn, FMinigameEndCallback delegate)
void AMinigame::Start(APlayerBase* playerPawn, FMinigameEndCallback delegate)
{
player = playerPawn;
callback = delegate;
if(input)
if(auto PC = Cast<APlayerController>(playerPawn->GetController()))
if(auto inputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer()))
inputSubsystem->AddMappingContext(input.LoadSynchronous(), 0);
OnStart();
}

View File

@ -26,12 +26,18 @@ public:
UFUNCTION(BlueprintCallable)
virtual void Start(class APlayerBase* playerPawn, FMinigameEndCallback delegate);
UFUNCTION(BlueprintImplementableEvent)
void OnStart();
UFUNCTION(BlueprintCallable)
virtual void End();
UFUNCTION(BlueprintCallable)
virtual void Restart();
UFUNCTION(BlueprintImplementableEvent)
void OnEnd();
UFUNCTION(BlueprintPure)
class UInputMappingContext* GetInputMappings();
@ -42,6 +48,9 @@ protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 score = 0;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
EMinigameResult result = EMinigameResult::Loss;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool ended = false;

View File

@ -0,0 +1,27 @@
// Oleg Petruny proprietary.
#include "RythmClickManager.h"
#include "MainGameModeBase.h"
#include "PlayerBase.h"
ARythmClickManager::ARythmClickManager()
{}
void ARythmClickManager::Start(APlayerBase* playerPawn, FMinigameEndCallback delegate)
{
if(!playerPawn)
return;
AMinigame::Start(playerPawn, delegate);
player->LockPlayer(FPlayerLock::All());
}
void ARythmClickManager::End()
{
player->UnlockPlayer(FPlayerLock::All());
AMinigame::End();
}

View File

@ -0,0 +1,19 @@
// Oleg Petruny proprietary.
#pragma once
#include "Minigame/Minigame.h"
#include "RythmClickManager.generated.h"
UCLASS(Blueprintable, BlueprintType, MinimalAPI)
class ARythmClickManager : public AMinigame
{
GENERATED_BODY()
public:
ARythmClickManager();
virtual void Start(class APlayerBase* playerPawn, FMinigameEndCallback delegate) override;
virtual void End() override;
};

View File

@ -18,7 +18,7 @@
ASubwaySurfManager::ASubwaySurfManager()
: AMinigame()
{
static ConstructorHelpers::FObjectFinder<UInputMappingContext> asset{ TEXT("/Script/EnhancedInput.InputMappingContext'/Game/Input/Minigame/IMC_SubwaySurf.IMC_SubwaySurf'") };
static ConstructorHelpers::FObjectFinder<UInputMappingContext> asset{ TEXT("/Script/EnhancedInput.InputMappingContext'/Game/Input/Minigame/IMC_Minigame_SubwaySurf.IMC_Minigame_SubwaySurf'") };
input = asset.Object;
auto root = CreateDefaultSubobject<USceneComponent>(TEXT("Scene"));
@ -40,8 +40,6 @@ void ASubwaySurfManager::Start(APlayerBase* playerPawn, FMinigameEndCallback del
AMinigame::Start(playerPawn, delegate);
AMainGameModeBase::GetWidgetsManager()->HideInteractionHints(nullptr);
player->LockPlayer(FPlayerLock::All());
player->SwitchToView(this);
@ -70,8 +68,6 @@ void ASubwaySurfManager::End()
for(int32 handler : inputHandlers)
player->inputComponent->RemoveActionBindingForHandle(handler);
AMainGameModeBase::GetWidgetsManager()->ShowInteractionHints(nullptr);
player->UnlockPlayer(FPlayerLock::All());
player->ReturnPlayerView();
@ -91,15 +87,13 @@ void ASubwaySurfManager::Hit()
return;
}
if(callback.IsBound())
callback.Execute(EMinigameResult::Loss, score);
result = EMinigameResult::Loss;
End();
}
void ASubwaySurfManager::Finish()
{
if(callback.IsBound())
callback.Execute(EMinigameResult::Win, score);
result = EMinigameResult::Win;
End();
}

View File

@ -141,6 +141,9 @@ void APlayerBase::LockPlayer(FPlayerLock lock)
interactionLocked += lock.interaction;
cameraLocked += lock.camera;
inventoryLocked += lock.inventory;
if(interactionLocked)
ResetIntractions();
}
void APlayerBase::UnlockPlayer(FPlayerLock lock)
@ -158,6 +161,11 @@ void APlayerBase::FlyMode(bool on)
GetCharacterMovement()->GravityScale = on ? 0.0f : 1.0f;
}
void APlayerBase::ResetIntractions()
{
InteractableDeactivated(lastInteractable, static_cast<EActivatorType>(0xFF));
}
FVector APlayerBase::GetCameraDirection()
{
return camera->GetForwardVector();

View File

@ -48,6 +48,7 @@ public:
void LockPlayer(const FPlayerLock lock);
void UnlockPlayer(const FPlayerLock lock);
void FlyMode(bool on);
void ResetIntractions();
UFUNCTION(BlueprintCallable, Category = Character)
void SwitchToView(class AActor* target);