diff --git a/Content/CombatSystem/Blueprints/Actor/BP_GreatSword.uasset b/Content/CombatSystem/Blueprints/Actor/BP_GreatSword.uasset new file mode 100644 index 00000000..bb21487a Binary files /dev/null and b/Content/CombatSystem/Blueprints/Actor/BP_GreatSword.uasset differ diff --git a/Content/CombatSystem/Blueprints/Actor/BP_ToughSword.uasset b/Content/CombatSystem/Blueprints/Actor/BP_ToughSword.uasset new file mode 100644 index 00000000..65a8c5e5 Binary files /dev/null and b/Content/CombatSystem/Blueprints/Actor/BP_ToughSword.uasset differ diff --git a/Content/CombatSystem/Blueprints/Animnotifies/AttachWeaponActor_AN.uasset b/Content/CombatSystem/Blueprints/Animnotifies/AttachWeaponActor_AN.uasset new file mode 100644 index 00000000..2cb0af06 Binary files /dev/null and b/Content/CombatSystem/Blueprints/Animnotifies/AttachWeaponActor_AN.uasset differ diff --git a/Content/CombatSystem/Blueprints/Animnotifies/ToggleCombat_AN.uasset b/Content/CombatSystem/Blueprints/Animnotifies/ToggleCombat_AN.uasset new file mode 100644 index 00000000..74d75dee Binary files /dev/null and b/Content/CombatSystem/Blueprints/Animnotifies/ToggleCombat_AN.uasset differ diff --git a/Content/CombatSystem/Blueprints/BP_CombatCharacter.uasset b/Content/CombatSystem/Blueprints/BP_CombatCharacter.uasset index e69f4c58..ba4742e5 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/Animations/LightSword/Equip/LightWeaponDisarm_Anim_Montage.uasset b/Content/CombatSystem/CourseFiles/Animations/LightSword/Equip/LightWeaponDisarm_Anim_Montage.uasset index 176c469e..51678649 100644 Binary files a/Content/CombatSystem/CourseFiles/Animations/LightSword/Equip/LightWeaponDisarm_Anim_Montage.uasset and b/Content/CombatSystem/CourseFiles/Animations/LightSword/Equip/LightWeaponDisarm_Anim_Montage.uasset differ diff --git a/Content/CombatSystem/CourseFiles/Animations/LightSword/Equip/LightWeaponDraw_Anim_Montage.uasset b/Content/CombatSystem/CourseFiles/Animations/LightSword/Equip/LightWeaponDraw_Anim_Montage.uasset index 2d894a19..0e8a27a4 100644 Binary files a/Content/CombatSystem/CourseFiles/Animations/LightSword/Equip/LightWeaponDraw_Anim_Montage.uasset and b/Content/CombatSystem/CourseFiles/Animations/LightSword/Equip/LightWeaponDraw_Anim_Montage.uasset differ diff --git a/D1.uproject b/D1.uproject index 660ce1aa..f3e2dc39 100644 --- a/D1.uproject +++ b/D1.uproject @@ -7,7 +7,10 @@ { "Name": "D1", "Type": "Runtime", - "LoadingPhase": "Default" + "LoadingPhase": "Default", + "AdditionalDependencies": [ + "Engine" + ] } ], "Plugins": [ diff --git a/Source/D1/Actor/BaseEquippable.cpp b/Source/D1/Actor/BaseEquippable.cpp new file mode 100644 index 00000000..6eb581de --- /dev/null +++ b/Source/D1/Actor/BaseEquippable.cpp @@ -0,0 +1,48 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Actor/BaseEquippable.h" +#include "GameFramework/Character.h" +//#include "SkeletalMesh.h" + +// Sets default values +ABaseEquippable::ABaseEquippable() +{ + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; + +} + +void ABaseEquippable::AttachActor(const FName SocketName) +{ + ACharacter* character = Cast(GetOwner()); + if (character) + { + USkeletalMeshComponent* mesh = character->GetMesh(); + AttachToComponent(mesh, FAttachmentTransformRules::SnapToTargetNotIncludingScale, SocketName); + } +} + +void ABaseEquippable::OnEquipped() +{ + bIsEquipped = true; + AttachToActor(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale, AttachSocketName); +} + +void ABaseEquippable::OnUnequipped() +{ + if (bIsEquipped) + bIsEquipped = false; +} + +void ABaseEquippable::SetIsEquipped(bool IsEquipped) +{ + bIsEquipped = IsEquipped; +} + +bool ABaseEquippable::GetIsEquipped() +{ + return bIsEquipped; +} + + diff --git a/Source/D1/Actor/BaseEquippable.h b/Source/D1/Actor/BaseEquippable.h new file mode 100644 index 00000000..f3914805 --- /dev/null +++ b/Source/D1/Actor/BaseEquippable.h @@ -0,0 +1,31 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "BaseEquippable.generated.h" + +UCLASS() +class D1_API ABaseEquippable : public AActor +{ + GENERATED_BODY() + +public: + // Sets default values for this actor's properties + ABaseEquippable(); + +public: + UFUNCTION(BlueprintCallable) + virtual void AttachActor(const FName SocketName); + virtual void OnEquipped(); + virtual void OnUnequipped(); + virtual void SetIsEquipped(bool IsEquipped); + virtual bool GetIsEquipped(); +protected: + UPROPERTY(VisibleAnywhere, BlueprintReadWrite) + bool bIsEquipped; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization") + FName AttachSocketName; +}; diff --git a/Source/D1/Actor/BaseWeapon.cpp b/Source/D1/Actor/BaseWeapon.cpp new file mode 100644 index 00000000..19fef983 --- /dev/null +++ b/Source/D1/Actor/BaseWeapon.cpp @@ -0,0 +1,26 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Actor/BaseWeapon.h" +#include "Components/CombatComponent.h" + +ABaseWeapon::ABaseWeapon() +{ + +} + +void ABaseWeapon::OnEquipped() +{ + SetIsEquipped(true); + AActor* owner = GetOwner(); + UCombatComponent* component = owner->GetComponentByClass(); + + if (component->GetCombatEnabled()) + AttachActor(HandSocketName); + else + AttachActor(AttachSocketName); + + CombatComponent->SetMainWeapon(this); + + //TODO Update Combat Type +} diff --git a/Source/D1/Actor/BaseWeapon.h b/Source/D1/Actor/BaseWeapon.h new file mode 100644 index 00000000..e76beef3 --- /dev/null +++ b/Source/D1/Actor/BaseWeapon.h @@ -0,0 +1,37 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Actor/BaseEquippable.h" +#include "Enums/CombatType.h" +#include "BaseWeapon.generated.h" + +/** + * + */ +UCLASS() +class D1_API ABaseWeapon : public ABaseEquippable +{ + GENERATED_BODY() + +public: + ABaseWeapon(); + +public: + void OnEquipped() override; + +protected: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization") + FName HandSocketName; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization") + ECombatType CombatType; + + UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components") + TObjectPtr CombatComponent; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Animations") + TObjectPtr EnterCombat; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Animations") + TObjectPtr ExitCombat; +}; diff --git a/Source/D1/Actor/PickupActor.cpp b/Source/D1/Actor/PickupActor.cpp new file mode 100644 index 00000000..dedef0e1 --- /dev/null +++ b/Source/D1/Actor/PickupActor.cpp @@ -0,0 +1,14 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Actor/PickupActor.h" + +// Sets default values +APickupActor::APickupActor() +{ + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; + +} + + diff --git a/Source/D1/Actor/PickupActor.h b/Source/D1/Actor/PickupActor.h new file mode 100644 index 00000000..aea640f7 --- /dev/null +++ b/Source/D1/Actor/PickupActor.h @@ -0,0 +1,20 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "PickupActor.generated.h" + +UCLASS() +class D1_API APickupActor : public AActor +{ + GENERATED_BODY() + +public: + // Sets default values for this actor's properties + APickupActor(); + +private: + +}; diff --git a/Source/D1/Animation/CombatAnimInstance.cpp b/Source/D1/Animation/CombatAnimInstance.cpp new file mode 100644 index 00000000..3836bb3e --- /dev/null +++ b/Source/D1/Animation/CombatAnimInstance.cpp @@ -0,0 +1,40 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Animation/CombatAnimInstance.h" +#include "GameFramework/Character.h" +#include "GameFramework/CharacterMovementComponent.h" +#include "Kismet/KismetMathLibrary.h" + +void UCombatAnimInstance::NativeInitializeAnimation() +{ + Super::NativeInitializeAnimation(); + + Character = Cast(TryGetPawnOwner()); + if (Character) + CharacterMovementComponent = Character->GetCharacterMovement(); +} + +void UCombatAnimInstance::NativeUpdateAnimation(float DeltaSeconds) +{ + Super::NativeUpdateAnimation(DeltaSeconds); + + Velocity = CharacterMovementComponent->Velocity; + + FVector2D vel = { Velocity.X, Velocity.Y }; + GroundSpeed = vel.Length(); + + ShouldMove = (GroundSpeed > 3.f) && (CharacterMovementComponent->GetCurrentAcceleration().Length() != 0); + + IsFalling = CharacterMovementComponent->IsFalling(); +} + +void UCombatAnimInstance::UpdateCombatType(ECombatType combatType) +{ + CombatType = combatType; +} + +void UCombatAnimInstance::UpdateCombatEnabled(bool combatEnabled) +{ + CombatEnabled = combatEnabled; +} diff --git a/Source/D1/Animation/CombatAnimInstance.h b/Source/D1/Animation/CombatAnimInstance.h new file mode 100644 index 00000000..f1a6ed3b --- /dev/null +++ b/Source/D1/Animation/CombatAnimInstance.h @@ -0,0 +1,46 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Animation/AnimInstance.h" +#include "Interface/IAnimInstance.h" +#include "Enums/CombatType.h" +#include "CombatAnimInstance.generated.h" + +/** + * + */ +UCLASS() +class D1_API UCombatAnimInstance : public UAnimInstance, public IIAnimInstance +{ + GENERATED_BODY() + +public: + virtual void NativeInitializeAnimation() override; + virtual void NativeUpdateAnimation(float DeltaSeconds) override; + +public: + virtual void UpdateCombatType(ECombatType combatType) override; + virtual void UpdateCombatEnabled(bool combatEnabled) override; + +private: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="References", meta=(AllowPrivateAccess="true")) + TObjectPtr Character; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="References", meta = (AllowPrivateAccess = "true")) + TObjectPtr CharacterMovementComponent; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EssentialMovementData", meta = (AllowPrivateAccess = "true")) + FVector Velocity; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EssentialMovementData", meta = (AllowPrivateAccess = "true")) + float GroundSpeed; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EssentialMovementData", meta = (AllowPrivateAccess = "true")) + bool ShouldMove; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="EssentialMovementData", meta = (AllowPrivateAccess = "true")) + bool IsFalling; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true")) + ECombatType CombatType; + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true")) + bool CombatEnabled; +}; diff --git a/Source/D1/Components/CombatComponent.cpp b/Source/D1/Components/CombatComponent.cpp new file mode 100644 index 00000000..48c80fa4 --- /dev/null +++ b/Source/D1/Components/CombatComponent.cpp @@ -0,0 +1,52 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Components/CombatComponent.h" +#include "Actor/BaseWeapon.h" +#include "Enums/CombatType.h" +#include "GameFramework/Character.h" + +// Sets default values for this component's properties +UCombatComponent::UCombatComponent() +{ + // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features + // off to improve performance if you don't need them. + PrimaryComponentTick.bCanEverTick = true; + + // ... +} + +void UCombatComponent::SetMainWeapon(ABaseWeapon* NewWeapon) +{ + if (IsValid(MainWeapon)) + { + MainWeapon->OnUnequipped(); + MainWeapon->Destroy(); + } + + MainWeapon = NewWeapon; +} + +ABaseWeapon* UCombatComponent::GetMainWeapon() +{ + return MainWeapon; +} + +void UCombatComponent::SetCombatEnabled(bool bInputCombat) +{ + bCombatEnabled = bInputCombat; + + ACharacter* character = Cast(GetOwner()); + if (character) + { + //TODO : AnimInstance ÈÄ¿¡ ó¸® + //character->GetMesh()->GetAnimInstance(); + } +} + +bool UCombatComponent::GetCombatEnabled() +{ + return bCombatEnabled; +} + + diff --git a/Source/D1/Components/CombatComponent.h b/Source/D1/Components/CombatComponent.h new file mode 100644 index 00000000..c3fca2db --- /dev/null +++ b/Source/D1/Components/CombatComponent.h @@ -0,0 +1,31 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "CombatComponent.generated.h" + + +class ABaseWeapon; +UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +class D1_API UCombatComponent : public UActorComponent +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + UCombatComponent(); + +public: + void SetMainWeapon(ABaseWeapon* NewWeapon); + ABaseWeapon* GetMainWeapon(); + void SetCombatEnabled(bool bInputCombat); + bool GetCombatEnabled(); +private: + UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) + TObjectPtr MainWeapon; + + UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) + bool bCombatEnabled; +}; diff --git a/Source/D1/D1.Build.cs b/Source/D1/D1.Build.cs index 381ab4f6..35505f8d 100644 --- a/Source/D1/D1.Build.cs +++ b/Source/D1/D1.Build.cs @@ -9,5 +9,7 @@ public class D1 : ModuleRules PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "EnhancedInput" }); + + PublicIncludePaths.AddRange(new string[] { "D1" }); } } diff --git a/Source/D1/Enums/CombatType.cpp b/Source/D1/Enums/CombatType.cpp new file mode 100644 index 00000000..18c8d950 --- /dev/null +++ b/Source/D1/Enums/CombatType.cpp @@ -0,0 +1,2 @@ +// Fill out your copyright notice in the Description page of Project Settings. +#include "Enums/CombatType.h" diff --git a/Source/D1/Enums/CombatType.h b/Source/D1/Enums/CombatType.h new file mode 100644 index 00000000..6b1a452f --- /dev/null +++ b/Source/D1/Enums/CombatType.h @@ -0,0 +1,15 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" + + +UENUM(BlueprintType) +enum class ECombatType : uint8 +{ + NONE UMETA(DisplayName = "NONE"), + LIGHTSWORD UMETA(DisplayName = "LIGHTSWORD"), + GREATSWORD UMETA(DisplayName = "GREATSWORD") +}; + diff --git a/Source/D1/Interface/IAnimInstance.cpp b/Source/D1/Interface/IAnimInstance.cpp new file mode 100644 index 00000000..e00409c1 --- /dev/null +++ b/Source/D1/Interface/IAnimInstance.cpp @@ -0,0 +1,6 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "IAnimInstance.h" + +// Add default functionality here for any IIAnimInstance functions that are not pure virtual. diff --git a/Source/D1/Interface/IAnimInstance.h b/Source/D1/Interface/IAnimInstance.h new file mode 100644 index 00000000..e2334c87 --- /dev/null +++ b/Source/D1/Interface/IAnimInstance.h @@ -0,0 +1,28 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "UObject/Interface.h" +#include "Enums/CombatType.h" +#include "IAnimInstance.generated.h" + +// This class does not need to be modified. +UINTERFACE(MinimalAPI) +class UIAnimInstance : public UInterface +{ + GENERATED_BODY() +}; + +/** + * + */ +class D1_API IIAnimInstance +{ + GENERATED_BODY() + + // Add interface functions to this class. This is the class that will be inherited to implement this interface. +public: + virtual void UpdateCombatType(ECombatType combatType) = 0; + virtual void UpdateCombatEnabled(bool combatEnabled) = 0; +};