diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index b6dcb8c3..0178f9be 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -156,4 +156,5 @@ ManualIPAddress= +PropertyRedirects=(OldName="/Script/D1.BaseConsumable.NumberOfUses",NewName="/Script/D1.BaseConsumable.CurrentNumberOfUses") +PropertyRedirects=(OldName="/Script/D1.BaseConsumable.NumberOfUses",NewName="/Script/D1.BaseConsumable.CurrentNumberOfUses") +PropertyRedirects=(OldName="/Script/D1.BaseConsumable.Value",NewName="/Script/D1.BaseConsumable.ModificationValue") ++PropertyRedirects=(OldName="/Script/D1.PickupActor.Item",NewName="/Script/D1.PickupActor.ItemClass") diff --git a/Content/CombatSystem/Blueprints/Actor/BP_PickupActor.uasset b/Content/CombatSystem/Blueprints/Actor/BP_PickupActor.uasset index 2a8ccbb6..3220a060 100644 Binary files a/Content/CombatSystem/Blueprints/Actor/BP_PickupActor.uasset and b/Content/CombatSystem/Blueprints/Actor/BP_PickupActor.uasset differ diff --git a/Content/CombatSystem/Blueprints/Actor/BP_ShowcaseSwordAndShield.uasset b/Content/CombatSystem/Blueprints/Actor/BP_ShowcaseSwordAndShield.uasset new file mode 100644 index 00000000..d705ad34 Binary files /dev/null and b/Content/CombatSystem/Blueprints/Actor/BP_ShowcaseSwordAndShield.uasset differ diff --git a/Content/CombatSystem/Blueprints/Actor/BP_ToughShield.uasset b/Content/CombatSystem/Blueprints/Actor/BP_ToughShield.uasset deleted file mode 100644 index d53242b4..00000000 Binary files a/Content/CombatSystem/Blueprints/Actor/BP_ToughShield.uasset and /dev/null differ diff --git a/Content/CombatSystem/Blueprints/BP_CombatCharacter.uasset b/Content/CombatSystem/Blueprints/BP_CombatCharacter.uasset index 9447dabe..dd8cb08c 100644 Binary files a/Content/CombatSystem/Blueprints/BP_CombatCharacter.uasset and b/Content/CombatSystem/Blueprints/BP_CombatCharacter.uasset differ diff --git a/Content/CombatSystem/CourseFiles/Meshes/Weapons/SM_ToughSword.uasset b/Content/CombatSystem/CourseFiles/Meshes/Weapons/SM_ToughSword.uasset index 56068563..9bf5bd37 100644 Binary files a/Content/CombatSystem/CourseFiles/Meshes/Weapons/SM_ToughSword.uasset and b/Content/CombatSystem/CourseFiles/Meshes/Weapons/SM_ToughSword.uasset differ diff --git a/Content/Maps/IceLandMap.umap b/Content/Maps/IceLandMap.umap index 6f54ad21..c7c9f1b6 100644 Binary files a/Content/Maps/IceLandMap.umap and b/Content/Maps/IceLandMap.umap differ diff --git a/Content/ParagonGreystone/Characters/Heroes/Greystone/Skins/Tough/Materials/M_Greystone_ToughSword.uasset b/Content/ParagonGreystone/Characters/Heroes/Greystone/Skins/Tough/Materials/M_Greystone_ToughShield.uasset similarity index 70% rename from Content/ParagonGreystone/Characters/Heroes/Greystone/Skins/Tough/Materials/M_Greystone_ToughSword.uasset rename to Content/ParagonGreystone/Characters/Heroes/Greystone/Skins/Tough/Materials/M_Greystone_ToughShield.uasset index 6f1acf0d..d8ed207d 100644 Binary files a/Content/ParagonGreystone/Characters/Heroes/Greystone/Skins/Tough/Materials/M_Greystone_ToughSword.uasset and b/Content/ParagonGreystone/Characters/Heroes/Greystone/Skins/Tough/Materials/M_Greystone_ToughShield.uasset differ diff --git a/Content/ParagonGreystone/Characters/Heroes/Greystone/Skins/Tough/Meshes/Greystone_Tough.uasset b/Content/ParagonGreystone/Characters/Heroes/Greystone/Skins/Tough/Meshes/Greystone_Tough.uasset index 9f11af79..3f5c196b 100644 Binary files a/Content/ParagonGreystone/Characters/Heroes/Greystone/Skins/Tough/Meshes/Greystone_Tough.uasset and b/Content/ParagonGreystone/Characters/Heroes/Greystone/Skins/Tough/Meshes/Greystone_Tough.uasset differ diff --git a/Content/ParagonKwang/Characters/Heroes/Kwang/Meshes/Kwang_Skeleton.uasset b/Content/ParagonKwang/Characters/Heroes/Kwang/Meshes/Kwang_Skeleton.uasset index a9f234fc..fa4aa51b 100644 Binary files a/Content/ParagonKwang/Characters/Heroes/Kwang/Meshes/Kwang_Skeleton.uasset and b/Content/ParagonKwang/Characters/Heroes/Kwang/Meshes/Kwang_Skeleton.uasset differ diff --git a/Source/D1/Actor/BaseShield.cpp b/Source/D1/Actor/BaseShield.cpp deleted file mode 100644 index 3326f242..00000000 --- a/Source/D1/Actor/BaseShield.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "Actor/BaseShield.h" - -#include "Components/CollisionComponent.h" -#include "Components/CombatComponent.h" -#include "GameFramework/Character.h" - -void ABaseShield::OnEquipped() -{ - SetIsEquipped(true); - AActor* owner = GetOwner(); - if (!owner) - return; - CombatComponent = owner->GetComponentByClass(); - CombatComponent->OnCombatToggled.AddUObject(this, &ABaseWeapon::ToggleWeaponCombat); - - OwnerStateManager = owner->GetComponentByClass(); - - if (CombatComponent->GetCombatEnabled()) - AttachActor(HandSocketName); - else - AttachActor(AttachSocketName); - - CombatComponent->SetShieldWeapon(this); - - CollisionComponent->SetCollisionMeshComponent(GetItemMesh()); - CollisionComponent->AddActorToIgnore(GetOwner()); -} - -void ABaseShield::OnUnequipped() -{ - Super::OnUnequipped(); - CombatComponent->SetShieldWeapon(nullptr); -} - -TArray ABaseShield::GetActionMontage(FGameplayTag characterAction) -{ - TArray outputArr; - - if (FCombatGameplayTags::Get().Character_Action_Attack_Blocking == characterAction) - outputArr = BlockAnimations; - else if (FCombatGameplayTags::Get().Character_Action_Attack_LightAttack == characterAction) - outputArr = LightAttackMontage; - else if (FCombatGameplayTags::Get().Character_Action_Attack_HeavyAttack == characterAction) - outputArr = HeavyAttackMontage; - else if (FCombatGameplayTags::Get().Character_Action_Attack_ChargedAttack == characterAction) - outputArr = ChargedAttackMontage; - else if (FCombatGameplayTags::Get().Character_Action_Attack_FallingAttack == characterAction) - outputArr = FallingAttackMontage; - else if (FCombatGameplayTags::Get().Character_Action_Attack_SprintAttack == characterAction) - outputArr = SprintAttackMontage; - else if (FCombatGameplayTags::Get().Character_Action_Dodge == characterAction) - outputArr = DodgeMontage; - else if (FCombatGameplayTags::Get().Character_Action_EnterCombat == characterAction) - outputArr.Add(EnterCombat); - else if (FCombatGameplayTags::Get().Character_Action_ExitCombat == characterAction) - outputArr.Add(ExitCombat); - - return outputArr; -} diff --git a/Source/D1/Actor/BaseShield.h b/Source/D1/Actor/BaseShield.h deleted file mode 100644 index ca15c61a..00000000 --- a/Source/D1/Actor/BaseShield.h +++ /dev/null @@ -1,25 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "Actor/BaseWeapon.h" -#include "BaseShield.generated.h" - -/** - * - */ -UCLASS() -class D1_API ABaseShield : public ABaseWeapon -{ - GENERATED_BODY() - -public: - virtual void OnEquipped() override; - virtual void OnUnequipped() override; - virtual TArray GetActionMontage(FGameplayTag characterAction) override; - -protected: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Montages") - TArray> BlockAnimations; -}; diff --git a/Source/D1/Actor/BaseWeapon.cpp b/Source/D1/Actor/BaseWeapon.cpp index 0d6cd9b8..bcf415b9 100644 --- a/Source/D1/Actor/BaseWeapon.cpp +++ b/Source/D1/Actor/BaseWeapon.cpp @@ -145,6 +145,8 @@ TArray ABaseWeapon::GetActionMontage(FGameplayTag characterAction outputArr.Add(EnterCombat); else if (FCombatGameplayTags::Get().Character_Action_ExitCombat == characterAction) outputArr.Add(ExitCombat); + else if (FCombatGameplayTags::Get().Character_Action_Attack_Blocking == characterAction) + outputArr = BlockAttackMontage; return outputArr; } diff --git a/Source/D1/Actor/BaseWeapon.h b/Source/D1/Actor/BaseWeapon.h index e924ebdd..267e6f04 100644 --- a/Source/D1/Actor/BaseWeapon.h +++ b/Source/D1/Actor/BaseWeapon.h @@ -77,6 +77,8 @@ protected: TArray> FallingAttackMontage; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Montages") TArray> SprintAttackMontage; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Montages") + TArray> BlockAttackMontage; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Status") float Damage; diff --git a/Source/D1/Actor/PickupActor.cpp b/Source/D1/Actor/PickupActor.cpp index 758642f0..071d940c 100644 --- a/Source/D1/Actor/PickupActor.cpp +++ b/Source/D1/Actor/PickupActor.cpp @@ -3,9 +3,12 @@ #include "Actor/PickupActor.h" #include "Actor/BaseEquippable.h" +#include "Components/EquipmentComponent.h" #include "Components/SceneComponent.h" #include "Components/StaticMeshComponent.h" #include "Components/SphereComponent.h" +#include "Particles/ParticleSystemComponent.h" + // Sets default values APickupActor::APickupActor() @@ -18,24 +21,17 @@ APickupActor::APickupActor() Cube = CreateDefaultSubobject(TEXT("Cube")); Cube->SetupAttachment(RootComponent); Sphere = CreateDefaultSubobject(TEXT("Sphere")); - Sphere->SetupAttachment(Cube); + Sphere->SetupAttachment(RootComponent); + ParticleSystem = CreateDefaultSubobject(TEXT("ParticleSystem")); + ParticleSystem->SetupAttachment(RootComponent); } void APickupActor::Interact(AActor* Caller) { if (Caller == nullptr) return; - - APawn* pawn = Cast(Caller); - if (pawn != nullptr) - { - FActorSpawnParameters spawnParam; - spawnParam.Owner = Caller; - spawnParam.Instigator = pawn; - ABaseEquippable* SpawnItem = Cast(GetWorld()->SpawnActor(Item, &GetActorTransform(), spawnParam)); - if (SpawnItem) - SpawnItem->OnEquipped(); - } + + Caller->GetComponentByClass()->EquipItem(ItemClass); } diff --git a/Source/D1/Actor/PickupActor.h b/Source/D1/Actor/PickupActor.h index 19ef7120..e2fea04e 100644 --- a/Source/D1/Actor/PickupActor.h +++ b/Source/D1/Actor/PickupActor.h @@ -21,14 +21,17 @@ public: private: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true")) - TObjectPtr DefaultSceneRoot; + TObjectPtr DefaultSceneRoot; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true")) - TObjectPtr Cube; + TObjectPtr Cube; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true")) TObjectPtr Sphere; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true")) + TObjectPtr ParticleSystem; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true")) - TSubclassOf Item; + TSubclassOf ItemClass; }; diff --git a/Source/D1/Actor/SwordAndShield.cpp b/Source/D1/Actor/SwordAndShield.cpp new file mode 100644 index 00000000..c2361d4c --- /dev/null +++ b/Source/D1/Actor/SwordAndShield.cpp @@ -0,0 +1,51 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Actor/SwordAndShield.h" + +#include "Components/CombatComponent.h" +#include "GameFramework/Character.h" + +ASwordAndShield::ASwordAndShield() +{ + ShieldMesh = CreateDefaultSubobject(TEXT("ShieldMesh")); + ShieldMesh->SetupAttachment(RootComponent); + ShieldMesh->SetCollisionEnabled(ECollisionEnabled::NoCollision); +} + +void ASwordAndShield::ToggleWeaponCombat(bool EnableCombat) +{ + Super::ToggleWeaponCombat(EnableCombat); + if(EnableCombat) + AttachShield(ShieldHandSocket); + else + AttachShield(ShieldAttachSocket); +} + +void ASwordAndShield::OnEquipped() +{ + Super::OnEquipped(); + + if (CombatComponent->GetCombatEnabled()) + AttachShield(ShieldHandSocket); + else + AttachShield(ShieldAttachSocket); + + CombatComponent->SetShieldEquipped(true); +} + +void ASwordAndShield::OnUnequipped() +{ + Super::OnUnequipped(); + CombatComponent->SetShieldEquipped(false); +} + +void ASwordAndShield::AttachShield(FName attachSocket) +{ + ACharacter* pCharacter = Cast(GetOwner()); + if(pCharacter) + { + FAttachmentTransformRules rules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, true); + ShieldMesh->AttachToComponent(pCharacter->GetMesh(), rules, attachSocket); + } +} diff --git a/Source/D1/Actor/SwordAndShield.h b/Source/D1/Actor/SwordAndShield.h new file mode 100644 index 00000000..1f03d550 --- /dev/null +++ b/Source/D1/Actor/SwordAndShield.h @@ -0,0 +1,32 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Actor/BaseWeapon.h" +#include "SwordAndShield.generated.h" + +/** + * + */ +UCLASS() +class D1_API ASwordAndShield : public ABaseWeapon +{ + GENERATED_BODY() +public: + ASwordAndShield(); +public: + virtual void ToggleWeaponCombat(bool EnableCombat) override; + virtual void OnEquipped() override; + virtual void OnUnequipped() override; +public: + void AttachShield(FName attachSocket); +public: + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Mesh", meta=(AllowPrivateAccess="true")) + TObjectPtr ShieldMesh; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization", meta = (AllowPrivateAccess = "true")) + FName ShieldAttachSocket; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization", meta = (AllowPrivateAccess = "true")) + FName ShieldHandSocket; +}; diff --git a/Source/D1/CombatPlayerCharacter.cpp b/Source/D1/CombatPlayerCharacter.cpp index 8e8eb873..75719d36 100644 --- a/Source/D1/CombatPlayerCharacter.cpp +++ b/Source/D1/CombatPlayerCharacter.cpp @@ -913,9 +913,9 @@ bool ACombatPlayerCharacter::PerformKnockdown() bool ACombatPlayerCharacter::PerformBlock() { - if(!IsValid(CombatComponent->GetShieldWeapon())) + if(!IsValid(CombatComponent->GetMainWeapon())) return false; - TArray hitMontage = CombatComponent->GetShieldWeapon()->GetActionMontage(FCombatGameplayTags::Get().Character_Action_Attack_Blocking); + TArray hitMontage = CombatComponent->GetMainWeapon()->GetActionMontage(FCombatGameplayTags::Get().Character_Action_Attack_Blocking); if(hitMontage.Num() <= 0) return false; @@ -1021,7 +1021,7 @@ bool ACombatPlayerCharacter::CanPerformBlock() ReturnValue &= !StateManagerComponent->IsCurrentStateEqualToAny(inputContainer); ReturnValue &= CombatComponent->GetCombatEnabled(); - ReturnValue &= IsValid(CombatComponent->GetShieldWeapon()); + ReturnValue &= CombatComponent->GetShieldEquipped(); ReturnValue &= bIsBlockPressed; //Block Key를 눌렀는가? return ReturnValue; diff --git a/Source/D1/Components/CombatComponent.h b/Source/D1/Components/CombatComponent.h index a379e873..121c77c6 100644 --- a/Source/D1/Components/CombatComponent.h +++ b/Source/D1/Components/CombatComponent.h @@ -38,9 +38,10 @@ public: FORCEINLINE int32 GetAttackCount() { return AttackCount; } void SetBlockingState(bool enableBlocking); - FORCEINLINE bool GetIsBlocking() {return bIsBlocking; } - FORCEINLINE void SetShieldWeapon(ABaseWeapon* inShield) { EquippedShield = inShield; } - FORCEINLINE ABaseWeapon* GetShieldWeapon() { return EquippedShield; } + FORCEINLINE bool GetIsBlocking() { return bIsBlocking; } + + FORCEINLINE void SetShieldEquipped(bool isEquipped) { bIsShieldEquipped = isEquipped; } + FORCEINLINE bool GetShieldEquipped() { return bIsShieldEquipped; } private: UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) @@ -54,13 +55,11 @@ private: UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) int32 AttackCount; - - UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) - TObjectPtr EquippedShield; UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) bool bIsBlocking; - + + bool bIsShieldEquipped; public: //Delegate FOnCombatToggled OnCombatToggled; FOnBlockingSet OnBlockingSet; diff --git a/Source/D1/Components/EquipmentComponent.cpp b/Source/D1/Components/EquipmentComponent.cpp index 3022d048..e97eea6e 100644 --- a/Source/D1/Components/EquipmentComponent.cpp +++ b/Source/D1/Components/EquipmentComponent.cpp @@ -36,37 +36,15 @@ void UEquipmentComponent::TickComponent(float DeltaTime, ELevelTick TickType, FA void UEquipmentComponent::InitializeEquipment() { + for (auto item : EquippedItems) + UnequipItem(item); + for (auto equipment : StartingEquipment) { if(!IsValid(equipment.Get())) continue; - AActor* owner = GetOwner(); - if(!IsValid(owner)) - continue; - APawn* ownerPawn = Cast(owner); - if(!IsValid(ownerPawn)) - continue; - FActorSpawnParameters SpawnParameters; - SpawnParameters.Owner = owner; - SpawnParameters.Instigator = ownerPawn; - - ABaseEquippable* EquipInstance = Cast(GetWorld()->SpawnActor(equipment, &owner->GetActorTransform(), SpawnParameters)); - if(EquipInstance) - { - EquippedItems.AddUnique(EquipInstance); - EquipInstance->OnEquipped(); - - //Player have Weapon until first time : probably temp coding - if(ACombatPlayerCharacter* Player = Cast(GetOwner())) - { - if(ABaseConsumable* consumableItem = Cast(EquipInstance)) - { - if(UUI_PotionAmountText* PotionAmountText = Cast(Player->PotionUI)) - PotionAmountText->InitializePotionData(consumableItem); //TODO : [UMG] 관련 부분 구조 변경 필요 - } - } - } + EquipItem(equipment); } } @@ -89,6 +67,43 @@ bool UEquipmentComponent::PerformActionFromItem(FGameplayTag ItemTag) return false; } +bool UEquipmentComponent::EquipItem(TSubclassOf InEquipment) +{ + if(!IsValid(InEquipment->GetClass())) + return false; + + for (auto item : EquippedItems) + { + if(item.GetClass() == InEquipment) + UnequipItem(item); + } + + AActor* owner = GetOwner(); + APawn* pawn = Cast(owner); + if (pawn == nullptr) + return false; + + FActorSpawnParameters spawnParam; + spawnParam.Owner = owner; + spawnParam.Instigator = pawn; + ABaseEquippable* SpawnItem = Cast(GetWorld()->SpawnActor(InEquipment, &owner->GetActorTransform(), spawnParam)); + if (SpawnItem) + { + SpawnItem->OnEquipped(); + EquippedItems.AddUnique(SpawnItem); + } + return true; +} + +void UEquipmentComponent::UnequipItem(ABaseEquippable* EquipmentToUnequip) +{ + if(IsValid(EquipmentToUnequip)) + { + EquipmentToUnequip->OnUnequipped(); + EquipmentToUnequip->Destroy(); //TODO : 현재는 장비를 해제하면 파괴함 임시처리 + } +} + ABaseEquippable* UEquipmentComponent::GetEquippedItemByTag(FGameplayTag itemTag) { for (auto Item : EquippedItems) diff --git a/Source/D1/Components/EquipmentComponent.h b/Source/D1/Components/EquipmentComponent.h index 582c12ac..657282d4 100644 --- a/Source/D1/Components/EquipmentComponent.h +++ b/Source/D1/Components/EquipmentComponent.h @@ -29,6 +29,9 @@ public: public: void InitializeEquipment(); bool PerformActionFromItem(FGameplayTag ItemTag); + bool EquipItem(TSubclassOf InEquipment); + void UnequipItem(ABaseEquippable* EquipmentToUnequip); + UFUNCTION(BlueprintCallable) ABaseEquippable* GetEquippedItemByTag(FGameplayTag itemTag);