当前位置: 首页 > wzjs >正文

wordpress外贸建站公司岚山网站建设公司

wordpress外贸建站公司,岚山网站建设公司,小程序开发平台认可的公司,网页游戏修改器文章目录添加一些新的属性创新一个UI用来显示属性在蓝图中继承UI,并显示UI添加一些新的属性 添加一些新的属性 UCLASS() class UCAttributeSet : public UAttributeSet {// 攻击力UPROPERTY(ReplicatedUsing OnRep_AttackDamage)FGameplayAttributeData AttackDa…

文章目录

  • 添加一些新的属性
  • 创新一个UI用来显示属性
  • 在蓝图中继承UI,并显示UI


添加一些新的属性

添加一些新的属性

UCLASS()
class UCAttributeSet : public UAttributeSet
{// 攻击力UPROPERTY(ReplicatedUsing = OnRep_AttackDamage)FGameplayAttributeData AttackDamage;ATTRIBUTE_ACCESSORS(UCAttributeSet, AttackDamage)// 护甲值UPROPERTY(ReplicatedUsing = OnRep_Armor)FGameplayAttributeData Armor;ATTRIBUTE_ACCESSORS(UCAttributeSet, Armor)// 移动速度UPROPERTY(ReplicatedUsing = OnRep_MoveSpeed)FGameplayAttributeData MoveSpeed;ATTRIBUTE_ACCESSORS(UCAttributeSet, MoveSpeed)// 移动加速度UPROPERTY(ReplicatedUsing = OnRep_MoveAcceleration)FGameplayAttributeData MoveAcceleration;ATTRIBUTE_ACCESSORS(UCAttributeSet, MoveAcceleration)UFUNCTION()void OnRep_AttackDamage(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_Armor(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_MoveSpeed(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_MoveAcceleration(const FGameplayAttributeData& OldValue);
};
void UCAttributeSet::GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const
{Super::GetLifetimeReplicatedProps(OutLifetimeProps);DOREPLIFETIME_CONDITION_NOTIFY(UCAttributeSet, Health, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCAttributeSet, MaxHealth, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCAttributeSet, Mana, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCAttributeSet, MaxMana, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCAttributeSet, AttackDamage, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCAttributeSet, Armor, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCAttributeSet, MoveSpeed, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCAttributeSet, MoveAcceleration, COND_None, REPNOTIFY_Always);
}void UCAttributeSet::OnRep_AttackDamage(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCAttributeSet, AttackDamage, OldValue);
}void UCAttributeSet::OnRep_Armor(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCAttributeSet, Armor, OldValue);
}void UCAttributeSet::OnRep_MoveSpeed(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCAttributeSet, MoveSpeed, OldValue);
}void UCAttributeSet::OnRep_MoveAcceleration(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCAttributeSet, MoveAcceleration, OldValue);
}

再创建一个玩家角色用的属性

