From c5d77baa69d513e9a23ae825da7f24205d222ff0 Mon Sep 17 00:00:00 2001 From: Jers Date: Mon, 29 Jan 2024 13:44:47 -0600 Subject: [PATCH] refactored party members into uobjects --- Content/Blueprints/BP_GameState.uasset | 4 +- Content/Blueprints/BP_PlayerController.uasset | 4 +- .../Blueprints/Editor/EW_PartyManager.uasset | 3 + .../PartyManager/EW_PartyManager.uasset | 3 + Content/Blueprints/Loot/BP_UnitLoot.uasset | 4 +- .../UI/BattleUI/WBP_BattleUI.uasset | 4 +- .../UI/MainMenu/WBP_MainMenu.uasset | 4 +- .../UI/PreBattle/WBP_Prebattle.uasset | 4 +- .../UI/PreBattle/WBP_UnitCard.uasset | 4 +- .../Blueprints/Units/Common/BP_Unit.uasset | 4 +- Content/Levels/MainMenu.umap | 4 +- Source/SpaceBattler/Private/PartyMember.cpp | 60 +++++++- .../SpaceBattler/Private/PartySubsystem.cpp | 132 ++++-------------- .../SpaceBattler/Private/SelectedUpgrade.cpp | 4 + Source/SpaceBattler/Private/Unit.cpp | 34 +++++ Source/SpaceBattler/Private/UnitUpgrade.cpp | 9 ++ Source/SpaceBattler/Private/Upgrade.cpp | 9 ++ .../SpaceBattler/Private/UpgradeSubsystem.cpp | 30 ++++ Source/SpaceBattler/Public/PartyMember.h | 29 +++- Source/SpaceBattler/Public/PartySubsystem.h | 46 +----- Source/SpaceBattler/Public/SelectedUpgrade.h | 22 +++ Source/SpaceBattler/Public/Unit.h | 63 +++++++++ Source/SpaceBattler/Public/UnitInfo.h | 3 + Source/SpaceBattler/Public/UnitUpgrade.h | 20 +++ Source/SpaceBattler/Public/Upgrade.h | 32 +++++ Source/SpaceBattler/Public/UpgradeSubsystem.h | 32 +++++ 26 files changed, 394 insertions(+), 173 deletions(-) create mode 100644 Content/Blueprints/Editor/EW_PartyManager.uasset create mode 100644 Content/Blueprints/Editor/PartyManager/EW_PartyManager.uasset create mode 100644 Source/SpaceBattler/Private/SelectedUpgrade.cpp create mode 100644 Source/SpaceBattler/Private/Unit.cpp create mode 100644 Source/SpaceBattler/Private/UnitUpgrade.cpp create mode 100644 Source/SpaceBattler/Private/Upgrade.cpp create mode 100644 Source/SpaceBattler/Private/UpgradeSubsystem.cpp create mode 100644 Source/SpaceBattler/Public/SelectedUpgrade.h create mode 100644 Source/SpaceBattler/Public/Unit.h create mode 100644 Source/SpaceBattler/Public/UnitUpgrade.h create mode 100644 Source/SpaceBattler/Public/Upgrade.h create mode 100644 Source/SpaceBattler/Public/UpgradeSubsystem.h diff --git a/Content/Blueprints/BP_GameState.uasset b/Content/Blueprints/BP_GameState.uasset index c1a4ddd..ad591aa 100644 --- a/Content/Blueprints/BP_GameState.uasset +++ b/Content/Blueprints/BP_GameState.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c826661034f5674a5570dfad12117a0221515c6904988bb36635f9011e06982f -size 285554 +oid sha256:a83b60ef4fd89ba94612f7ec1aa5996798ce42ae41e134b81297b1b1b117eccf +size 294615 diff --git a/Content/Blueprints/BP_PlayerController.uasset b/Content/Blueprints/BP_PlayerController.uasset index 7997752..dc37a1c 100644 --- a/Content/Blueprints/BP_PlayerController.uasset +++ b/Content/Blueprints/BP_PlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:917a48772af40e057ce74c69e7c20c4c5497f3bb733b15de7ef824c9043431c5 -size 516768 +oid sha256:9958042a5a23ddec02118f01ebce8f8c6814325d07fa66c07646a84baf2119e6 +size 498093 diff --git a/Content/Blueprints/Editor/EW_PartyManager.uasset b/Content/Blueprints/Editor/EW_PartyManager.uasset new file mode 100644 index 0000000..d080215 --- /dev/null +++ b/Content/Blueprints/Editor/EW_PartyManager.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad32d38e19e691887f2c62c2ba34f54d09d29467a30928c077323285d3994a02 +size 2584 diff --git a/Content/Blueprints/Editor/PartyManager/EW_PartyManager.uasset b/Content/Blueprints/Editor/PartyManager/EW_PartyManager.uasset new file mode 100644 index 0000000..09306c5 --- /dev/null +++ b/Content/Blueprints/Editor/PartyManager/EW_PartyManager.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b4e31cbc57642353bf45383c9533a50a28dd7cc07691c06fce6023834b5316ac +size 66410 diff --git a/Content/Blueprints/Loot/BP_UnitLoot.uasset b/Content/Blueprints/Loot/BP_UnitLoot.uasset index 3c6fde3..4e3beec 100644 --- a/Content/Blueprints/Loot/BP_UnitLoot.uasset +++ b/Content/Blueprints/Loot/BP_UnitLoot.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1661be48ba76cf36e7614a8e8a95cecde1dea962a75b282e4197724d9443726c -size 42884 +oid sha256:4d0af9d39cb48bb63f3f2091f858afe358d719fdb966337474a34196cb739b00 +size 45257 diff --git a/Content/Blueprints/UI/BattleUI/WBP_BattleUI.uasset b/Content/Blueprints/UI/BattleUI/WBP_BattleUI.uasset index d9200d0..9e76bdc 100644 --- a/Content/Blueprints/UI/BattleUI/WBP_BattleUI.uasset +++ b/Content/Blueprints/UI/BattleUI/WBP_BattleUI.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:691aa1204cbbbd7ec0e6e4c3ff009de335788261afacc017e07d8a49e5d1b989 -size 318521 +oid sha256:70605d242e0bcdc3f4cef1f50fb121f1e7540bd81c38f8fd36731ad47e6d47f5 +size 316634 diff --git a/Content/Blueprints/UI/MainMenu/WBP_MainMenu.uasset b/Content/Blueprints/UI/MainMenu/WBP_MainMenu.uasset index d1880bf..6e9c1bb 100644 --- a/Content/Blueprints/UI/MainMenu/WBP_MainMenu.uasset +++ b/Content/Blueprints/UI/MainMenu/WBP_MainMenu.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b115bc33cfdf48a8c9b10374201455572e0903bc83be66a2c2245aec3d03776d -size 212656 +oid sha256:162ceb6f8598463af60ecc9f6f9334e3e8c9b1478b60f2a636094d4d8eb5ca19 +size 228042 diff --git a/Content/Blueprints/UI/PreBattle/WBP_Prebattle.uasset b/Content/Blueprints/UI/PreBattle/WBP_Prebattle.uasset index 7304cdb..628e0ec 100644 --- a/Content/Blueprints/UI/PreBattle/WBP_Prebattle.uasset +++ b/Content/Blueprints/UI/PreBattle/WBP_Prebattle.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f1eadf852e781038436d11bc525c0a06fc0e2142d54df2383e035dd2871b00b3 -size 95972 +oid sha256:be0180f957febead45012a67e544e9505ddfc79cdcc3aa6b531368417bcc0eb6 +size 75219 diff --git a/Content/Blueprints/UI/PreBattle/WBP_UnitCard.uasset b/Content/Blueprints/UI/PreBattle/WBP_UnitCard.uasset index 5e21afc..c550b55 100644 --- a/Content/Blueprints/UI/PreBattle/WBP_UnitCard.uasset +++ b/Content/Blueprints/UI/PreBattle/WBP_UnitCard.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c051b4a0a71490d2bd88af13c6e588798bbba8fb230d9d663f69596155fbb766 -size 98939 +oid sha256:f6bb65d8cecfd6b9c6c81c5a514192638e2c3b61133208b3eb707dee9ed3e730 +size 95363 diff --git a/Content/Blueprints/Units/Common/BP_Unit.uasset b/Content/Blueprints/Units/Common/BP_Unit.uasset index 986e5c3..8538290 100644 --- a/Content/Blueprints/Units/Common/BP_Unit.uasset +++ b/Content/Blueprints/Units/Common/BP_Unit.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cd951cd446d6f5f8eec38a5be44ffd57a8dc77cdec9e771664ac661458f3eba6 -size 532429 +oid sha256:c8ae4c401b9ba1a2e5ae234d1e36de38c8d4557a5b9875664ceec4d21d06e525 +size 525023 diff --git a/Content/Levels/MainMenu.umap b/Content/Levels/MainMenu.umap index 4bcf3f5..8810656 100644 --- a/Content/Levels/MainMenu.umap +++ b/Content/Levels/MainMenu.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bb0d460ff74a1ac619c1b718e11e537aaa5e2f518b783aee78c326b7196371fe -size 42724 +oid sha256:685701c30adebf45941803aab31e2773bc7d7d8a31357bf067bd18907314a9aa +size 41706 diff --git a/Source/SpaceBattler/Private/PartyMember.cpp b/Source/SpaceBattler/Private/PartyMember.cpp index 83f232e..9511acd 100644 --- a/Source/SpaceBattler/Private/PartyMember.cpp +++ b/Source/SpaceBattler/Private/PartyMember.cpp @@ -3,12 +3,64 @@ #include "PartyMember.h" -FPartyMember::FPartyMember() +int32 UPartyMember::GetAllocated() { - UnitInfo = nullptr; + return Allocated; } -FPartyMember::FPartyMember(UUnitInfo* InUnitInfo) +void UPartyMember::AddToParty() { - UnitInfo = InUnitInfo; + if(Allocated == Available++) + { + Allocated++; + } } + + +int32 UPartyMember::GetAvailable() +{ + return Available; +} + +int32 UPartyMember::SetAllocation(int32 Amount) +{ + if(Amount > Available) + { + Allocated = Available; + } else if (Amount < 0) + { + Allocated = 0; + } else + { + Allocated = Amount; + } + + return Allocated; +} + +int32 UPartyMember::AllocateMember() +{ + if(Allocated == Available) + { + return Allocated; + } else + { + return ++Allocated; + } +} + +int32 UPartyMember::DeallocateMember() +{ + if(Allocated == 0) + { + return Allocated; + } else + { + return --Allocated; + } +} + + + + + diff --git a/Source/SpaceBattler/Private/PartySubsystem.cpp b/Source/SpaceBattler/Private/PartySubsystem.cpp index b07c17f..9a600f0 100644 --- a/Source/SpaceBattler/Private/PartySubsystem.cpp +++ b/Source/SpaceBattler/Private/PartySubsystem.cpp @@ -3,31 +3,10 @@ #include "PartySubsystem.h" +#include "Unit.h" +#include "UpgradeSubsystem.h" #include "Kismet/GameplayStatics.h" -void UPartySubsystem::AddToParty(UUnitInfo* UnitInfo) -{ - for (FPartyMember &Unit : Members) - { - if(Unit.UnitInfo == UnitInfo) - { - const bool UpdateAllocated = GetMemberAvailable(Unit) == GetMemberAllocated(Unit); - - SetMemberAvailable(Unit, GetMemberAvailable(Unit) + 1); - if (UpdateAllocated) - { - AllocateMember(Unit); - } - return; - } - } -} - -TArray UPartySubsystem::GetMembers() -{ - return Members; -} - int32 UPartySubsystem::SpawnParty(const float InVerticalSpacing, const float InHorizontalOffset, const float InHorizontalSpacing, const int InNumRows) { this->VerticalSpacing = InVerticalSpacing; @@ -42,12 +21,11 @@ int32 UPartySubsystem::SpawnParty(const float InVerticalSpacing, const float InH UGameplayStatics::GetAllActorsWithTag(GetWorld(), "PlayerSpawn", SpawnPoints); SpawnPoint = SpawnPoints[0]; - for (FPartyMember &Unit : GetMembers()) + for (UPartyMember* Unit : PartyMembers) { - const int32 Allocated = GetMemberAllocated(Unit); - for(auto i = 0; i < Allocated; i++) + for(auto i = 0; i < Unit->GetAllocated(); i++) { - SpawnQueue.Add(GetMemberUnitInfo(Unit)->GetCharacterClass()); + SpawnQueue.Add(Unit->UnitInfo->GetCharacterClass()); } } @@ -86,6 +64,11 @@ void UPartySubsystem::SpawnUnits() if(NewActor != nullptr) { NewActor->Tags.Add(TEXT("player")); + TObjectPtr NewUnit = Cast(NewActor); + if(NewUnit != nullptr) + { + GetWorld()->GetFirstLocalPlayerFromController()->GetSubsystem()->ApplyUnitUpgrades(NewUnit); + } } FHitResult Hit; @@ -105,104 +88,43 @@ void UPartySubsystem::SpawnUnits() CurrentColumn++; } -TArray UPartySubsystem::GetUnitsByTier(const int32 Tier) const -{ - TArray TierMembers; - - for(FPartyMember Member : Members) - { - if(GetMemberUnitInfo(Member)->GetTier() == Tier) - { - TierMembers.Add(GetMemberUnitInfo(Member)); - } - } - - return TierMembers; -} - void UPartySubsystem::SetCredits(const int32 Amount) { Credits = Amount; } -bool UPartySubsystem::AllocateMember(FPartyMember& Member) -{ - Member.Allocated++; - if(Member.Allocated > Member.Available) - { - Member.Allocated = Member.Available; - return false; - } - - return true; -} - -bool UPartySubsystem::DeallocateMember(FPartyMember &Member) +int32 UPartySubsystem::GetTotalAvailablePartyMembers() { - Member.Allocated--; - - if (Member.Allocated < 0) + int32 Total = 0; + for(auto const Member : PartyMembers) { - Member.Allocated = 0; - return false; + Total += Member->GetAvailable(); } - return true; -} - -void UPartySubsystem::SetMemberMax(FPartyMember& Member) -{ - Member.Allocated = Member.Available; -} - -void UPartySubsystem::ClearMember(FPartyMember& Member) -{ - Member.Allocated = 0; -} - -int32 UPartySubsystem::GetMemberAllocated(FPartyMember& Member) const -{ - return Member.Allocated; -} - -int32 UPartySubsystem::GetMemberAvailable(FPartyMember& Member) const -{ - return Member.Available; -} - -void UPartySubsystem::SetMemberAvailable(FPartyMember& Member, int32 const Amount) -{ - Member.Available = Amount; -} - -void UPartySubsystem::SetMemberUnitInfo(FPartyMember& Member, UUnitInfo* InUnitInfo) -{ - Member.UnitInfo = InUnitInfo; -} - -UUnitInfo* UPartySubsystem::GetMemberUnitInfo(FPartyMember& Member) const -{ - return Member.UnitInfo; + return Total; } -int32 UPartySubsystem::GetTotalAvailablePartyMembers() +int32 UPartySubsystem::GetTotalAllocatedPartyMembers() { int32 Total = 0; - for(auto const Member : Members) + for(auto const Member : PartyMembers) { - Total += Member.Available; + Total += Member->GetAllocated(); } return Total; } -int32 UPartySubsystem::GetTotalAllocatedPartyMembers() +TArray UPartySubsystem::GetMembersInTier(const int32 Tier) { - int32 Total = 0; - for(auto const Member : Members) + TArray TierMembers; + for(auto Member : PartyMembers) { - Total += Member.Allocated; + if (Member->UnitInfo->GetTier() == Tier) + { + TierMembers.Add(Member); + } } - return Total; -} \ No newline at end of file + return TierMembers; +} diff --git a/Source/SpaceBattler/Private/SelectedUpgrade.cpp b/Source/SpaceBattler/Private/SelectedUpgrade.cpp new file mode 100644 index 0000000..21560a1 --- /dev/null +++ b/Source/SpaceBattler/Private/SelectedUpgrade.cpp @@ -0,0 +1,4 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "SelectedUpgrade.h" diff --git a/Source/SpaceBattler/Private/Unit.cpp b/Source/SpaceBattler/Private/Unit.cpp new file mode 100644 index 0000000..14528a8 --- /dev/null +++ b/Source/SpaceBattler/Private/Unit.cpp @@ -0,0 +1,34 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Unit.h" + +// Sets default values +AUnit::AUnit() +{ + // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; + +} + +// Called when the game starts or when spawned +void AUnit::BeginPlay() +{ + Super::BeginPlay(); + +} + +// Called every frame +void AUnit::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); + +} + +// Called to bind functionality to input +void AUnit::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) +{ + Super::SetupPlayerInputComponent(PlayerInputComponent); + +} + diff --git a/Source/SpaceBattler/Private/UnitUpgrade.cpp b/Source/SpaceBattler/Private/UnitUpgrade.cpp new file mode 100644 index 0000000..3194363 --- /dev/null +++ b/Source/SpaceBattler/Private/UnitUpgrade.cpp @@ -0,0 +1,9 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "UnitUpgrade.h" + +void UUnitUpgrade::ApplyToUnit(AUnit* Unit) +{ + +} diff --git a/Source/SpaceBattler/Private/Upgrade.cpp b/Source/SpaceBattler/Private/Upgrade.cpp new file mode 100644 index 0000000..7da6dba --- /dev/null +++ b/Source/SpaceBattler/Private/Upgrade.cpp @@ -0,0 +1,9 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Upgrade.h" + +TArray UUpgrade::GetApplicableTags() +{ + return ApplicableTags; +} diff --git a/Source/SpaceBattler/Private/UpgradeSubsystem.cpp b/Source/SpaceBattler/Private/UpgradeSubsystem.cpp new file mode 100644 index 0000000..f76650f --- /dev/null +++ b/Source/SpaceBattler/Private/UpgradeSubsystem.cpp @@ -0,0 +1,30 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "UpgradeSubsystem.h" + +#include "UnitUpgrade.h" + +void UUpgradeSubsystem::ApplyUnitUpgrades(AUnit* Unit) +{ + for (const auto Upgrade : SelectedUpgrades) + { + UUnitUpgrade* UnitUpgrade = Cast(Upgrade.UpgradeData); + if(UnitUpgrade != nullptr) + { + for (const FString Tag : Upgrade.UpgradeData->GetApplicableTags()) + { + if(Unit->UnitTags.Contains(Tag)) + { + UnitUpgrade->ApplyToUnit(Unit); + } + } + } + } +} + + +void UUpgradeSubsystem::ApplyGlobalUpgrades() +{ + +} diff --git a/Source/SpaceBattler/Public/PartyMember.h b/Source/SpaceBattler/Public/PartyMember.h index d38ea57..ba6461e 100644 --- a/Source/SpaceBattler/Public/PartyMember.h +++ b/Source/SpaceBattler/Public/PartyMember.h @@ -9,17 +9,34 @@ /** * */ -USTRUCT(Blueprintable, BlueprintType) -struct SPACEBATTLER_API FPartyMember +UCLASS(Blueprintable, BlueprintType) +class SPACEBATTLER_API UPartyMember : public UObject { GENERATED_BODY() - FPartyMember(); - explicit FPartyMember(UUnitInfo* InUnitInfo); +public: + UPROPERTY(BlueprintReadWrite, meta=(ExposeOnSpawn=true)) + UUnitInfo* UnitInfo; + + UFUNCTION(BlueprintCallable) + void AddToParty(); + + UFUNCTION(BlueprintCallable) + int32 GetAvailable(); + + UFUNCTION(BlueprintCallable) + int32 GetAllocated(); - UPROPERTY(BlueprintReadWrite) - UUnitInfo* UnitInfo = nullptr; + UFUNCTION(BlueprintCallable) + int32 AllocateMember(); + UFUNCTION(BlueprintCallable) + int32 DeallocateMember(); + + UFUNCTION(BlueprintCallable) + int32 SetAllocation(int32 Amount); + +protected: UPROPERTY(BlueprintReadOnly) int32 Available = 0; diff --git a/Source/SpaceBattler/Public/PartySubsystem.h b/Source/SpaceBattler/Public/PartySubsystem.h index bceab88..f173614 100644 --- a/Source/SpaceBattler/Public/PartySubsystem.h +++ b/Source/SpaceBattler/Public/PartySubsystem.h @@ -4,7 +4,6 @@ #include "CoreMinimal.h" #include "PartyMember.h" -#include "UnitInfo.h" #include "Subsystems/LocalPlayerSubsystem.h" #include "PartySubsystem.generated.h" @@ -18,60 +17,27 @@ class SPACEBATTLER_API UPartySubsystem : public UGameInstanceSubsystem public: UFUNCTION(BlueprintCallable) int32 SpawnParty(const float InVerticalSpacing, const float InHorizontalOffset, const float InHorizontalSpacing, const int InNumRows); - - UFUNCTION(BlueprintCallable) - void AddToParty(UUnitInfo* UnitInfo); - - UFUNCTION(BlueprintCallable) - TArray GetMembers(); - - UFUNCTION(BlueprintCallable) - TArray GetUnitsByTier(const int32 Tier) const; UFUNCTION(BlueprintCallable) void SetCredits(int32 Amount); - UFUNCTION(BlueprintCallable) - void SetMemberUnitInfo(UPARAM(ref) FPartyMember& Member, UUnitInfo* UnitInfo); - - UFUNCTION(BlueprintCallable) - bool AllocateMember(UPARAM(ref) FPartyMember& Member); - - UFUNCTION(BlueprintCallable) - bool DeallocateMember(UPARAM(ref) FPartyMember &Member); - - UFUNCTION(BlueprintCallable) - void SetMemberMax(UPARAM(ref) FPartyMember& Member); - - UFUNCTION(BlueprintCallable) - void ClearMember(UPARAM(ref) FPartyMember& Member); - - UFUNCTION(BlueprintCallable) - void SetMemberAvailable(UPARAM(ref) FPartyMember& Member,int32 const Amount); - - UFUNCTION(BlueprintCallable) - int32 GetMemberAvailable(UPARAM(ref) FPartyMember& Member) const; - - UFUNCTION(BlueprintCallable) - int32 GetMemberAllocated(UPARAM(ref) FPartyMember& Member) const; - - UFUNCTION(BlueprintCallable) - UUnitInfo* GetMemberUnitInfo(UPARAM(ref) FPartyMember& Member) const; - UFUNCTION(BlueprintCallable) int32 GetTotalAvailablePartyMembers(); UFUNCTION(BlueprintCallable) int32 GetTotalAllocatedPartyMembers(); + + UFUNCTION(BlueprintCallable) + TArray GetMembersInTier(const int32 Tier); protected: void SpawnUnits(); + UPROPERTY(BlueprintReadWrite, EditAnywhere) + TArray> PartyMembers; + UPROPERTY() TArray> SpawnQueue; - - UPROPERTY(BlueprintReadWrite, EditAnywhere) - TArray Members; UPROPERTY(BlueprintReadWrite, EditAnywhere) UPrimaryDataAsset* SelectedGeneral; diff --git a/Source/SpaceBattler/Public/SelectedUpgrade.h b/Source/SpaceBattler/Public/SelectedUpgrade.h new file mode 100644 index 0000000..36915f0 --- /dev/null +++ b/Source/SpaceBattler/Public/SelectedUpgrade.h @@ -0,0 +1,22 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Upgrade.h" +#include "SelectedUpgrade.generated.h" + +/** + * + */ +USTRUCT(BlueprintType) +struct FSelectedUpgrade +{ + GENERATED_BODY() + + UPROPERTY(BlueprintReadWrite) + UUpgrade* UpgradeData; + + UPROPERTY(BlueprintReadWrite) + int32 TimesSelected; +}; diff --git a/Source/SpaceBattler/Public/Unit.h b/Source/SpaceBattler/Public/Unit.h new file mode 100644 index 0000000..74f911e --- /dev/null +++ b/Source/SpaceBattler/Public/Unit.h @@ -0,0 +1,63 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Character.h" +#include "Unit.generated.h" + +UCLASS() +class SPACEBATTLER_API AUnit : public ACharacter +{ + GENERATED_BODY() + +public: + // Sets default values for this character's properties + AUnit(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + +public: + // Called every frame + virtual void Tick(float DeltaTime) override; + + // Called to bind functionality to input + virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + + /** Please add a variable description */ + UPROPERTY(BlueprintReadWrite, Category="Unit Info Copy") + double MaxHP; + + /** Please add a variable description */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="State") + double HP; + + /** Please add a variable description */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Unit Info Copy") + double Attack; + + /** Please add a variable description */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Unit Info Copy") + double Range; + + /** Please add a variable description */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Unit Info Copy") + double RangedProjectileSpeed; + + /** Please add a variable description */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Unit Info Copy") + double RangedProjectileDelay; + + /** Please add a variable description */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Unit Info Copy") + int32 RangedProjectileAmount; + + /** Please add a variable description */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Unit Info Copy") + double Cooldown; + + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Unit Info Copy") + TArray UnitTags; +}; diff --git a/Source/SpaceBattler/Public/UnitInfo.h b/Source/SpaceBattler/Public/UnitInfo.h index 563b501..4efae58 100644 --- a/Source/SpaceBattler/Public/UnitInfo.h +++ b/Source/SpaceBattler/Public/UnitInfo.h @@ -74,4 +74,7 @@ protected: UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Ranged Info") UAnimMontage* RangedProjectileMontage; + + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Information") + TArray UnitTags; }; diff --git a/Source/SpaceBattler/Public/UnitUpgrade.h b/Source/SpaceBattler/Public/UnitUpgrade.h new file mode 100644 index 0000000..963cd9a --- /dev/null +++ b/Source/SpaceBattler/Public/UnitUpgrade.h @@ -0,0 +1,20 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Unit.h" +#include "Upgrade.h" +#include "UnitUpgrade.generated.h" + +/** + * + */ +UCLASS() +class SPACEBATTLER_API UUnitUpgrade : public UUpgrade +{ + GENERATED_BODY() + +public: + void ApplyToUnit(AUnit* Unit); +}; diff --git a/Source/SpaceBattler/Public/Upgrade.h b/Source/SpaceBattler/Public/Upgrade.h new file mode 100644 index 0000000..a65c169 --- /dev/null +++ b/Source/SpaceBattler/Public/Upgrade.h @@ -0,0 +1,32 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Engine/DataAsset.h" +#include "Upgrade.generated.h" + +/** + * + */ +UCLASS() +class SPACEBATTLER_API UUpgrade : public UPrimaryDataAsset +{ + GENERATED_BODY() + +public: + TArray GetApplicableTags(); + +protected: + UPROPERTY(BlueprintReadWrite) + FText Name; + + UPROPERTY(BlueprintReadWrite, meta=(MultiLine=true)) + FText Description; + + UPROPERTY(BlueprintReadWrite) + bool Repeatable; + + UPROPERTY(BlueprintReadWrite, EditAnywhere) + TArray ApplicableTags; +}; diff --git a/Source/SpaceBattler/Public/UpgradeSubsystem.h b/Source/SpaceBattler/Public/UpgradeSubsystem.h new file mode 100644 index 0000000..f484448 --- /dev/null +++ b/Source/SpaceBattler/Public/UpgradeSubsystem.h @@ -0,0 +1,32 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "SelectedUpgrade.h" +#include "Unit.h" +#include "Subsystems/LocalPlayerSubsystem.h" +#include "UpgradeSubsystem.generated.h" + +/** + * + */ +UCLASS() +class SPACEBATTLER_API UUpgradeSubsystem : public ULocalPlayerSubsystem +{ + GENERATED_BODY() + +public: + UFUNCTION(BlueprintCallable) + void ApplyUnitUpgrades(AUnit* Unit); + + UFUNCTION(BlueprintCallable) + void ApplyGlobalUpgrades(); + +protected: + UPROPERTY(BlueprintReadWrite) + int32 BattleTier; + + UPROPERTY(BlueprintReadWrite) + TArray SelectedUpgrades; +};