温泉篝火mod
来源:互联网 发布:淘宝app怎么开店 编辑:程序博客网 时间:2024/04/27 05:53
UnionActivityFireMod = Lplus.Extend(require("MUModle"),"UnionActivityFireMod")
local ConfirmView = require("ConfirmView")
local ConfArea = require ("ConfArea")
local def = UnionActivityFireMod.define
local m_Instance = nil
local timer = nil
local updateTimerRate = 1
local ActivityState = { Ready = 1,--准备阶段
Hangup = 2,--挂机阶段
Throwing = 3,--投掷阶段
Idle = 4,--空闲待机阶段
}
def.field("number").mUpdateTime =0
def.field("number").mCurrentStageLeftTime =999
def.field("number").mCurrentStageTotleTime =999
def.field("boolean").bIsInActiveArea =false
def.field("number").mCurrentActiveState =0
def.field("number").mCurrentActiveType =0
def.field("number").mInteractionCount =0
def.field("number").mExpPercent =0
def.field("number").mPlayerCount =0
def.field("string").mCurrentInteractionId =""
def.field("string").mLeftTimeTipText =""
--测试代码
local function GetTestProtolInfo()
local protolInfo = {}
protolInfo.type = 1
protolInfo.state = 1
protolInfo.remainTime = 30
protolInfo.playerCount = 1
protolInfo.expPercent = 100
protolInfo.done = 0
protolInfo.total = 30
protolInfo.interactNum = 0
protolInfo.usedItemSn = 0
protolInfo.randomValue = 0
return protolInfo
end
-------------------------------------------------- protocol function --------------------------------------------------
--客户端请求:查看温泉篝火活动挂机信息
def.method().OnCSUnionActivityFireInfo =function(self)
local msg = MsgMgr.CSUnionActivityFireInfo()
SendMessage(msg)
end
--服务端返回或通知: 温泉篝火活动挂机信息
def.method("table").OnSCUnionActivityFireInfo =function(self,proto)
local dataProtocol = (proto)
local leftTime = dataProtocol.remainTime
if dataProtocol.state == ActivityState.Readythen
self:SetTotleTime(30)
elseif dataProtocol.state == ActivityState.Hangupthen
self:SetTotleTime(600)
end
self:SetLeftTime(leftTime)
self:SetLeftTimeTipText(dataProtocol.state)
self:SetCurrentActiveType(dataProtocol.type)
self:SetCurrentActiveState(dataProtocol.state)
self:SetInteractionCount(dataProtocol.interactNum)
self:SetExpPercent(dataProtocol.expPercent)
self:SetPlayerCount(dataProtocol.playerCount)
local bInArea = self:GetIsInActiveArea()
if bInArea == false then
return
end
--测试代码(现在 view 不用管 活动更新与否 UI显示所有内容全由 mod 获取) 活动信息更新
--EventMgr:Brocast(UnionActiveEvents.OnActivityInfoUpdate, dataProtocol)
end
--服务器通知:温泉篝火活动开启
def.method("table").OnSCUnionActivityFireBegin =function(self,proto)
local dataProtocol = (proto) --MsgMgr.SCUpdateInstanceProgress()
--玩家等级大于 15 级 并且有帮派
if DataMgr.StageHeroData ==nil or DataMgr.StageHeroData.level ==nilthen
print("StageHeroData or StageHeroData.level is null",DataMgr.StageHeroData,DataMgr.StageHeroData.level)
return
end
if DataMgr.StageHeroData.level <15then
print(" level less 15 ")
return
end
--弹出 帮派篝火的 对话框 event
local activityType = dataProtocol.type
UnionActivityFireMod:SetCurrentActiveType(activityType)
self:OnActiveBegin()
end
--服务器通知:温泉篝火活动分阶段开始
def.method("table").OnSCUnionActivityFireStateStart =function(self,proto)
local dataProtocol = (proto)
self:SetCurrentActiveType(dataProtocol.type)
self:SetCurrentActiveState(dataProtocol.state)
local bInArea = self:GetIsInActiveArea()
if bInArea == false then
return
end
if dataProtocol.state == ActivityState.Readythen
UIMgr:ShowView(UINames.UI_WenQuan)
end
--如果是 投掷活动开始 小界面关闭
if dataProtocol.state == ActivityState.Throwingthen
UIMgr:HideView(UINames.UI_WenQuan)
UIMgr:ShowView(UINames.UI_WenQuanSaiZi)
end
if dataProtocol.state == ActivityState.Idlethen
UIMgr:HideView(UINames.UI_WenQuan)
UIMgr:HideView(UINames.UI_WenQuanSaiZi)
end
end
--客户端请求:温泉篝火活动使用加成道具
def.method("number").OnCSUnionActivityFireUseItem =function(self,itemSn)
local msg = MsgMgr.CSUnionActivityFireUseItem()
msg.itemSn = itemSn
SendMessage(msg)
end
--服务端返回: 温泉篝火活动使用加成道具结果
def.method("table").OnSCUnionActivityFireUseItem =function(self,proto)
local dataProtocol = (proto)
if dataProtocol.result ==0then
MainTipsMgr:ShowSysMsg("使用xxx道具成功成功")
else
ShowErrorCode(dataProtocol.result)
end
end
--客户端请求:温泉篝火活动交互
def.method("string").OnCSUnionActivityFireInteract =function(self,targetId)
local msg = MsgMgr.CSUnionActivityFireInteract()
msg.targetHumanId = targetId
SendMessage(msg)
end
--服务端返回: 温泉篝火活动交互结果
def.method("table").OnSCUnionActivityFireInteract =function(self,proto)
local dataProtocol = (proto) --MsgMgr.SCUpdateInstanceProgress()
if dataProtocol.result ==0then
MainTipsMgr:ShowSysMsg("服务器推送:我 赠与了 xxx 一壶烈酒!!!!")
else
ShowErrorCode(dataProtocol.result)
end
end
--客户端请求:温泉篝火活动投掷
def.method().OnCSUnionActivityFireRandom =function(self)
local msg = MsgMgr.CSUnionActivityFireRandom()
SendMessage(msg)
--测试代码 :假设发送请求成功
EventMgr:Brocast(UnionActiveEvents.OnThrowSuccess,111)
end
-- 服务端返回: 温泉篝火活动投掷结果
def.method("table").OnSCUnionActivityFireRandom =function(self,proto)
local dataProtocol = (proto)
local resultValue = dataProtocol.value
if result == 0 then
MainTipsMgr:ShowSysMsg("xxx 在帮派摇塞子活动中 投掷出了xxx点")
--发送投掷成功事件
EventMgr:Brocast(UnionActiveEvents.OnThrowSuccess, resultValue)
else
--返回错误码
ShowErrorCode(result)
return
end
end
--服务器通知:温泉篝火活动结束
def.method("table").OnSCUnionActivityFireEnd =function(self,proto)
local dataProtocol = (proto)
EventMgr:Brocast(UnionActiveEvents.OnActivityEnd)
self:OnActivityEnd()
end
-------------------------------------------------- 功能函数 --------------------------------------------------
def.method("number","=>","string").LeftTimeSecondToStr =function(self,leftTime)
local min = math.floor(leftTime /60)
local second = math.mod(leftTime,60)
local tiemLeftStr = min..":"..second
return tiemLeftStr
end
def.method("=>","boolean").IsNeedSwicthState =function(self)
local sceneInfo = SceneMod.Instance().CurStageInfo
--测试代码 需要帮派驻地场景配置
if sceneInfo.sn ~=2001then
return true
else
return false
end
end
def.method("string").SwicthState =function(self,areaSwitchKey)
if (FuBenMgr:IsCurInFuBen())then
MainTipsMgr:ShowSysMsg(GetStr(2000101))
return
end
if (TeamMgr:IsFollow())then
MainTipsMgr:ShowSysMsg(GetStr(1030116))
return
end
local hero = ControllerMgr:GetHero()
if (hero ~= nil and hero.StageRoleData ~=nil
and hero.StageRoleData.hpCur ~=nil and hero.StageRoleData.hpCur <=0)then
return -- 死亡了不能传送
end
local msg = MsgMgr:CSStageSwitch()
msg.areaSwitchKey = areaSwitchKey
SendMessage(msg)
AutoFightMgr:StopAutoFight(EM_AutoFightType.Strong)
end
def.method("boolean").OnIsInAreaUpdate =function(self,boolValue)
local activityType = self:GetCurrentActiveType()
local activityState = self:GetCurrentActiveState()
if boolValue == true then
if activityState == ActivityState.Ready or activityState == ActivityState.Hangupthen
UIMgr:ShowView(UINames.UI_WenQuan)
end
else
UIMgr:HideView(UINames.UI_WenQuan)
UIMgr:HideView(UINames.UI_WenQuanSaiZi)
end
end
def.method("table","table","table").UpdateIsInCircleArea =function(self,area,centerPos,serverPos)
local bIsInArea = UnionActivityFireMod:GetIsInActiveArea()
--圆形区域(距离小于半径)
local distance = GetDistanceIgnoreY(centerPos, serverPos)
if distance <= 12 then
UnionActivityFireMod:SetIsInActiveArea(true)
EventMgr:Brocast(UnionActiveEvents.OnIsInAreaUpdate,true)
else
UnionActivityFireMod:SetIsInActiveArea(false)
EventMgr:Brocast(UnionActiveEvents.OnIsInAreaUpdate,false)
end
end
def.method().UpdateIsInRectangleArea =function(self,area,centerPos,serverPos)
local bIsInArea = UnionActivityFireMod:GetIsInActiveArea()
--矩形区域
local width = area.param[1] /2
local height = area.param[1] /2
if math.abs(serverPos.x - centerPos.x) <=width andmath.abs(serverPos.z - centerPos.z) <=heightthen
UnionActivityFireMod:SetIsInActiveArea(true)
if bIsInArea ~= true then
EventMgr:Brocast(UnionActiveEvents.OnIsInAreaUpdate,true)
end
else
UnionActivityFireMod:SetIsInActiveArea(false)
if bIsInArea ~= false then
EventMgr:Brocast(UnionActiveEvents.OnIsInAreaUpdate,false)
end
end
end
def.method().UpdateIsInRotateRectangleArea =function(self,area,centerPos,serverPos)
local bIsInArea = UnionActivityFireMod:GetIsInActiveArea()
--旋转过的矩形区域
local ret = Utils.SysUtil.InRectangle(serverPos, centerPos, area.param[1], area.param[2], area.param[3])
if ret == true then
UnionActivityFireMod:SetIsInActiveArea(true)
if bIsInArea ~= true then
EventMgr:Brocast(UnionActiveEvents.OnIsInAreaUpdate,true)
end
else
UnionActivityFireMod:SetIsInActiveArea(false)
if bIsInArea ~= false then
EventMgr:Brocast(UnionActiveEvents.OnIsInAreaUpdate,false)
end
end
end
def.method().OnClickThrowButton =function(self)
self:OnCSUnionActivityFireRandom()
end
def.method().OnEndInteraction =function(self)
local targetId = self:GetCurrentInteractionId()
if targetId == 0 then
--测试代码 (需要str配置)
MainTipsMgr:ShowSysMsg("请先选择交互的玩家哦!")
return
else
--测试代码
MainTipsMgr:ShowSysMsg("客户端测试: 我 赠与了 xxx 一壶烈酒!!!!")
self:OnCSUnionActivityFireInteract(targetId)
end
end
def.method().OnEnterStage =function(self)
--如果 活动还没开启 那就 return
if self.mCurrentActiveState ==0 or timer ==nilthen
return
end
--移动到帮派驻地活动区域
local hero = ControllerMgr:GetHero()
if (hero == nil) then
return
end
local position = self:GetUnionActivityAreaPos()
hero:MoveToPos(position, Functor(self.OnReachUnionFirePosition,self))
end
def.method("=>","table").GetUnionActivityAreaPos =function(self)
--测试代码 (需要 获得区域配置)
local row = ConfArea.Get(57)
if row.pos ==nil or #(row.pos) ~=3then
print(" position is error :", row.pos)
end
local position = {}
position.x = row.pos[1]
position.y = row.pos[2]
position.z = row.pos[3]
--位置在区域内随机
--TODO:
return position
end
def.method("=>","number").GetUnionActivitSceneSn =function(self)
local unionActivitSceneSn = 2001
return unionActivitSceneSn
end
def.method().InitMemAttribute =function(self)
self.mUpdateTime =0
self.mCurrentStageLeftTime =999
self.mCurrentStageTotleTime =999
self.bIsInActiveArea =false
self.mCurrentActiveState =0
self.mCurrentActiveType =0
self.mInteractionCount =0
self.mCurrentInteractionId =0
self.mExpPercent =0
self.mPlayerCount =0
end
def.method().ClearTimer =function(self)
if timer ~= nil then
timer:Stop()
timer = nil
end
end
def.method().BeginTimer =function(self)
self:ClearTimer()
timer = Timer.New(Functor(self.UpdateSecond,self), updateTimerRate, -1,false)
timer:Start()
end
-----------------------------------------------------update 每秒更新 --------------------------------------------
def.method().UpdateSecond =function(self)
--增加一次交互机会
if self.mCurrentStageLeftTime <=590 andself.mCurrentStageLeftTime >=589then
self:SetInteractionCount(1)
end
--测试代码 准备 活动 开始
if self.mUpdateTime ==0then
local protolData = {}
protolData.type = 1
protolData.state = 1
self:OnSCUnionActivityFireStateStart(protolData)
--准备时候服务器推送 准备state 活动info
local protoInfo = GetTestProtolInfo()
protoInfo.remainTime = 30
protoInfo.expPercent = 160
protoInfo.state = 1
self:OnSCUnionActivityFireInfo(protoInfo)
end
--测试代码 挂机 活动 开始
if self.mUpdateTime >=29.5 andself.mUpdateTime <=30.5then
local protolData = {}
protolData.type = 1
protolData.state = 2
self:OnSCUnionActivityFireStateStart(protolData)
--在推送 挂机 的protoinfo
local protoInfo = GetTestProtolInfo()
protoInfo.remainTime = 600
protoInfo.expPercent = 250
protoInfo.state = 2
self:OnSCUnionActivityFireInfo(protoInfo)
end
--发送 摇塞子 活动 开始
if self.mUpdateTime >=59.5 andself.mUpdateTime <=60.5then
local protolData = {}
protolData.type = 1
protolData.state = 3
self:OnSCUnionActivityFireStateStart(protolData)
--在推送 摇塞子 的protoinfo
end
self:UpdateCurrentLeftTime()
self:UpdateIsInActiveArea()
self:UpdateInteracttionUI()
end
def.method().UpdateCurrentLeftTime =function(self)
self.mUpdateTime =self.mUpdateTime +1
self.mCurrentStageLeftTime =self.mCurrentStageLeftTime -1
end
def.method().UpdateInteracttionUI =function(self)
local count = self:GetInteractionCount()
local bIsInArea = UnionActivityFireMod:GetIsInActiveArea()
if count >0 and bIsInArea ==truethen
--不完善代码 如果 用户手动点了 关闭 那是否还显示
UIMgr:ShowView(UINames.UI_UnionInteractionButton) --交换按钮
UIMgr:ShowView(UINames.UI_UnionInteractionTalk) --交互信息
else
UIMgr:HideView(UINames.UI_UnionInteractionButton) --交换按钮
UIMgr:HideView(UINames.UI_UnionInteractionTalk) --交互信息
end
end
def.method().UpdateIsInActiveArea =function(self,activityType)
local hero = ControllerMgr:GetHero()
if (hero == nil) then
return
end
local serverPos = hero:GetServerPos()
--根据活动类型 获取 配置到的 位置信息
--todo: activityType
--测试代码 (需要活动区域配置)
local area = ConfArea.Get(57)
local hero = ControllerMgr:GetHero()
if (hero == nil) then
return
end
if area.pos ==nil or #(area.pos) ~=3then
print(" position is error :", area.pos)
end
local centerPos = {}
centerPos.x = area.pos[1]
centerPos.y = area.pos[2]
centerPos.z = area.pos[3]
if area.areaType ==0then
self:UpdateIsInCircleArea(area, centerPos, serverPos)
elseif area.areaType ==1then
self:UpdateIsInRectangleArea(area, centerPos, serverPos)
elseif area.areaType ==2then
self:UpdateIsInRotateRectangleArea(area, centerPos, serverPos)
end
end
-------------------------------------------------- 活动开始 --------------------------------------------------
def.method().OnActiveBegin =function(self)
self:BeginTimer()
self:SetLeftTime(600) --设置倒计时 基础时间
self:SetTotleTime(30) --设置当期活动持续时间
local activityType = self:GetCurrentActiveType()
self:SetLeftTimeTipText(activityType)
if activityType == UnionActivityType.Spathen
--测试代码 (需要str配置)
ShowConfirmBoxEx(GetStr(2100004),"前往参加",ObjFuncDelegate(self,self.NoticeDetermineCallBack),"取消",
ObjFuncDelegate(self.NoticeCancelCallBack,self),ObjFuncDelegate(self.NoticeCloseCallBack,self))
elseif activityType == UnionActivityType.Bonfirethen
ShowConfirmBoxEx(GetStr(2100007),"前往参加",ObjFuncDelegate(self,self.NoticeDetermineCallBack),"取消",
ObjFuncDelegate(self,self.NoticeCancelCallBack),ObjFuncDelegate(self,self.NoticeCloseCallBack))
end
end
def.method().NoticeDetermineCallBack =function(self)
print("NoticeDetermineCallBack")
local myUnion = UnionMgr:GetMyUnion()
if myUnion == nil then
--浮动提示 并弹出帮派申请界面 -- 测试 代码
MainTipsMgr:ShowSysMsg(GetStr(2000500))
UIMgr:ShowView(UINames.UI_BangPai)
return
end
local hero = ControllerMgr:GetHero()
if (hero == nil) then
return
end
--测试代码(需要配置帮派驻地的场景) 切换场景
local bSwitchState = self:IsNeedSwicthState()
if bSwitchState == true then
local stateSn = self:GetUnionActivitSceneSn()
local switchKey = tostring(stateSn)
self:SwicthState(switchKey)
else
--移动到指定地点
local position = self:GetUnionActivityAreaPos()
hero:MoveToPos(position, Functor(self.OnReachUnionFirePosition,self))
end
end
def.method().OnReachUnionFirePosition =function(self)
local bInArea = self:GetIsInActiveArea()
if bInArea == false then
print("OnReachUnionFirePosition but bInArea is false")
return
end
--测试 代码
MainTipsMgr:ShowSysMsg("已到达帮派温泉活动区域")
end
def.method().NoticeCancelCallBack =function(self)
print("NoticeCancelCallBack")
end
def.method().NoticeCloseCallBack =function(self)
print("NoticeCloseCallBack")
end
-------------------------------------------------- 分阶段活动开始 --------------------------------------------------
def.method().OnActivityEnd =function(self)
MainTipsMgr:ShowSysMsg("活动结束")
UIMgr:HideView(UINames.UI_WenQuan)
UIMgr:HideView(UINames.UI_WenQuanSaiZi)
UIMgr:HideView(UINames.UI_UnionInteractionTalk)
UIMgr:HideView(UINames.UI_UnionInteractionButton)
self:ClearTimer()
InitMemAttribute()
end
def.static("=>", UnionActivityFireMod).Instance =function()
if not m_Instance then
m_Instance = UnionActivityFireMod()
m_Instance:Init()
end
return m_Instance
end
def.override().Init =function(self)
self:RegMsg()
self:RegEvent()
end
def.method().RegEvent =function(self)
self:AddEvent(UnionActiveEvents.OnActivityEnd,Functor(self.OnActivityEnd,self))
self:AddEvent(UnionActiveEvents.OnIsInAreaUpdate,Functor(self.OnIsInAreaUpdate,self, boolValue))
self:AddEvent(UnionActiveEvents.OnEndInteraction,Functor(self.OnEndInteraction,self))
self:AddEvent(EVENT_STAGE.OnEnterStage,Functor(self.OnEnterStage,self))
end
def.method().RegMsg =function(self)
self:AddMsg(MsgID.SCAuctionQueryResult,ObjFuncDelegateArg1(self,self.OnSCUnionActivityFireInfo))
self:AddMsg(MsgID.SCUnionActivityFireBegin,ObjFuncDelegateArg1(self,self.OnSCUnionActivityFireBegin))
self:AddMsg(MsgID.SCUnionActivityFireStateStart,ObjFuncDelegateArg1(self,self.OnSCUnionActivityFireStateStart))
self:AddMsg(MsgID.SCUnionActivityFireUseItem,ObjFuncDelegateArg1(self,self.OnSCUnionActivityFireUseItem))
self:AddMsg(MsgID.SCUnionActivityFireInteract,ObjFuncDelegateArg1(self,self.OnSCUnionActivityFireInteract))
self:AddMsg(MsgID.SCUnionActivityFireRandom,ObjFuncDelegateArg1(self,self.OnSCUnionActivityFireRandom))
self:AddMsg(MsgID.SCUnionActivityFireEnd,ObjFuncDelegateArg1(self,self.OnSCUnionActivityFireEnd))
end
-------------------------------------------------- Get or Set Member attribute --------------------------------------------------
def.method("=>","number").GetPlayerCount =function(self)
return self.mPlayerCount
end
def.method("number").SetPlayerCount =function(self,count)
self.mPlayerCount = count
end
def.method("=>","number").GetExpPercent =function(self)
return self.mExpPercent
end
def.method("number").SetExpPercent =function(self,exp)
self.mExpPercent = exp
end
def.method("=>","string").GetCurrentInteractionId =function(self)
return self.mCurrentInteractionId
end
def.method("string").SetCurrentInteractionId =function(self,targetId)
self.mCurrentInteractionId = targetId
end
def.method("=>","number").GetInteractionCount =function(self)
return self.mInteractionCount
end
def.method("number").SetInteractionCount =function(self,count)
self.mInteractionCount = count
end
def.method("=>","number").GetCurrentActiveType =function(self)
return self.mCurrentActiveType
end
def.method("number").SetCurrentActiveType =function(self,type)
self.mCurrentActiveType = type
end
def.method("=>","number").GetCurrentActiveState =function(self)
return self.mCurrentActiveState
end
def.method("number").SetCurrentActiveState =function(self,state)
self.mCurrentActiveState = state
end
def.method("=>","boolean").GetIsInActiveArea =function(self)
return self.bIsInActiveArea
end
def.method("boolean").SetIsInActiveArea =function(self,boolValue)
self.bIsInActiveArea = boolValue
end
def.method("=>","number").GetLeftTime =function(self)
return self.mCurrentStageLeftTime
end
def.method("number").SetLeftTime =function(self,time)
self.mCurrentStageLeftTime = time
end
def.method("=>","number").GetTotleTime =function(self)
return self.mCurrentStageTotleTime
end
def.method("number").SetTotleTime =function(self,time)
self.mCurrentStageTotleTime = time
end
def.method("=>","string").GetLeftTimeTipText =function(self)
return self.mLeftTimeTipText
end
def.method("number").SetLeftTimeTipText =function(self,activityState)
if activityState == ActivityState.Readythen
self.mLeftTimeTipText ="即将开始"
else
self.mLeftTimeTipText ="剩余时间"
end
end
return UnionActivityFireMod.Commit()
阅读全文
0 0
- 温泉篝火mod
- 温泉
- 温泉
- 泡温泉
- MOD
- mod..........
- Mod
- Mod
- mod
- 篝火晚会 题解
- VIJOS 1008 篝火晚会
- 【模拟】篝火晚会(noip2005)
- Vijos1008 篝火晚会
- Codevs 1106 篝火晚会
- NOIP2005 篝火晚会
- NOIP2005篝火晚会
- RQNOJ 篝火晚会
- NOIP2005 篝火晚会
- eclipse本地调试tomcat服务器代码,找不到server
- Mongodb数据库去重
- LeetCode:Two Sum
- 表单序列化为JSON对象 serializeObject
- Windows下安装nvm和node.js
- 温泉篝火mod
- Markdown 绘制 UML 图 -- PlantUML + Gravizo
- Struts2入门
- salt python接口使用分组
- 检测浏览器是否支持某css属性
- 利用crond进行切片清理
- Light1052 String Growth【矩阵快速幂】
- 51node1574
- oracle累计求和