-- 获取主角色
local mainActor = SL:GetMetaValue("MAIN_ACTOR_ID")
-- 定义舞蹈动作序列
local danceSequence = {
{action = global.MMO.ACTION_WALK, direction = 4, duration = 8,name = "预备"}, -- 站立 1 秒,方向 0
{action = global.MMO.ACTION_HXJ, direction = 5, duration = 4,name = "伸展运动"}, -- 走 2 秒,方向 1(右)
{action = global.MMO.ACTION_HXJ, direction = 3, duration = 4,name = "伸展运动"}, -- 施法 1 秒,方向 2(右)
{action = global.MMO.ACTION_BTXD, direction = 6, duration = 4,name = "四肢运动"}, -- 伸展运动
{action = global.MMO.ACTION_BTXD, direction = 2, duration = 4,name = "四肢运动"},
{action = global.MMO.ACTION_ASSASSIN_SY, direction = 6, duration = 1,name = "肩部运动"}, -- 四肢运动
{action = global.MMO.ACTION_ASSASSIN_SY, direction = 2, duration = 1,name = "肩部运动"},
{action = global.MMO.ACTION_ASSASSIN_SY, direction = 6, duration = 1,name = "肩部运动"}, -- 四肢运动
{action = global.MMO.ACTION_ASSASSIN_SY, direction = 2, duration = 1,name = "肩部运动"},
{action = global.MMO.ACTION_ASSASSIN_SY, direction = 6, duration = 1,name = "肩部运动"}, -- 四肢运动
{action = global.MMO.ACTION_ASSASSIN_SY, direction = 2, duration = 1,name = "肩部运动"},
{action = global.MMO.ACTION_ASSASSIN_SY, direction = 6, duration = 1,name = "肩部运动"}, -- 四肢运动
{action = global.MMO.ACTION_ASSASSIN_SY, direction = 2, duration = 1,name = "肩部运动"},
{action = global.MMO.ACTION_JY2, direction = 5, duration = 4,name = "扩胸运动"}, -- 肩部运动
{action = global.MMO.ACTION_JY2, direction = 3, duration = 4,name = "扩胸运动"},
{action = global.MMO.ACTION_ASSASSIN_XFT, direction = 6, duration = 4,name = "踢腿运动"}, -- 扩胸运动
{action = global.MMO.ACTION_ASSASSIN_XFT, direction = 2, duration = 4,name = "踢腿运动"},
{action = global.MMO.ACTION_FWJ, direction = 6, duration = 4,name = "体转运动"}, -- 扩XX运动
{action = global.MMO.ACTION_FWJ, direction = 2, duration = 4,name = "体转运动"},
{action = global.MMO.ACTION_ZXC, direction = 4, duration = 1,name = "全身运动"}, -- 扩XX运动
{action = global.MMO.ACTION_ZXC, direction = 5, duration = 1,name = "全身运动"},
{action = global.MMO.ACTION_ZXC, direction = 6, duration = 1,name = "全身运动"}, -- 扩XX运动
{action = global.MMO.ACTION_ZXC, direction = 7, duration = 1,name = "全身运动"},
{action = global.MMO.ACTION_ZXC, direction = 0, duration = 1,name = "全身运动"}, -- 扩XX运动
{action = global.MMO.ACTION_ZXC, direction = 1, duration = 1,name = "全身运动"},
{action = global.MMO.ACTION_ZXC, direction = 2, duration = 1,name = "全身运动"}, -- 扩XX运动
{action = global.MMO.ACTION_ZXC, direction = 3, duration = 1,name = "全身运动"},
{action = global.MMO.ACTION_ASSASSIN_SMITE, direction = 6, duration = 4,name = "跑跳运动"}, -- 扩XX运动
{action = global.MMO.ACTION_ASSASSIN_SMITE, direction = 2, duration = 4,name = "跑跳运动"},
{action = global.MMO.ACTION_JLB, direction = 5, duration = 4,name = "准备"}, -- 扩XX运动
{action = global.MMO.ACTION_JLB, direction = 3, duration = 4,name = "准备"},
{action = global.MMO.ACTION_WALK, direction = 5, duration = 4,name = "准备"}, -- 扩XX运动
{action = global.MMO.ACTION_WALK, direction = 3, duration = 4,name = "准备"},
}
-- 获取当前视野中的玩家
local play = SL:FindPlayerInCurrViewField(false)
for k, v in pairs(play) do
me = v:GetAvatarNode()
-- 当前动作索引
local currentActionIndex = 1
local currentActionTime = 0 -- 当前动作已执行时间
-- 更新舞蹈动作的函数
function updateDance(dt)
if currentActionIndex > #danceSequence then
SL:print("自由活动 yeah")
SL:UnSchedule(dingshiqi)
SL:print("DebugInfo: 0 textures, for 0 KB (0.00 MB)")
-- 移除父节点的所有子节点
if parent then
SL:print("存在!")
GUI:removeAllChildren(parent)
end
radius = 100
-- 创建父窗口
local parent = GUI:Win_Create("Win_1", 500, 500, 1136, 640)
-- 定义 8 个方向的向量
local directions = {
cc.p(0, 1), -- 上
cc.p(1, 1), -- 右上
cc.p(1, 0), -- 右
cc.p(1, -1), -- 右下
cc.p(0, -1), -- 下
cc.p(-1, -1), -- 左下
cc.p(-1, 0), -- 左
cc.p(-1, 1) -- 左上
}
-- 公转中心点
local centerX, centerY = 0, 0 -- 父窗口中心点
local radius = 150 -- 公转半径
local angleSpeed = 1 -- 公转角速度(度/帧)
-- 创建火球术特效列表
local fireballs = {}
for i, dir in ipairs(directions) do
local fireball = GUI:Effect_Create(parent, "sfx"..i, 0, 0, 4, 47+i, 1, 3, 8-i, 1)
if not fireball then
return
end
a1 = math.random(255)
-- yanse = cc.c3b( a1, a1, a1)
-- fireball:setColor(yanse)
-- fireball:setOpacity(255)
-- 初始化公转角度
fireball.angle = (i - 1) * 45 -- 每个特效初始角度相差 45 度
table.insert(fireballs, fireball)
end
-- 更新位置
local function updateFireballPosition(dt)
for i, fireball in ipairs(fireballs) do
if not fireball or tolua.isnull(fireball) then -- 检查对象是否已被销毁
if schedulerEntry then
cc.Director:getInstance():getScheduler():unscheduleScriptEntry(schedulerEntry)
schedulerEntry = nil
end
return
end
-- 更新公转角度
fireball.angle = fireball.angle + angleSpeed
if fireball.angle >= 720 then
fireball.angle = fireball.angle - 720 -- 角度超过 360 度时重置
end
GUI:runAction(fireball, GUI:ActionSequence(GUI:ActionScaleTo(1, 1.3), GUI:ActionScaleTo(1, 1), GUI:CallFunc(callback)))
-- 计算公转轨迹上的位置
local radians = math.rad(fireball.angle) -- 将角度转换为弧度
local newX = centerX + radius * math.cos(radians)
local newY = centerY + radius * math.sin(radians)
-- 设置特效的新位置
fireball:setPosition(newX, newY)
end
end
-- 每帧更新
if not schedulerEntry then
schedulerEntry = cc.Director:getInstance():getScheduler():scheduleScriptFunc(updateFireballPosition, 0, false)
end
return
end
local currentAction = danceSequence[currentActionIndex]
v:SetDirection(currentAction.direction) -- 设置当前方向
v:SetAction(currentAction.action) -- 设置当前动作
-- 打印调试信息
SL:print("当前动作: " .. tostring(currentAction.name) .. ", 方向: " .. tostring(currentAction.direction) .. ", 已执行时间: " .. tostring(currentActionTime))
-- 更新已执行时间
currentActionTime = currentActionTime + dt
-- 检查是否切换到下一个动作
if currentActionTime >= currentAction.duration then
currentActionIndex = currentActionIndex + 1 -- 切换到下一个动作
currentActionTime = 0 -- 重置已执行时间
end
end
-- local schedulerEntry = cc.Director:getInstance():getScheduler():scheduleScriptFunc(updateDance, 1, false)
end
dingshiqi = SL:Schedule(updateDance, 1)