Implemented Game Combat
This commit is contained in:
parent
10ca9843a2
commit
d02f832733
@ -7,3 +7,5 @@ bReplaceBlueprintWithClass= true
|
||||
bDontLoadBlueprintOutsideEditor= true
|
||||
bBlueprintIsNotBlueprintType= true
|
||||
|
||||
[/Script/AdvancedPreviewScene.SharedProfiles]
|
||||
|
||||
|
@ -1,7 +1,17 @@
|
||||
[/Script/EngineSettings.GameMapsSettings]
|
||||
GameDefaultMap=/Game/Main.Main
|
||||
EditorStartupMap=/Game/Main.Main
|
||||
GlobalDefaultGameMode="/Script/COMP250_1_2101327_AI.COMP250_1_2101327_AIGameMode"
|
||||
LocalMapOptions=
|
||||
TransitionMap=None
|
||||
bUseSplitscreen=True
|
||||
TwoPlayerSplitscreenLayout=Horizontal
|
||||
ThreePlayerSplitscreenLayout=FavorTop
|
||||
FourPlayerSplitscreenLayout=Grid
|
||||
bOffsetPlayerGamepadIds=False
|
||||
GameInstanceClass=/Script/Engine.GameInstance
|
||||
GameDefaultMap=/Game/Main.Main
|
||||
ServerDefaultMap=/Engine/Maps/Entry.Entry
|
||||
GlobalDefaultGameMode=/Game/Blueprints/BP_DefaultGM.BP_DefaultGM_C
|
||||
GlobalDefaultServerGameMode=None
|
||||
|
||||
[/Script/Engine.RendererSettings]
|
||||
r.ReflectionMethod=1
|
||||
|
BIN
COMP250_1_2101327_AI/Content/Blueprints/BP_DefaultGM.uasset
(Stored with Git LFS)
Normal file
BIN
COMP250_1_2101327_AI/Content/Blueprints/BP_DefaultGM.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Blueprints/BP_Enemy.uasset
(Stored with Git LFS)
Normal file
BIN
COMP250_1_2101327_AI/Content/Blueprints/BP_Enemy.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Blueprints/BP_PlayerCharacter.uasset
(Stored with Git LFS)
Normal file
BIN
COMP250_1_2101327_AI/Content/Blueprints/BP_PlayerCharacter.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Blueprints/Combat_UI/BP_TurnBaseCombatV2.uasset
(Stored with Git LFS)
BIN
COMP250_1_2101327_AI/Content/Blueprints/Combat_UI/BP_TurnBaseCombatV2.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Blueprints/Combat_UI/Combat_UI.uasset
(Stored with Git LFS)
BIN
COMP250_1_2101327_AI/Content/Blueprints/Combat_UI/Combat_UI.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Blueprints/StatusEffects/BP_DamageOverTime.uasset
(Stored with Git LFS)
BIN
COMP250_1_2101327_AI/Content/Blueprints/StatusEffects/BP_DamageOverTime.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Blueprints/StatusEffects/BP_HealOverTime.uasset
(Stored with Git LFS)
BIN
COMP250_1_2101327_AI/Content/Blueprints/StatusEffects/BP_HealOverTime.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Blueprints/StatusEffects/BP_Thorns.uasset
(Stored with Git LFS)
BIN
COMP250_1_2101327_AI/Content/Blueprints/StatusEffects/BP_Thorns.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Blueprints/Status_UI/StatusIcon.uasset
(Stored with Git LFS)
Normal file
BIN
COMP250_1_2101327_AI/Content/Blueprints/Status_UI/StatusIcon.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Blueprints/Status_UI/StatusIndicator.uasset
(Stored with Git LFS)
Normal file
BIN
COMP250_1_2101327_AI/Content/Blueprints/Status_UI/StatusIndicator.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Fonts/Hachicro.uasset
(Stored with Git LFS)
BIN
COMP250_1_2101327_AI/Content/Fonts/Hachicro.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Fonts/Hachicro_Font.uasset
(Stored with Git LFS)
BIN
COMP250_1_2101327_AI/Content/Fonts/Hachicro_Font.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/MSPresets/MSTextures/Black.uasset
(Stored with Git LFS)
Normal file
BIN
COMP250_1_2101327_AI/Content/MSPresets/MSTextures/Black.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/Main.umap
(Stored with Git LFS)
BIN
COMP250_1_2101327_AI/Content/Main.umap
(Stored with Git LFS)
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/StarterContent/Architecture/Floor_400x400.uasset
(Stored with Git LFS)
BIN
COMP250_1_2101327_AI/Content/StarterContent/Architecture/Floor_400x400.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
COMP250_1_2101327_AI/Content/StarterContent/Particles/P_Ambient_Dust.uasset
(Stored with Git LFS)
BIN
COMP250_1_2101327_AI/Content/StarterContent/Particles/P_Ambient_Dust.uasset
(Stored with Git LFS)
Binary file not shown.
@ -23,6 +23,7 @@ class ACOMP250_1_2101327_AICharacter : public ACharacter
|
||||
|
||||
/** MappingContext */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
// ReSharper disable once UnrealHeaderToolError
|
||||
class UInputMappingContext* DefaultMappingContext;
|
||||
|
||||
/** Jump Input Action */
|
||||
|
@ -0,0 +1,35 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "GOAPAgent.h"
|
||||
|
||||
|
||||
// Sets default values for this component's properties
|
||||
UGOAPAgent::UGOAPAgent()
|
||||
{
|
||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
||||
// off to improve performance if you don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
||||
// Called when the game starts
|
||||
void UGOAPAgent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
// ...
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Called every frame
|
||||
void UGOAPAgent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "GOAPAgent.generated.h"
|
||||
|
||||
|
||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||
class COMP250_1_2101327_AI_API UGOAPAgent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UGOAPAgent();
|
||||
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
};
|
@ -34,23 +34,23 @@ ATurnBaseCombatV2::ATurnBaseCombatV2()
|
||||
void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
|
||||
{
|
||||
if (Enemy == nullptr) return;
|
||||
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
|
||||
//UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
|
||||
|
||||
if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return;
|
||||
EnemyBlackboard->SetValueAsBool("IsInCombat", true);
|
||||
//if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return;
|
||||
//EnemyBlackboard->SetValueAsBool("IsInCombat", true);
|
||||
FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health"));
|
||||
int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy);
|
||||
EnemyHealth = EnemyHealthPtr;
|
||||
|
||||
if (EnemyBlackboard->GetValueAsBool("Sight"))
|
||||
{
|
||||
//bEnemyHasExtraTurn = true;
|
||||
SwitchTurn();
|
||||
}
|
||||
else
|
||||
{
|
||||
bPlayerHasExtraTurn = true;
|
||||
}
|
||||
// if (EnemyBlackboard->GetValueAsBool("Sight"))
|
||||
// {
|
||||
// //bEnemyHasExtraTurn = true;
|
||||
// SwitchTurn();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// bPlayerHasExtraTurn = true;
|
||||
// }
|
||||
|
||||
if (HUD->IsInViewport()) return;
|
||||
HUD->AddToViewport();
|
||||
@ -71,11 +71,11 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
|
||||
PlayerController->SetInputMode(FInputModeUIOnly());
|
||||
PlayerController->bShowMouseCursor = true;
|
||||
|
||||
FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation();
|
||||
Direction.Normalize();
|
||||
FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
|
||||
LookAtRotation.Pitch = -9.0f;
|
||||
PlayerController->SetControlRotation(LookAtRotation);
|
||||
// FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation();
|
||||
// Direction.Normalize();
|
||||
// FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
|
||||
// LookAtRotation.Pitch = -9.0f;
|
||||
// PlayerController->SetControlRotation(LookAtRotation);
|
||||
|
||||
//DrawDebugPoint(GetWorld(), Enemy->GetActorLocation(), 10, FColor::Red, false, 10);
|
||||
|
||||
@ -152,14 +152,20 @@ void ATurnBaseCombatV2::BeginPlay()
|
||||
AButton = Cast<UButton>(HUD->GetWidgetFromName("AButton"));
|
||||
IButton = Cast<UButton>(HUD->GetWidgetFromName("IButton"));
|
||||
BackspaceButton = Cast<UButton>(HUD->GetWidgetFromName("BackspaceButton"));
|
||||
RunButton = Cast<UButton>(HUD->GetWidgetFromName("RunButton"));
|
||||
//RunButton = Cast<UButton>(HUD->GetWidgetFromName("RunButton"));
|
||||
CastButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::CastButtonOnClick);
|
||||
PButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::PButtonOnClick);
|
||||
EButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::EButtonOnClick);
|
||||
AButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::AButtonOnClick);
|
||||
IButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::IButtonOnClick);
|
||||
BackspaceButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::BackspaceButtonOnClick);
|
||||
RunButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::RunButtonOnClick);
|
||||
//RunButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::RunButtonOnClick);
|
||||
|
||||
UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), AActor::StaticClass(), FName("Enemy"), AllCharacterActorsInScene);
|
||||
for (AActor* Actor : AllCharacterActorsInScene)
|
||||
{
|
||||
StartCombat(Actor);
|
||||
}
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::ExecuteCast(FString Combo)
|
||||
@ -212,12 +218,12 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
|
||||
}
|
||||
}
|
||||
|
||||
if (GunEffect)
|
||||
{
|
||||
const UStaticMeshComponent* GunComponent = Cast<UStaticMeshComponent>(PlayerActor->GetComponentsByTag(UPrimitiveComponent::StaticClass(), FName("Gun"))[0]);
|
||||
const FVector GunLocationOffset = GunComponent->GetSocketTransform("Muzzle").TransformPosition(FVector(-100, 0, 0));
|
||||
UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), GunEffect, GunLocationOffset, PlayerActor->GetActorRotation());
|
||||
}
|
||||
// if (GunEffect)
|
||||
// {
|
||||
// const UStaticMeshComponent* GunComponent = Cast<UStaticMeshComponent>(PlayerActor->GetComponentsByTag(UPrimitiveComponent::StaticClass(), FName("Gun"))[0]);
|
||||
// const FVector GunLocationOffset = GunComponent->GetSocketTransform("Muzzle").TransformPosition(FVector(-100, 0, 0));
|
||||
// UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), GunEffect, GunLocationOffset, PlayerActor->GetActorRotation());
|
||||
// }
|
||||
|
||||
CurrentComboString = "";
|
||||
UpdateComboString(CurrentComboString);
|
||||
@ -434,13 +440,13 @@ void ATurnBaseCombatV2::BackspaceButtonOnClick()
|
||||
UpdateResourceBars();
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::RunButtonOnClick()
|
||||
{
|
||||
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent();
|
||||
|
||||
EnemyBlackboard->SetValueAsBool("IsInCombat", false);
|
||||
EndCombat();
|
||||
}
|
||||
// void ATurnBaseCombatV2::RunButtonOnClick()
|
||||
// {
|
||||
// UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent();
|
||||
//
|
||||
// EnemyBlackboard->SetValueAsBool("IsInCombat", false);
|
||||
// EndCombat();
|
||||
// }
|
||||
|
||||
void ATurnBaseCombatV2::UpdateComboString(FString NewCombo) const
|
||||
{
|
||||
@ -489,7 +495,7 @@ void ATurnBaseCombatV2::ToggleButtons() const
|
||||
IButton->SetIsEnabled(!IButton->GetIsEnabled());
|
||||
BackspaceButton->SetIsEnabled(!BackspaceButton->GetIsEnabled());
|
||||
CastButton->SetIsEnabled(!CastButton->GetIsEnabled());
|
||||
RunButton->SetIsEnabled(!RunButton->GetIsEnabled());
|
||||
//RunButton->SetIsEnabled(!RunButton->GetIsEnabled());
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::EnemyTurn()
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "StatusEffects/Thorns.h"
|
||||
#include "TurnBaseCombatV2.generated.h"
|
||||
|
||||
class UNiagaraSystem;
|
||||
//class UNiagaraSystem;
|
||||
|
||||
UCLASS()
|
||||
class COMP250_1_2101327_AI_API ATurnBaseCombatV2 : public AGameStateBase
|
||||
@ -192,8 +192,8 @@ private:
|
||||
|
||||
UFUNCTION()
|
||||
void BackspaceButtonOnClick();
|
||||
UFUNCTION()
|
||||
void RunButtonOnClick();
|
||||
//UFUNCTION()
|
||||
//void RunButtonOnClick();
|
||||
|
||||
void UpdateComboString(FString NewCombo) const;
|
||||
void UpdateActionPoints() const;
|
||||
|
Loading…
Reference in New Issue
Block a user