188 lines
6.8 KiB
Lua
188 lines
6.8 KiB
Lua
---@class WB_UseBuffs_C:UAEUserWidget
|
|
---@field TipHidden UWidgetAnimation
|
|
---@field Button_Buff UButton
|
|
---@field Button_Tip UButton
|
|
---@field Image_Cooldown UImage
|
|
---@field Image_Icon UImage
|
|
---@field Image_Remind UImage
|
|
---@field Image_Select UImage
|
|
---@field Overlay_Skill UOverlay
|
|
---@field TextBlock_Continue UTextBlock
|
|
---@field TextBlock_Cooldown UTextBlock
|
|
---@field TextBlock_Desc UTextBlock
|
|
--Edit Below--
|
|
---@type WB_UseBuffs_C
|
|
local WB_UseBuffs = { bInitDoOnce = false; };
|
|
|
|
function WB_UseBuffs:Construct()
|
|
UITool.BindButtonPressed(self.Button_Buff, self.OnClickUseBuff, self);
|
|
UGCEventSystem.AddListener(EventTypes.PlayerUseBuff, self.OnPlayerUseBuff, self);
|
|
UGCEventSystem.AddListener(EventTypes.SelectSoldierType, self.SetSoldierType, self);
|
|
|
|
self.Button_Tip:SetVisibility(ESlateVisibility.Collapsed);
|
|
|
|
UGCEventSystem.SetTimer(self, function()
|
|
self:PlayAnimation(self.TipHidden, 0, 1, EUMGSequencePlayMode.Reverse, 1);
|
|
UGCEventSystem.SetTimer(self, function()
|
|
if self.bHadShow then
|
|
self:PlayAnimation(self.TipHidden, 0, 1, EUMGSequencePlayMode.Forward, 1);
|
|
UGCEventSystem.SetTimer(self, function()
|
|
self.Button_Tip:SetVisibility(ESlateVisibility.Collapsed);
|
|
end, 0.7);
|
|
else
|
|
self.Button_Tip:SetVisibility(ESlateVisibility.Collapsed);
|
|
end
|
|
end, 10);
|
|
end, 15);
|
|
end
|
|
|
|
-- function WB_UseBuffs:Tick(MyGeometry, InDeltaTime)
|
|
|
|
-- end
|
|
|
|
-- function WB_UseBuffs:Destruct()
|
|
|
|
-- end
|
|
|
|
WB_UseBuffs.bHadShow = true;
|
|
|
|
function WB_UseBuffs:OnClickUseBuff()
|
|
UGCSendRPCSystem.ActorRPCNotify(LocalPlayerKey, LocalPlayerController, "Server_PlayerUseBuff", LocalPlayerController:GetSoldierType());
|
|
self.Button_Buff:SetIsEnabled(false);
|
|
self.Image_Remind:SetVisibility(ESlateVisibility.Collapsed);
|
|
end
|
|
|
|
WB_UseBuffs.ContinueTime = 0.;
|
|
WB_UseBuffs.CooldownTime = 0.;
|
|
WB_UseBuffs.ConstCooldownTime = 0.;
|
|
WB_UseBuffs.ContinueTimer = nil;
|
|
WB_UseBuffs.CoolDownTimer = nil;
|
|
|
|
-- 存一份的技能配置
|
|
WB_UseBuffs.SkillConfig = {};
|
|
|
|
---@param Config NextUseBuffTimeStruct
|
|
function WB_UseBuffs:OnPlayerUseBuff(InPlayerKey, InBuffType, Config, InServerTime)
|
|
if InPlayerKey ~= LocalPlayerKey then return; end
|
|
UGCLogSystem.LogTree(string.format("[WB_UseBuffs:OnPlayerUseBuff] Config ="), Config)
|
|
-- 设置倒计时
|
|
local Time = Config.EndTime - Config.StartTime;
|
|
-- 设置时间
|
|
if Time > 0 then
|
|
UGCEventSystem.SetTimer(self, function()
|
|
self.Button_Buff:SetIsEnabled(true);
|
|
self.Overlay_Skill:SetVisibility(ESlateVisibility.Collapsed);
|
|
end, Time);
|
|
end
|
|
|
|
-- 显示当前是否在释放,和技能还有多长时间 转好
|
|
if self.ContinueTimer ~= nil then
|
|
UGCEventSystem.StopTimer(self.ContinueTimer);
|
|
self.ContinueTimer = nil;
|
|
self.ContinueTime = 0.;
|
|
end
|
|
|
|
if self.CoolDownTimer ~= nil then
|
|
UGCEventSystem.StopTimer(self.CoolDownTimer);
|
|
self.CoolDownTimer = nil;
|
|
self.CooldownTime = 0.;
|
|
end
|
|
|
|
if table.isEmpty(self.SkillConfig) then
|
|
-- 找到一下
|
|
local Type = UGCGameSystem.GameState:GetSoldierTypeByPlayerKey(LocalPlayerKey);
|
|
if Type == nil then return end
|
|
|
|
local Skill = SoldierConfig.Skills[Type]
|
|
if Skill.SkillType ~= SoldierConfig.ESkillType.Active then return; end
|
|
self.SkillConfig = TableHelper.DeepCopyTable(Skill.Skills[1]);
|
|
end
|
|
|
|
UGCLogSystem.LogTree(string.format("[WB_UseBuffs:OnPlayerUseBuff] self.SkillConfig ="), self.SkillConfig)
|
|
|
|
self.Overlay_Skill:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
|
--- 说明当前没有
|
|
if self.SkillConfig.ContinueTime ~= nil then
|
|
UGCLogSystem.Log("[WB_UseBuffs:OnPlayerUseBuff] ContinueTime = %s", tostring(self.SkillConfig.ContinueTime))
|
|
self.TextBlock_Continue:SetText(tostring(self.SkillConfig.ContinueTime));
|
|
self.TextBlock_Continue:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
|
self.TextBlock_Cooldown:SetVisibility(ESlateVisibility.Collapsed);
|
|
|
|
self.ContinueTime = self.SkillConfig.ContinueTime;
|
|
self.ContinueTimer = UGCEventSystem.SetTimerLoop(self, function()
|
|
self.ContinueTime = self.ContinueTime - 0.5;
|
|
self.TextBlock_Continue:SetText(tostring(math.floor(self.ContinueTime)));
|
|
if self.ContinueTime <= 0.5 then
|
|
self.TextBlock_Continue:SetVisibility(ESlateVisibility.Collapsed);
|
|
self.TextBlock_Cooldown:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
|
|
|
if self.ContinueTimer ~= nil then
|
|
UGCEventSystem.StopTimer(self.ContinueTimer);
|
|
end
|
|
end
|
|
end, 0.5)
|
|
else
|
|
self.TextBlock_Continue:SetVisibility(ESlateVisibility.Collapsed);
|
|
self.TextBlock_Cooldown:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
|
end
|
|
|
|
-- 在之后进行
|
|
if self.SkillConfig.Cooldown ~= nil then
|
|
self.CooldownTime = self.SkillConfig.ContinueTime == nil and self.SkillConfig.Cooldown or self.SkillConfig.ContinueTime + self.SkillConfig.Cooldown;
|
|
self.ConstCooldownTime = self.CooldownTime;
|
|
self.CoolDownTimer = UGCEventSystem.SetTimerLoop(self, function()
|
|
self.CooldownTime = self.CooldownTime - 0.5;
|
|
self.TextBlock_Cooldown:SetText(tostring(math.floor(self.CooldownTime)));
|
|
self:UpdateCoolingTime(self.ConstCooldownTime, self.CooldownTime);
|
|
|
|
if self.CooldownTime <= 0 then
|
|
self.TextBlock_Cooldown:SetVisibility(ESlateVisibility.Collapsed);
|
|
self.Overlay_Skill:SetVisibility(ESlateVisibility.Collapsed);
|
|
if self.CoolDownTimer ~= nil then
|
|
UGCEventSystem.StopTimer(self.CoolDownTimer);
|
|
self.CoolDownTimer = nil;
|
|
end
|
|
end
|
|
end, 0.5)
|
|
else
|
|
self.TextBlock_Cooldown:SetVisibility(ESlateVisibility.Collapsed);
|
|
end
|
|
end
|
|
|
|
function WB_UseBuffs:UpdateCoolingTime(InTotal, InTime)
|
|
local Material = self.Image_Cooldown:GetDynamicMaterial()
|
|
if Material ~= nil then
|
|
Material:SetScalarParameterValue("Mask_Percent", 1. - InTime / InTotal);
|
|
end
|
|
end
|
|
|
|
function WB_UseBuffs:EnableButton(IsEnable)
|
|
self.Button_Buff:SetIsEnabled(true);
|
|
self.Overlay_Skill:SetVisibility(ESlateVisibility.Collapsed);
|
|
self.TextBlock_Continue:SetVisibility(ESlateVisibility.Collapsed);
|
|
self.TextBlock_Cooldown:SetVisibility(ESlateVisibility.Collapsed);
|
|
end
|
|
|
|
function WB_UseBuffs:SetSoldierType(InTypeList)
|
|
if LocalPlayerKey == nil then return; end
|
|
|
|
local SoldierType = InTypeList[LocalPlayerKey];
|
|
if SoldierType == nil then
|
|
UGCLogSystem.Log("[WB_UseBuffs:SetSoldierType] 现在还没有兵种信息")
|
|
return;
|
|
end
|
|
UGCLogSystem.Log("[WB_UseBuffs:SetSoldierType] 兵种信息 = %s", tostring(SoldierType));
|
|
|
|
local Skills = SoldierConfig.Skills[SoldierType];
|
|
UGCLogSystem.LogTree("[WB_UseBuffs:SetSoldierType] Skills = ", Skills);
|
|
if Skills.SkillType ~= SoldierConfig.ESkillType.Active then return end
|
|
local InType = Skills.Skills[1].BuffType;
|
|
UE.AsyncLoadObject(BuffConfig.BuffInfo[InType].Icon, function(TargetObject)
|
|
self.Image_Icon:SetBrushFromTexture(TargetObject);
|
|
end);
|
|
self.Image_Icon:SetColorAndOpacity(BuffConfig.BuffInfo[InType].Color);
|
|
self.Image_Select:SetColorAndOpacity(BuffConfig.BuffInfo[InType].Color);
|
|
self.TextBlock_Desc:SetText(BuffConfig.BuffInfo[InType].Desc)
|
|
end
|
|
|
|
return WB_UseBuffs; |