parent
71fd6242fe
commit
422b1439e5
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,63 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "Components/Button.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "BattleUI.h"
|
||||
#include "BattlePlayerController.h"
|
||||
#include "BattlePlayerState.h"
|
||||
|
||||
|
||||
void UBattleUI::NativeConstruct() {
|
||||
Super::NativeConstruct();
|
||||
EndTurnButton->OnClicked.AddDynamic(this, &ThisClass::OnEndTurnClicked);
|
||||
ButtonAction_0->OnClicked.AddDynamic(this, &ThisClass::OnActionSwitched_0);
|
||||
ButtonAction_1->OnClicked.AddDynamic(this, &ThisClass::OnActionSwitched_1);
|
||||
ButtonAction_2->OnClicked.AddDynamic(this, &ThisClass::OnActionSwitched_2);
|
||||
}
|
||||
|
||||
void UBattleUI::SetWidgetText_Implementation(const FString &Text) {
|
||||
InformationText->SetText(FText::FromString(Text));
|
||||
}
|
||||
|
||||
void UBattleUI::SetWhoseTurnText_Implementation(bool IsThisPlayerTurn) {
|
||||
if (IsThisPlayerTurn) {
|
||||
SetWidgetText(TEXT("Your turn!"));
|
||||
} else {
|
||||
SetWidgetText(TEXT("Opponent's turn"));
|
||||
}
|
||||
}
|
||||
|
||||
void UBattleUI::OnEndTurnClicked() {
|
||||
Cast<ABattlePlayerController>(GetWorld()->GetFirstPlayerController())->
|
||||
EndTurn();
|
||||
}
|
||||
|
||||
void UBattleUI::OnActionSwitched_0() {
|
||||
ButtonAction_0->SetIsEnabled(false);
|
||||
ButtonAction_1->SetIsEnabled(true);
|
||||
ButtonAction_2->SetIsEnabled(true);
|
||||
ActionType = 0;
|
||||
OnActionSwitched();
|
||||
}
|
||||
|
||||
void UBattleUI::OnActionSwitched_1() {
|
||||
ButtonAction_0->SetIsEnabled(true);
|
||||
ButtonAction_1->SetIsEnabled(false);
|
||||
ButtonAction_2->SetIsEnabled(true);
|
||||
ActionType = 1;
|
||||
OnActionSwitched();
|
||||
}
|
||||
|
||||
void UBattleUI::OnActionSwitched_2() {
|
||||
ButtonAction_0->SetIsEnabled(true);
|
||||
ButtonAction_1->SetIsEnabled(true);
|
||||
ButtonAction_2->SetIsEnabled(false);
|
||||
ActionType = 2;
|
||||
OnActionSwitched();
|
||||
}
|
||||
|
||||
void UBattleUI::OnActionSwitched() const {
|
||||
Cast<ABattlePlayerController>(GetWorld()->GetFirstPlayerController())->
|
||||
GetPlayerState<ABattlePlayerState>()->SetCurrentAction(ActionType);
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "BattleUI.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class TURNBASEDTUTORIAL_API UBattleUI : public UUserWidget {
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
UFUNCTION(Client, Reliable)
|
||||
void SetWhoseTurnText(bool IsThisPlayerTurn);
|
||||
|
||||
UFUNCTION(Client, Reliable)
|
||||
void SetWidgetText(const FString &Text);
|
||||
|
||||
protected:
|
||||
int ActionType = 0;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UButton *EndTurnButton;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UButton *ButtonAction_0;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UButton *ButtonAction_1;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UButton *ButtonAction_2;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UTextBlock *InformationText;
|
||||
|
||||
UFUNCTION()
|
||||
void OnEndTurnClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void OnActionSwitched_0();
|
||||
|
||||
UFUNCTION()
|
||||
void OnActionSwitched_1();
|
||||
|
||||
UFUNCTION()
|
||||
void OnActionSwitched_2();
|
||||
|
||||
UFUNCTION()
|
||||
void OnActionSwitched() const;
|
||||
|
||||
};
|
@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "ManageSquadWidget.h"
|
||||
#include "Components/Button.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
|
||||
void UManageSquadWidget::NativeConstruct() {
|
||||
Super::NativeConstruct();
|
||||
BackButton->OnClicked.AddDynamic(
|
||||
this, &ThisClass::UManageSquadWidget::OnBackButtonClicked);
|
||||
}
|
||||
|
||||
void UManageSquadWidget::OnBackButtonClicked() {
|
||||
UGameplayStatics::OpenLevel(GetWorld(), "MainMenuLevel");
|
||||
RemoveFromParent();
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "ManageSquadWidget.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class TURNBASEDTUTORIAL_API UManageSquadWidget : public UUserWidget {
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UButton *BackButton;
|
||||
|
||||
UFUNCTION()
|
||||
void OnBackButtonClicked();
|
||||
};
|
Loading…
Reference in new issue