Compare commits
18 Commits
2984aaa4be
...
d8623fb375
Author | SHA1 | Date | |
---|---|---|---|
d8623fb375 | |||
82c3644b5a | |||
e0102c5635 | |||
88f822d5de | |||
aded160ce0 | |||
25f8adc0a8 | |||
aa7ceba750 | |||
f6d7112248 | |||
59c715af32 | |||
7b57eaa7ac | |||
9762d2cb0f | |||
4e7af37166 | |||
2c30f24aad | |||
f5db40d884 | |||
0bed66d5ca | |||
ff988535aa | |||
5e186c3d06 | |||
8b558f8a56 |
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/DataTable/FishRods.uasset
Normal file
BIN
ProjectFish/Content/DataTable/FishRods.uasset
Normal file
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/FishingRodSkills/UFRS_TriggerBySKill.uasset
Normal file
BIN
ProjectFish/Content/FishingRodSkills/UFRS_TriggerBySKill.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/SkillTrigger/SkillTrigger_ByTag.uasset
Normal file
BIN
ProjectFish/Content/SkillTrigger/SkillTrigger_ByTag.uasset
Normal file
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/Textures/Skill/lock.uasset
Normal file
BIN
ProjectFish/Content/Textures/Skill/lock.uasset
Normal file
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/UI/WBP_FishRod.uasset
Normal file
BIN
ProjectFish/Content/UI/WBP_FishRod.uasset
Normal file
Binary file not shown.
BIN
ProjectFish/Content/UI/WBP_PawnInfo.uasset
Normal file
BIN
ProjectFish/Content/UI/WBP_PawnInfo.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/UI/WBP_SkillLock.uasset
Normal file
BIN
ProjectFish/Content/UI/WBP_SkillLock.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,96 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "FishingRodComponent.h"
|
||||
|
||||
#include "EngineUtils.h"
|
||||
#include "ProjectFish/Definations.h"
|
||||
#include "ProjectFish/PawnWithSkill.h"
|
||||
|
||||
|
||||
// Sets default values for this component's properties
|
||||
UFishingRodComponent::UFishingRodComponent()
|
||||
{
|
||||
// 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 UFishingRodComponent::AddFishRodDamage(int32 Damage)
|
||||
{
|
||||
FishRodData.Damage += Damage;
|
||||
}
|
||||
|
||||
|
||||
// Called when the game starts
|
||||
void UFishingRodComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
for (auto rowName: FishRodDataTable.DataTable->GetRowMap())
|
||||
{
|
||||
FFishingRod* data = reinterpret_cast<FFishingRod*>(rowName.Value);
|
||||
if (data && data->FishingRod_Name ==FishRodDataTable.RowContents )
|
||||
{
|
||||
FishRodData = *data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
APawnWithSkill* OwnerPawn = Cast<APawnWithSkill>(GetOwner());
|
||||
|
||||
if (OwnerPawn != nullptr)
|
||||
{
|
||||
//叠加角色的属性信息
|
||||
OwnerPawn->CurrentEndurance += FishRodData.Endurance_Add;
|
||||
OwnerPawn->MaxEndurance += FishRodData.Endurance_Add;
|
||||
OwnerPawn->CurrentTenacity += FishRodData.Tenacity_Add;
|
||||
OwnerPawn->MaxTenacity+= FishRodData.Tenacity_Add;
|
||||
|
||||
GetWorld()->GetTimerManager().SetTimerForNextTick([this, OwnerPawn]()
|
||||
{
|
||||
// 执行依赖其他Actor的逻辑
|
||||
for (auto pawn: TActorRange<APawnWithSkill>(GetWorld()))
|
||||
{
|
||||
if (pawn != OwnerPawn)
|
||||
{
|
||||
Enemy = pawn;
|
||||
}
|
||||
}
|
||||
//初始化鱼竿技能
|
||||
for (auto skill : FishRodData.Skills)
|
||||
{
|
||||
UFishingRodSKill_Base* SkillObject = NewObject<UFishingRodSKill_Base>(OwnerPawn, skill.SkillClass);
|
||||
if (SkillObject != nullptr)
|
||||
{
|
||||
FRSkills.Add(SkillObject);
|
||||
SkillObject->Init(OwnerPawn);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
// ...
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Called every frame
|
||||
void UFishingRodComponent::TickComponent(float DeltaTime, ELevelTick TickType,
|
||||
FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
CurrentCDTime += DeltaTime;
|
||||
if (CurrentCDTime >= FishRodData.DamageCD)
|
||||
{
|
||||
CurrentCDTime = 0;
|
||||
UE_LOG(LogTemp, Warning, TEXT("鱼竿: %s 造成伤害 %d"), *FishRodData.FishingRod_Name.ToString(), FishRodData.Damage);
|
||||
if (Enemy)
|
||||
{
|
||||
Enemy->ApplyyEndurance(-FishRodData.Damage);
|
||||
}
|
||||
}
|
||||
// ...
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "ProjectFish/Definations.h"
|
||||
#include "ProjectFish/FishingRodSKill_Base.h"
|
||||
#include "FishingRodComponent.generated.h"
|
||||
|
||||
|
||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||
class PROJECTFISH_API UFishingRodComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UFishingRodComponent();
|
||||
void AddFishRodDamage(int32 Damage);
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType,
|
||||
FActorComponentTickFunction* ThisTickFunction) override;
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, meta = (ToolTip = "鱼竿配置文件"))
|
||||
FDataTableCategoryHandle FishRodDataTable;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "鱼竿数据"))
|
||||
FFishingRod FishRodData;
|
||||
|
||||
class APawnWithSkill* Enemy;
|
||||
float CurrentCDTime = 0.f;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
TArray<UFishingRodSKill_Base*> FRSkills;
|
||||
};
|
@ -17,34 +17,38 @@ enum class ESkillEffectType: uint8
|
||||
Charge UMETA(DisplayName = "充能", ToolTip = "使技能的冷却进度加快"),
|
||||
ModifySpeed UMETA(DisplayName = "速度修改", ToolTip = "使技能冷却进度倍率进展 持续指定时间"),
|
||||
SkillEnduranceRestore UMETA(DisplayName = "技能耐久度恢复", ToolTip = "使技能耐久度恢复"),
|
||||
EnhanceFishRod UMETA(DisplayName = "增强鱼竿", ToolTip = "使鱼竿上海增加"),
|
||||
EnhanceSkill UMETA(DisplayName = "增强技能", ToolTip = "增强指定的技能数值"),
|
||||
DamageReduce UMETA(DisplayName = "减伤", ToolTip = "减少所受的伤害"),
|
||||
};
|
||||
|
||||
//技能对象类型
|
||||
UENUM(BlueprintType)
|
||||
enum class ESkillTargetType: uint8
|
||||
{
|
||||
Self UMETA(DisplayName = "自身"),
|
||||
Other UMETA(DisplayName = "对方"),
|
||||
AdjacentLeft UMETA(DisplayName = "左侧相邻"),
|
||||
AdjacentRight UMETA(DisplayName = "右侧相邻"),
|
||||
AllLeft UMETA(DisplayName = "左侧全部"),
|
||||
AllRight UMETA(DisplayName = "右侧全部"),
|
||||
Self UMETA(DisplayName = "目标是自身角色"),
|
||||
Other UMETA(DisplayName = "目标是对方角色"),
|
||||
Around UMETA(DisplayName = "格子周围的技能")
|
||||
// AdjacentLeft UMETA(DisplayName = "左侧相邻"),
|
||||
// AdjacentRight UMETA(DisplayName = "右侧相邻"),
|
||||
// AllLeft UMETA(DisplayName = "左侧全部"),
|
||||
// AllRight UMETA(DisplayName = "右侧全部"),
|
||||
};
|
||||
//随机对象类型
|
||||
UENUM(BlueprintType)
|
||||
enum class ERandomTargetType: uint8
|
||||
{
|
||||
AllSelf UMETA(DisplayName = "我方全部"),
|
||||
AllOther UMETA(DisplayName = "敌方全部"),
|
||||
AllSelf UMETA(DisplayName = "我方全部技能"),
|
||||
AllOther UMETA(DisplayName = "敌方全部技能"),
|
||||
};
|
||||
|
||||
//技能选择器类型
|
||||
UENUM(BlueprintType)
|
||||
enum class ETargetSelecterType: uint8
|
||||
{
|
||||
SkillPos UMETA(DisplayName = "根据技能位置选择"),
|
||||
SkillPos UMETA(DisplayName = "指定对象选择"),
|
||||
SkillTag UMETA(DisplayName = "根据技能Tag选择"),
|
||||
RandomScope UMETA(DisplayName = "随机范围选择"),
|
||||
RandomScope UMETA(DisplayName = "指定技能组选择"),
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
@ -53,8 +57,8 @@ struct FSkillContext
|
||||
GENERATED_BODY()
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "敌人"))
|
||||
class USkillManager* SkillManager;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "自身"))
|
||||
APawnWithSkill* Self;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "所属的技能"))
|
||||
class USkill* OwnerSkill;
|
||||
|
||||
};
|
||||
|
||||
@ -111,21 +115,31 @@ struct FSkillData: public FTableRowBase
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (AllowedClasses = "Texture2D", ToolTip = "技能图片"))
|
||||
FSoftObjectPath SkillTexture;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能CD"))
|
||||
float CD;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能CD速度"))
|
||||
float Speed = 1.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能耐久度"))
|
||||
int32 Endurance;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能Tag"))
|
||||
FGameplayTag SkillTag;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "背包占用"))
|
||||
int32 WeightLimit;
|
||||
FIntPoint SkillWeight = FIntPoint(1, 1);
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "是否为主动技能"))
|
||||
bool bActiveSkill = true;
|
||||
|
||||
//主动技能属性
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能CD", EditConditionHides, EditCondition = "bActiveSkill"))
|
||||
float CD;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能CD速度", EditConditionHides, EditCondition = "bActiveSkill"))
|
||||
float Speed = 1.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能耐久度", EditConditionHides, EditCondition = "bActiveSkill"))
|
||||
int32 Endurance;
|
||||
|
||||
//被动技能属性
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "被动技能触发器,没有配置的话为光环类技能默认进行触发", AllowedClasses = "SkillTrigger", EditConditionHides, EditCondition = "!bActiveSkill"))
|
||||
TSubclassOf<class USkillTrigger> SkillTrigger;
|
||||
|
||||
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能效果组"))
|
||||
TArray<FSkillEffectData> SkillEffects;
|
||||
@ -142,6 +156,7 @@ public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FName SkillRowName;
|
||||
|
||||
};
|
||||
/**
|
||||
*
|
||||
@ -152,3 +167,43 @@ class PROJECTFISH_API UDefinations : public UObject
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FFishingRodSkill
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "鱼竿技能名称"))
|
||||
FName SkillName;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "鱼钩技能"))
|
||||
TSubclassOf<class UFishingRodSKill_Base> SkillClass;
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FFishingRod: public FTableRowBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "鱼竿名称"))
|
||||
FName FishingRod_Name;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "鱼竿伤害CD"))
|
||||
int32 DamageCD;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "鱼竿伤害"))
|
||||
int32 Damage;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "附加的耐力值"))
|
||||
int32 Endurance_Add;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "附加的附加的韧性值"))
|
||||
int32 Tenacity_Add;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "物品背包大小"))
|
||||
FIntPoint BagSize;
|
||||
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能效果组"))
|
||||
TArray<FFishingRodSkill> Skills;
|
||||
};
|
||||
|
8
ProjectFish/Source/ProjectFish/FishingRodSKill_Base.cpp
Normal file
8
ProjectFish/Source/ProjectFish/FishingRodSKill_Base.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "FishingRodSKill_Base.h"
|
||||
|
||||
UFishingRodSKill_Base::UFishingRodSKill_Base()
|
||||
{
|
||||
}
|
22
ProjectFish/Source/ProjectFish/FishingRodSKill_Base.h
Normal file
22
ProjectFish/Source/ProjectFish/FishingRodSKill_Base.h
Normal file
@ -0,0 +1,22 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Definations.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "FishingRodSKill_Base.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Blueprintable)
|
||||
class PROJECTFISH_API UFishingRodSKill_Base : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UFishingRodSKill_Base();
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void Init(class APawnWithSkill* Owner);
|
||||
|
||||
};
|
@ -13,14 +13,33 @@ APawnWithSkill::APawnWithSkill()
|
||||
|
||||
void APawnWithSkill::ApplyyEndurance_Implementation(float enduranceOffset)
|
||||
{
|
||||
if (enduranceOffset < 0)
|
||||
{
|
||||
//受到伤害
|
||||
OnReceiveDamage.Broadcast();
|
||||
//受到的伤害最低为1点
|
||||
enduranceOffset = FMath::Min(-1, enduranceOffset + DamageReduce);
|
||||
}
|
||||
CurrentEndurance += enduranceOffset;;
|
||||
|
||||
}
|
||||
|
||||
void APawnWithSkill::ApplyyTenacity_Implementation(float tenacityOffset)
|
||||
{
|
||||
CurrentTenacity += tenacityOffset;
|
||||
}
|
||||
|
||||
void APawnWithSkill::SetDamageReduce(int32 damageReduce)
|
||||
{
|
||||
DamageReduce = damageReduce;
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void APawnWithSkill::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
CurrentEndurance = MaxEndurance;
|
||||
CurrentEndurance += MaxEndurance;
|
||||
CurrentTenacity += MaxTenacity;
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "GameFramework/Pawn.h"
|
||||
#include "PawnWithSkill.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnReceiveDamage);
|
||||
UCLASS()
|
||||
class PROJECTFISH_API APawnWithSkill : public APawn
|
||||
{
|
||||
@ -16,6 +17,10 @@ public:
|
||||
APawnWithSkill();
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
||||
void ApplyyEndurance(float enduranceOffset);
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
||||
void ApplyyTenacity(float tenacityOffset);
|
||||
|
||||
void SetDamageReduce(int32 damageReduce);
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
@ -29,7 +34,23 @@ public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "当前耐久度"))
|
||||
float CurrentEndurance;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "减伤值"))
|
||||
float DamageReduce;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= Default, meta = (DisplayPriority = 0, ToolTip = "最大耐久度"))
|
||||
float MaxEndurance;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "当前韧性"))
|
||||
float CurrentTenacity;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= Default, meta = (DisplayPriority = 0, ToolTip = "最大韧性"))
|
||||
float MaxTenacity;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= Default, meta = (DisplayPriority = 0, ToolTip = "韧性归零时眩晕时长"))
|
||||
float TenacityStun_Time = 5;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOnReceiveDamage OnReceiveDamage;
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,7 @@ public class ProjectFish : ModuleRules
|
||||
public ProjectFish(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
OptimizeCode = CodeOptimization.Never;
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "NavigationSystem", "AIModule", "Niagara", "EnhancedInput", "GameplayTags" });
|
||||
}
|
||||
}
|
||||
|
@ -3,18 +3,23 @@
|
||||
|
||||
#include "Skill.h"
|
||||
|
||||
#include "SkillTrigger.h"
|
||||
#include "SkillEffects/SkillEffect_Charge.h"
|
||||
#include "SkillEffects/SkillEffect_Damage.h"
|
||||
#include "SkillEffects/SkillEffect_DamageReduce.h"
|
||||
#include "SkillEffects/SkillEffect_EnhanceFishRod.h"
|
||||
#include "SkillEffects/SkillEffect_EnhanceSkill.h"
|
||||
#include "SkillEffects/SkillEffect_Heal.h"
|
||||
#include "SkillEffects/SkillEffect_ModifyCD.h"
|
||||
#include "SkillEffects/SkillEffect_ModifySpeed.h"
|
||||
#include "SkillEffects/SkillEffect_SER.h"
|
||||
|
||||
void USkill::InitSkill(APawnWithSkill* owner, USkillManager* skillManager, FSkillData skillData)
|
||||
void USkill::InitSkill(APawnWithSkill* owner, USkillManager* skillManager, FSkillData skillData, FIntPoint BagPos)
|
||||
{
|
||||
this->Owner = owner;
|
||||
this->SkillManager = skillManager;
|
||||
this->SkillData = skillData;
|
||||
this->BagPosition = BagPos;
|
||||
this->RemainingTime = SkillData.CD;
|
||||
this->RemainingEndurance = SkillData.Endurance;
|
||||
for (auto effectData: skillData.SkillEffects)
|
||||
@ -40,6 +45,18 @@ void USkill::InitSkill(APawnWithSkill* owner, USkillManager* skillManager, FSkil
|
||||
case ESkillEffectType::SkillEnduranceRestore:
|
||||
skillEffect = NewObject<USkillEffect>(this, USkillEffect_SER::StaticClass());
|
||||
break;
|
||||
case ESkillEffectType::EnhanceFishRod:
|
||||
skillEffect = NewObject<USkillEffect>(this, USkillEffect_EnhanceFishRod::StaticClass());
|
||||
break;
|
||||
case ESkillEffectType::EnhanceSkill:
|
||||
skillEffect = NewObject<USkillEffect>(this, USkillEffect_EnhanceSkill::StaticClass());
|
||||
break;
|
||||
case ESkillEffectType::DamageReduce:
|
||||
skillEffect = NewObject<USkillEffect>(this, USkillEffect_DamageReduce::StaticClass());
|
||||
break;
|
||||
default:
|
||||
const UEnum* EnumPtr = StaticEnum<ESkillEffectType>();
|
||||
UE_LOG(LogTemp, Error, TEXT("没有配置 %s类型的Skill Effect"), *EnumPtr->GetNameStringByValue(static_cast<int64>(effectData.EffectType)))
|
||||
}
|
||||
if (IsValid(skillEffect))
|
||||
{
|
||||
@ -50,37 +67,69 @@ void USkill::InitSkill(APawnWithSkill* owner, USkillManager* skillManager, FSkil
|
||||
}
|
||||
}
|
||||
|
||||
void USkill::InitSkillTrigger()
|
||||
{
|
||||
if (!SkillData.bActiveSkill)
|
||||
{
|
||||
if (SkillData.SkillTrigger)
|
||||
{
|
||||
USkillTrigger* SkillTrigger = NewObject<USkillTrigger>(this, SkillData.SkillTrigger);
|
||||
FSkillContext context;
|
||||
context.OwnerSkill = this;
|
||||
context.SkillManager = SkillManager;
|
||||
SkillTrigger->Init(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
//UE_LOG(LogTemp, Warning, TEXT("没有Trigger的被动技能,直接触发"));
|
||||
ExecuteSkill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool USkill::SkillTickAble()
|
||||
{
|
||||
return RemainingEndurance >0 || RemainingEndurance == -1;
|
||||
//剩余次数无限制或者拥有者没有被韧性眩晕
|
||||
return (RemainingEndurance >0 || RemainingEndurance == -1 ) && Owner->CurrentTenacity > 0 && SkillData.bActiveSkill;
|
||||
}
|
||||
|
||||
void USkill::TickSkill(float deltaTime)
|
||||
{
|
||||
RemainingTime -= deltaTime * SkillData.Speed;
|
||||
if (RemainingTime <= 0 && SkillTickAble())
|
||||
if (SkillTickAble())
|
||||
RemainingTime -= deltaTime * SkillData.Speed;
|
||||
if (RemainingTime <= 0 )
|
||||
{
|
||||
RemainingTime = 0;
|
||||
if (RemainingEndurance >0)
|
||||
--RemainingEndurance;
|
||||
FSkillContext context;
|
||||
context.Self = Owner;
|
||||
context.SkillManager = SkillManager;
|
||||
for (auto Effect: SkillEffects)
|
||||
{
|
||||
Effect->Execute(context);
|
||||
}
|
||||
RemainingTime = SkillData.CD;
|
||||
ExecuteSkill();
|
||||
}
|
||||
if (RemainingEndurance == 0)
|
||||
{
|
||||
FSkillContext context;
|
||||
context.OwnerSkill = this;
|
||||
context.SkillManager = SkillManager;
|
||||
for (auto Effect: SkillEffects)
|
||||
{
|
||||
Effect->EffectEnded();
|
||||
Effect->EffectEnded(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void USkill::ExecuteSkill()
|
||||
{
|
||||
RemainingTime = 0;
|
||||
if (RemainingEndurance >0)
|
||||
--RemainingEndurance;
|
||||
FSkillContext context;
|
||||
context.OwnerSkill = this;
|
||||
context.SkillManager = SkillManager;
|
||||
for (auto Effect: SkillEffects)
|
||||
{
|
||||
Effect->Execute(context);
|
||||
}
|
||||
RemainingTime = SkillData.CD;
|
||||
OnSkillExecute.Broadcast(SkillData.SkillName.ToString());
|
||||
}
|
||||
|
||||
FString USkill::GetSkillName() const
|
||||
{
|
||||
return SkillData.SkillName.ToString();;
|
||||
@ -91,6 +140,11 @@ FSkillData& USkill::GetSkillData()
|
||||
return SkillData;
|
||||
}
|
||||
|
||||
FIntPoint USkill::GetBagPos()
|
||||
{
|
||||
return BagPosition;
|
||||
}
|
||||
|
||||
void USkill::SetSkillData(FSkillData data)
|
||||
{
|
||||
SkillData = data;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "Skill.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FSkillUpdate);
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSkillExecute, FString, SkillName );
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -19,15 +19,24 @@ class PROJECTFISH_API USkill : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
void InitSkill(class APawnWithSkill* owner, USkillManager* skillManager, FSkillData SkillData);
|
||||
void InitSkill(class APawnWithSkill* owner, USkillManager* skillManager, FSkillData SkillData, FIntPoint BagPos);
|
||||
void InitSkillTrigger();
|
||||
void TickSkill(float deltaTime);
|
||||
void ExecuteSkill();
|
||||
|
||||
FString GetSkillName() const;
|
||||
class APawnWithSkill* GetOwner();
|
||||
|
||||
FSkillData& GetSkillData();
|
||||
TArray<USkillEffect*> GetAllSkillEffects()
|
||||
{
|
||||
return SkillEffects;
|
||||
}
|
||||
|
||||
FIntPoint GetBagPos();
|
||||
void SetSkillData( FSkillData SkillData);
|
||||
void ApplyRemainingTimeOffset(int timeOffset);
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void ApplyRemainingTimeOffset(int timeOffset);
|
||||
void ApplyRemainingRemainingEnduranceOffset(int Offset);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
@ -35,6 +44,9 @@ public:
|
||||
protected:
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FSkillUpdate OnSkillUpdate;
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FSkillExecute OnSkillExecute;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "技能效果"))
|
||||
FSkillData SkillData;
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "技能效果"))
|
||||
@ -47,6 +59,9 @@ protected:
|
||||
float RemainingTime;
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "剩余耐久度"))
|
||||
int32 RemainingEndurance;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, EditAnywhere, meta = (ToolTip = "背包位置"))
|
||||
FIntPoint BagPosition;
|
||||
};
|
||||
|
||||
|
||||
|
@ -34,13 +34,14 @@ void USkillEffect::Execute(const FSkillContext& context)
|
||||
const UEnum* EnumPtr = StaticEnum<ESkillEffectType>();
|
||||
FString type = EnumPtr->GetNameStringByValue(static_cast<int64>(effectData.EffectType)) ;
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("技能:%s 目标: %s 效果: %s")
|
||||
UE_LOG(LogTemp, Warning, TEXT("技能:%s 拥有者: %s 目标: %s 效果: %s")
|
||||
, *OwnerSkill->GetSkillData().SkillName.ToString()
|
||||
,*OwnerSkill->GetOwner()->GetActorNameOrLabel()
|
||||
,*strTargets
|
||||
, *( GetSkillEffectDes()));
|
||||
}
|
||||
|
||||
void USkillEffect::EffectEnded()
|
||||
void USkillEffect::EffectEnded(const FSkillContext& context)
|
||||
{
|
||||
}
|
||||
|
||||
@ -132,52 +133,15 @@ void USkillEffect::GetEffectTargetsByTargetType(const FSkillContext& context, TA
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ESkillTargetType::AdjacentLeft:
|
||||
case ESkillTargetType::Around:
|
||||
{
|
||||
//技能左侧的技能
|
||||
TArray<USkill*> aroundSkills = context.SkillManager->GetSkillsAround(context.OwnerSkill);
|
||||
for (auto skill: aroundSkills)
|
||||
{
|
||||
//技能左侧的技能
|
||||
TArray< USkill*> allSkills = context.SkillManager->GetAllSkills();
|
||||
int32 index = allSkills.Find(OwnerSkill);
|
||||
if ((index - 1) >= 0)
|
||||
{
|
||||
result.Add(allSkills[index - 1]);
|
||||
}
|
||||
break;;
|
||||
}
|
||||
case ESkillTargetType::AdjacentRight:
|
||||
{
|
||||
//技能右侧的技能
|
||||
TArray< USkill*> allSkills = context.SkillManager->GetAllSkills();
|
||||
int32 index = allSkills.Find(OwnerSkill);
|
||||
if ((index + 1) < allSkills.Num())
|
||||
{
|
||||
result.Add(allSkills[index + 1]);
|
||||
result.Add(skill);
|
||||
}
|
||||
break;;
|
||||
}
|
||||
case ESkillTargetType::AllLeft:
|
||||
{
|
||||
//所有当前技能左侧的技能
|
||||
TArray< USkill*> allSkills = context.SkillManager->GetAllSkills();
|
||||
int32 index = allSkills.Find(OwnerSkill);
|
||||
for (int i = 0; i < index; ++i)
|
||||
{
|
||||
if (allSkills[i]->GetOwner() == OwnerSkill->GetOwner())
|
||||
result.Add(allSkills[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ESkillTargetType::AllRight:
|
||||
{
|
||||
//所有当前技能右侧的技能
|
||||
TArray< USkill*> allSkills = context.SkillManager->GetAllSkills();
|
||||
int32 index = allSkills.Find(OwnerSkill);
|
||||
for (int i = index + 1; i < allSkills.Num(); ++i)
|
||||
{
|
||||
if (allSkills[i]->GetOwner() == OwnerSkill->GetOwner())
|
||||
result.Add(allSkills[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,15 @@ class USkillEffect : public UObject
|
||||
public:
|
||||
void InitSkillEffect(class USkill* skill, FSkillEffectData data);
|
||||
virtual void Execute(const FSkillContext& context) ;
|
||||
virtual void EffectEnded();
|
||||
virtual void EffectEnded(const FSkillContext& context);
|
||||
TArray<UObject*> GetApplyTargets(const FSkillContext& context);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
virtual FString GetSkillEffectDes();
|
||||
|
||||
FSkillEffectData& GetEffectData()
|
||||
{
|
||||
return effectData;
|
||||
}
|
||||
private:
|
||||
void GetEffectTargetsByTargetType(const FSkillContext& context, TArray<UObject*>& result);
|
||||
protected:
|
||||
|
@ -0,0 +1,49 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "SkillEffect_DamageReduce.h"
|
||||
|
||||
#include "ProjectFish/Skill/Skill.h"
|
||||
|
||||
void USkillEffect_DamageReduce::Execute(const FSkillContext& context)
|
||||
{
|
||||
Super::Execute(context);
|
||||
TArray<UObject*> targets = GetApplyTargets(context);
|
||||
for (auto target: targets)
|
||||
{
|
||||
if (!target->GetClass()->IsChildOf(APawnWithSkill::StaticClass()))
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("skill %s apply target is not a pawn "), *(OwnerSkill->GetSkillName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
//设置目标护盾值
|
||||
APawnWithSkill* OwnerPawn = Cast<APawnWithSkill>(target);
|
||||
OwnerPawn->SetDamageReduce( (int32)(effectData.EffectValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void USkillEffect_DamageReduce::EffectEnded(const FSkillContext& context)
|
||||
{
|
||||
Super::EffectEnded(context);
|
||||
TArray<UObject*> targets = GetApplyTargets(context);
|
||||
for (auto target: targets)
|
||||
{
|
||||
if (!target->GetClass()->IsChildOf(APawnWithSkill::StaticClass()))
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("skill %s apply target is not a pawn "), *(OwnerSkill->GetSkillName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
//恢复目标护盾值
|
||||
APawnWithSkill* OwnerPawn = Cast<APawnWithSkill>(target);
|
||||
OwnerPawn->SetDamageReduce(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FString USkillEffect_DamageReduce::GetSkillEffectDes()
|
||||
{
|
||||
return FString::Printf(TEXT("减少目标受到的伤害 %d点"), (int32)(effectData.EffectValue));
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ProjectFish/Skill/SkillEffect.h"
|
||||
#include "SkillEffect_DamageReduce.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class PROJECTFISH_API USkillEffect_DamageReduce : public USkillEffect
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
void Execute(const FSkillContext& context) override;
|
||||
void EffectEnded(const FSkillContext& context) override;
|
||||
FString GetSkillEffectDes() override;
|
||||
};
|
@ -0,0 +1,38 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "SkillEffect_EnhanceFishRod.h"
|
||||
|
||||
#include "ProjectFish/Components/FishingRodComponent.h"
|
||||
#include "ProjectFish/Skill/Skill.h"
|
||||
|
||||
void USkillEffect_EnhanceFishRod::Execute(const FSkillContext& context)
|
||||
{
|
||||
Super::Execute(context);
|
||||
TArray<UObject*> targets = GetApplyTargets(context);
|
||||
for (auto target: targets)
|
||||
{
|
||||
if (!target->GetClass()->IsChildOf(APawnWithSkill::StaticClass()))
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("skill %s apply target is not a pawn with fish rod"), *(OwnerSkill->GetSkillName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
//修改技能的冷却时间
|
||||
APawnWithSkill* OwnerPawn = Cast<APawnWithSkill>(target);
|
||||
if (OwnerPawn->GetComponentByClass(UFishingRodComponent::StaticClass()) != NULL)
|
||||
{
|
||||
UFishingRodComponent* rod = Cast<UFishingRodComponent>(OwnerPawn->GetComponentByClass(UFishingRodComponent::StaticClass()));
|
||||
rod->AddFishRodDamage( (int32)(effectData.EffectValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
FString USkillEffect_EnhanceFishRod::GetSkillEffectDes()
|
||||
{
|
||||
return FString::Printf(TEXT("使鱼竿的伤害增加 %d点"), (int32)(effectData.EffectValue));
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ProjectFish/Skill/SkillEffect.h"
|
||||
#include "SkillEffect_EnhanceFishRod.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class PROJECTFISH_API USkillEffect_EnhanceFishRod : public USkillEffect
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
void Execute(const FSkillContext& context) override;
|
||||
FString GetSkillEffectDes() override;
|
||||
};
|
@ -0,0 +1,32 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "SkillEffect_EnhanceSkill.h"
|
||||
#include "ProjectFish/Skill/Skill.h"
|
||||
|
||||
void USkillEffect_EnhanceSkill::Execute(const FSkillContext& context)
|
||||
{
|
||||
Super::Execute(context);
|
||||
TArray<UObject*> targets = GetApplyTargets(context);
|
||||
for (auto target: targets)
|
||||
{
|
||||
if (!target->GetClass()->IsChildOf(USkill::StaticClass()))
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("skill %s apply target is not a skill"), *(OwnerSkill->GetSkillName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
//修改技能的冷却时间
|
||||
USkill* targetSkill = Cast<USkill>(target);
|
||||
for (auto skilleffect: targetSkill->GetAllSkillEffects())
|
||||
{
|
||||
skilleffect->GetEffectData().EffectValue +=(int32)(effectData.EffectValue)*(skilleffect->GetEffectData().EffectValue/FMath::Abs(skilleffect->GetEffectData().EffectValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FString USkillEffect_EnhanceSkill::GetSkillEffectDes()
|
||||
{
|
||||
return FString::Printf(TEXT("增强目标技能 %d点"), (int32)(effectData.EffectValue));
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ProjectFish/Skill/SkillEffect.h"
|
||||
#include "SkillEffect_EnhanceSkill.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class PROJECTFISH_API USkillEffect_EnhanceSkill : public USkillEffect
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
void Execute(const FSkillContext& context) override;
|
||||
FString GetSkillEffectDes() override;
|
||||
};
|
@ -36,9 +36,9 @@ void USkillEffect_ModifySpeed::Execute(const FSkillContext& context)
|
||||
}
|
||||
}
|
||||
|
||||
void USkillEffect_ModifySpeed::EffectEnded()
|
||||
void USkillEffect_ModifySpeed::EffectEnded(const FSkillContext& context)
|
||||
{
|
||||
Super::EffectEnded();
|
||||
Super::EffectEnded(context);
|
||||
//GetWorld()->GetTimerManager().ClearTimer(TimerHandle);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class PROJECTFISH_API USkillEffect_ModifySpeed : public USkillEffect
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
void Execute(const FSkillContext& context) override;
|
||||
void EffectEnded() override;
|
||||
void EffectEnded(const FSkillContext& context) override;
|
||||
FString GetSkillEffectDes() override;
|
||||
private:
|
||||
FTimerHandle TimerHandle;
|
||||
|
@ -22,20 +22,120 @@ TStatId USkillManager::GetStatId() const
|
||||
return Super::GetStatID();
|
||||
}
|
||||
|
||||
void USkillManager::InitPawns(TArray<APawnWithSkill*> Pawns)
|
||||
void USkillManager::AddPawn(class APawnWithSkill* Pawn, FIntPoint BagSize)
|
||||
{
|
||||
this->SkillPawns = Pawns;
|
||||
PawnInfo.Add(Pawn, BagSize);
|
||||
TMap<FIntPoint, int32> states;
|
||||
for (int y = 0; y < BagSize.Y; y++)
|
||||
{
|
||||
for (int x = 0; x < BagSize.X; x++)
|
||||
{
|
||||
states.Add(FIntPoint(x, y), -1);
|
||||
|
||||
}
|
||||
}
|
||||
PawnBagState.Add(Pawn, states);
|
||||
}
|
||||
|
||||
USkill* USkillManager::CreateSkill(FSkillData data, APawnWithSkill* Pawn)
|
||||
// void USkillManager::InitPawns(TArray<APawnWithSkill*> Pawns)
|
||||
// {
|
||||
// this->SkillPawns = Pawns;
|
||||
// }
|
||||
|
||||
USkill* USkillManager::AddSkill(FSkillData data, APawnWithSkill* Pawn, FIntPoint& BagPos)
|
||||
{
|
||||
USkill* skill = NewObject<USkill>(this);
|
||||
skill->InitSkill(Pawn, this, data);
|
||||
Skills.Add(skill);
|
||||
return skill;
|
||||
TMap<FIntPoint, int32>* states = PawnBagState.Find(Pawn);
|
||||
FIntPoint BagSize = *PawnInfo.Find(Pawn);
|
||||
bool bAddAble = true;
|
||||
for (int y = 0; y < BagSize.Y; y++)
|
||||
{
|
||||
for (int x = 0; x < BagSize.X; x++)
|
||||
{
|
||||
bAddAble = true;
|
||||
for (int skillX = 0; skillX < data.SkillWeight.X; skillX++)
|
||||
{
|
||||
for (int skillY = 0; skillY < data.SkillWeight.Y; skillY++)
|
||||
{
|
||||
if (states->Find(FIntPoint(x, y) + FIntPoint(skillX, skillY)) == nullptr
|
||||
|| *states->Find(FIntPoint(x, y) + FIntPoint(skillX, skillY)) != -1)
|
||||
{
|
||||
bAddAble = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
//满足条件
|
||||
if (bAddAble)
|
||||
{
|
||||
BagPos = FIntPoint(x, y);
|
||||
USkill* skill = NewObject<USkill>(this);
|
||||
skill->InitSkill(Pawn, this, data, BagPos);
|
||||
Skills.Add(skill);
|
||||
//设置占用状态
|
||||
for (int xTemp = 0; xTemp < data.SkillWeight.X; xTemp++)
|
||||
{
|
||||
for (int yTemp = 0; yTemp < data.SkillWeight.Y; yTemp++)
|
||||
{
|
||||
states->Add(FIntPoint(xTemp, yTemp) + FIntPoint(x, y), GetSkillIndex(skill));
|
||||
}
|
||||
}
|
||||
|
||||
return skill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void USkillManager::OnAllSkillAdded()
|
||||
{
|
||||
//所有技能初始化后,初始化技能的触发器
|
||||
for (auto Skill : Skills)
|
||||
{
|
||||
Skill->InitSkillTrigger();
|
||||
}
|
||||
}
|
||||
|
||||
class USkill* USkillManager::GetSkillByTag(FGameplayTag Tag)
|
||||
{
|
||||
for (auto Skill : Skills)
|
||||
{
|
||||
if (Skill->GetSkillData().SkillTag == Tag)
|
||||
return Skill;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32 USkillManager::GetSkillIndex(USkill* Skill)
|
||||
{
|
||||
return Skills.Find(Skill);
|
||||
}
|
||||
|
||||
TArray<USkill*> USkillManager::GetSkillsAround(USkill* TargetSkill)
|
||||
{
|
||||
TArray<USkill*> aroundSkills;
|
||||
TMap<FIntPoint, int32> *BagStates = PawnBagState.Find(TargetSkill->GetOwner());
|
||||
FIntPoint BagPos = TargetSkill->GetBagPos();
|
||||
FIntPoint BagSize = *PawnInfo.Find(TargetSkill->GetOwner());
|
||||
FSkillData data = TargetSkill->GetSkillData();
|
||||
int beginX = FMath::Max(0, BagPos.X- 1);
|
||||
int endX = FMath::Min(BagSize.X - 1, BagPos.X + 1);
|
||||
int beginY = FMath::Max(0, BagPos.Y - 1);
|
||||
int endY = FMath::Min(BagSize.Y - 1, BagPos.Y + 1);
|
||||
for (int x = beginX; x <= endX; x++)
|
||||
{
|
||||
for (int y = beginY; y <= endY; y++)
|
||||
{
|
||||
|
||||
int32 skillIndex = *BagStates->Find(FIntPoint(x, y));
|
||||
if (skillIndex != -1 && skillIndex != GetSkillIndex(TargetSkill) && !aroundSkills.Contains(Skills[skillIndex]))
|
||||
{
|
||||
aroundSkills.Add(Skills[skillIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return aroundSkills;
|
||||
}
|
||||
|
||||
void USkillManager::RemoveSkill(USkill* Skill)
|
||||
{
|
||||
@ -44,7 +144,23 @@ void USkillManager::RemoveSkill(USkill* Skill)
|
||||
|
||||
TArray<APawnWithSkill*> USkillManager::GetAllPawns()
|
||||
{
|
||||
return SkillPawns;
|
||||
TArray<APawnWithSkill*> Pawns;
|
||||
for (auto info: PawnInfo)
|
||||
{
|
||||
Pawns.Add(info.Key);
|
||||
}
|
||||
return Pawns;
|
||||
}
|
||||
|
||||
TArray<class USkill*> USkillManager::GetSkillsByOwner(APawnWithSkill* Pawn)
|
||||
{
|
||||
TArray<class USkill*> skills;
|
||||
for (auto Skill : Skills)
|
||||
{
|
||||
if (Skill->GetOwner() == Pawn)
|
||||
skills.Add(Skill);
|
||||
}
|
||||
return skills;
|
||||
}
|
||||
|
||||
TArray< USkill*> USkillManager::GetAllSkills()
|
||||
|
@ -20,11 +20,23 @@ public:
|
||||
virtual bool IsTickable() const override;
|
||||
virtual TStatId GetStatId() const override;
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void InitPawns(TArray<APawnWithSkill*> Pawns);
|
||||
void AddPawn(class APawnWithSkill* Pawn, FIntPoint BagSize);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
USkill* CreateSkill(FSkillData data, APawnWithSkill* Pawn);
|
||||
USkill* AddSkill(FSkillData data, APawnWithSkill* Pawn, FIntPoint& BagPos);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void OnAllSkillAdded();
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
class USkill* GetSkillByTag(FGameplayTag Tag);
|
||||
|
||||
int32 GetSkillIndex(USkill* Skill);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
TArray<USkill*> GetSkillsAround(USkill *TargetSkill);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void RemoveSkill(class USkill *Skill);
|
||||
@ -32,13 +44,20 @@ public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
TArray<APawnWithSkill*> GetAllPawns();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintPure)
|
||||
TArray<class USkill*> GetSkillsByOwner(APawnWithSkill* Pawn);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
TArray<class USkill*> GetAllSkills();
|
||||
protected:
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
TArray<class USkill *> Skills;
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
TArray<class APawnWithSkill *> SkillPawns;
|
||||
TMap<class APawnWithSkill*, FIntPoint> PawnInfo;
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
bool bGameEnd = false;
|
||||
|
||||
TMap<APawnWithSkill*, TMap<FIntPoint, int32>> PawnBagState;
|
||||
};
|
||||
|
||||
|
||||
|
17
ProjectFish/Source/ProjectFish/Skill/SkillTrigger.cpp
Normal file
17
ProjectFish/Source/ProjectFish/Skill/SkillTrigger.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "SkillTrigger.h"
|
||||
|
||||
#include "Skill.h"
|
||||
|
||||
|
||||
void USkillTrigger::Init_Implementation(FSkillContext context)
|
||||
{
|
||||
SkillContext = context;
|
||||
}
|
||||
|
||||
void USkillTrigger::OnTrigger()
|
||||
{
|
||||
SkillContext.OwnerSkill->ExecuteSkill();
|
||||
}
|
26
ProjectFish/Source/ProjectFish/Skill/SkillTrigger.h
Normal file
26
ProjectFish/Source/ProjectFish/Skill/SkillTrigger.h
Normal file
@ -0,0 +1,26 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ProjectFish/Definations.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "SkillTrigger.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Blueprintable)
|
||||
class PROJECTFISH_API USkillTrigger : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
void Init(FSkillContext context);
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void OnTrigger();
|
||||
|
||||
protected:
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FSkillContext SkillContext;
|
||||
};
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user