Added Steal Functionality
This commit is contained in:
parent
50edc1aa0a
commit
4639a4d1ac
@ -135,6 +135,8 @@ void ATurnBaseCombatV2::BeginPlay()
|
||||
AButton = Cast<UButton>(HUD->GetWidgetFromName("AButton"));
|
||||
IButton = Cast<UButton>(HUD->GetWidgetFromName("IButton"));
|
||||
BackspaceButton = Cast<UButton>(HUD->GetWidgetFromName("BackspaceButton"));
|
||||
StealButton = Cast<UButton>(HUD->GetWidgetFromName("StealButton"));
|
||||
StealButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::StealButtonOnClick);
|
||||
CastButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::CastButtonOnClick);
|
||||
PButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::PButtonOnClick);
|
||||
EButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::EButtonOnClick);
|
||||
@ -210,7 +212,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
|
||||
{
|
||||
case true:
|
||||
// Player Turn
|
||||
DamageEnemy(*ValidCombos.Find(Combo));
|
||||
DamageEnemy(*ValidCombos.Find(Combo), Combo);
|
||||
OnPlayerTurn.Broadcast(PlayerActor, EnemyActor);
|
||||
break;
|
||||
case false:
|
||||
@ -522,5 +524,43 @@ void ATurnBaseCombatV2::UpdateActionPlanWidget()
|
||||
|
||||
void ATurnBaseCombatV2::ClearActionPlanWidget()
|
||||
{
|
||||
return;
|
||||
for (UUserWidget* ActionWidget : ActionPlanWidgets)
|
||||
{
|
||||
ActionPlanWrapBox->RemoveChild(ActionWidget);
|
||||
}
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::StealButtonOnClick()
|
||||
{
|
||||
StealButton->SetIsEnabled(false);
|
||||
ClearActionPlanWidget();
|
||||
TArray<int*> Resources = {&EnemyProbertiumResource, &EnemyEisResource, &EnemyAzosResource, &EnemyIroquoidResource};
|
||||
Resources.Sort([](const int& A, const int& B) { return A > B; });
|
||||
for (int* Resource : Resources)
|
||||
{
|
||||
if (*Resource > 0)
|
||||
{
|
||||
*Resource -= 1;
|
||||
if (Resource == &EnemyProbertiumResource)
|
||||
{
|
||||
ProbertiumResource += 1;
|
||||
}
|
||||
else if (Resource == &EnemyEisResource)
|
||||
{
|
||||
EisResource += 1;
|
||||
}
|
||||
else if (Resource == &EnemyAzosResource)
|
||||
{
|
||||
AzosResource += 1;
|
||||
}
|
||||
else if (Resource == &EnemyIroquoidResource)
|
||||
{
|
||||
IroquoidResource += 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
UpdateResourceBars();
|
||||
EnemyActionPlan = EnemyGOAPAgent->Plan(GetWorldState(), EnemyGOAPAgent->Goals);
|
||||
UpdateActionPlanWidget();
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ private:
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UButton* BackspaceButton;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UButton* RunButton;
|
||||
UButton* StealButton;
|
||||
|
||||
UFUNCTION()
|
||||
void CastButtonOnClick();
|
||||
@ -244,4 +244,6 @@ private:
|
||||
void UpdateActionPlanWidget();
|
||||
UFUNCTION()
|
||||
void ClearActionPlanWidget();
|
||||
UFUNCTION()
|
||||
void StealButtonOnClick();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user