This commit is contained in:
Akbar Yahya
2022-11-21 16:30:31 +08:00
commit e0d4d8040c
3326 changed files with 683000 additions and 0 deletions

View File

@@ -0,0 +1,213 @@
require('Actor/ActorCommon')
local subGlobalActorProxy = require('Actor/SubGlobal/SubGlobalActorProxy')
local LimitRegionGlobalActor = class("LimitRegionGlobalActor", subGlobalActorProxy)
LimitRegionGlobalActor.defaultAlias = "LimitRegionGlobal"
LimitRegionGlobalActor.TeachingDialogList =
{
{dialogID = 3500101, audioEvtName = "", duration = 3},
}
LimitRegionGlobalActor.TeachingDuration = 0
LimitRegionGlobalActor.TeachingDurationCnt = 0
LimitRegionGlobalActor.Teaching = false
LimitRegionGlobalActor.WarningDialogList =
{
--[[ {dialogID = 3520501, audioEvtName = "", duration = 3},
{dialogID = 3520601, audioEvtName = "", duration = 3},
{dialogID = 3520701, audioEvtName = "", duration = 3}, ]]
}
LimitRegionGlobalActor.WarningDialogIndex = 1
LimitRegionGlobalActor.WarningDuration = 0
LimitRegionGlobalActor.WarningDurationCnt = 0
LimitRegionGlobalActor.testLength = 25
LimitRegionGlobalActor.transOffset = 7
LimitRegionGlobalActor.checkTask = nil
LimitRegionGlobalActor.pauseTask = false
LimitRegionGlobalActor.Warnning = false
--@region Method
function LimitRegionGlobalActor:PerformWarningNarrator()
if self.WarningDialogList == nil then
return -1.0
end
local dialogNum = #(self.WarningDialogList)
if self.WarningDialogIndex > dialogNum then
return -1.0
end
local currDialog = self.WarningDialogList[self.WarningDialogIndex]
if currDialog == nil then
self.WarningDialogIndex = 1
currDialog = self.WarningDialogList[self.WarningDialogIndex]
if currDialog == nil then
return -1.0
end
end
self.WarningDuration = currDialog.duration
self.WarningDurationCnt = 0
local dialogID = currDialog.dialogID
self:SayWarningNarrator(dialogID)
return self.WarningDuration
end
function LimitRegionGlobalActor:StopPerformAllNarrator()
self:StopWarningNarrator()
end
function LimitRegionGlobalActor:PerformTeachingNarrator()
local currDialog = self.TeachingDialogList[1]
if currDialog == nil then
return false
end
local dialogID = currDialog.dialogID
self.TeachingDuration = currDialog.duration
self.TeachingDurationCnt = 0
local audioEvtName = currDialog.audioEvtName
self:SayWarningNarrator(dialogID)
return true
end
--@endregion
function LimitRegionGlobalActor:CheckLimit(task, deltaTime)
if self.Teaching then
self.TeachingDurationCnt = self.TeachingDurationCnt + deltaTime
if self.TeachingDurationCnt >= self.TeachingDuration then
self:StopWarningNarrator()
self.uActor:AvatarPaimonDisappear()
self.Teaching = false
end
end
self.WarningDurationCnt = self.WarningDurationCnt + deltaTime
local avatarPos = self.uActor:GetAvatarPos()
local radius = self:GetLimitRegionDis(avatarPos, self.testLength)
local curAlpha = 1
if radius < self.testLength then
curAlpha = radius / self.testLength
if self.WarningDurationCnt >= self.WarningDuration then
self.WarningDialogIndex = self.WarningDialogIndex + 1
if self:PerformWarningNarrator() ~= true then
self.WarningDialogIndex = 0
end
self.Warnning = true
end
else
if self.Warnning == true then
self:StopWarningNarrator()
self.Warnning = false
end
end
self.uActor:BlackScreen(curAlpha)
if radius ~= 0 then
return
end
local avatarPos = self.uActor:GetAvatarPos()
-- 人经常会莫名的拉到0,0,0点会播放语音并进行控制只能加个保护
local len = avatarPos.x * avatarPos.x + avatarPos.y * avatarPos.y + avatarPos.z * avatarPos.z;
if len == 0 then
return
end
local newPos = self:CheckNeedTrans(avatarPos, self.transOffset)
local disX = newPos.x - avatarPos.x
local disZ = newPos.z - avatarPos.z
local disSquare = disX * disX + disZ * disZ;
if disSquare < 10 then
return
end
if self.pauseTask then
return
end
self.pauseTask = true
self.uActor:AvatarPaimonAppear(function ()
self.pauseTask = false
-- self.uActor:AvatarPaimonPlayer("Domangic")
end)
self:PerformTeachingNarrator();
self.uActor:AvatarGotoPoint(newPos, function ()
end)
end
function LimitRegionGlobalActor:PerformTeachingNarrator()
local currDialog = self.TeachingDialogList[1]
if currDialog == nil then
return false
end
local dialogID = currDialog.dialogID
self.TeachingDuration = currDialog.duration
self.TeachingDurationCnt = 0
local audioEvtName = currDialog.audioEvtName
self:SayWarningNarrator(dialogID)
if audioEvtName ~= nil and audioEvtName ~= "" then
self.uActor:PlayAudio(audioEvtName)
end
self.Teaching = true
end
function LimitRegionGlobalActor:Register()
print("CreateLimitRegion")
self:CreateLimitRegion("CB1OpenArea")
if self.checkTask == nil then
self.checkTask = self:CreateTask(self.MOVE_TASK_ID, LuaTaskType.LIMIT_REGION, "Lock")
self.checkTask:InitWithData(self, self)
--self.checkTask:TickEvent('+', self.CheckLimit)
end
end
function LimitRegionGlobalActor:UseFreshmeatRegion()
print("FreshmeatRegion")
self:DestroyLimitRegion("CB1OpenArea")
self:CreateLimitRegion("FreshmeatRegion")
end
function LimitRegionGlobalActor:OnFinishedRegion()
print("DestroyLimitRegion")
globalActor:EnablePlayerInput(true)
globalActor:BackPage()
self:DestroyLimitRegion("FreshmeatRegion")
self:CreateLimitRegion("CB1OpenArea")
-- actorMgr:DestroyActor("LimitRegionGlobal")
end
function LimitRegionGlobalActor:FinishLimitRegion()
self.uActor:BlackScreen(1)
globalActor:ShowPage("InLevelMapPageContext")
globalActor:InvokePageFunction("ShowDisableLimitRegion")
globalActor:EnablePlayerInput(false)
self:CallDelay(3, self.OnFinishedRegion)
end
function LimitRegionGlobalActor:Unregister()
if self.checkTask ~= nill then
self.checkTask:FinishTask()
self.checkTask = nil
end
end
function LimitRegionGlobalActor:Start()
end
return LimitRegionGlobalActor

