diff --git a/Content/Blueprints/BP_GameState.uasset b/Content/Blueprints/BP_GameState.uasset index 599d741..e46f37a 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:b3c4abc61ec78b1dbe0d9012673435ad7245c517c03f7f2deece34074e1c8c6d -size 200805 +oid sha256:f25b353bb71dfb576fd9ff15b24444e90115fd18f237767dacb739563a6cfda7 +size 371035 diff --git a/Content/Blueprints/BP_PlayerController.uasset b/Content/Blueprints/BP_PlayerController.uasset index a6266ec..4e4da33 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:f34141e80382f30ed31c60743104fcdcee25ca402a9fe9c58e6f1e623f9aefbb -size 138303 +oid sha256:13dedbcf0f435c4dcfcfc179ae073e150d1112c2fbe26d3e112e5b29ead10043 +size 68916 diff --git a/Content/Blueprints/Loot/BP_UnitLoot.uasset b/Content/Blueprints/Loot/BP_UnitLoot.uasset index ca36d0f..27f48bb 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:b56353ee77780504f672535a730bcf4d6ffa2b8ec3b58099a9c91a39ecd6e7df -size 67081 +oid sha256:522c9f9d49f5d0da7db9991eaaa25af74e21120f350ef185aa2fcb5ee20ef09d +size 42130 diff --git a/Content/Blueprints/UI/HUD/WBP_HUD.uasset b/Content/Blueprints/UI/HUD/WBP_HUD.uasset new file mode 100644 index 0000000..5cbe585 --- /dev/null +++ b/Content/Blueprints/UI/HUD/WBP_HUD.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c63d04665be3158dce36a0c8ff731cc25bb16da02a4c3ae28b0849b761ff1e01 +size 62495 diff --git a/Content/Blueprints/UI/MainMenu/WBP_ColumnSelect.uasset b/Content/Blueprints/UI/MainMenu/WBP_ColumnSelect.uasset index 5fc605d..121cb65 100644 --- a/Content/Blueprints/UI/MainMenu/WBP_ColumnSelect.uasset +++ b/Content/Blueprints/UI/MainMenu/WBP_ColumnSelect.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:73ef3823d07ba0b5f024b298b3d843ecca06a9dfe72d1ad1eaaf02550524ad73 -size 120976 +oid sha256:e21b48ae31b4705a4e6f9cf34ebf963026dd171cf22b0e51668d5abfa9250faa +size 127239 diff --git a/Content/Blueprints/UI/MainMenu/WBP_GeneralSelect.uasset b/Content/Blueprints/UI/MainMenu/WBP_GeneralSelect.uasset index 31e5df1..c97f1d5 100644 --- a/Content/Blueprints/UI/MainMenu/WBP_GeneralSelect.uasset +++ b/Content/Blueprints/UI/MainMenu/WBP_GeneralSelect.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b8462fd50a58341418bbf36ccb47e71778d0ac0c4f99da4437311ee0f88b2dc -size 57611 +oid sha256:84986f03dd0fdc9c7adc944d5e5eb471cd153c41027688ce25f4f87a60542db5 +size 50490 diff --git a/Content/Blueprints/UI/MainMenu/WBP_LootSelect.uasset b/Content/Blueprints/UI/MainMenu/WBP_LootSelect.uasset index e842caf..ee7ae09 100644 --- a/Content/Blueprints/UI/MainMenu/WBP_LootSelect.uasset +++ b/Content/Blueprints/UI/MainMenu/WBP_LootSelect.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5a8ba9f039e687c92d646d3edf7eaa59c83bf9c341d92a30432815cd51b07a36 -size 21210 +oid sha256:a7e0d3f92ce0c9b3f91e245bbfe0d4607415a33178e35d531b4cdf1bbbc2ce5a +size 56783 diff --git a/Content/Blueprints/UI/MainMenu/WBP_MainMenu.uasset b/Content/Blueprints/UI/MainMenu/WBP_MainMenu.uasset index 1ebe7d0..54b6d22 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:9935539e626172975b2da1757961aaf3920c93fd8cc51a1403d5033934403767 -size 36875 +oid sha256:915721d596a8bed3828bb2c88cc35b873b1339134641f0b5e45032878d804418 +size 35479 diff --git a/Content/Blueprints/UI/Prebattle/WBP_Prebattle.uasset b/Content/Blueprints/UI/Prebattle/WBP_Prebattle.uasset new file mode 100644 index 0000000..23feceb --- /dev/null +++ b/Content/Blueprints/UI/Prebattle/WBP_Prebattle.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfd3b516942bb519ccabf8db6fa68da1008aa3534dd11d00b6900e683883feb0 +size 51331 diff --git a/Content/Blueprints/UI/Prebattle/WBP_UnitCard.uasset b/Content/Blueprints/UI/Prebattle/WBP_UnitCard.uasset new file mode 100644 index 0000000..35d58f9 --- /dev/null +++ b/Content/Blueprints/UI/Prebattle/WBP_UnitCard.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:875dfed0e7b0221bd2a9a31bb28e79d8b89d86aa1ed019df864f2ee7e27f1481 +size 89287 diff --git a/Content/Levels/MainMenu.umap b/Content/Levels/MainMenu.umap index a1672bc..6362a30 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:441454854f37138d176ff7b6e7acbd263a364bf1878aa222cd873e0f68fbee0b -size 43389 +oid sha256:e2231285163474553f6690b72e007c13991699bf3b08ea6625d9620d7c576181 +size 41472 diff --git a/Source/SpaceBattler/Private/Loot.cpp b/Source/SpaceBattler/Private/Loot.cpp index 7229836..79237de 100644 --- a/Source/SpaceBattler/Private/Loot.cpp +++ b/Source/SpaceBattler/Private/Loot.cpp @@ -3,11 +3,7 @@ #include "Loot.h" -ULoot::ULoot() -{ -} - -void ULoot::Init_Implementation(AGameStateBase* GameState) +void ULoot::Init_Implementation(AGameStateBase* GameState, APlayerController* PlayerController) { } diff --git a/Source/SpaceBattler/Private/PartyMember.cpp b/Source/SpaceBattler/Private/PartyMember.cpp new file mode 100644 index 0000000..83f232e --- /dev/null +++ b/Source/SpaceBattler/Private/PartyMember.cpp @@ -0,0 +1,14 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "PartyMember.h" + +FPartyMember::FPartyMember() +{ + UnitInfo = nullptr; +} + +FPartyMember::FPartyMember(UUnitInfo* InUnitInfo) +{ + UnitInfo = InUnitInfo; +} diff --git a/Source/SpaceBattler/Private/PartySubsystem.cpp b/Source/SpaceBattler/Private/PartySubsystem.cpp index 867eacf..b5851d3 100644 --- a/Source/SpaceBattler/Private/PartySubsystem.cpp +++ b/Source/SpaceBattler/Private/PartySubsystem.cpp @@ -5,41 +5,43 @@ void UPartySubsystem::AddToParty(UUnitInfo* UnitInfo) { - for (TPair &Unit : Members) + for (FPartyMember &Unit : Members) { - if(Unit.Key->GetClass() == UnitInfo->GetClass()) + if(GetMemberUnitInfo(Unit)->GetClass() == UnitInfo->GetClass()) { - Unit.Value++; + const bool UpdateAllocated = GetMemberAvailable(Unit) == GetMemberAllocated(Unit); + + SetMemberAvailable(Unit, GetMemberAvailable(Unit) + 1); + if (UpdateAllocated) + { + AllocateMember(Unit); + } return; } } } -TMap UPartySubsystem::GetMembers() +TArray UPartySubsystem::GetMembers() { return Members; } -int32 UPartySubsystem::SpawnParty(float InVerticalSpacing, float InHorizontalOffset, int InNumRows) +int32 UPartySubsystem::SpawnParty(const float InVerticalSpacing, const float InHorizontalOffset, const float InHorizontalSpacing, const int InNumRows) { this->VerticalSpacing = InVerticalSpacing; this->HorizontalOffset = InHorizontalOffset; this->NumRows = InNumRows; - - GetMembers().KeySort([](const UUnitInfo& A, const UUnitInfo& B) - { - return A.GetTier() < B.GetTier(); - }); + this->HorizontalSpacing = InHorizontalSpacing; - for (TPair &Unit : GetMembers()) + for (FPartyMember &Unit : GetMembers()) { - for(auto i = 0; i < Unit.Value; i++) + for(auto i = 0; i < GetMemberAllocated(Unit); i++) { - SpawnQueue.Add(Unit.Key->GetCharacterClass()); + SpawnQueue.Add(GetMemberUnitInfo(Unit)->GetCharacterClass()); } } - auto NumUnits= SpawnQueue.Num(); + const auto NumUnits= SpawnQueue.Num(); SpawnUnits(); GetWorld()->GetTimerManager().SetTimer( @@ -61,9 +63,94 @@ void UPartySubsystem::SpawnUnits() GetWorld()->GetTimerManager().ClearTimer(SpawnTimerHandle); return; } - FVector Location = FVector(VerticalSpacing * i - VerticalSpacing, -HorizontalOffset, 0); - GetWorld()->SpawnActor(SpawnQueue[i + LastSpawnIndex], &Location); + + FActorSpawnParameters SpawnActorParameters = {}; + SpawnActorParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn; + + FVector Location = FVector( VerticalSpacing * i - VerticalSpacing, -HorizontalOffset, 0); + GetWorld()->SpawnActor(SpawnQueue[i + LastSpawnIndex], &Location, nullptr, SpawnActorParameters); } LastSpawnIndex += NumRows; + 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) +{ + Member.Allocated--; + + if (Member.Allocated < 0) + { + Member.Allocated = 0; + return false; + } + + 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; +} \ No newline at end of file diff --git a/Source/SpaceBattler/Private/StateMachineSubsystem.cpp b/Source/SpaceBattler/Private/StateMachineSubsystem.cpp index 4a878b4..92929d8 100644 --- a/Source/SpaceBattler/Private/StateMachineSubsystem.cpp +++ b/Source/SpaceBattler/Private/StateMachineSubsystem.cpp @@ -10,7 +10,7 @@ void UStateMachineSubsystem::Initialize(FSubsystemCollectionBase& Collection) UE_LOG(LogTemp, Display, TEXT("Starting game state machine in MAINMENU state")) } -bool UStateMachineSubsystem::ChangeState(EGameState NewState) +bool UStateMachineSubsystem::ChangeState(const EGameState NewState) { // Exit from old state switch (CurrentState) diff --git a/Source/SpaceBattler/Private/WaveSubsystem.cpp b/Source/SpaceBattler/Private/WaveSubsystem.cpp index 9ac783a..66eb5b5 100644 --- a/Source/SpaceBattler/Private/WaveSubsystem.cpp +++ b/Source/SpaceBattler/Private/WaveSubsystem.cpp @@ -3,13 +3,13 @@ #include "WaveSubsystem.h" -void UWaveSubsystem::Init(TArray InWaves, int32 CurrWave = 0) +void UWaveSubsystem::Init(const TArray InWaves, const int32 CurrWave = 0) { CurrentWave = CurrWave; Waves = InWaves; } -int32 UWaveSubsystem::SpawnWave(float InVerticalSpacing, float InHorizontalOffset, int InNumRows) +int32 UWaveSubsystem::SpawnWave(const float InVerticalSpacing, const float InHorizontalOffset, const int InNumRows) { NumRows = InNumRows; HorizontalOffset = InHorizontalOffset; diff --git a/Source/SpaceBattler/Public/Loot.h b/Source/SpaceBattler/Public/Loot.h index c76c940..1db3f0c 100644 --- a/Source/SpaceBattler/Public/Loot.h +++ b/Source/SpaceBattler/Public/Loot.h @@ -13,10 +13,8 @@ class SPACEBATTLER_API ULoot : public UObject { GENERATED_BODY() public: - ULoot(); - UFUNCTION(BlueprintCallable, Blueprintable, BlueprintNativeEvent) - void Init(AGameStateBase* GameState); + void Init(AGameStateBase* GameState, APlayerController* PlayerController); UPROPERTY(BlueprintReadWrite, EditAnywhere) FText Name; diff --git a/Source/SpaceBattler/Public/PartyMember.h b/Source/SpaceBattler/Public/PartyMember.h new file mode 100644 index 0000000..d38ea57 --- /dev/null +++ b/Source/SpaceBattler/Public/PartyMember.h @@ -0,0 +1,28 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "UnitInfo.h" +#include "PartyMember.generated.h" + +/** + * + */ +USTRUCT(Blueprintable, BlueprintType) +struct SPACEBATTLER_API FPartyMember +{ + GENERATED_BODY() + + FPartyMember(); + explicit FPartyMember(UUnitInfo* InUnitInfo); + + UPROPERTY(BlueprintReadWrite) + UUnitInfo* UnitInfo = nullptr; + + UPROPERTY(BlueprintReadOnly) + int32 Available = 0; + + UPROPERTY(BlueprintReadOnly) + int32 Allocated = 0; +}; diff --git a/Source/SpaceBattler/Public/PartySubsystem.h b/Source/SpaceBattler/Public/PartySubsystem.h index 700b130..eda2845 100644 --- a/Source/SpaceBattler/Public/PartySubsystem.h +++ b/Source/SpaceBattler/Public/PartySubsystem.h @@ -3,6 +3,7 @@ #pragma once #include "CoreMinimal.h" +#include "PartyMember.h" #include "UnitInfo.h" #include "Subsystems/LocalPlayerSubsystem.h" #include "PartySubsystem.generated.h" @@ -10,19 +11,52 @@ /** * */ -UCLASS() -class SPACEBATTLER_API UPartySubsystem : public ULocalPlayerSubsystem +UCLASS(meta=(ShowWorldContextPin)) +class SPACEBATTLER_API UPartySubsystem : public UGameInstanceSubsystem { GENERATED_BODY() public: UFUNCTION(BlueprintCallable) - int32 SpawnParty(float VerticalSpacing, float HorizontalOffset, int NumRows); + int32 SpawnParty(const float InVerticalSpacing, const float InHorizontalOffset, const float InHorizontalSpacing, const int InNumRows); UFUNCTION(BlueprintCallable) void AddToParty(UUnitInfo* UnitInfo); UFUNCTION(BlueprintCallable) - TMap GetMembers(); + TArray GetMembers(); + + UFUNCTION(BlueprintCallable) + TArray GetUnitsByTier(const int32 Tier) const; + + UFUNCTION(BlueprintCallable) + void SetCredits(int32 Amount); + + UFUNCTION(BlueprintCallable) + void SetMemberUnitInfo(FPartyMember& Member, UUnitInfo* UnitInfo); + + UFUNCTION(BlueprintCallable) + bool AllocateMember(FPartyMember& Member); + + UFUNCTION(BlueprintCallable) + bool DeallocateMember(FPartyMember& Member); + + UFUNCTION(BlueprintCallable) + void SetMemberMax(FPartyMember& Member); + + UFUNCTION(BlueprintCallable) + void ClearMember(FPartyMember& Member); + + UFUNCTION(BlueprintCallable) + void SetMemberAvailable(FPartyMember& Member,int32 const Amount); + + UFUNCTION(BlueprintCallable) + int32 GetMemberAvailable(FPartyMember& Member) const; + + UFUNCTION(BlueprintCallable) + int32 GetMemberAllocated(FPartyMember& Member) const; + + UFUNCTION(BlueprintCallable) + UUnitInfo* GetMemberUnitInfo(FPartyMember& Member) const; protected: void SpawnUnits(); @@ -31,14 +65,19 @@ protected: TArray> SpawnQueue; UPROPERTY(BlueprintReadWrite, EditAnywhere) - TMap Members; + TArray Members; UPROPERTY(BlueprintReadWrite, EditAnywhere) UPrimaryDataAsset* SelectedGeneral; + + UPROPERTY(BlueprintReadWrite, EditAnywhere) + int32 Credits; FTimerHandle SpawnTimerHandle; int32 LastSpawnIndex; int32 NumRows; + int32 CurrentColumn; float HorizontalOffset; float VerticalSpacing; + float HorizontalSpacing; };