165 lines
4.8 KiB
Lua
165 lines
4.8 KiB
Lua
---@class BP_DigitalTrap_C:AActor
|
|
---@field Floor2 UStaticMeshComponent
|
|
---@field Floor1 UStaticMeshComponent
|
|
---@field Floor2Center USceneComponent
|
|
---@field Floor1Center USceneComponent
|
|
---@field BoxOverlap UBoxComponent
|
|
---@field FloorMesh UStaticMeshComponent
|
|
---@field Floor USceneComponent
|
|
---@field WidgetNum UWidgetComponent
|
|
---@field RotatorComponent USceneComponent
|
|
---@field DefaultSceneRoot USceneComponent
|
|
---@field TrapID int32
|
|
---@field TargetRot1 FRotator
|
|
---@field TargetRot2 FRotator
|
|
---@field EnableTrapCurve UCurveFloat
|
|
---@field ResetTrapCurve UCurveFloat
|
|
---@field AnimPlayTime float
|
|
---@field StartRot1 FRotator
|
|
---@field StartRot2 FRotator
|
|
--Edit Below--
|
|
local BP_DigitalTrap = {
|
|
TargetDigital = -1;
|
|
bEnable = false;
|
|
StartTrapAnimTime = -100;
|
|
IsEnableTrapAnim = true;
|
|
LastDigital = 9;
|
|
};
|
|
|
|
|
|
function BP_DigitalTrap:ReceiveBeginPlay()
|
|
self.SuperClass.ReceiveBeginPlay(self);
|
|
if UGCGameSystem.IsServer() then
|
|
UGCSystemLibrary.BindBeginOverlapFunc(self.BoxOverlap, self.PlayerOverlap, self)
|
|
end
|
|
end
|
|
|
|
--function BP_DigitalTrap:SetEnable(InbEnable)
|
|
-- self.bEnable = InbEnable
|
|
--end
|
|
|
|
function BP_DigitalTrap:SetTrapID(InTrapID)
|
|
self.TrapID = InTrapID
|
|
end
|
|
|
|
function BP_DigitalTrap:GetTrapID()
|
|
return self.TrapID
|
|
end
|
|
|
|
function BP_DigitalTrap:BindNumberZeroingNotify(BindFunc, BindObj)
|
|
self.NumberZeroingNotifyFunc = BindFunc
|
|
self.NumberZeroingNotifyObj = BindObj
|
|
end
|
|
|
|
function BP_DigitalTrap:BindPlayerOverlap(BindFunc, BindObj)
|
|
self.PlayerOverlapNotifyFunc = BindFunc
|
|
self.PlayerOverlapNotifyObj = BindObj
|
|
end
|
|
|
|
function BP_DigitalTrap:SetTargetDigital(Digital)
|
|
self.TargetDigital = Digital
|
|
end
|
|
|
|
function BP_DigitalTrap:GetTargetDigital()
|
|
return self.TargetDigital
|
|
end
|
|
|
|
function BP_DigitalTrap:MinusOne()
|
|
if self.TargetDigital > 0 then
|
|
self:SetTargetDigital( self.TargetDigital - 1)
|
|
end
|
|
end
|
|
|
|
function BP_DigitalTrap:PlayerOverlap()
|
|
if self.PlayerOverlapNotifyFunc then
|
|
self.PlayerOverlapNotifyFunc(self.PlayerOverlapNotifyObj, self)
|
|
else
|
|
self.PlayerOverlapNotifyFunc(self)
|
|
end
|
|
end
|
|
|
|
function BP_DigitalTrap:SetTrapCollision(bHasCollision)
|
|
self.FloorMesh:SetCollisionEnabled(bHasCollision and ECollisionEnabled.QueryAndPhysics or ECollisionEnabled.NoCollision)
|
|
if not UGCGameSystem.IsServer() then
|
|
if bHasCollision == false then
|
|
self:ChangeTrapTypeEffect(bHasCollision)
|
|
end
|
|
end
|
|
end
|
|
|
|
--- 客户端在改变碰撞时触发的动画或者特效
|
|
function BP_DigitalTrap:ChangeTrapTypeEffect(bHasCollision)
|
|
self.StartTrapAnimTime = UGCSystemLibrary.GetGameTime()
|
|
self.AnimPlaying = true
|
|
self.IsEnableTrapAnim = not bHasCollision
|
|
end
|
|
|
|
--- 客户端更新数字
|
|
function BP_DigitalTrap:ClientSetDigital(Digital)
|
|
self.WidgetNum:GetUserWidgetObject():SetNum(Digital)
|
|
self.WidgetNum:RequestRedraw()
|
|
if Digital > 0 and self.LastDigital == 0 then
|
|
self:ChangeTrapTypeEffect(true)
|
|
end
|
|
self.LastDigital = Digital
|
|
end
|
|
|
|
|
|
function BP_DigitalTrap:ReceiveTick(DeltaTime)
|
|
self.SuperClass.ReceiveTick(self, DeltaTime);
|
|
if not UGCGameSystem.IsServer() then
|
|
self:NumLookToCamera()
|
|
self:PlayTrapAnim(DeltaTime)
|
|
end
|
|
end
|
|
|
|
function BP_DigitalTrap:NumLookToCamera()
|
|
local CameraManager = UGCSystemLibrary.GetLocalPlayerController().PlayerCameraManager
|
|
local TargetRot = KismetMathLibrary.MakeRotFromX(CameraManager:GetActorForwardVector())
|
|
TargetRot.Roll = 0.
|
|
TargetRot.Pitch = 0.
|
|
TargetRot.Yaw = TargetRot.Yaw + 180
|
|
self.RotatorComponent:K2_SetWorldRotation(TargetRot)
|
|
end
|
|
|
|
function BP_DigitalTrap:PlayTrapAnim(DeltaTime)
|
|
|
|
if self.AnimPlaying then
|
|
local NowTime = UGCSystemLibrary.GetGameTime()
|
|
local AnimTimeValue = NowTime - self.StartTrapAnimTime
|
|
if AnimTimeValue >= self.AnimPlayTime then
|
|
self.AnimPlaying = false
|
|
end
|
|
|
|
if self.IsEnableTrapAnim then
|
|
local CurveValue = self.EnableTrapCurve:GetFloatValue(AnimTimeValue / self.AnimPlayTime)
|
|
self.Floor1Center:K2_SetRelativeRotation(KismetMathLibrary.RLerp(self.StartRot1, self.TargetRot1, CurveValue))
|
|
self.Floor2Center:K2_SetRelativeRotation(KismetMathLibrary.RLerp(self.StartRot2, self.TargetRot2, CurveValue))
|
|
else
|
|
local CurveValue = self.ResetTrapCurve:GetFloatValue(AnimTimeValue / self.AnimPlayTime)
|
|
self.Floor1Center:K2_SetRelativeRotation(KismetMathLibrary.RLerp(self.TargetRot1, self.StartRot1, CurveValue))
|
|
self.Floor2Center:K2_SetRelativeRotation(KismetMathLibrary.RLerp(self.TargetRot2, self.StartRot2, CurveValue))
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
--[[
|
|
function BP_DigitalTrap:ReceiveEndPlay()
|
|
self.SuperClass.ReceiveEndPlay(self);
|
|
end
|
|
--]]
|
|
|
|
--[[
|
|
function BP_DigitalTrap:GetReplicatedProperties()
|
|
return
|
|
end
|
|
--]]
|
|
|
|
--[[
|
|
function BP_DigitalTrap:GetAvailableServerRPCs()
|
|
return
|
|
end
|
|
--]]
|
|
|
|
return BP_DigitalTrap; |