diff --git a/Content/Assets/Objects/Blue_Jelly/BlueJelly_Cylinder.uasset b/Content/Assets/Objects/Blue_Jelly/BlueJelly_Cylinder.uasset new file mode 100644 index 0000000..8aec2fd --- /dev/null +++ b/Content/Assets/Objects/Blue_Jelly/BlueJelly_Cylinder.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca8b57cfbdcd8348470e39d8c28aa3f2cb3e0da6e81be5750c7e8bced379045c +size 39551 diff --git a/Content/Assets/Objects/Blue_Jelly/BlueJelly_Mball_009.uasset b/Content/Assets/Objects/Blue_Jelly/BlueJelly_Mball_009.uasset new file mode 100644 index 0000000..8d6a890 --- /dev/null +++ b/Content/Assets/Objects/Blue_Jelly/BlueJelly_Mball_009.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b34cad3ae6933b9958c0366df60f26ed8861b6c7faf8926f77eb9d77c57a14e3 +size 102108 diff --git a/Content/Assets/Objects/Blue_Jelly/Material_001.uasset b/Content/Assets/Objects/Blue_Jelly/Material_001.uasset new file mode 100644 index 0000000..a6f03fa --- /dev/null +++ b/Content/Assets/Objects/Blue_Jelly/Material_001.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4cfaa4f57bf66b81bb79bc771e9dc4a12e839f7013713c576f2cc0f0d6fec17b +size 7982 diff --git a/Content/Assets/Objects/Blue_Jelly/Material_002.uasset b/Content/Assets/Objects/Blue_Jelly/Material_002.uasset new file mode 100644 index 0000000..b63b60b --- /dev/null +++ b/Content/Assets/Objects/Blue_Jelly/Material_002.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4a7c513681ca7acfa66d54e22e631b06471bacf059d31e2b0c4df2f2ee1c87a +size 7553 diff --git a/Content/Assets/Objects/Red_Jelly/Material_001.uasset b/Content/Assets/Objects/Red_Jelly/Material_001.uasset new file mode 100644 index 0000000..19cf8df --- /dev/null +++ b/Content/Assets/Objects/Red_Jelly/Material_001.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed9efc59130655d42cf557ef3026512a72c7582dfd28e4088cb8e899e6ca8572 +size 7326 diff --git a/Content/Assets/Objects/Red_Jelly/Material_002.uasset b/Content/Assets/Objects/Red_Jelly/Material_002.uasset new file mode 100644 index 0000000..374de08 --- /dev/null +++ b/Content/Assets/Objects/Red_Jelly/Material_002.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b712614cebd3c1cc786fd40866cf4c47657e7cd3e7e74fb154c9e83032fb6ab +size 7580 diff --git a/Content/Assets/Objects/Red_Jelly/Redjelly_Cylinder.uasset b/Content/Assets/Objects/Red_Jelly/Redjelly_Cylinder.uasset new file mode 100644 index 0000000..78e71c9 --- /dev/null +++ b/Content/Assets/Objects/Red_Jelly/Redjelly_Cylinder.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aeaf5f844d2499c0f9376361f8205bb1851deec49e37bbbe9fde8827a2a14321 +size 39558 diff --git a/Content/Assets/Objects/Red_Jelly/Redjelly_Mball_009.uasset b/Content/Assets/Objects/Red_Jelly/Redjelly_Mball_009.uasset new file mode 100644 index 0000000..203fb89 --- /dev/null +++ b/Content/Assets/Objects/Red_Jelly/Redjelly_Mball_009.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9cbd3275bdc85e115cd900d3d96dde3ef29b41ef8030dccb0fae2f18c531a933 +size 102016 diff --git a/Content/BlueprintAI/AI/AIBruh.uasset b/Content/BlueprintAI/AI/AIBruh.uasset index 43e3a9b..25592c5 100644 --- a/Content/BlueprintAI/AI/AIBruh.uasset +++ b/Content/BlueprintAI/AI/AIBruh.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f991e2ffa722c07c9b215206e7e72e5f3405afb1da07d40d608f47419c25ecfd -size 79285 +oid sha256:800bdc6bd6084e775a08f93e15e6c3131bc1e42051c43aeed6cce77a4a694319 +size 82006 diff --git a/Content/BlueprintAI/AI/BTT_ChaseBruh.uasset b/Content/BlueprintAI/AI/BTT_ChaseBruh.uasset index cacd89d..93d5191 100644 --- a/Content/BlueprintAI/AI/BTT_ChaseBruh.uasset +++ b/Content/BlueprintAI/AI/BTT_ChaseBruh.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:da96ad8696b48b09139d79173aea8aea87bfb325c8f817e7ccf413d95f3f034f -size 39894 +oid sha256:93fb62549b8029d2b30422681be1c1a29b22b4819a7b8c94eaec4167a4119c65 +size 31978 diff --git a/Content/BlueprintAI/AI/BT_Bruh.uasset b/Content/BlueprintAI/AI/BT_Bruh.uasset index 2d51dcb..8c9e379 100644 --- a/Content/BlueprintAI/AI/BT_Bruh.uasset +++ b/Content/BlueprintAI/AI/BT_Bruh.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e1d788b5da4588cdcc0f487c37f6fb0de042672d3e874cbfad39b12336ede9fc -size 22998 +oid sha256:3808112aa42d25a44b52ffafe6703131ffa192d567f3b563aad1f433f066ff23 +size 22630 diff --git a/Content/Blueprints/Combat_UI/CombatCharacter.uasset b/Content/Blueprints/Combat_UI/CombatCharacter.uasset index 95ef963..7bbbcdc 100644 --- a/Content/Blueprints/Combat_UI/CombatCharacter.uasset +++ b/Content/Blueprints/Combat_UI/CombatCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:465dda65f6f573e5b213f73e85bf00219e3bbcc762d215532bb138add6695028 -size 82954 +oid sha256:e3a1680f53dbcb4b94ac3846215b6a7be418f2dd1b0b81468b68b3e303f9f022 +size 72456 diff --git a/Content/Blueprints/Combat_UI/Combat_UI.uasset b/Content/Blueprints/Combat_UI/Combat_UI.uasset index aeebd00..416a260 100644 --- a/Content/Blueprints/Combat_UI/Combat_UI.uasset +++ b/Content/Blueprints/Combat_UI/Combat_UI.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1f42716c7e52f59d5e57aabb8ff5699d656b0a43c6f95ad8802a31c9e13e0765 -size 77433 +oid sha256:52a0bccd38454b1877744bb682416d170c6d74c8de74517c8856432b45915b79 +size 78977 diff --git a/Content/Blueprints/Combat_UI/NS_GunEffect.uasset b/Content/Blueprints/Combat_UI/NS_GunEffect.uasset index 484df23..0e7e0b6 100644 --- a/Content/Blueprints/Combat_UI/NS_GunEffect.uasset +++ b/Content/Blueprints/Combat_UI/NS_GunEffect.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9375494bd5fe3b69508c04d2e5f19de73629aa81b24ba1c91a99136a0179c9a8 -size 1192218 +oid sha256:98e3118e947a8661b40edd468bdcbb0b51d3c612af7117d5e0d9d6ca3d955c96 +size 1073632 diff --git a/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset b/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset index cb0fa3a..239df23 100644 --- a/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset +++ b/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5aba7e76546797d974d8c1fbb2f989416f27912dbd289acc8c16a5bc5b25eefd -size 70965 +oid sha256:dd57bdf81793aa6f3b76784e3be306fef5ca81c5e2fa7065a29abadd420c4e0b +size 75420 diff --git a/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset b/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset index 0c71209..0c1f862 100644 --- a/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset +++ b/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:22b2132cd76cdc49d851a897a8295bac996dd4b048ee16722f3747a0b0a0fd42 -size 68094 +oid sha256:0fe126443f981aa1875e8efe299d76c4f0f570aff93f9313cc9503bb811365a5 +size 51324 diff --git a/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset b/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset index 3d3b44f..7eecebb 100644 --- a/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset +++ b/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8cc4e9151595d71a12c6f44c47b8f62ebb2687944cc124a6927fb8cddcf6a1fc -size 51431 +oid sha256:abe53946825159c2220acd237c3cc7360478b63836d52e3cbe000876e43eb5d5 +size 63822 diff --git a/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset b/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset index 5420305..8e7650a 100644 --- a/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset +++ b/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4f15b92c944a3038b636058b7f8fb3a6573a2ec271c3a6a1670bb5b9541c9d7c -size 52018 +oid sha256:936f77df55a4f4c1baca361f8ca9384f1af821ab6c0e8c9b016a3ede25c9f8d1 +size 63821 diff --git a/Content/Blueprints/Player/BP_MyTempCharacter.uasset b/Content/Blueprints/Player/BP_MyTempCharacter.uasset index 3cd68ed..f1f038b 100644 --- a/Content/Blueprints/Player/BP_MyTempCharacter.uasset +++ b/Content/Blueprints/Player/BP_MyTempCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:48787fb18ad9d51b32e5b837c8c1605b11d1b60014c75f2efa1ab910d621415b -size 56881 +oid sha256:be58819ba52b5638a31c272d4b3d2b93cfd6c75d2ad1717183b971c1c9d78234 +size 54639 diff --git a/Content/Levels/CombatTest.umap b/Content/Levels/CombatTest.umap deleted file mode 100644 index a1a8b59..0000000 --- a/Content/Levels/CombatTest.umap +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f9336348b2e1f84fb09314f0877836bec1973c977e1368b37276d5ab3db5344f -size 36124 diff --git a/Content/Levels/MerchantPrototype.umap b/Content/Levels/MerchantPrototype.umap index 7daa7d9..ea85903 100644 --- a/Content/Levels/MerchantPrototype.umap +++ b/Content/Levels/MerchantPrototype.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0ffba42fc8f6527bb83238b65ee72d5d2de2589f1d1bc825c23c5d86fc732889 -size 27144 +oid sha256:838c48c134383d4b1db178233640e11ef2c4bcd49102f53648cf621dd1dcbf8a +size 27100 diff --git a/Content/Levels/RealTimeCombatSystemTest.umap b/Content/Levels/RealTimeCombatSystemTest.umap deleted file mode 100644 index 9535012..0000000 --- a/Content/Levels/RealTimeCombatSystemTest.umap +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6fdfa02987672d19d3e4258aa21b585b6756ac110117681237b05928a3ae2891 -size 78727 diff --git a/Content/Levels/Testing/CopyStalagite.uasset b/Content/Levels/Testing/CopyStalagite.uasset new file mode 100644 index 0000000..b431889 --- /dev/null +++ b/Content/Levels/Testing/CopyStalagite.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db92152f858900ca683a3802711017f8096bfa3fa3cb4927ab66e1aab4da448b +size 1342607 diff --git a/Content/Levels/Testing/DestructableEnvironment.umap b/Content/Levels/Testing/DestructableEnvironment.umap new file mode 100644 index 0000000..7ec9da9 --- /dev/null +++ b/Content/Levels/Testing/DestructableEnvironment.umap @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f06da83cd4d0159f28d9f56a2b3adfcefac21f62021d145a7a112422b75326c +size 38502 diff --git a/Content/Levels/Testing/Stalagite_GeometryCollection.uasset b/Content/Levels/Testing/Stalagite_GeometryCollection.uasset new file mode 100644 index 0000000..681a240 --- /dev/null +++ b/Content/Levels/Testing/Stalagite_GeometryCollection.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e82c52e382833121ae4732dc3d9e99795b251a33ded6f5c8cf9590d46968bd98 +size 52222503 diff --git a/Content/Levels/Top_layer_level.umap b/Content/Levels/Top_layer_level.umap index aa3ec45..a574ef5 100644 --- a/Content/Levels/Top_layer_level.umap +++ b/Content/Levels/Top_layer_level.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bc511bc4e7b19332f111ac8a01b482bb15532a09a8b69d7f55b3ac82eff0b344 -size 226899 +oid sha256:621ffccf274045b06759e9739e5738e0362d79d9d3fe198be817f4d42b521cdd +size 229102 diff --git a/Misc/Additional Resources/Links To Additional Resources.txt b/Misc/Additional Resources/Links To Additional Resources.txt index 1101c45..e79ccf7 100644 --- a/Misc/Additional Resources/Links To Additional Resources.txt +++ b/Misc/Additional Resources/Links To Additional Resources.txt @@ -1,4 +1,6 @@ Combat Spread Sheet: -https://docs.google.com/spreadsheets/d/1s_uxjS8ir1pbt4-ofdOVpSPaQZVC8x9gQzS78bzE3KI/edit#gid=0 \ No newline at end of file +https://docs.google.com/spreadsheets/d/1s_uxjS8ir1pbt4-ofdOVpSPaQZVC8x9gQzS78bzE3KI/edit#gid=0 +https://docs.google.com/document/d/1Y6eYoKQPw9n8gl7p030fmtPjfJcE132YHAvwL7Gk4jk/edit + diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index 192d23c..beaad39 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -9,6 +9,7 @@ #include "GameFramework/Character.h" #include "Components/WidgetComponent.h" #include "Kismet/KismetMathLibrary.h" +#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" // Sets default values @@ -23,6 +24,40 @@ void AInteraction::BeginPlay() { Super::BeginPlay(); + //Character & Camera refs + TempCharacterRef = Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()); + MainCamera = Cast(TempCharacterRef->FindComponentByClass()); + //Item refs + + TargetHealingLocation = HealingItem->GetActorLocation(); + TargetBuffLocation = BuffItem->GetActorLocation(); + + // Dialog refs + + ShopDialogWidget = CreateWidget(GetWorld(), ShopDialog); + ShopDialogWidget->SetVisibility(ESlateVisibility::Hidden); + ShopDialogWidget->AddToViewport(); + + //Item Selector refs + ItemSelectorWidget = CreateWidget(GetWorld(), ItemSelector); + ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); + ItemSelectorWidget->AddToViewport(); + //We are getting the property of interaction since we need a reference for when we cast in BP and we need the reference to be self + Property = ItemSelectorWidget->GetClass()->FindPropertyByName("publicActor"); + + //Confirm Buy refs + BuyBuffTextWidget = CreateWidget(GetWorld(), BuyBuffText); + BuyBuffTextWidget->SetVisibility(ESlateVisibility::Hidden); + BuyBuffTextWidget->AddToViewport(); + //We are getting the property of interaction since we need a reference for when we cast in BP and we need the reference to be self + BuyBuffProperty = BuyBuffTextWidget->GetClass()->FindPropertyByName("publicActor"); + + BuyHealingTextWidget = CreateWidget(GetWorld(), BuyHealingText); + BuyHealingTextWidget->SetVisibility(ESlateVisibility::Hidden); + BuyHealingTextWidget->AddToViewport(); + //We are getting the property of interaction since we need a reference for when we cast in BP and we need the reference to be self + BuyHealingProperty = BuyHealingTextWidget->GetClass()->FindPropertyByName("publicActor"); + } // Called every frame @@ -35,14 +70,17 @@ void AInteraction::Tick(float DeltaTime) void AInteraction::OnInteract() { bDisableShopDialMove = true; - ShopDialogWidget = CreateWidget(GetWorld(), ShopDialog); if (ShopDialogWidget == nullptr) { + UE_LOG(LogTemp, Display, TEXT("ShopDialogWidget is null")); return; } else { - ShopDialogWidget->AddToViewport(0); + //Shop Widget to visible + ShopDialogWidget->SetVisibility(ESlateVisibility::Visible); + //Call a custom event in a blueprint called "PlayText" + ShopDialogWidget->CallFunctionByNameWithArguments(TEXT("PlayText"), *GLog, nullptr, true); } //handles the widget disappearing from the viewport FTimerHandle WidgetTimer; @@ -53,13 +91,22 @@ void AInteraction::OnInteract() void AInteraction::RemoveWidget() { bisDisabled = true; - ShopDialogWidget->RemoveFromViewport(); + //Setting ShopWidgetText back to hidden + ShopDialogWidget->SetVisibility(ESlateVisibility::Hidden); + if (ShopDialogWidget->IsVisible()) + { + return; + } + else + { + UE_LOG(LogTemp, Display, TEXT("You cant open this widget when this widget is open")); + } UE_LOG(LogTemp, Display, TEXT("setting isDisabled to true")); - ItemSelectorWidget = CreateWidget(GetWorld(), ItemSelector); - FProperty* Property = ItemSelectorWidget->GetClass()->FindPropertyByName("publicActor"); + if (Property == nullptr) { UE_LOG(LogTemp, Error, TEXT("Property not found")); + return; } else { @@ -72,7 +119,7 @@ void AInteraction::RemoveWidget() } else { - ItemSelectorWidget->AddToViewport(0); + ItemSelectorWidget->SetVisibility(ESlateVisibility::Visible); bisDisabled = false; } } @@ -80,9 +127,7 @@ void AInteraction::RemoveWidget() void AInteraction::CameraLeftMover() { UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed")); - TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); - MainCamera = Cast(TempCharacter->FindComponentByClass()); - if (TempCharacter == nullptr) + if (TempCharacterRef == nullptr || BuyHealingProperty == nullptr) { UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); return; @@ -90,18 +135,21 @@ void AInteraction::CameraLeftMover() else { UE_LOG(LogTemp, Display, TEXT("Character Found in interaction.cpp")); - if (MainCamera == nullptr) + if (MainCamera == nullptr || HealingItem == nullptr) { UE_LOG(LogTemp, Display, TEXT("Camera not found in Interaction.cpp")); return; } else { - FVector TargetLocation = FVector(5700,-1270,4040); - FVector CameraLocation = MainCamera->GetComponentLocation(); - FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetLocation); + FObjectPropertyBase* ObjectProperty = static_cast(BuyHealingProperty); + ObjectProperty->SetObjectPropertyValue(ObjectProperty->ContainerPtrToValuePtr(BuyHealingTextWidget), this); + + CameraLocation = MainCamera->GetComponentLocation(); + FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetHealingLocation); MainCamera->SetWorldRotation(CameraRotation); MainCamera->SetFieldOfView(40); + BuyHealingTextWidget->SetVisibility(ESlateVisibility::Visible); } } } @@ -109,9 +157,7 @@ void AInteraction::CameraLeftMover() void AInteraction::CameraRightMover() { UE_LOG(LogTemp, Display, TEXT("Button Right is being pressed")); - TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); - MainCamera = Cast(TempCharacter->FindComponentByClass()); - if (TempCharacter == nullptr) + if (TempCharacterRef == nullptr || BuyBuffProperty == nullptr) { UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); return; @@ -119,18 +165,45 @@ void AInteraction::CameraRightMover() else { UE_LOG(LogTemp, Display, TEXT("Character Found in interaction.cpp")); - if (MainCamera == nullptr) + if (MainCamera == nullptr || BuffItem == nullptr) { UE_LOG(LogTemp, Display, TEXT("Camera not found in Interaction.cpp")); return; } else { - FVector TargetLocation = FVector(5260, -840, 4070); - FVector CameraLocation = MainCamera->GetComponentLocation(); - FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetLocation); + FObjectPropertyBase* ObjectProperty = static_cast(BuyBuffProperty); + ObjectProperty->SetObjectPropertyValue(ObjectProperty->ContainerPtrToValuePtr(BuyBuffTextWidget), this); + + CameraLocation = MainCamera->GetComponentLocation(); + FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetBuffLocation); MainCamera->SetWorldRotation(CameraRotation); MainCamera->SetFieldOfView(40); + BuyBuffTextWidget->SetVisibility(ESlateVisibility::Visible); } } } + +void AInteraction::CancelPurchase() +{ + BuyBuffTextWidget->SetVisibility(ESlateVisibility::Hidden); + BuyHealingTextWidget->SetVisibility(ESlateVisibility::Hidden); +} + +void AInteraction::ExitScreen() +{ + if (TempCharacterRef == nullptr) + { + UE_LOG(LogTemp, Display, TEXT("TempCharacterRef in Interaction.cpp not found")); + return; + } + else + { + TempCharacterRef->InputEnabler(); + ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); + } +} + + + + diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h index fb771a9..76af4db 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h @@ -5,6 +5,7 @@ #include "CoreMinimal.h" #include "Camera/CameraComponent.h" #include "GameFramework/Actor.h" +#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" #include "Interaction.generated.h" UCLASS() @@ -24,12 +25,18 @@ public: // Called every frame virtual void Tick(float DeltaTime) override; - UPROPERTY(EditAnywhere) + UPROPERTY(EditAnywhere, Category= "Widgets") TSubclassOf ShopDialog; - UPROPERTY(EditAnywhere) + UPROPERTY(EditAnywhere, Category= "Widgets") TSubclassOf ItemSelector; + UPROPERTY(EditAnywhere, Category = "Widgets") + TSubclassOf BuyBuffText; + + UPROPERTY(EditAnywhere, Category = "Widgets") + TSubclassOf BuyHealingText; + virtual void OnInteract(); virtual void RemoveWidget(); @@ -39,8 +46,14 @@ public: UPROPERTY() UUserWidget* ItemSelectorWidget; + + UPROPERTY() + UUserWidget* BuyBuffTextWidget; - UPROPERTY(EditAnywhere) + UPROPERTY() + UUserWidget* BuyHealingTextWidget; + + UPROPERTY(EditAnywhere, Category= "Widgets") float WaitTimer = 8.0f; UPROPERTY() @@ -48,6 +61,7 @@ public: UPROPERTY() bool bDisableShopDialMove = false; + UFUNCTION(BlueprintCallable, Category= "ButtonLeft") virtual void CameraLeftMover(); @@ -58,7 +72,29 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera") UCameraComponent* MainCamera; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player") - ACharacter* TempCharacter; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items") + AActor* HealingItem; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items") + AActor* BuffItem; + + UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") + virtual void CancelPurchase(); + + UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") + virtual void ExitScreen(); + + UPROPERTY(EditAnywhere, Category = "Player") + ATempCharacter* TempCharacterRef; + +private: + + FVector TargetHealingLocation; + FVector TargetBuffLocation; + FVector CameraLocation; + + FProperty* Property; + FProperty* BuyBuffProperty; + FProperty* BuyHealingProperty; }; diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 50029de..bfdfe06 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -101,18 +101,35 @@ void ATempCharacter::LineTraceLogic() if (AInteraction* MyInteractable = Cast(OutHit.GetActor())) { - DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f); - MyInteractable->OnInteract(); - UE_LOG(LogTemp, Display, TEXT("OnInteract activated")); - UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName()); - - // While loop to check bisDisabled var until it changes to true - while (MyInteractable->bisDisabled == false || MyInteractable->bDisableShopDialMove == false) + if (MyInteractable->ShopDialogWidget->IsVisible()) { - if (MyInteractable->bisDisabled == true || MyInteractable->bDisableShopDialMove == true) + UE_LOG(LogTemp, Display, TEXT("ShopKeeper text is visible")); + bShopKeeperText = true; + return; + } + //if there is no text on screen this triggers + else + { + if (MyInteractable->ItemSelectorWidget->IsVisible()) { - InputDisabler(); - break; + return; + } + else + { + DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f); + MyInteractable->OnInteract(); + UE_LOG(LogTemp, Display, TEXT("OnInteract activated")); + UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName()); + + // While loop to check bisDisabled var until it changes to true + while (MyInteractable->bisDisabled == false || MyInteractable->bDisableShopDialMove == false) + { + if (MyInteractable->bisDisabled == true || MyInteractable->bDisableShopDialMove == true) + { + InputDisabler(); + break; + } + } } } } @@ -122,6 +139,7 @@ void ATempCharacter::LineTraceLogic() void ATempCharacter::InputDisabler() { UE_LOG(LogTemp, Display, TEXT("Disabling playermovement")); + //GetWorld()->GetFirstPlayerController()->InputComponent->RemoveActionBinding("Interact", IE_Pressed); GetWorld()->GetFirstPlayerController()->SetIgnoreLookInput(true); GetWorld()->GetFirstPlayerController()->SetIgnoreMoveInput(true); GetWorld()->GetFirstPlayerController()->bShowMouseCursor = true; @@ -150,6 +168,7 @@ void ATempCharacter::InputEnabler() GetWorld()->GetFirstPlayerController()->bShowMouseCursor = false; GetWorld()->GetFirstPlayerController()->bEnableClickEvents = false; GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = false; + //GetWorld()->GetFirstPlayerController()->InputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed); TraceDistance = 300; ThisCamera = Cast(this->FindComponentByClass()); if (ThisCamera == nullptr) @@ -161,7 +180,6 @@ void ATempCharacter::InputEnabler() ThisCamera->SetWorldLocation(OriginalCameraLocation); ThisCamera->SetWorldRotation(OriginalCameraRotation); ThisCamera->FieldOfView = OriginalCameraFOV; - //ulog the originalcameralocation value UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString()); } diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 052239c..928b8df 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -31,7 +31,10 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true")) class UInventoryComponent* Inventory; //Using the InventoryComponent class - + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets") + UUserWidget* ItemSelectorWidget; + // Called to bind functionality to input virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; @@ -43,6 +46,8 @@ public: void InputDisabler(); void LineTraceLogic(); + + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Health") float Health; @@ -70,5 +75,7 @@ public: UFUNCTION(BlueprintCallable, Category= "Items") void BuyItem(); + + bool bShopKeeperText = false; }; diff --git a/Source/the_twilight_abyss/RealTimeCombat/RealTimeCombat.cpp b/Source/the_twilight_abyss/RealTimeCombat/RealTimeCombat.cpp deleted file mode 100644 index 4242df1..0000000 --- a/Source/the_twilight_abyss/RealTimeCombat/RealTimeCombat.cpp +++ /dev/null @@ -1,319 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "RealTimeCombat.h" -#include "CoreMinimal.h" -#include "Blueprint/UserWidget.h" -#include "Components/TextBlock.h" -#include "Components/ProgressBar.h" -#include "Kismet/GameplayStatics.h" - - -ARealTimeCombat::ARealTimeCombat() -{ - PrimaryActorTick.bCanEverTick = true; - if (HUDWidget == nullptr) - { - // Load the HUD widget from the specified path - static ConstructorHelpers::FClassFinder HUDWidgetClass(TEXT("/Game/Blueprints/Combat_UI/Combat_UI_RT")); - HUDWidget = HUDWidgetClass.Class; - } -} - -void ARealTimeCombat::StartCombat() -{ - if (HUD->IsInViewport()) return; - HUD->AddToViewport(); - bStartTimer = true; - //EnemyActor = Enemy; - - // if (APlayerController* PC = Cast(GetWorld()->GetFirstPlayerController())) - // { - // PC->bShowMouseCursor = true; - // PC->bEnableClickEvents = true; - // PC->bEnableMouseOverEvents = true; - // } -} - -void ARealTimeCombat::EndCombat() -{ - //Remove the HUD from the viewport - HUD->RemoveFromViewport(); -} - -void ARealTimeCombat::OnMouseClick() -{ - ExecuteCast(CurrentComboString); -} - -void ARealTimeCombat::OnQPress() -{ - if (ActiveActionPoints <= 0) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Action Points")); - return; - } - if (IronResource <= 0) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Iron")); - return; - } - UseActionPoint(); - CurrentComboString.AppendChar('F'); - UpdateComboString(CurrentComboString); - IronResource -= 1; - UpdateResourceBars(); -} - -void ARealTimeCombat::OnEPress() -{ - if (ActiveActionPoints <= 0) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Action Points")); - return; - } - if (SulfurResource <= 0) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Sulfur")); - return; - } - UseActionPoint(); - CurrentComboString.AppendChar('W'); - UpdateComboString(CurrentComboString); - SulfurResource -= 1; - UpdateResourceBars(); -} - -void ARealTimeCombat::OnBackspacePress() -{ - if (CurrentComboString.Len() <= 0) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Blank Combo")); - return; - } - ReuseActionPoint(); - if (CurrentComboString.Right(1) == "F") - { - IronResource += 1; - } - else if (CurrentComboString.Right(1) == "W") - { - SulfurResource += 1; - } - CurrentComboString.RemoveAt(CurrentComboString.Len() - 1); - UpdateComboString(CurrentComboString); - UpdateResourceBars(); -} - -void ARealTimeCombat::BeginPlay() -{ - Super::BeginPlay(); - - TArray AllCharacterActorsInScene; - UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), AActor::StaticClass(), FName("Enemy"), AllCharacterActorsInScene); - for (AActor* Actor : AllCharacterActorsInScene) - { - EnemyActor = Cast(Actor); - } - - UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), AActor::StaticClass(), FName("Player"), AllCharacterActorsInScene); - for (AActor* Actor : AllCharacterActorsInScene) - { - PlayerActor = Cast(Actor); - } - - HUD = CreateWidget(GetWorld(), HUDWidget); - - CurrentComboTextBlock = Cast(HUD->GetWidgetFromName("CurrentCombo")); - ActionPointsTextBlock = Cast(HUD->GetWidgetFromName("ActionPoints")); - BattleLogTextBlock = Cast(HUD->GetWidgetFromName("BattleLog")); - PlayerHealthBar = Cast(HUD->GetWidgetFromName("PlayerHealthBar")); - EnemyHealthBar = Cast(HUD->GetWidgetFromName("EnemyHealthBar")); - IronResourceBar = Cast(HUD->GetWidgetFromName("IronResourceBar")); - SulfurResourceBar = Cast(HUD->GetWidgetFromName("SulfurResourceBar")); - ActionPointsBar = Cast(HUD->GetWidgetFromName("ActionPointsBar")); -} - -void ARealTimeCombat::ExecuteCast(FString Combo) -{ - if (!IsValidCombo(Combo)) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Invalid Combo")); - //For each character in the current combo add back the resource - for (int i = 0; i < Combo.Len(); i++) - { - if (Combo[i] == 'F') - { - IronResource += 1; - } - else if (Combo[i] == 'W') - { - SulfurResource += 1; - } - } - CurrentComboString = ""; - UpdateComboString(CurrentComboString); - RevertActionPoints(); - UpdateActionPoints(); - UpdateResourceBars(); - return; - } - - CurrentComboString = ""; - UpdateComboString(CurrentComboString); - RevertActionPoints(); - UpdateActionPoints(); - - if (!HitEnemy()) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Missed")); - return; - } - - switch (bIsPlayerTurn) - { - case true: - // Player Turn - DamageEnemy(*ValidCombos.Find(Combo)); - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("Enemy Damaged %d"), *ValidCombos.Find(Combo))); - break; - case false: - // Enemy Turn - DamagePlayer(*ValidCombos.Find(Combo)); - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("Player Damaged %d"), *ValidCombos.Find(Combo))); - break; - } - //End Combat if either the player or enemy is dead - if (EnemyHealth <= 0) - { - EndCombat(); - EnemyActor->Destroy(); - return; - } - if (PlayerHealth <= 0) - { - EndCombat(); - return; - } - - // SwitchTurn(); -} - -void ARealTimeCombat::UseActionPoint() -{ - if (HeldActionPoints > 0 && ActiveActionPoints <= HeldActionPoints) - { - ActiveActionPoints -= 1; - UpdateActionPoints(); - } -} - -void ARealTimeCombat::ReuseActionPoint() -{ - ActiveActionPoints += 1; - UpdateActionPoints(); -} - -void ARealTimeCombat::RevertActionPoints() -{ - ActiveActionPoints = HeldActionPoints; - UpdateActionPoints(); -} - -void ARealTimeCombat::DamagePlayer(int Damage) -{ - PlayerHealth -= FMath::Clamp(Damage, 0, 100); - UpdateProgressBars(); - AddBattleLogMessage("Player was damaged for " + FString::FromInt(Damage) + " damage."); -} - -void ARealTimeCombat::DamageEnemy(int Damage) -{ - EnemyHealth -= FMath::Clamp(Damage, 0, 100); - UpdateProgressBars(); - AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage) + " damage."); -} - -void ARealTimeCombat::UpdateProgressBars() const -{ - PlayerHealthBar->SetPercent(PlayerHealth / 100.0f); - EnemyHealthBar->SetPercent(EnemyHealth / 100.0f); -} - -void ARealTimeCombat::Tick(float DeltaSeconds) -{ - Super::Tick(DeltaSeconds); - if (ActionPointsTimer >= 1.0f && HeldActionPoints < MaxActionPoints && bStartTimer) - { - HeldActionPoints += 1; - ActiveActionPoints += 1; - UpdateActionPoints(); - ActionPointsTimer = 0.0f; - } - else - { - ActionPointsTimer += DeltaSeconds; - ActionPointsBar->SetPercent(ActionPointsTimer); - } -} - -bool ARealTimeCombat::IsValidCombo(FString Combo) const -{ - return ValidCombos.Contains(Combo); -} - -void ARealTimeCombat::UpdateComboString(FString NewCombo) const -{ - CurrentComboTextBlock->SetText(FText::FromString(NewCombo)); -} - -void ARealTimeCombat::UpdateActionPoints() const -{ - ActionPointsTextBlock->SetText(FText::FromString(FString::FromInt(ActiveActionPoints))); -} - -void ARealTimeCombat::AddBattleLogMessage(FString Message) -{ - BattleLog.Append(Message + "\n"); - UpdateBattleLog(); -} - -void ARealTimeCombat::ClearBattleLog() -{ - BattleLog = ""; -} - -void ARealTimeCombat::UpdateBattleLog() -{ - TArray TempArray; - if (const int32 LineCount = BattleLog.ParseIntoArray(TempArray, TEXT("\n"), true); LineCount > 10) - { - ClearBattleLog(); - } - BattleLogTextBlock->SetText(FText::FromString(BattleLog)); -} - -void ARealTimeCombat::UpdateResourceBars() const -{ - IronResourceBar->SetPercent(IronResource / 10.0f); - SulfurResourceBar->SetPercent(SulfurResource / 10.0f); -} - -bool ARealTimeCombat::HitEnemy() const -{ - FHitResult HitResult; - FVector Start = PlayerActor->GetActorLocation(); - FVector End = PlayerActor->GetActorForwardVector() * 1000.0f + Start; - FCollisionQueryParams CollisionParams; - CollisionParams.AddIgnoredActor(PlayerActor); - if (GetWorld()->LineTraceSingleByChannel(HitResult, Start, End, ECC_Pawn, CollisionParams)) - { - DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 5.0f, 0, 10.0f); - if (HitResult.GetActor() == EnemyActor) - { - return true; - } - } - DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, 5.0f, 0, 10.0f); - return false; -} diff --git a/Source/the_twilight_abyss/RealTimeCombat/RealTimeCombat.h b/Source/the_twilight_abyss/RealTimeCombat/RealTimeCombat.h deleted file mode 100644 index c6cfae9..0000000 --- a/Source/the_twilight_abyss/RealTimeCombat/RealTimeCombat.h +++ /dev/null @@ -1,127 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "Components/Button.h" -#include "Components/ProgressBar.h" -#include "Components/TextBlock.h" -#include "GameFramework/GameStateBase.h" -#include "RealTimeCombat.generated.h" - -UCLASS() -class THE_TWILIGHT_ABYSS_API ARealTimeCombat : public AGameStateBase -{ - GENERATED_BODY() - ARealTimeCombat(); - - UPROPERTY(EditDefaultsOnly) - int PlayerHealth = 100; - UPROPERTY(EditDefaultsOnly) - int EnemyHealth = 100; - UPROPERTY(EditDefaultsOnly) - int MaxActionPoints = 3; - UPROPERTY(EditDefaultsOnly) - int ActiveActionPoints = 0; - UPROPERTY(EditDefaultsOnly) - int IronResource = 10; // F - UPROPERTY(EditDefaultsOnly) - int SulfurResource = 10; // W - - UPROPERTY(VisibleAnywhere) - AActor* PlayerActor; - UPROPERTY(VisibleAnywhere) - AActor* EnemyActor; - // AActor* ActiveActor; - - /* - TODO: - Reference Player Inventory - */ - UPROPERTY(EditAnywhere) - TSubclassOf HUDWidget; - UPROPERTY(EditAnywhere) - TMap ValidCombos = - { - {"F", 10}, - {"W", 10}, - {"WW", 15}, - {"FW", 20}, - {"FFW", 30} - }; - - FString BattleLog; - - UFUNCTION(BlueprintCallable) - void StartCombat(); - UFUNCTION(BlueprintCallable) - void EndCombat(); - UFUNCTION(BlueprintCallable) - void OnMouseClick(); - UFUNCTION(BlueprintCallable) - void OnQPress(); - UFUNCTION(BlueprintCallable) - void OnEPress(); - UFUNCTION(BlueprintCallable) - void OnBackspacePress(); - -protected: - virtual void BeginPlay() override; - void ExecuteCast(FString Combo); - void UseActionPoint(); - void ReuseActionPoint(); - void RevertActionPoints(); - void DamagePlayer(int Damage); - void DamageEnemy(int Damage); - void UpdateProgressBars() const; - virtual void Tick(float DeltaSeconds) override; - -private: - bool IsValidCombo(FString Combo) const; - float ActionPointsTimer = 0.0f; - int HeldActionPoints = 0; - - UPROPERTY() - UUserWidget* HUD; - - UPROPERTY(VisibleAnywhere) - bool bIsPlayerTurn = true; - - UPROPERTY(VisibleAnywhere) - FString CurrentComboString = ""; - - UPROPERTY(VisibleAnywhere) - UTextBlock* CurrentComboTextBlock; - - UPROPERTY(VisibleAnywhere) - UTextBlock* BattleLogTextBlock; - - UPROPERTY(VisibleAnywhere) - UTextBlock* ActionPointsTextBlock; - - UPROPERTY(VisibleAnywhere) - UProgressBar* PlayerHealthBar; - - UPROPERTY(VisibleAnywhere) - UProgressBar* EnemyHealthBar; - - UPROPERTY(VisibleAnywhere) - UProgressBar* IronResourceBar; - - UPROPERTY(VisibleAnywhere) - UProgressBar* SulfurResourceBar; - - UPROPERTY(VisibleAnywhere) - UProgressBar* ActionPointsBar; - - void UpdateComboString(FString NewCombo) const; - void UpdateActionPoints() const; - - void AddBattleLogMessage(FString Message); - void ClearBattleLog(); - void UpdateBattleLog(); - void UpdateResourceBars() const; - bool HitEnemy() const; - - bool bStartTimer = false; -}; diff --git a/Source/the_twilight_abyss/TurnBasedCombat/PlayerCharacterCombatTest.cpp b/Source/the_twilight_abyss/TurnBasedCombat/PlayerCharacterCombatTest.cpp deleted file mode 100644 index 99dbb55..0000000 --- a/Source/the_twilight_abyss/TurnBasedCombat/PlayerCharacterCombatTest.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "PlayerCharacterCombatTest.h" - -// Sets default values -APlayerCharacterCombatTest::APlayerCharacterCombatTest() -{ - // 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; - - Tags.Add(FName("Character")); -} - -// Called when the game starts or when spawned -void APlayerCharacterCombatTest::BeginPlay() -{ - Super::BeginPlay(); - -} - -// Called every frame -void APlayerCharacterCombatTest::Tick(float DeltaTime) -{ - Super::Tick(DeltaTime); - -} - -// Called to bind functionality to input -void APlayerCharacterCombatTest::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) -{ - Super::SetupPlayerInputComponent(PlayerInputComponent); - -} - diff --git a/Source/the_twilight_abyss/TurnBasedCombat/PlayerCharacterCombatTest.h b/Source/the_twilight_abyss/TurnBasedCombat/PlayerCharacterCombatTest.h deleted file mode 100644 index ffffd26..0000000 --- a/Source/the_twilight_abyss/TurnBasedCombat/PlayerCharacterCombatTest.h +++ /dev/null @@ -1,29 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "GameFramework/Character.h" -#include "PlayerCharacterCombatTest.generated.h" - -UCLASS() -class THE_TWILIGHT_ABYSS_API APlayerCharacterCombatTest : public ACharacter -{ - GENERATED_BODY() - -public: - // Sets default values for this character's properties - APlayerCharacterCombatTest(); - -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; - -}; diff --git a/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.cpp b/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.cpp deleted file mode 100644 index 8856b35..0000000 --- a/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.cpp +++ /dev/null @@ -1,297 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "TurnBaseCombat.h" -#include "CoreMinimal.h" -#include "Blueprint/UserWidget.h" -#include "Components/TextBlock.h" -#include "Components/ProgressBar.h" -#include "Kismet/GameplayStatics.h" - -ATurnBaseCombat::ATurnBaseCombat() -{ - if (HUDWidget == nullptr) - { - // Load the HUD widget from the specified path - static ConstructorHelpers::FClassFinder HUDWidgetClass(TEXT("/Game/Blueprints/Combat_UI/Combat_UI")); - HUDWidget = HUDWidgetClass.Class; - } -} - -void ATurnBaseCombat::StartCombat(AActor* Enemy) -{ - if (HUD->IsInViewport()) return; - HUD->AddToViewport(); - EnemyActor = Enemy; - - if (APlayerController* PC = Cast(GetWorld()->GetFirstPlayerController())) - { - PC->bShowMouseCursor = true; - PC->bEnableClickEvents = true; - PC->bEnableMouseOverEvents = true; - } -} - -void ATurnBaseCombat::EndCombat() -{ - //Remove the HUD from the viewport - HUD->RemoveFromViewport(); -} - -void ATurnBaseCombat::BeginPlay() -{ - Super::BeginPlay(); - - TArray AllCharacterActorsInScene; - UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), AActor::StaticClass(), FName("Character"), AllCharacterActorsInScene); - - HUD = CreateWidget(GetWorld(), HUDWidget); - - TurnIndicatorTextBlock = Cast(HUD->GetWidgetFromName("TurnIndicator")); - CurrentComboTextBlock = Cast(HUD->GetWidgetFromName("CurrentCombo")); - ActionPointsTextBlock = Cast(HUD->GetWidgetFromName("ActionPoints")); - BattleLogTextBlock = Cast(HUD->GetWidgetFromName("BattleLog")); - PlayerHealthBar = Cast(HUD->GetWidgetFromName("PlayerHealthBar")); - EnemyHealthBar = Cast(HUD->GetWidgetFromName("EnemyHealthBar")); - IronResourceBar = Cast(HUD->GetWidgetFromName("IronResourceBar")); - SulfurResourceBar = Cast(HUD->GetWidgetFromName("SulfurResourceBar")); - CastButton = Cast(HUD->GetWidgetFromName("CastButton")); - FButton = Cast(HUD->GetWidgetFromName("FButton")); - WButton = Cast(HUD->GetWidgetFromName("WButton")); - BackspaceButton = Cast(HUD->GetWidgetFromName("BackspaceButton")); - CastButton->OnClicked.AddDynamic(this, &ATurnBaseCombat::CastButtonOnClick); - FButton->OnClicked.AddDynamic(this, &ATurnBaseCombat::FButtonOnClick); - WButton->OnClicked.AddDynamic(this, &ATurnBaseCombat::WButtonOnClick); - BackspaceButton->OnClicked.AddDynamic(this, &ATurnBaseCombat::BackspaceButtonOnClick); -} - -void ATurnBaseCombat::ExecuteCast(FString Combo) -{ - if (!IsValidCombo(Combo)) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Invalid Combo")); - //For each character in the current combo add back the resource - for (int i = 0; i < Combo.Len(); i++) - { - if (Combo[i] == 'F') - { - IronResource += 1; - } - else if (Combo[i] == 'W') - { - SulfurResource += 1; - } - } - CurrentComboString = ""; - UpdateComboString(CurrentComboString); - RevertActionPoints(); - UpdateActionPoints(); - UpdateResourceBars(); - return; - } - - CurrentComboString = ""; - UpdateComboString(CurrentComboString); - RevertActionPoints(); - UpdateActionPoints(); - - switch (bIsPlayerTurn) - { - case true: - // Player Turn - DamageEnemy(*ValidCombos.Find(Combo)); - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("Enemy Damaged %d"), *ValidCombos.Find(Combo))); - break; - case false: - // Enemy Turn - DamagePlayer(*ValidCombos.Find(Combo)); - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("Player Damaged %d"), *ValidCombos.Find(Combo))); - break; - } - //End Combat if either the player or enemy is dead - if (EnemyHealth <= 0) - { - EndCombat(); - EnemyActor->Destroy(); - return; - } - if (PlayerHealth <= 0) - { - EndCombat(); - return; - } - - SwitchTurn(); -} - -void ATurnBaseCombat::UseActionPoint() -{ - ActiveActionPoints += 1; - UpdateActionPoints(); -} - -void ATurnBaseCombat::ReuseActionPoint() -{ - ActiveActionPoints -= 1; - UpdateActionPoints(); -} - -void ATurnBaseCombat::RevertActionPoints() -{ - ActiveActionPoints = 0; - UpdateActionPoints(); -} - -void ATurnBaseCombat::DamagePlayer(int Damage) -{ - PlayerHealth -= FMath::Clamp(Damage, 0, 100); - UpdateProgressBars(); - AddBattleLogMessage("Player was damaged for " + FString::FromInt(Damage) + " damage."); -} - -void ATurnBaseCombat::DamageEnemy(int Damage) -{ - EnemyHealth -= FMath::Clamp(Damage, 0, 100); - UpdateProgressBars(); - AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage) + " damage."); -} - -void ATurnBaseCombat::UpdateProgressBars() const -{ - PlayerHealthBar->SetPercent(PlayerHealth / 100.0f); - EnemyHealthBar->SetPercent(EnemyHealth / 100.0f); -} - -bool ATurnBaseCombat::IsValidCombo(FString Combo) const -{ - return ValidCombos.Contains(Combo); -} - -void ATurnBaseCombat::SwitchTurn() -{ - //TurnIndicatorTextBlock->SetText(FText::FromString(bIsPlayerTurn ? "Enemy Turn" : "Player Turn")); - //bIsPlayerTurn = !bIsPlayerTurn; - TurnIndicatorTextBlock->SetText(FText::FromString("Enemy Turn")); - ToggleButtons(); - //wait for 2 seconds - FTimerHandle UnusedHandle; - GetWorldTimerManager().SetTimer(UnusedHandle, this, &ATurnBaseCombat::EnemyTurn, 2.0f, false); - - //activeActor = bIsPlayerTurn ? enemyActor : playerActor; -} - -void ATurnBaseCombat::CastButtonOnClick() -{ - ExecuteCast(CurrentComboString); -} - -void ATurnBaseCombat::FButtonOnClick() -{ - if (ActiveActionPoints >= DefaultActionPoints) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Action Points")); - return; - } - if (IronResource <= 0) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Iron")); - return; - } - UseActionPoint(); - CurrentComboString.AppendChar('F'); - UpdateComboString(CurrentComboString); - IronResource -= 1; - UpdateResourceBars(); -} - -void ATurnBaseCombat::WButtonOnClick() -{ - if (ActiveActionPoints >= DefaultActionPoints) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Action Points")); - return; - } - if (SulfurResource <= 0) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Sulfur")); - return; - } - UseActionPoint(); - CurrentComboString.AppendChar('W'); - UpdateComboString(CurrentComboString); - SulfurResource -= 1; - UpdateResourceBars(); -} - -void ATurnBaseCombat::BackspaceButtonOnClick() -{ - if (CurrentComboString.Len() <= 0) - { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Blank Combo")); - return; - } - ReuseActionPoint(); - if (CurrentComboString.Right(1) == "F") - { - IronResource += 1; - } - else if (CurrentComboString.Right(1) == "W") - { - SulfurResource += 1; - } - CurrentComboString.RemoveAt(CurrentComboString.Len() - 1); - UpdateComboString(CurrentComboString); - UpdateResourceBars(); -} - -void ATurnBaseCombat::UpdateComboString(FString NewCombo) const -{ - CurrentComboTextBlock->SetText(FText::FromString(NewCombo)); -} - -void ATurnBaseCombat::UpdateActionPoints() const -{ - ActionPointsTextBlock->SetText(FText::FromString(FString::FromInt(ActiveActionPoints))); -} - -void ATurnBaseCombat::AddBattleLogMessage(FString Message) -{ - BattleLog.Append(Message + "\n"); - UpdateBattleLog(); -} - -void ATurnBaseCombat::ClearBattleLog() -{ - BattleLog = ""; -} - -void ATurnBaseCombat::UpdateBattleLog() -{ - TArray TempArray; - if (const int32 LineCount = BattleLog.ParseIntoArray(TempArray, TEXT("\n"), true); LineCount > 10) - { - ClearBattleLog(); - } - BattleLogTextBlock->SetText(FText::FromString(BattleLog)); -} - -void ATurnBaseCombat::UpdateResourceBars() const -{ - IronResourceBar->SetPercent(IronResource / 10.0f); - SulfurResourceBar->SetPercent(SulfurResource / 10.0f); -} - -void ATurnBaseCombat::ToggleButtons() const -{ - FButton->SetIsEnabled(!FButton->bIsEnabled); - WButton->SetIsEnabled(!WButton->bIsEnabled); - BackspaceButton->SetIsEnabled(!BackspaceButton->bIsEnabled); - CastButton->SetIsEnabled(!CastButton->bIsEnabled); -} - -void ATurnBaseCombat::EnemyTurn() -{ - DamagePlayer(10); - TurnIndicatorTextBlock->SetText(FText::FromString("Player Turn")); - ToggleButtons(); -} diff --git a/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.h b/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.h deleted file mode 100644 index 8b8409a..0000000 --- a/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.h +++ /dev/null @@ -1,145 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "Components/Button.h" -#include "Components/ProgressBar.h" -#include "Components/TextBlock.h" -#include "GameFramework/GameStateBase.h" -#include "TurnBaseCombat.generated.h" - -/** - * - */ -UCLASS() -class THE_TWILIGHT_ABYSS_API ATurnBaseCombat : public AGameStateBase -{ - GENERATED_BODY() - -public: - ATurnBaseCombat(); - - UPROPERTY(EditDefaultsOnly) - int PlayerHealth = 100; - UPROPERTY(EditDefaultsOnly) - int EnemyHealth = 100; - UPROPERTY(EditDefaultsOnly) - int DefaultActionPoints = 3; - UPROPERTY(EditDefaultsOnly) - int ActiveActionPoints = 0; - UPROPERTY(EditDefaultsOnly) - int IronResource = 10; // F - UPROPERTY(EditDefaultsOnly) - int SulfurResource = 10; // W - - // AActor* PlayerActor; - UPROPERTY(VisibleAnywhere) - AActor* EnemyActor; - // AActor* ActiveActor; - - /* - TODO: - Reference Player Inventory - */ - UPROPERTY(EditAnywhere) - TSubclassOf HUDWidget; - UPROPERTY(EditAnywhere) - TMap ValidCombos = - { - {"F", 10}, - {"W", 10}, - {"WW", 15}, - {"FW", 20}, - {"FFW", 30} - }; - - FString BattleLog; - - UFUNCTION(BlueprintCallable) - void StartCombat(AActor* Enemy); - UFUNCTION(BlueprintCallable) - void EndCombat(); - -protected: - virtual void BeginPlay() override; - void ExecuteCast(FString Combo); - void UseActionPoint(); - void ReuseActionPoint(); - void RevertActionPoints(); - void DamagePlayer(int Damage); - void DamageEnemy(int Damage); - void UpdateProgressBars() const; - -private: - bool IsValidCombo(FString Combo) const; - - UPROPERTY() - UUserWidget* HUD; - - UPROPERTY(VisibleAnywhere) - bool bIsPlayerTurn = true; - - UPROPERTY(VisibleAnywhere) - FString CurrentComboString = ""; - - void SwitchTurn(); - - UPROPERTY(VisibleAnywhere) - UTextBlock* TurnIndicatorTextBlock; - - UPROPERTY(VisibleAnywhere) - UTextBlock* CurrentComboTextBlock; - - UPROPERTY(VisibleAnywhere) - UTextBlock* BattleLogTextBlock; - - UPROPERTY(VisibleAnywhere) - UTextBlock* ActionPointsTextBlock; - - UPROPERTY(VisibleAnywhere) - UProgressBar* PlayerHealthBar; - - UPROPERTY(VisibleAnywhere) - UProgressBar* EnemyHealthBar; - - UPROPERTY(VisibleAnywhere) - UProgressBar* IronResourceBar; - - UPROPERTY(VisibleAnywhere) - UProgressBar* SulfurResourceBar; - - UPROPERTY(VisibleAnywhere) - UButton* CastButton; - - UPROPERTY(VisibleAnywhere) - UButton* FButton; - - UPROPERTY(VisibleAnywhere) - UButton* WButton; - - UPROPERTY(VisibleAnywhere) - UButton* BackspaceButton; - - UFUNCTION() - void CastButtonOnClick(); - - UFUNCTION() - void FButtonOnClick(); - - UFUNCTION() - void WButtonOnClick(); - - UFUNCTION() - void BackspaceButtonOnClick(); - - void UpdateComboString(FString NewCombo) const; - void UpdateActionPoints() const; - - void AddBattleLogMessage(FString Message); - void ClearBattleLog(); - void UpdateBattleLog(); - void UpdateResourceBars() const; - void ToggleButtons() const; - void EnemyTurn(); -}; diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp index 22fd2a7..543908c 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp @@ -24,11 +24,11 @@ void UHoldToInitCombat::BeginPlay() Super::BeginPlay(); InitCombatWidget = CreateWidget(GetWorld(), InitCombatWidgetClass); - UInputComponent* playerInputComponent = GetWorld()->GetFirstPlayerController()->InputComponent; + UInputComponent* PlayerInputComponent = GetWorld()->GetFirstPlayerController()->InputComponent; //Bind Right Mouse Button to the function OnRightClickDown - playerInputComponent->BindAction("RightClick", IE_Pressed, this, &UHoldToInitCombat::OnRightClickDown); + PlayerInputComponent->BindAction("RightClick", IE_Pressed, this, &UHoldToInitCombat::OnRightClickDown); //Bind Right Mouse Button to the function OnRightClickUp - playerInputComponent->BindAction("RightClick", IE_Released, this, &UHoldToInitCombat::OnRightClickUp); + PlayerInputComponent->BindAction("RightClick", IE_Released, this, &UHoldToInitCombat::OnRightClickUp); } @@ -37,17 +37,22 @@ void UHoldToInitCombat::TickComponent(float DeltaTime, ELevelTick TickType, FAct { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - //If the player is holding down the right mouse button for 3 seconds, then the player will enter combat mode - if (bRightClickDown && RightClickDownTime < 0.1f) + // //If the player is holding down the right mouse button for 3 seconds, then the player will enter combat mode + // if (bRightClickDown && RightClickDownTime < 0.1f) + // { + // RightClickDownTime += DeltaTime; + // } + // else if (bRightClickDown && RightClickDownTime >= 0.1f) + // { + // //Enter Combat Mode + // Cast(GetWorld()->GetGameState())->StartCombat(TargetEnemy); + // //UBlackboardComponent* TargetEnemyBlackboard = Cast(TargetEnemy->GetComponentByClass(UBlackboardComponent::StaticClass())); + // //TargetEnemyBlackboard->SetValueAsBool("IsInCombat", true); + // OnRightClickUp(); + // } + if (bRightClickDown) { - RightClickDownTime += DeltaTime; - } - else if (bRightClickDown && RightClickDownTime >= 0.1f) - { - //Enter Combat Mode Cast(GetWorld()->GetGameState())->StartCombat(TargetEnemy); - //UBlackboardComponent* TargetEnemyBlackboard = Cast(TargetEnemy->GetComponentByClass(UBlackboardComponent::StaticClass())); - //TargetEnemyBlackboard->SetValueAsBool("IsInCombat", true); OnRightClickUp(); } } @@ -58,7 +63,17 @@ void UHoldToInitCombat::OnRightClickDown() { TargetEnemy = RightClickHit; bRightClickDown = true; - InitCombatWidget->AddToViewport(); + //InitCombatWidget->AddToViewport(); + } + + if (GunEffect) + { + //Get Player Actor + const AActor* PlayerActor = GetWorld()->GetFirstPlayerController()->GetPawn(); + //Get Static Mesh Location on the player actor + const UStaticMeshComponent* GunComponent = Cast(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()); } } @@ -68,29 +83,29 @@ void UHoldToInitCombat::OnRightClickUp() RightClickDownTime = 0.0f; if (InitCombatWidget->IsInViewport()) { - InitCombatWidget->RemoveFromViewport(); + InitCombatWidget->RemoveFromParent(); } } AActor* UHoldToInitCombat::LookingAtEnemy() const { FVector Start = GetOwner()->GetActorLocation(); - FVector End = GetOwner()->GetActorForwardVector() * 1500.0f + Start; + FVector End = GetOwner()->GetActorForwardVector() * 1000.0f + Start; FCollisionQueryParams CollisionParams; CollisionParams.AddIgnoredActor(GetOwner()); if (FHitResult HitResult; GetWorld()->LineTraceSingleByChannel(HitResult, Start, End, ECC_Pawn, CollisionParams)) { - DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 5.0f, 0, 10.0f); + //DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 5.0f, 0, 10.0f); if (HitResult.GetActor()->Tags.Contains("Enemy")) { return HitResult.GetActor(); } if (HitResult.GetActor()->Tags.Contains("Break")) - { + { HitResult.GetActor()->Destroy(); - return nullptr; - } + return nullptr; + } } - DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, 5.0f, 0, 10.0f); + //DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, 5.0f, 0, 10.0f); return nullptr; } diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.h b/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.h index 3cba925..c29c0ca 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.h @@ -4,8 +4,11 @@ #include "CoreMinimal.h" #include "Components/ActorComponent.h" +#include "NiagaraComponent.h" +#include "NiagaraFunctionLibrary.h" #include "HoldToInitCombat.generated.h" +class UNiagaraSystem; UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) class THE_TWILIGHT_ABYSS_API UHoldToInitCombat : public UActorComponent @@ -20,6 +23,9 @@ public: UPROPERTY() TSubclassOf InitCombatWidgetClass; + UPROPERTY(EditDefaultsOnly) + UNiagaraSystem* GunEffect; + protected: // Called when the game starts virtual void BeginPlay() override; diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp index 7a73bb1..11417e9 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp @@ -3,16 +3,18 @@ #include "TurnBaseCombatV2.h" #include "CoreMinimal.h" +#include "AIController.h" #include "Blueprint/UserWidget.h" +#include "BehaviorTree/BlackboardComponent.h" #include "Components/TextBlock.h" #include "Components/ProgressBar.h" #include "GameFramework/Character.h" #include "Kismet/GameplayStatics.h" +#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" // Sets default values ATurnBaseCombatV2::ATurnBaseCombatV2() { - if (HUDWidget == nullptr) { // Load the HUD widget from the specified path @@ -23,10 +25,23 @@ ATurnBaseCombatV2::ATurnBaseCombatV2() void ATurnBaseCombatV2::StartCombat(AActor* Enemy) { + if (Enemy == nullptr) return; + UBlackboardComponent* EnemyBlackboard = Cast(Enemy->GetInstigatorController())->GetBlackboardComponent(); + + if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return; + EnemyBlackboard->SetValueAsBool("IsInCombat", true); + FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health")); + int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr(Enemy); + + EnemyHealth = EnemyHealthPtr; + if (HUD->IsInViewport()) return; HUD->AddToViewport(); EnemyActor = Enemy; + IronResource = 10; + SulfurResource = 10; + if (APlayerController* PC = Cast(GetWorld()->GetFirstPlayerController())) { PC->bShowMouseCursor = true; @@ -48,7 +63,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy) void ATurnBaseCombatV2::EndCombat() { //Remove the HUD from the viewport - HUD->RemoveFromViewport(); + HUD->RemoveFromParent(); APawn* PlayerPawn = Cast(GetWorld()->GetFirstPlayerController()->GetPawn()); PlayerPawn->bUseControllerRotationYaw = true; PlayerPawn->bUseControllerRotationPitch = true; @@ -57,6 +72,17 @@ void ATurnBaseCombatV2::EndCombat() { PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController()); } + if (APlayerController* PC = Cast(GetWorld()->GetFirstPlayerController())) + { + PC->bShowMouseCursor = false; + PC->bEnableClickEvents = false; + PC->bEnableMouseOverEvents = false; + } + GetWorld()->GetFirstPlayerController()->SetIgnoreLookInput(false); + GetWorld()->GetFirstPlayerController()->SetIgnoreMoveInput(false); + GetWorld()->GetFirstPlayerController()->bShowMouseCursor = false; + GetWorld()->GetFirstPlayerController()->bEnableClickEvents = false; + GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = false; } void ATurnBaseCombatV2::FKeyPressed() @@ -80,6 +106,7 @@ void ATurnBaseCombatV2::BeginPlay() { PlayerActor = Cast(Actor); } + PlayerHealth = &Cast(PlayerActor)->Health; HUD = CreateWidget(GetWorld(), HUDWidget); @@ -95,10 +122,12 @@ void ATurnBaseCombatV2::BeginPlay() FButton = Cast(HUD->GetWidgetFromName("FButton")); WButton = Cast(HUD->GetWidgetFromName("WButton")); BackspaceButton = Cast(HUD->GetWidgetFromName("BackspaceButton")); + RunButton = Cast(HUD->GetWidgetFromName("RunButton")); CastButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::CastButtonOnClick); FButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::FButtonOnClick); WButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::WButtonOnClick); BackspaceButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::BackspaceButtonOnClick); + RunButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::RunButtonOnClick); } void ATurnBaseCombatV2::ExecuteCast(FString Combo) @@ -153,13 +182,13 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo) break; } //End Combat if either the player or enemy is dead - if (EnemyHealth <= 0) + if (*EnemyHealth <= 0) { EndCombat(); EnemyActor->Destroy(); return; } - if (PlayerHealth <= 0) + if (*PlayerHealth <= 0) { EndCombat(); return; @@ -188,22 +217,22 @@ void ATurnBaseCombatV2::RevertActionPoints() void ATurnBaseCombatV2::DamagePlayer(int Damage) { - PlayerHealth -= FMath::Clamp(Damage, 0, 100); + *PlayerHealth -= FMath::Clamp(Damage, 0, 100); UpdateProgressBars(); AddBattleLogMessage("Player was damaged for " + FString::FromInt(Damage) + " damage."); } void ATurnBaseCombatV2::DamageEnemy(int Damage) { - EnemyHealth -= FMath::Clamp(Damage, 0, 100); + *EnemyHealth -= FMath::Clamp(Damage, 0, 100); UpdateProgressBars(); AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage) + " damage."); } void ATurnBaseCombatV2::UpdateProgressBars() const { - PlayerHealthBar->SetPercent(PlayerHealth / 100.0f); - EnemyHealthBar->SetPercent(EnemyHealth / 100.0f); + PlayerHealthBar->SetPercent(*PlayerHealth / 100.0f); + EnemyHealthBar->SetPercent(*EnemyHealth / 100.0f); } bool ATurnBaseCombatV2::IsValidCombo(FString Combo) const @@ -220,7 +249,7 @@ void ATurnBaseCombatV2::SwitchTurn() //wait for 2 seconds FTimerHandle UnusedHandle; GetWorldTimerManager().SetTimer(UnusedHandle, this, &ATurnBaseCombatV2::EnemyTurn, 2.0f, false); - + //activeActor = bIsPlayerTurn ? enemyActor : playerActor; } @@ -288,6 +317,14 @@ void ATurnBaseCombatV2::BackspaceButtonOnClick() UpdateResourceBars(); } +void ATurnBaseCombatV2::RunButtonOnClick() +{ + UBlackboardComponent* EnemyBlackboard = Cast(EnemyActor->GetInstigatorController())->GetBlackboardComponent(); + + EnemyBlackboard->SetValueAsBool("IsInCombat", false); + EndCombat(); +} + void ATurnBaseCombatV2::UpdateComboString(FString NewCombo) const { CurrentComboTextBlock->SetText(FText::FromString(NewCombo)); @@ -295,7 +332,7 @@ void ATurnBaseCombatV2::UpdateComboString(FString NewCombo) const void ATurnBaseCombatV2::UpdateActionPoints() const { - ActionPointsTextBlock->SetText(FText::FromString(FString::FromInt(ActiveActionPoints))); + ActionPointsTextBlock->SetText(FText::FromString(FString::FromInt(DefaultActionPoints - ActiveActionPoints))); } void ATurnBaseCombatV2::AddBattleLogMessage(FString Message) @@ -331,6 +368,7 @@ void ATurnBaseCombatV2::ToggleButtons() const WButton->SetIsEnabled(!WButton->GetIsEnabled()); BackspaceButton->SetIsEnabled(!BackspaceButton->GetIsEnabled()); CastButton->SetIsEnabled(!CastButton->GetIsEnabled()); + RunButton->SetIsEnabled(!RunButton->GetIsEnabled()); } void ATurnBaseCombatV2::EnemyTurn() @@ -338,4 +376,4 @@ void ATurnBaseCombatV2::EnemyTurn() DamagePlayer(10); TurnIndicatorTextBlock->SetText(FText::FromString("Player Turn")); ToggleButtons(); -} \ No newline at end of file +} diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h index 9260d84..283ef1e 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h @@ -21,10 +21,8 @@ class THE_TWILIGHT_ABYSS_API ATurnBaseCombatV2 : public AGameStateBase public: ATurnBaseCombatV2(); - UPROPERTY(EditDefaultsOnly) - int PlayerHealth = 100; - UPROPERTY(EditDefaultsOnly) - int EnemyHealth = 100; + int* EnemyHealth = nullptr; + float* PlayerHealth = nullptr; UPROPERTY(EditDefaultsOnly) int DefaultActionPoints = 3; UPROPERTY(EditDefaultsOnly) @@ -128,6 +126,9 @@ private: UPROPERTY(VisibleAnywhere) UButton* BackspaceButton; + UPROPERTY(VisibleAnywhere) + UButton* RunButton; + UFUNCTION() void CastButtonOnClick(); @@ -140,6 +141,9 @@ private: UFUNCTION() void BackspaceButtonOnClick(); + UFUNCTION() + void RunButtonOnClick(); + void UpdateComboString(FString NewCombo) const; void UpdateActionPoints() const; diff --git a/Source/the_twilight_abyss/the_twilight_abyss.Build.cs b/Source/the_twilight_abyss/the_twilight_abyss.Build.cs index 98ba233..b8c5d17 100644 --- a/Source/the_twilight_abyss/the_twilight_abyss.Build.cs +++ b/Source/the_twilight_abyss/the_twilight_abyss.Build.cs @@ -8,7 +8,7 @@ public class the_twilight_abyss : ModuleRules { PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; - PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Niagara" }); + PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Niagara", "AIModule" }); PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); diff --git a/Source/the_twilight_abyssEditor.Target.cs b/Source/the_twilight_abyssEditor.Target.cs index 6a6f8ad..527000c 100644 --- a/Source/the_twilight_abyssEditor.Target.cs +++ b/Source/the_twilight_abyssEditor.Target.cs @@ -9,6 +9,7 @@ public class the_twilight_abyssEditorTarget : TargetRules { Type = TargetType.Editor; DefaultBuildSettings = BuildSettingsVersion.V2; + IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1; ExtraModuleNames.AddRange( new string[] { "the_twilight_abyss" } ); } } diff --git a/readme.md b/readme.md index f091f16..da7878c 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,7 @@ # The Twilight Abyss ## By Team 2:13 + +### Character Dialogue + +https://docs.google.com/spreadsheets/d/13iVCQuveBiaihpREnY145OZi5QT-1sseNoI0A5v8D1o/edit?usp=sharing diff --git a/the_twilight_abyss.uproject b/the_twilight_abyss.uproject index 73e857f..5d45481 100644 --- a/the_twilight_abyss.uproject +++ b/the_twilight_abyss.uproject @@ -30,6 +30,10 @@ "Mac", "Linux" ] + }, + { + "Name": "ApexDestruction", + "Enabled": true } ], "TargetPlatforms": [