// 幻雨喜欢小猫咪#pragma once#include "CoreMinimal.h"
#include "AttributeSet.h"
#include "AbilitySystemComponent.h"
#include "CHeroAttributeSet.generated.h"// 属性访问器宏,自动生成属性的Getter/Setter等
#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)/*** 英雄属性集(UCHeroAttributeSet)* 用于管理英雄的成长属性、经验、等级、升级点、金币等* 支持属性同步、属性变化回调等功能*/
UCLASS()
class UCHeroAttributeSet : public UAttributeSet
{GENERATED_BODY()
public:// 属性访问器声明(自动生成标准接口)ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, Intelligence)             // 智力ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, Strength)                 // 力量ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, Experience)               // 当前经验ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, PrevLevelExperience)      // 上一级所需经验ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, NextLevelExperience)      // 下一级所需经验ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, Level)                    // 当前等级ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, UpgradePoint)             // 可用升级点ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, MaxLevel)                 // 最大等级ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, MaxLevelExperience)       // 满级所需经验ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, Gold)                     // 金币ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, StrengthGrowthRate)       // 力量成长率ATTRIBUTE_ACCESSORS(UCHeroAttributeSet, IntelligenceGrowthRate)   // 智力成长率// 属性同步(网络复制)配置virtual void GetLifetimeReplicatedProps( TArray< class FLifetimeProperty > & OutLifetimeProps ) const override;
private:// 智力UPROPERTY(ReplicatedUsing = OnRep_Intelligence)FGameplayAttributeData Intelligence;// 力量UPROPERTY(ReplicatedUsing = OnRep_Strength)FGameplayAttributeData Strength;// 当前经验UPROPERTY(ReplicatedUsing = OnRep_Experience)FGameplayAttributeData Experience;// 力量成长率UPROPERTY()FGameplayAttributeData StrengthGrowthRate;// 智力成长率UPROPERTY()FGameplayAttributeData IntelligenceGrowthRate;// 上一级所需经验UPROPERTY(ReplicatedUsing = OnRep_PrevLevelExperience)FGameplayAttributeData PrevLevelExperience;// 下一级所需经验UPROPERTY(ReplicatedUsing = OnRep_NextLevelExperience)FGameplayAttributeData NextLevelExperience;// 当前等级UPROPERTY(ReplicatedUsing = OnRep_Level)FGameplayAttributeData Level;// 可用升级点UPROPERTY(ReplicatedUsing = OnRep_UpgradePoint)FGameplayAttributeData UpgradePoint;// 最大等级UPROPERTY(ReplicatedUsing = OnRep_MaxLevel)FGameplayAttributeData MaxLevel;// 满级所需经验UPROPERTY(ReplicatedUsing = OnRep_MaxLevelExperience)FGameplayAttributeData MaxLevelExperience;// 金币UPROPERTY(ReplicatedUsing = OnRep_Gold)FGameplayAttributeData Gold;// 属性同步回调(用于客户端属性变化通知)UFUNCTION()void OnRep_Intelligence(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_Strength(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_Experience(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_PrevLevelExperience(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_NextLevelExperience(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_Level(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_UpgradePoint(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_MaxLevel(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_MaxLevelExperience(const FGameplayAttributeData& OldValue);UFUNCTION()void OnRep_Gold(const FGameplayAttributeData& OldValue);
};
// 幻雨喜欢小猫咪#include "GAS/Core/CHeroAttributeSet.h"
#include "Net/UnrealNetwork.h"
#include "GameplayEffectExtension.h"void UCHeroAttributeSet::GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const
{Super::GetLifetimeReplicatedProps(OutLifetimeProps);DOREPLIFETIME_CONDITION_NOTIFY(UCHeroAttributeSet, Intelligence, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCHeroAttributeSet, Strength, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCHeroAttributeSet, Experience, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCHeroAttributeSet, PrevLevelExperience, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCHeroAttributeSet, NextLevelExperience, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCHeroAttributeSet, Level, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCHeroAttributeSet, UpgradePoint, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCHeroAttributeSet, MaxLevel, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCHeroAttributeSet, MaxLevelExperience, COND_None, REPNOTIFY_Always);DOREPLIFETIME_CONDITION_NOTIFY(UCHeroAttributeSet, Gold, COND_None, REPNOTIFY_Always);
}void UCHeroAttributeSet::OnRep_Intelligence(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCHeroAttributeSet, Intelligence, OldValue);
}void UCHeroAttributeSet::OnRep_Strength(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCHeroAttributeSet, Strength, OldValue);
}void UCHeroAttributeSet::OnRep_Experience(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCHeroAttributeSet, Experience, OldValue);
}void UCHeroAttributeSet::OnRep_PrevLevelExperience(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCHeroAttributeSet, PrevLevelExperience, OldValue);
}void UCHeroAttributeSet::OnRep_NextLevelExperience(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCHeroAttributeSet, NextLevelExperience, OldValue);
}void UCHeroAttributeSet::OnRep_Level(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCHeroAttributeSet, Level, OldValue);
}void UCHeroAttributeSet::OnRep_UpgradePoint(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCHeroAttributeSet, UpgradePoint, OldValue);
}void UCHeroAttributeSet::OnRep_MaxLevel(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCHeroAttributeSet, MaxLevel, OldValue);
}void UCHeroAttributeSet::OnRep_MaxLevelExperience(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCHeroAttributeSet, MaxLevelExperience, OldValue);
}void UCHeroAttributeSet::OnRep_Gold(const FGameplayAttributeData& OldValue)
{GAMEPLAYATTRIBUTE_REPNOTIFY(UCHeroAttributeSet, Gold, OldValue);
}

