挂机修改提交

dev_chengFeng
jiaoyangna 2021-04-17 21:04:09 +08:00
parent 12f1a42161
commit c94f1051da
4 changed files with 167 additions and 102 deletions

View File

@ -448,5 +448,9 @@ GameEvent = {
}, },
SDK={ SDK={
InitSuccess = "SDK.InitSuccess", InitSuccess = "SDK.InitSuccess",
},
GuaJi={
getEvent = "GuaJi.getEvent",
} }
} }

View File

@ -34,7 +34,7 @@ function this.Initialize()
this.chapterGiftData = {} this.chapterGiftData = {}
this.chapterGetRewardState = {} this.chapterGetRewardState = {}
this.isOpenWeekCard = false--今天是否打开过周卡 this.isOpenWeekCard = false--今天是否打开过周卡
this.mission = {}
-- 每次登录显示兑换红点 -- 每次登录显示兑换红点
this.SetExchangeRedStatus(true) this.SetExchangeRedStatus(true)

View File

@ -100,11 +100,11 @@ end
function this:AddListener() function this:AddListener()
--Game.GlobalEvent:AddEvent(GameEvent.Adventure.OnRefeshBoxRewardShow, this.HideEffect)
end end
function this:RemoveListener() function this:RemoveListener()
--Game.GlobalEvent:RemoveEvent(GameEvent.Adventure.OnRefeshBoxRewardShow, this.HideEffect)
end end
function this:Init() function this:Init()
@ -229,19 +229,26 @@ function this.ReleaseIconList()
this.isCanUseIconList = 0 this.isCanUseIconList = 0
end end
function this.AsideTriggerJudge(data,isSelf) function this.AsideTriggerJudge(data,isSelf,_userData)
--LogGreen("data:"..tostring(data).." pos:"..tostring(Map_UV2Pos(data.u - 1, data.v)))
local isGetIconList = false local isGetIconList = false
local iconList = this.iconList local iconList = this.iconList
-- coroutine.start(function() coroutine.start(function()
while(not isGetIconList) do
--LogGreen("没有得到访问权")
iconList = this.RequestIconList()
if iconList and LengthOfTable(iconList) > 0 then
isGetIconList = true
else
--LogGreen("等待中")
coroutine.wait(0.01)
end
end
--LogGreen("得到了访问权")
-- while(not isGetIconList) do for k,v in pairs(iconList) do
-- iconList = this.RequestIconList() --LogGreen("iconList k:"..tostring(k))
-- if iconList and LengthOfTable(iconList) > 0 then end
-- isGetIconList = true
-- else
-- coroutine.wait(0.01)
-- end
-- end
local selfPos = Map_UV2Pos(data.u, data.v) local selfPos = Map_UV2Pos(data.u, data.v)
--LogGreen("selfPos:"..tostring(selfPos)) --LogGreen("selfPos:"..tostring(selfPos))
@ -251,35 +258,41 @@ function this.AsideTriggerJudge(data,isSelf)
posList[3] = Map_UV2Pos(data.u, data.v - 1) posList[3] = Map_UV2Pos(data.u, data.v - 1)
posList[4] = Map_UV2Pos(data.u, data.v + 1) posList[4] = Map_UV2Pos(data.u, data.v + 1)
for k,pos in pairs(posList) do for k,pos in pairs(posList) do
if iconList[pos] and not this.selectIconList[pos] then --LogGreen("posList pos:"..tostring(pos))
this.AddSelectIconList(pos) if iconList[pos] and this.HasSelectIconList(pos,_userData.userId) then
return {event = iconList[pos],pos = pos} this.RemoveSelectIconList(_userData.eventPointPos)
this.AddSelectIconList(pos,_userData.userId)
--LogGreen("发送了消息")
Game.GlobalEvent:DispatchEvent(GameEvent.GuaJi.getEvent,{goData = _userData, event = iconList[pos], pos = pos})
this.ReleaseIconList()
return
elseif FightPointPassManager.talkingTime == 0 or (GetTimeStamp() - FightPointPassManager.talkingTime >= 60) then elseif FightPointPassManager.talkingTime == 0 or (GetTimeStamp() - FightPointPassManager.talkingTime >= 60) then
if isSelf and this.playerViews and LengthOfTable(this.playerViews) > 2 then if isSelf and this.playerViews and LengthOfTable(this.playerViews) > 2 then
for k,v in pairs(this.playerViews) do for k,v in pairs(this.playerViews) do
if not v.isSelf and Map_UV2Pos(v.roleCurPos.u, v.roleCurPos.v) == pos and (v.state == 0 or v.eventPointDataPos == selfPos) then if not v.isSelf and Map_UV2Pos(v.roleCurPos.u, v.roleCurPos.v) == pos and (v.state == 0) then
FightPointPassManager.talkingTime = GetTimeStamp() FightPointPassManager.talkingTime = GetTimeStamp()
return {event = v,pos = pos} Game.GlobalEvent:DispatchEvent(GameEvent.GuaJi.getEvent,{goData = _userData,event = v,pos = pos})
end this.ReleaseIconList()
end return
elseif not isSelf and this.playerViews and LengthOfTable(this.playerViews) > 2 then
for k,v in pairs(this.playerViews) do
if v.isSelf and Map_UV2Pos(v.roleCurPos.u, v.roleCurPos.v) == pos and (v.state == 0 or v.eventPointDataPos == pos) then
FightPointPassManager.talkingTime = GetTimeStamp()
return {event = v,pos = pos}
end end
end end
end end
end end
end end
--this.ReleaseIconList() this.ReleaseIconList()
--end) end)
return nil
end end
function this.AddSelectIconList(pos) function this.HasSelectIconList(pos,uid)
this.selectIconList[pos] = pos if this.selectIconList[pos] and this.selectIconList[pos] ~= uid then
return false
else
return true
end
end
function this.AddSelectIconList(pos,uid)
this.selectIconList[pos] = uid
end end
function this.RemoveSelectIconList(pos) function this.RemoveSelectIconList(pos)

