2025-09-28 01:32:54 +08:00
|
|
|
local LevelFoxRole = {}
|
2025-10-08 02:52:32 +08:00
|
|
|
local Vector2D = require("Utils.Vector2D")
|
|
|
|
|
|
|
|
|
|
function LevelFoxRole:ctor()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function LevelFoxRole:ReceiveBeginPlay()
|
|
|
|
|
self["SpineAnimationComponent"]:SetAnimation(0, "Idle/Front", true)
|
|
|
|
|
self.last_animation = "Idle/Front"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function LevelFoxRole:OnMoveDirectionChanged(InDirection)
|
|
|
|
|
-- 运动组件更新方向响应函数
|
|
|
|
|
local cur_animation
|
|
|
|
|
if Vector2D.Equals(InDirection, Vector2D.Zero) then -- Idle的情况
|
|
|
|
|
local forward_direction = self["MovementComponent"]:GetForwardDirection()
|
|
|
|
|
if(forward_direction.Y >= 0) then
|
|
|
|
|
cur_animation = "Idle/Front"
|
|
|
|
|
else
|
|
|
|
|
cur_animation = "Idle/Back"
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if(InDirection.Y >= 0) then
|
|
|
|
|
cur_animation = "Move/Front"
|
|
|
|
|
else
|
|
|
|
|
cur_animation = "Move/Back"
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-10-08 15:22:38 +08:00
|
|
|
if cur_animation ~= self.last_animation then
|
|
|
|
|
self["SpineAnimationComponent"]:SetAnimation(0, cur_animation, true)
|
|
|
|
|
self.last_animation = cur_animation
|
|
|
|
|
end
|
2025-10-13 11:57:19 +08:00
|
|
|
|
|
|
|
|
self["SpineAnimationComponent"]:SetTimeScale(1.0)
|
2025-10-08 02:52:32 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function LevelFoxRole:OnMove(location)
|
|
|
|
|
-- 控制器移动相应函数
|
|
|
|
|
self["MovementComponent"]:MoveTo(location)
|
|
|
|
|
end
|
2025-09-28 01:32:54 +08:00
|
|
|
|
2025-10-13 11:57:19 +08:00
|
|
|
function LevelFoxRole:OnUltimateSkill()
|
|
|
|
|
print("LevelFoxRole:OnUltimateSkill")
|
|
|
|
|
local sprint_distance = 600
|
|
|
|
|
local sprint_speed_rate = 3.8
|
|
|
|
|
|
|
|
|
|
-- 获取角色朝向
|
|
|
|
|
local forward_direction = self["MovementComponent"]:GetForwardDirection()
|
|
|
|
|
|
|
|
|
|
self["MovementComponent"]:SprintTo(sprint_distance, sprint_speed_rate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local anim_comp = self["SpineAnimationComponent"]
|
|
|
|
|
if forward_direction.X >= 0 then
|
|
|
|
|
anim_comp:SetAnimation(0, "Ultimate/Right/UltimateStage1", false)
|
|
|
|
|
else
|
|
|
|
|
anim_comp:SetAnimation(0, "Ultimate/Left/UltimateStage1", false)
|
|
|
|
|
end
|
|
|
|
|
local anim_entry = anim_comp:GetCurrent(0)
|
|
|
|
|
|
|
|
|
|
local anim_total_time = anim_entry:GetAnimationEnd()
|
|
|
|
|
local sprint_time = sprint_distance / (self:GetSpeed() * sprint_speed_rate)
|
|
|
|
|
|
|
|
|
|
anim_comp:SetTimeScale(anim_total_time / sprint_time)
|
|
|
|
|
|
|
|
|
|
print("hahhh", anim_total_time, sprint_time)
|
|
|
|
|
end
|
|
|
|
|
|
2025-09-28 01:32:54 +08:00
|
|
|
|
|
|
|
|
return Class(nil, nil, LevelFoxRole)
|