在玩家角色中创建该属性集

#pragma region Gameplay Ability
private:// 瞄准状态变化时回调virtual void OnAimStateChanged(bool bIsAiming) override;UPROPERTY()TObjectPtr<UCHeroAttributeSet> HeroAttributeSet;
#pragma endregion

在构造函数中创建该属性集

ACPlayerCharacter::ACPlayerCharacter()
{HeroAttributeSet = CreateDefaultSubobject<UCHeroAttributeSet>(TEXT("HeroAttributeSet"));
}

创新一个UI用来显示属性

创建一个StatsGauge将属性传入过去显示

// 幻雨喜欢小猫咪#pragma once#include "CoreMinimal.h"
#include "AttributeSet.h"
#include "Blueprint/UserWidget.h"
#include "GameplayEffectTypes.h"
#include "Components/Image.h"
#include "Components/TextBlock.h"
#include "StatsGauge.generated.h"/*** 绑定属性数值的UI*/
UCLASS()
class CRUNCH_API UStatsGauge : public UUserWidget
{GENERATED_BODY()
public:// 构建前virtual void NativePreConstruct() override;// 构建时virtual void NativeConstruct() override;private:// 属性图标控件UPROPERTY(meta=(BindWidget))TObjectPtr<UImage> Icon;// 属性数值文本控件UPROPERTY(meta=(BindWidget))TObjectPtr<UTextBlock> AttributeText;// 需要显示的属性UPROPERTY(EditAnywhere, Category = "Attribute")FGameplayAttribute Attribute;// 图标资源UPROPERTY(EditAnywhere, Category = "Visual")TObjectPtr<UTexture2D> IconTexture;// 设置属性数值显示void SetValue(float NewVal);// 数字格式化选项FNumberFormattingOptions NumberFormattingOptions;// 属性变化回调void AttributeChanged(const FOnAttributeChangeData& Data);
};
// 幻雨喜欢小猫咪#include "UI/Gameplay/StatsGauge.h"#include "AbilitySystemBlueprintLibrary.h"
#include "AbilitySystemComponent.h"void UStatsGauge::NativePreConstruct()
{Super::NativePreConstruct();Icon->SetBrushFromTexture(IconTexture);
}void UStatsGauge::NativeConstruct()
{Super::NativeConstruct();// 设置为整数格式NumberFormattingOptions.MaximumFractionalDigits = 0;APawn* OwnerPlayerPawn = GetOwningPlayerPawn();if (!OwnerPlayerPawn) return;UAbilitySystemComponent* OwnerASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(OwnerPlayerPawn);if (OwnerASC){bool bFound;float AttributeValue = OwnerASC->GetGameplayAttributeValue(Attribute, bFound);if (bFound){SetValue(AttributeValue);}OwnerASC->GetGameplayAttributeValueChangeDelegate(Attribute).AddUObject(this, &UStatsGauge::AttributeChanged);}
}void UStatsGauge::SetValue(float NewVal)
{AttributeText->SetText(FText::AsNumber(NewVal, &NumberFormattingOptions));
}void UStatsGauge::AttributeChanged(const FOnAttributeChangeData& Data)
{SetValue(Data.NewValue);
}

将属性UI放到游戏界面中,在GameplayWidget中添加几个属性UI

	// 属性面板:攻击力显示控件UPROPERTY(meta=(BindWidget))TObjectPtr<UStatsGauge> AttackDamageGauge;// 属性面板:护甲显示控件UPROPERTY(meta=(BindWidget))TObjectPtr<UStatsGauge> ArmorGauge;// 属性面板:移动速度显示控件UPROPERTY(meta=(BindWidget))TObjectPtr<UStatsGauge> MoveSpeedGauge;// 属性面板:智力显示控件UPROPERTY(meta=(BindWidget))TObjectPtr<UStatsGauge> IntelligenceGauge;// 属性面板:力量显示控件UPROPERTY(meta=(BindWidget))TObjectPtr<UStatsGauge> StrengthGauge;

