82 lines
3.6 KiB
Lua
82 lines
3.6 KiB
Lua
|
---
|
|||
|
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
|||
|
--- Created by LT.
|
|||
|
--- DateTime: 2024/3/5 17:56
|
|||
|
---
|
|||
|
|
|||
|
--- 该base只能作为父类使用,无法直接用,因为函数中存在子类的变量名
|
|||
|
|
|||
|
local ShootingTargetBase = {
|
|||
|
bCanHit = true;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
---@field ReceivePointDamage:fun(Damage:float,DamageType:UDamageType,HitLocation:FVector,HitNormal:FVector,HitComponent:UPrimitiveComponent,BoneName:FName,ShotFromDirection:FVector,InstigatedBy:AController,DamageCauser:AActor,HitInfo:FHitResult)
|
|||
|
function ShootingTargetBase:ReceivePointDamage(Damage, DamageType, HitLocation, HitNormal, HitComponent, BoneName, ShotFromDirection, InstigatedBy, DamageCauser, HitInfo)
|
|||
|
if UGCGameSystem.IsServer() and self.bCanHit then
|
|||
|
local TripleScoreCenter = self.TripleScoreRange:K2_GetComponentLocation()
|
|||
|
if VectorHelper.Length(VectorHelper.Sub(HitLocation, TripleScoreCenter)) <= self.TripleScoreRangeRadius then
|
|||
|
-- 增加双倍分
|
|||
|
self:PlayerAddScore(EScoreDoubleType.TripleScore, InstigatedBy.PlayerKey)
|
|||
|
return
|
|||
|
end
|
|||
|
local DoubleScoreCenter = self.DoubleScoreRange:K2_GetComponentLocation()
|
|||
|
if VectorHelper.Length(VectorHelper.Sub(HitLocation, DoubleScoreCenter)) <= self.DoubleScoreRangeRadius then
|
|||
|
-- 增加双倍分
|
|||
|
self:PlayerAddScore(EScoreDoubleType.DoubleScore, InstigatedBy.PlayerKey)
|
|||
|
return
|
|||
|
end
|
|||
|
local BaseScoreCenter = self.BaseScoreRange:K2_GetComponentLocation()
|
|||
|
if VectorHelper.Length(VectorHelper.Sub(HitLocation, BaseScoreCenter)) <= self.BaseScoreRangeRadius then
|
|||
|
-- 增加单倍分
|
|||
|
self:PlayerAddScore(EScoreDoubleType.BaseScore, InstigatedBy.PlayerKey)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function ShootingTargetBase:PlayerAddScore(DoubleType, HitPlayer)
|
|||
|
self.bCanHit = false
|
|||
|
UGCEventSystem.SendEvent(EventEnum.ShootingTargetAddScore, HitPlayer, (DoubleType + 1) * self.BaseScore)
|
|||
|
UGCSendRPCSystem.ActorRPCNotify(nil, self, "ClientHitEffect", HitPlayer, DoubleType)
|
|||
|
UGCEventSystem.SetTimer(self, self.ResetShootingTarget, self.ResetTime)
|
|||
|
end
|
|||
|
|
|||
|
function ShootingTargetBase:ResetShootingTarget()
|
|||
|
UGCSendRPCSystem.ActorRPCNotify(nil, self, "ClientRestoreEffect")
|
|||
|
UGCEventSystem.SetTimer(self, function() self.bCanHit = true end, self.HitEffectPlayTime)
|
|||
|
end
|
|||
|
|
|||
|
function ShootingTargetBase:ClientHitEffect(HitPlayer, DoubleType)
|
|||
|
self.IsHitEffect = true
|
|||
|
self.PlayerEffectStartTime = UGCSystemLibrary.GetGameTime()
|
|||
|
self.bPlayerEffect = true
|
|||
|
if UGCSystemLibrary.GetLocalPlayerKey() == HitPlayer then
|
|||
|
self.Widget:GetUserWidgetObject():ShowHitScore(DoubleType)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function ShootingTargetBase:ClientRestoreEffect()
|
|||
|
self.IsHitEffect = false
|
|||
|
self.PlayerEffectStartTime = UGCSystemLibrary.GetGameTime()
|
|||
|
self.bPlayerEffect = true
|
|||
|
end
|
|||
|
|
|||
|
function ShootingTargetBase:TickPlayEffect()
|
|||
|
-- UGCLogSystem.Log("[ShootingTargetBase_TickPlayEffect]")
|
|||
|
if self.bPlayerEffect then
|
|||
|
local NowTime = UGCSystemLibrary.GetGameTime()
|
|||
|
if NowTime - self.PlayerEffectStartTime >= self.HitEffectPlayTime then
|
|||
|
self.bPlayerEffect = false
|
|||
|
end
|
|||
|
local Alpha = math.clamp(NowTime - self.PlayerEffectStartTime, 0., self.HitEffectPlayTime) / self.HitEffectPlayTime
|
|||
|
local TargetTF
|
|||
|
if self.IsHitEffect then
|
|||
|
TargetTF = KismetMathLibrary.TLerp(self.StartTF, self.FinishTF, Alpha)
|
|||
|
else
|
|||
|
TargetTF = KismetMathLibrary.TLerp(self.FinishTF, self.StartTF, Alpha)
|
|||
|
end
|
|||
|
self.TargetMesh:K2_SetRelativeTransform(TargetTF)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
return ShootingTargetBase
|