View File

@@ -0,0 +1,125 @@
----------------------
-- 这是Lua端SubGlobalActorProxy的基类包含了注册全局回调的方法。继承自BaseActorProxy
-- @classmod SubGlobalActorProxy
require('Actor/ActorCommon')
local baseActorProxy = require('Actor/BaseActorProxy')
local SubGlobalActorProxy = class("SubGlobalActorProxy", baseActorProxy)
SubGlobalActorProxy.actorType = ActorType.SUB_GLOBAL_ACTOR
--- SubGlobalActorProxy alias
SubGlobalActorProxy.defaultAlias = "SubGlobal"
local super = nil
function SubGlobalActorProxy:OnPreInit()
super = self.__super
super:OnPreInit()
end
function SubGlobalActorProxy:OnInit(alias)
super:OnInit(alias)
self.uActor = self:CreateUActor(alias)
end
function SubGlobalActorProxy:OnPostInit()
self:Register()
end
function SubGlobalActorProxy:OnDestroy()
self:Unregister()
end
--- SubGlobalActorProxy
function SubGlobalActorProxy:CreateLimitRegion(name)
return self.uActor:CreateLimitRegion(name)
end
--- SubGlobalActorProxy
function SubGlobalActorProxy:DestroyLimitRegion(name)
self.uActor:DestroyLimitRegion(name)
end
--- SubGlobalActorProxy检查是否有超出区域
function SubGlobalActorProxy:CheckNeedTrans(pos, offset)
return self.uActor:CheckNeedTrans(pos, offset)
end
--- SubGlobalActorProxy检查是否有超出区域
function SubGlobalActorProxy:GetLimitRegionDis(pos, offset)
return self.uActor:GetLimitRegionDis(pos, offset)
end
function SubGlobalActorProxy:CreateUActor(alias)
local uActor = actorUtils.CreateActor(self, ActorType.SUB_GLOBAL_ACTOR, alias, self.metaPath)
uActor = actorUtils.CreateGlobalActor(uActor)
return uActor
end
function SubGlobalActorProxy:Register()
end
function SubGlobalActorProxy:Unregister()
end
--- SubGlobalActor昼夜相关方法
-- @section daynight
--- SubGlobalActor注册到白天了的回调
-- @tparam function dayCallback 到白天了的调用方法
function SubGlobalActorProxy:RegisterDayCallback(dayCallback)
self.uActor:RegisterDayCallback(dayCallback)
end
--- SubGlobalActor取消注册到白天了的回调
-- @tparam function dayCallback 到白天了的调用方法
function SubGlobalActorProxy:UnregisterDayCallback(dayCallback)
self.uActor:UnregisterDayCallback(dayCallback)
end
--- SubGlobalActor注册到晚上了的回调
-- @tparam function nightCallback 到晚上了的调用方法
function SubGlobalActorProxy:RegisterNightCallback(nightCallback)
self.uActor:RegisterNightCallback(nightCallback)
end
--- SubGlobalActor取消注册到晚上了的回调
-- @tparam function nightCallback 到晚上了的调用方法
function SubGlobalActorProxy:UnregisterNightCallback(nightCallback)
self.uActor:UnregisterNightCallback(nightCallback)
end
--- SubGlobalActor注册小时的回调
-- @tparam function hourCallback 小时回调
function SubGlobalActorProxy:RegisterHourCallback(hourCallback)
self.uActor:RegisterHourCallback(hourCallback)
end
--- SubGlobalActor取消注册小时的回调
-- @tparam function nightCallback 小时回调
function SubGlobalActorProxy:UnregisterHourCallback(hourCallback)
self.uActor:UnregisterHourCallback(hourCallback)
end
--- SubGlobalActor天气相关方法
-- @section weather
--- SubGlobalActor注册天气变化的回调
-- @tparam function weatherCallback 天气变化的回调回调需接受一个WeathType类型的参数
function SubGlobalActorProxy:RegisterWeatherCallback(weatherCallback)
self.uActor:RegisterWeatherCallback(weatherCallback)
end
--- SubGlobalActor取消注册天气变化的回调
-- @tparam function weatherCallback 天气变化的回调回调需接受一个WeathType类型的参数
function SubGlobalActorProxy:UnregisterWeatherCallback(weatherCallback)
self.uActor:UnregisterWeatherCallback(weatherCallback)
end
--- SubGlobalActor改变天气
-- @tparam string weatherName 天气配置的名字
function SubGlobalActorProxy:ChangeWeather(weatherName)
self.uActor:ChangeWeather(weatherName)
end
--- SubGlobalActor恢复天气到服务器当前
function SubGlobalActorProxy:LeaveWeather()
self.uActor:LeaveWeather()
end
return SubGlobalActorProxy

