Minigame
This commit is contained in:
parent
5e8473f27f
commit
60ba66b249
@ -27,6 +27,8 @@ void ACustomPlayerController::AppendInputContext(TSoftObjectPtr<class UInputMapp
|
||||
|
||||
void ACustomPlayerController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
instance = this;
|
||||
|
||||
subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer());
|
||||
|
@ -23,9 +23,6 @@ void ALevelBase::BeginPlay()
|
||||
{
|
||||
AMainGameModeBase::leadLevel = TStrongObjectPtr<ALevelBase>{ this };
|
||||
|
||||
for(TActorIterator<AMinigame> it(GetWorld()); it; ++it)
|
||||
ACustomPlayerController::AppendInputContext(it->GetInputMappings());
|
||||
|
||||
ALevelScriptActor::BeginPlay();
|
||||
|
||||
BroadcastNewLevelBeginPlay();
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "AgeOfWarManager.h"
|
||||
|
||||
#include "Camera/CameraComponent.h"
|
||||
|
@ -1,12 +1,11 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "AgeOfWarUnit.h"
|
||||
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Components/StaticMeshComponent.h"
|
||||
|
||||
#include "AgeOfWarManager.h"
|
||||
#include <Components/BoxComponent.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "CrossyRoadManager.h"
|
||||
|
||||
#include "Camera/CameraComponent.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "CrossyRoadObstacle.h"
|
||||
|
||||
#include "CrossyRoadManager.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "FishingManager.h"
|
||||
|
||||
#include "EnhancedInputComponent.h"
|
||||
|
@ -1,11 +1,8 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "Minigame.h"
|
||||
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "InputMappingContext.h"
|
||||
|
||||
#include "CustomPlayerController.h"
|
||||
#include "PlayerBase.h"
|
||||
|
||||
AMinigame::AMinigame()
|
||||
@ -22,23 +19,13 @@ void AMinigame::End()
|
||||
OnEnd();
|
||||
}
|
||||
|
||||
void AMinigame::Restart()
|
||||
{}
|
||||
|
||||
UInputMappingContext* AMinigame::GetInputMappings()
|
||||
{
|
||||
return context.LoadSynchronous();
|
||||
}
|
||||
|
||||
void AMinigame::Start(APlayerBase* playerPawn, FMinigameEndCallback delegate)
|
||||
{
|
||||
player = playerPawn;
|
||||
callback = delegate;
|
||||
|
||||
if(context)
|
||||
if(auto PC = Cast<APlayerController>(playerPawn->GetController()))
|
||||
if(auto inputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer()))
|
||||
inputSubsystem->AddMappingContext(context.LoadSynchronous(), 0);
|
||||
if(context.IsValid())
|
||||
ACustomPlayerController::AppendInputContext(context);
|
||||
|
||||
OnStart();
|
||||
}
|
||||
|
@ -15,7 +15,14 @@ enum class EMinigameResult : uint8
|
||||
|
||||
DECLARE_DYNAMIC_DELEGATE_TwoParams(FMinigameEndCallback, EMinigameResult, result, int32, score);
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType, MinimalAPI, Abstract)
|
||||
/**
|
||||
* Interface for all minigame classes.
|
||||
* Any minigame is started/ended/restarted by executing Start()/End()/Restart() on specific instance.
|
||||
* Each call is after broadcasted into a blueprint event also.
|
||||
* On start the caller can pass a OnEndCallback delegate to receive result and score on a minigame end.
|
||||
* Each minigame can have its own contextInput
|
||||
*/
|
||||
UCLASS(Abstract, Blueprintable, BlueprintType, MinimalAPI)
|
||||
class AMinigame : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
@ -25,21 +32,21 @@ 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(BlueprintCallable)
|
||||
virtual void Restart() {}
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void OnRestart();
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
class UInputMappingContext* GetInputMappings();
|
||||
TSoftObjectPtr<class UInputMappingContext> GetInputMappings() { return context; }
|
||||
|
||||
protected:
|
||||
FMinigameEndCallback callback;
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "RythmClickManager.h"
|
||||
|
||||
#include "MainGameModeBase.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "SubwaySurfManager.h"
|
||||
|
||||
#include "Camera/CameraComponent.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "SubwaySurfObstacle.h"
|
||||
|
||||
#include "SubwaySurfManager.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "AutohideWidget.h"
|
||||
|
||||
#include "Animation/WidgetAnimation.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "DialogueRowWidgetManager.h"
|
||||
|
||||
#include "Blueprint/WidgetTree.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "InteractableHintWidgetManager.h"
|
||||
|
||||
#include "Blueprint/WidgetTree.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "JournalWidget.h"
|
||||
|
||||
#include "Blueprint/WidgetTree.h"
|
||||
|
@ -1,5 +1,4 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "MainMenuButtonWidget.h"
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "MainMenuWidget.h"
|
||||
|
||||
#include "Animation/WidgetAnimation.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "QuickTimeEventWidget.h"
|
||||
|
||||
#include "Animation/WidgetAnimation.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "QuickTimeEventWidgetManager.h"
|
||||
|
||||
#include "Animation/UMGSequencePlayer.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "ResolutionResponsiveUserWidget.h"
|
||||
|
||||
#include "Components/PanelSlot.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "WidgetsManager.h"
|
||||
|
||||
#include "Blueprint/UserWidget.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Oleg Petruny proprietary.
|
||||
|
||||
|
||||
#include "WorldDilationResponsiveUserWidget.h"
|
||||
|
||||
#include "Animation/UMGSequencePlayer.h"
|
||||
|
Loading…
Reference in New Issue
Block a user