View File

@ -13,6 +13,27 @@ local m_oldManTextPos = {
[4] = {pos = Vector3.New(154, 130, 0), angleOffset = 180} -- 反之 [4] = {pos = Vector3.New(154, 130, 0), angleOffset = 180} -- 反之
} }
function SingleFightPlayerView:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.GuaJi.getEvent, self.ReciveData,self)
end
function SingleFightPlayerView:ReciveData(data)
if data.goData.userId == self.userId then
self.eventPointPos = data.event
self.state = 1
self:RoleWalkEnd(data)
elseif (data.event and data.event.userId and data.event.userId == self.userId) then
self.eventPointPos = data.event
self.state = 1
self:RoleWalkEnd(data)
end
return
end
function SingleFightPlayerView:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.GuaJi.getEvent, self.ReciveData, self)
end
function SingleFightPlayerView:New(gameObject) function SingleFightPlayerView:New(gameObject)
local b = {} local b = {}
b.gameObject = gameObject b.gameObject = gameObject
@ -56,17 +77,19 @@ function SingleFightPlayerView:InitComponent()
Util.GetGameObject(self.ui,"roleOption"):SetActive(false) Util.GetGameObject(self.ui,"roleOption"):SetActive(false)
self:SetBattleState(false) self:SetBattleState(false)
--角色当前方向
self.curDir = nil self.curDir = nil
self.gameObject:SetActive(true) self.gameObject:SetActive(true)
--- 注册组件 --- 注册组件
self.callList = Stack.New() self.callList = Stack.New()
--当前选中点的位置
self.selectPointPos = 0 self.selectPointPos = 0
-- 角色停止行走时的朝向, 上 下 左 右1 2 3 4 -- 角色停止行走时的朝向, 上 下 左 右1 2 3
self.eventpoint = 0
self.state = 0
self.m_roleFaceDir = Vector2.New(-1, 0) self.m_roleFaceDir = Vector2.New(-1, 0)
--角色停止行走时的朝向
self.eventpoint = 0
--当前触发的事件点
self.eventPointPos = nil
self.name = Util.GetGameObject(self.ui, "name"):GetComponent("Text") self.name = Util.GetGameObject(self.ui, "name"):GetComponent("Text")
self.hurtNum = {} self.hurtNum = {}
@ -121,13 +144,30 @@ function SingleFightPlayerView:SetData(u,v,isSelf,data)
self.playerLiveView = nil self.playerLiveView = nil
end end
local npc = NameManager.roleSex == ROLE_SEX.BOY and npc1 or npc2 local npc,scale
local scale = NameManager.roleSex == ROLE_SEX.BOY and 1 or 0.5 if self.isSelf then
npc = NameManager.roleSex == ROLE_SEX.BOY and npc1 or npc2
scale = NameManager.roleSex == ROLE_SEX.BOY and 1 or 0.5
self.userId = PlayerManager.uid
self.playerLiveView = PlayerLiveView:New(self.roleRoot,1,nil)
else
npc = data.sex == ROLE_SEX.BOY and npc1 or npc2
scale = data.sex == ROLE_SEX.BOY and 1 or 0.5
self.userId = data.uid
self.playerLiveView = PlayerLiveView:New(self.roleRoot,2, {
skin = data.userSkin,
sex = data.sex,
ride = data.userMount,
designation = data.userTitle,
})
end
self.playerLiveView = PlayerLiveView:New(self.roleRoot,1, nil)
self.playerLiveView:OnOpen(GetPlayerRoleSingleConFig().Scale2) self.playerLiveView:OnOpen(GetPlayerRoleSingleConFig().Scale2)
self.playerLiveView.name = "npc" self.playerLiveView.name = "npc"
--角色当前的uv
self.roleCurPos = TileMapView.GetMapData():GetMapData(u, v) self.roleCurPos = TileMapView.GetMapData():GetMapData(u, v)
self.bLeaderIsIdle = true self.bLeaderIsIdle = true
self:SetWalkDir(WALK_DIR.LAUCH) self:SetWalkDir(WALK_DIR.LAUCH)
self:HideSomeTrash() self:HideSomeTrash()
@ -138,6 +178,9 @@ function SingleFightPlayerView:SetData(u,v,isSelf,data)
self.name.text = data.userName self.name.text = data.userName
self.name.gameObject:SetActive(true) self.name.gameObject:SetActive(true)
end end
--当前状态
self.state = 0
PlayUIAnim(self.gameObject) PlayUIAnim(self.gameObject)
end end
@ -169,42 +212,35 @@ end
function SingleFightPlayerView:hitCallBack(pos) function SingleFightPlayerView:hitCallBack(pos)
self:SetWalkDir(WALK_DIR.IDLE_FRONT) self:SetWalkDir(WALK_DIR.IDLE_FRONT)
self.state = 0 self.state = 0
self.eventPointDataPos = nil
self.parent.BattleEnd(pos) -- 战斗结束 self.parent.BattleEnd(pos) -- 战斗结束
if self.isSelf then if self.isSelf then
self:SetEffect(self.selectPointPos) self:SetEffect(self.selectPointPos)
self.selectPointPos = nil
end end
if self.targetTimer then if self.targetTimer then
self.targetTimer:Stop() self.targetTimer:Stop()
self.targetTimer = nil self.targetTimer = nil
end end
self:SetRoleHitTarget()
self.targetTimer = Timer.New(function () -- 延迟生成下一个小怪 self.targetTimer = Timer.New(function () -- 延迟生成下一个小怪
self.parent.LoadPointIcon(false) self.parent.LoadPointIcon(false)
self:SetRoleHitTarget()
end, 0.5) end, 0.5)
self.targetTimer:Start() self.targetTimer:Start()
end end
local funcCanPass = function(data)
return data.val <= 1
end
-- 随机一个位置给大爷走走 -- 随机一个位置给大爷走走
function SingleFightPlayerView:SetRoleHitTarget() function SingleFightPlayerView:SetRoleHitTarget()
coroutine.start(function() coroutine.start(function()
local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf) --local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf)
if eventPoint then --self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf)
self:RoleWalkEnd(eventPoint)
else
local pos local pos
while not pos do while not pos do
coroutine.wait(0.01) coroutine.wait(0.01)
pos = self:SelectTargetPos() pos = self:SelectTargetPos()
end end
LogGreen("选中的点:"..tostring(pos)) LogGreen("选中的点:"..tostring(pos).." "..tostring(self.userId))
local pathlist = self:SetRoleWalk(pos) local pathlist = self:SetRoleWalk(pos)
self:RoleMove(pathlist) self:RoleMove(pathlist)
end
end) end)
end end
@ -215,7 +251,7 @@ function SingleFightPlayerView:SelectTargetPos()
local selectIconList = {} local selectIconList = {}
local minDis = 999 local minDis = 999
for i, v in pairs(iconList) do for i, v in pairs(iconList) do
if not self.parent.selectIconList[i] then if self.parent.HasSelectIconList(i,self.userId) then
local targetU, targetV = Map_Pos2UV(i) local targetU, targetV = Map_Pos2UV(i)
-- 计算相对距离 -- 计算相对距离
local dis = math.abs(self.roleCurPos.u - targetU) + math.abs(self.roleCurPos.v - targetV) local dis = math.abs(self.roleCurPos.u - targetU) + math.abs(self.roleCurPos.v - targetV)
@ -241,11 +277,14 @@ function SingleFightPlayerView:SelectTargetPos()
-- 万一图标还没生出来 -- 万一图标还没生出来
local targetPos = 0 local targetPos = 0
LogGreen("#selectIconList:"..#selectIconList.." self.uid:"..self.userId)
if #selectIconList > 1 then if #selectIconList > 1 then
self.parent.AddSelectIconList(selectIconList[1].pos,self.userId)
targetPos = self:GetTargetPos(selectIconList[1].pos) targetPos = self:GetTargetPos(selectIconList[1].pos)
self.parent.AddSelectIconList(targetPos) self.parent.RemoveSelectIconList(self.eventPointPos)
else else
targetPos = self:GetTargetPos(Map_UV2Pos(self.roleCurPos.u,self.roleCurPos.v)) self.parent.ReleaseIconList()
return
end end
self.parent.ReleaseIconList() self.parent.ReleaseIconList()
return targetPos return targetPos
@ -288,6 +327,9 @@ function SingleFightPlayerView:GetTargetPos(iconPos)
end end
function SingleFightPlayerView:SetRoleWalk(targetPos) function SingleFightPlayerView:SetRoleWalk(targetPos)
local funcCanPass = function(data)
return data.val <= 1
end
local pathList = TileMapView.ShowPath(self.roleCurPos.u, self.roleCurPos.v, targetPos.x, targetPos.y, funcCanPass) local pathList = TileMapView.ShowPath(self.roleCurPos.u, self.roleCurPos.v, targetPos.x, targetPos.y, funcCanPass)
TileMapView.ClearPath() TileMapView.ClearPath()
return pathList return pathList
@ -295,16 +337,15 @@ end
function SingleFightPlayerView:RoleMove(pathList) function SingleFightPlayerView:RoleMove(pathList)
if not pathList or #pathList == 0 then if not pathList or #pathList == 0 then
local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf) self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf,self)
self:RoleWalkEnd(eventPoint)
return return
end end
--把最终回调最先入栈 -- --把最终回调最先入栈
self.callList:Push(function () -- self.callList:Push(function ()
local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf) -- local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf,self)
self:RoleWalkEnd(eventPoint) -- self:RoleWalkEnd(eventPoint)
end) -- end)
for i=1, #pathList-1 do --最后的点为起点,不处理 for i=1, #pathList-1 do --最后的点为起点,不处理
local data = pathList[i] local data = pathList[i]
@ -321,16 +362,14 @@ function SingleFightPlayerView:RoleMove(pathList)
TileMapView.SetCameraPos(v4) TileMapView.SetCameraPos(v4)
end end
end):OnComplete(function () end):OnComplete(function ()
local eventPoint = self.parent.AsideTriggerJudge(data,self.isSelf) self.parent.AsideTriggerJudge(data,self.isSelf,self)
if eventPoint then --self:SetRoleHitTarget()
self:RoleWalkEnd(eventPoint) if self.state == 0 then
return
end
self:StackPop() self:StackPop()
end
end):SetEase(Ease.Linear) end):SetEase(Ease.Linear)
end) end)
end end
-- 退出第一个栈
self:StackPop() self:StackPop()
self:PlayerMove() self:PlayerMove()
end end
@ -351,14 +390,21 @@ function SingleFightPlayerView:RoleWalkEnd(eventPoint)
self.callList:Clear() self.callList:Clear()
self:PlayerIdle() self:PlayerIdle()
if eventPoint then if eventPoint then
local iconType = eventPoint.event.iconId or -1
if iconType == -1 then
if self.isSelf then
self.selectPointPos = eventPoint.pos self.selectPointPos = eventPoint.pos
LogGreen("eventPoint.pos:"..tostring(eventPoint.pos)) else
self.selectPointPos = Map_UV2Pos(eventPoint.goData.roleCurPos.u,eventPoint.goData.roleCurPos.v)
end
else
self.selectPointPos = eventPoint.pos
end
LogGreen("eventPoint.pos:"..tostring(self.selectPointPos))
-- 检测方向 -- 检测方向
self:SetRoleDir(self.roleCurPos.u * 256 + self.roleCurPos.v, eventPoint.pos) self:SetRoleDir(self.roleCurPos.u * 256 + self.roleCurPos.v, self.selectPointPos)
-- 设置角色纵深 -- 设置角色纵深
self:SetRoleLayer(self:IsRoleFront(eventPoint.pos)) self:SetRoleLayer(self:IsRoleFront(self.selectPointPos))
self.state = 1
self.eventPointDataPos = eventPoint.pos
self:SetIconShow(eventPoint) self:SetIconShow(eventPoint)
else else
self:SetRoleHitTarget() self:SetRoleHitTarget()
@ -476,14 +522,11 @@ function SingleFightPlayerView:SetIconShow(_eventpoint)
strList = string.split(str,"#") strList = string.split(str,"#")
local num = math.random(1,#strList) local num = math.random(1,#strList)
self.context.text = strList[num] self.context.text = strList[num]
end
local boxPos = self.selectPointPos local boxPos = self.selectPointPos
Timer.New(function() Timer.New(function()
if self.isSelf then
self:SetEffect(boxPos) self:SetEffect(boxPos)
end,1.5):Start()
end end
end,2):Start()
self:NotBattleShow() self:NotBattleShow()
elseif iconType == 7 then -- NPC, 不一样的BB elseif iconType == 7 then -- NPC, 不一样的BB
self:SetWalkDir(WALK_DIR.JINGYA) self:SetWalkDir(WALK_DIR.JINGYA)
@ -532,7 +575,8 @@ function SingleFightPlayerView:SetEffect(pos)
local tartPos = boxEffectPos[boxState] local tartPos = boxEffectPos[boxState]
LogGreen("boxState:" ..boxState) LogGreen("boxState:" ..boxState)
if not self.parent.moneyEffect then LogGreen("isBeginFight:"..tostring(FightPointPassManager.isBeginFight))
if self.parent.moneyEffect then
self.parent.moneyEffect:GetComponent("RectTransform").anchoredPosition = SetObjPosByUV(pos) self.parent.moneyEffect:GetComponent("RectTransform").anchoredPosition = SetObjPosByUV(pos)
Util.ClearTrailRender(self.parent.moneyEffect) Util.ClearTrailRender(self.parent.moneyEffect)
self:SetBoxEffect(false, Vector3.zero) self:SetBoxEffect(false, Vector3.zero)
@ -540,9 +584,6 @@ function SingleFightPlayerView:SetEffect(pos)
self.parent.moneyEffect:SetActive(true) self.parent.moneyEffect:SetActive(true)
end end
self.parent.moneyEffect:GetComponent("RectTransform"):DOAnchorPos(Vector2.New(tartPos.x + 88, tartPos.y + 359), 0.6, false):OnComplete(function () self.parent.moneyEffect:GetComponent("RectTransform"):DOAnchorPos(Vector2.New(tartPos.x + 88, tartPos.y + 359), 0.6, false):OnComplete(function ()
if self.parent.moneyEffect then
self.parent.moneyEffect:SetActive(false)
end
if not FightPointPassManager.isBeginFight then if not FightPointPassManager.isBeginFight then
self:SetBoxEffect(true, boxState) self:SetBoxEffect(true, boxState)
end end
@ -705,9 +746,10 @@ function SingleFightPlayerView:NotBattleShow()
self:SetBattleState(false) self:SetBattleState(false)
self.targetTimer = Timer.New(function () self.targetTimer = Timer.New(function ()
self.parent.LoadPointIcon(false) self.parent.LoadPointIcon(false)
self.state = 0
self.eventPointDataPos = nil
self:SetRoleHitTarget() self:SetRoleHitTarget()
self.state = 0
self.selectPointPos = nil
self.eventPointPos = nil
end, 0.5) end, 0.5)
self.targetTimer:Start() self.targetTimer:Start()
end, 1) end, 1)
@ -721,8 +763,6 @@ end
function SingleFightPlayerView:OnClose() function SingleFightPlayerView:OnClose()
self.hitEffect = {}
self.hurtNum = {}
self.buffTipList = {} self.buffTipList = {}
if self.playerLiveView then if self.playerLiveView then
self.playerLiveView:OnClose() self.playerLiveView:OnClose()
@ -736,7 +776,6 @@ function SingleFightPlayerView:OnClose()
self.callbackTimer:Stop() self.callbackTimer:Stop()
self.callbackTimer = nil self.callbackTimer = nil
end end
self.callList = {}
if self.hurtNumTimer then if self.hurtNumTimer then
self.hurtNumTimer:Stop() self.hurtNumTimer:Stop()
self.hurtNumTimer = nil self.hurtNumTimer = nil
@ -745,5 +784,14 @@ function SingleFightPlayerView:OnClose()
self.battleTimer:Stop() self.battleTimer:Stop()
self.battleTimer = nil self.battleTimer = nil
end end
--角色当前方向
self.curDir = nil
--当前选中点的位置
self.selectPointPos = 0
--角色停止行走时的朝向
self.eventpoint = 0
--当前触发的事件点
self.eventPointPos = nil
self.state = 0
end end
return SingleFightPlayerView return SingleFightPlayerView