View File

@@ -0,0 +1,76 @@
require('Actor/ActorCommon')
local subGlobalActorProxy = require('Actor/SubGlobal/SubGlobalActorProxy')
local WindTestGlobalActor = class("WindTestGlobalActor", subGlobalActorProxy)
WindTestGlobalActor.defaultAlias = "WindTestGlobal"
WindTestGlobalActor.SpeedFieldDir = { x = 2.71, y = -9, z = -26.08 }
WindTestGlobalActor.SpeedFieldPos =
{
{x=1600.12, y=330, z=-6262.65},
{x=1602.83, y=324, z=-6288.73},
{x=1605.54, y=318, z=-6314.81},
{x=1608.24, y=312, z=-6340.89},
{x=1610.95, y=306, z=-6366.97},
{x=1613.66, y=300, z=-6393.05},
{x=1616.37, y=294, z=-6419.13},
{x=1619.08, y=288, z=-6445.21},
{x=1621.79, y=282, z=-6471.29},
{x=1624.49, y=276, z=-6497.36},
{x=1627.2, y=270, z=-6523.44},
{x=1629.91, y=264, z=-6549.52},
-- {x=1632.62, y=258, z=-6575.6},
-- {x=1635.33, y=252, z=-6601.68},
-- {x=1638.04, y=246, z=-6627.76},
-- {x=1640.74, y=240, z=-6653.84},
-- {x=1643.45, y=234, z=-6679.92},
-- {x=1646.16, y=228, z=-6706},
}
WindTestGlobalActor.StartSpeedField = function()
-- print("StartSpeedField")
-- for i=1, #WindTestGlobalActor.SpeedFieldPos do
-- globalActor:SpawnGadget(70690002, WindTestGlobalActor.SpeedFieldPos[i], M.Dir2Euler(WindTestGlobalActor.SpeedFieldDir), "MuskSpeedField" .. tostring(i))
-- end
end
WindTestGlobalActor.EndSpeedField = function()
-- print("EndSpeedField")
-- for i=1, #WindTestGlobalActor.SpeedFieldPos do
-- globalActor:UnSpawn("MuskSpeedField" .. tostring(i))
-- end
end
WindTestGlobalActor.DoTestHour = function(hour)
-- print("Do Test test" .. tostring(hour))
-- if hour == 6 then
-- print("StartSpeedField")
-- for i=1, #WindTestGlobalActor.SpeedFieldPos do
-- globalActor:SpawnGadget(70690002, WindTestGlobalActor.SpeedFieldPos[i], M.Dir2Euler(WindTestGlobalActor.SpeedFieldDir), "MuskSpeedField" .. tostring(i))
-- end
-- elseif hour == 9 then
-- print("EndSpeedField")
-- for i=1, #WindTestGlobalActor.SpeedFieldPos do
-- globalActor:UnSpawn("MuskSpeedField" .. tostring(i))
-- end
-- end
end
function WindTestGlobalActor:Register()
-- self:RegisterDayCallback(self.StartSpeedField)
-- self:RegisterNightCallback(self.EndSpeedField)
self:RegisterHourCallback(self.DoTestHour)
end
function WindTestGlobalActor:Unregister()
-- self:UnregisterDayCallback(self.StartSpeedField)
-- self:UnregisterNightCallback(self.EndSpeedField)
self:UnregisterHourCallback(self.DoTestHour)
end
function WindTestGlobalActor:Start()
end
return WindTestGlobalActor