在蓝图中继承UI,并显示UI

去到UE中创建蓝图版本的属性UI,再将其添加到GameplayWidget中去
在这里插入图片描述

在这里插入图片描述
添加一个边界作为底色
在这里插入图片描述


文章转载自:

http://az36C6ZC.xqknL.cn
http://RvOp0xcr.xqknL.cn
http://xm6VxliN.xqknL.cn
http://fkCka4Gn.xqknL.cn
http://Rdd1Pwuq.xqknL.cn
http://dpNN2cq2.xqknL.cn
http://xFvmA6nt.xqknL.cn
http://kFStcAly.xqknL.cn
http://MgCIn8Kg.xqknL.cn
http://49APeFww.xqknL.cn
http://97NnOQUm.xqknL.cn
http://2EAzIH5H.xqknL.cn
http://kqhHDEBo.xqknL.cn
http://NRhhqFi2.xqknL.cn
http://1VX6gmex.xqknL.cn
http://HPd2MWne.xqknL.cn
http://5J2DbM2k.xqknL.cn
http://X80VKk8e.xqknL.cn
http://UJynTpd5.xqknL.cn
http://jOjMNq0V.xqknL.cn
http://Ig9v9bgs.xqknL.cn
http://SfRS8avn.xqknL.cn
http://z0TUTyTI.xqknL.cn
http://u7Q1tvRr.xqknL.cn
http://XmcoNSEe.xqknL.cn
http://nyLXoqmE.xqknL.cn
http://cG4GGLab.xqknL.cn
http://cs2KZB5q.xqknL.cn
http://9domiync.xqknL.cn
http://mSem49qb.xqknL.cn
http://www.dtcms.com/wzjs/642390.html

相关文章:

  • 莱芜网站建设方案公司工装装修公司排名
  • wordpress 停站看网站用什么软件
  • 毕业设计如何用dw做网站百度搜索 相关网站
  • 杭州四喜做网站建设么找国外人做网站
  • 网站站外推广方法网页设计与制作黑马程序员
  • wordpress建两个网站吗昆明建个网站哪家便宜
  • 有域名的话怎么做网站wordpress中logo大小
  • 做网站每天更新两篇文章怎么把自己的网站推广出去
  • 做网站的哪里好学校网站首页设计图片
  • 做除尘环保的如何推广自己的网站蓝色高科技网站模板
  • 南宁网站建设策划外包广州黄埔区做网站培训机构
  • 通道县城市建设投资有限公司网站北京网站建设推荐q479185700上快
  • 门户网站建设厂商名录怎样用自己的pid做搜索网站
  • 为什么要给大夫做网站闵行区教育局官网
  • 首饰设计网站推荐苏州网站建设需要多少钱
  • 免费做问卷的网站中国十大流量网站
  • 什么是网络营销网络营销与电商营销有什么区别营口网站seo
  • 缔客网络上海响应式网站建设中国设计师联盟网站
  • 搜房网网站跳出率网站虚拟主机有什么用
  • 怎么才能注册做网站个人网站也要备案吗
  • 学生作业网站阿里云怎么做网站
  • 最专业的佛山网站建设价格手机界面设计
  • 建设京东类的网站需要什么流程专业网站制作公司采用哪些技术制作网站?
  • 酷站官网设计本室内设计师网
  • 那些网站可以做0首付分期手机外网如何访问群晖wordpress
  • 福建网站建设有限公司襄樊网站制作公司
  • 重庆网站建设 狐灵国内建筑设计网站
  • 做ppt的背景图片网站网站改版 删除栏目
  • 深圳网站建设团队买卖链接网站
  • wordpress检查全站链接WordPress上不了