挂机修改提交
parent
12f1a42161
commit
c94f1051da
|
@ -448,5 +448,9 @@ GameEvent = {
|
|||
},
|
||||
SDK={
|
||||
InitSuccess = "SDK.InitSuccess",
|
||||
},
|
||||
|
||||
GuaJi={
|
||||
getEvent = "GuaJi.getEvent",
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ function this.Initialize()
|
|||
this.chapterGiftData = {}
|
||||
this.chapterGetRewardState = {}
|
||||
this.isOpenWeekCard = false--今天是否打开过周卡
|
||||
|
||||
this.mission = {}
|
||||
|
||||
-- 每次登录显示兑换红点
|
||||
this.SetExchangeRedStatus(true)
|
||||
|
|
|
@ -100,11 +100,11 @@ end
|
|||
|
||||
|
||||
function this:AddListener()
|
||||
--Game.GlobalEvent:AddEvent(GameEvent.Adventure.OnRefeshBoxRewardShow, this.HideEffect)
|
||||
|
||||
end
|
||||
|
||||
function this:RemoveListener()
|
||||
--Game.GlobalEvent:RemoveEvent(GameEvent.Adventure.OnRefeshBoxRewardShow, this.HideEffect)
|
||||
|
||||
end
|
||||
|
||||
function this:Init()
|
||||
|
@ -229,19 +229,26 @@ function this.ReleaseIconList()
|
|||
this.isCanUseIconList = 0
|
||||
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 iconList = this.iconList
|
||||
-- coroutine.start(function()
|
||||
|
||||
-- while(not isGetIconList) do
|
||||
-- iconList = this.RequestIconList()
|
||||
-- if iconList and LengthOfTable(iconList) > 0 then
|
||||
-- isGetIconList = true
|
||||
-- else
|
||||
-- coroutine.wait(0.01)
|
||||
-- end
|
||||
-- end
|
||||
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("得到了访问权")
|
||||
|
||||
for k,v in pairs(iconList) do
|
||||
--LogGreen("iconList k:"..tostring(k))
|
||||
end
|
||||
|
||||
local selfPos = Map_UV2Pos(data.u, data.v)
|
||||
--LogGreen("selfPos:"..tostring(selfPos))
|
||||
|
@ -251,35 +258,41 @@ function this.AsideTriggerJudge(data,isSelf)
|
|||
posList[3] = Map_UV2Pos(data.u, data.v - 1)
|
||||
posList[4] = Map_UV2Pos(data.u, data.v + 1)
|
||||
for k,pos in pairs(posList) do
|
||||
if iconList[pos] and not this.selectIconList[pos] then
|
||||
this.AddSelectIconList(pos)
|
||||
return {event = iconList[pos],pos = pos}
|
||||
--LogGreen("posList pos:"..tostring(pos))
|
||||
if iconList[pos] and this.HasSelectIconList(pos,_userData.userId) then
|
||||
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
|
||||
if isSelf and this.playerViews and LengthOfTable(this.playerViews) > 2 then
|
||||
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()
|
||||
return {event = v,pos = pos}
|
||||
end
|
||||
end
|
||||
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}
|
||||
Game.GlobalEvent:DispatchEvent(GameEvent.GuaJi.getEvent,{goData = _userData,event = v,pos = pos})
|
||||
this.ReleaseIconList()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--this.ReleaseIconList()
|
||||
--end)
|
||||
|
||||
return nil
|
||||
this.ReleaseIconList()
|
||||
end)
|
||||
end
|
||||
|
||||
function this.AddSelectIconList(pos)
|
||||
this.selectIconList[pos] = pos
|
||||
function this.HasSelectIconList(pos,uid)
|
||||
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
|
||||
|
||||
function this.RemoveSelectIconList(pos)
|
||||
|
|
|
@ -13,6 +13,27 @@ local m_oldManTextPos = {
|
|||
[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)
|
||||
local b = {}
|
||||
b.gameObject = gameObject
|
||||
|
@ -56,17 +77,19 @@ function SingleFightPlayerView:InitComponent()
|
|||
Util.GetGameObject(self.ui,"roleOption"):SetActive(false)
|
||||
|
||||
self:SetBattleState(false)
|
||||
|
||||
--角色当前方向
|
||||
self.curDir = nil
|
||||
self.gameObject:SetActive(true)
|
||||
--- 注册组件
|
||||
self.callList = Stack.New()
|
||||
--当前选中点的位置
|
||||
self.selectPointPos = 0
|
||||
-- 角色停止行走时的朝向, 上 下 左 右,1 2 3 4
|
||||
self.eventpoint = 0
|
||||
self.state = 0
|
||||
-- 角色停止行走时的朝向, 上 下 左 右,1 2 3
|
||||
self.m_roleFaceDir = Vector2.New(-1, 0)
|
||||
|
||||
--角色停止行走时的朝向
|
||||
self.eventpoint = 0
|
||||
--当前触发的事件点
|
||||
self.eventPointPos = nil
|
||||
self.name = Util.GetGameObject(self.ui, "name"):GetComponent("Text")
|
||||
|
||||
self.hurtNum = {}
|
||||
|
@ -121,13 +144,30 @@ function SingleFightPlayerView:SetData(u,v,isSelf,data)
|
|||
self.playerLiveView = nil
|
||||
end
|
||||
|
||||
local npc = NameManager.roleSex == ROLE_SEX.BOY and npc1 or npc2
|
||||
local scale = NameManager.roleSex == ROLE_SEX.BOY and 1 or 0.5
|
||||
|
||||
self.playerLiveView = PlayerLiveView:New(self.roleRoot,1, nil)
|
||||
local npc,scale
|
||||
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:OnOpen(GetPlayerRoleSingleConFig().Scale2)
|
||||
self.playerLiveView.name = "npc"
|
||||
|
||||
--角色当前的uv
|
||||
self.roleCurPos = TileMapView.GetMapData():GetMapData(u, v)
|
||||
|
||||
self.bLeaderIsIdle = true
|
||||
self:SetWalkDir(WALK_DIR.LAUCH)
|
||||
self:HideSomeTrash()
|
||||
|
@ -138,6 +178,9 @@ function SingleFightPlayerView:SetData(u,v,isSelf,data)
|
|||
self.name.text = data.userName
|
||||
self.name.gameObject:SetActive(true)
|
||||
end
|
||||
|
||||
--当前状态
|
||||
self.state = 0
|
||||
PlayUIAnim(self.gameObject)
|
||||
end
|
||||
|
||||
|
@ -169,42 +212,35 @@ end
|
|||
function SingleFightPlayerView:hitCallBack(pos)
|
||||
self:SetWalkDir(WALK_DIR.IDLE_FRONT)
|
||||
self.state = 0
|
||||
self.eventPointDataPos = nil
|
||||
self.parent.BattleEnd(pos) -- 战斗结束
|
||||
if self.isSelf then
|
||||
self:SetEffect(self.selectPointPos)
|
||||
self.selectPointPos = nil
|
||||
end
|
||||
if self.targetTimer then
|
||||
self.targetTimer:Stop()
|
||||
self.targetTimer = nil
|
||||
end
|
||||
self:SetRoleHitTarget()
|
||||
self.targetTimer = Timer.New(function () -- 延迟生成下一个小怪
|
||||
self.parent.LoadPointIcon(false)
|
||||
self:SetRoleHitTarget()
|
||||
self.parent.LoadPointIcon(false)
|
||||
end, 0.5)
|
||||
self.targetTimer:Start()
|
||||
end
|
||||
|
||||
local funcCanPass = function(data)
|
||||
return data.val <= 1
|
||||
end
|
||||
|
||||
-- 随机一个位置给大爷走走
|
||||
function SingleFightPlayerView:SetRoleHitTarget()
|
||||
coroutine.start(function()
|
||||
local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf)
|
||||
if eventPoint then
|
||||
self:RoleWalkEnd(eventPoint)
|
||||
else
|
||||
local pos
|
||||
while not pos do
|
||||
coroutine.wait(0.01)
|
||||
pos = self:SelectTargetPos()
|
||||
end
|
||||
LogGreen("选中的点:"..tostring(pos))
|
||||
local pathlist = self:SetRoleWalk(pos)
|
||||
self:RoleMove(pathlist)
|
||||
--local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf)
|
||||
--self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf)
|
||||
local pos
|
||||
while not pos do
|
||||
coroutine.wait(0.01)
|
||||
pos = self:SelectTargetPos()
|
||||
end
|
||||
LogGreen("选中的点:"..tostring(pos).." "..tostring(self.userId))
|
||||
local pathlist = self:SetRoleWalk(pos)
|
||||
self:RoleMove(pathlist)
|
||||
end)
|
||||
end
|
||||
|
||||
|
@ -215,7 +251,7 @@ function SingleFightPlayerView:SelectTargetPos()
|
|||
local selectIconList = {}
|
||||
local minDis = 999
|
||||
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 dis = math.abs(self.roleCurPos.u - targetU) + math.abs(self.roleCurPos.v - targetV)
|
||||
|
@ -241,11 +277,14 @@ function SingleFightPlayerView:SelectTargetPos()
|
|||
|
||||
-- 万一图标还没生出来
|
||||
local targetPos = 0
|
||||
LogGreen("#selectIconList:"..#selectIconList.." self.uid:"..self.userId)
|
||||
if #selectIconList > 1 then
|
||||
targetPos = self:GetTargetPos(selectIconList[1].pos)
|
||||
self.parent.AddSelectIconList(targetPos)
|
||||
self.parent.AddSelectIconList(selectIconList[1].pos,self.userId)
|
||||
targetPos = self:GetTargetPos(selectIconList[1].pos)
|
||||
self.parent.RemoveSelectIconList(self.eventPointPos)
|
||||
else
|
||||
targetPos = self:GetTargetPos(Map_UV2Pos(self.roleCurPos.u,self.roleCurPos.v))
|
||||
self.parent.ReleaseIconList()
|
||||
return
|
||||
end
|
||||
self.parent.ReleaseIconList()
|
||||
return targetPos
|
||||
|
@ -288,6 +327,9 @@ function SingleFightPlayerView:GetTargetPos(iconPos)
|
|||
end
|
||||
|
||||
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)
|
||||
TileMapView.ClearPath()
|
||||
return pathList
|
||||
|
@ -295,16 +337,15 @@ end
|
|||
|
||||
function SingleFightPlayerView:RoleMove(pathList)
|
||||
if not pathList or #pathList == 0 then
|
||||
local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf)
|
||||
self:RoleWalkEnd(eventPoint)
|
||||
self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf,self)
|
||||
return
|
||||
end
|
||||
|
||||
--把最终回调最先入栈
|
||||
self.callList:Push(function ()
|
||||
local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf)
|
||||
self:RoleWalkEnd(eventPoint)
|
||||
end)
|
||||
-- --把最终回调最先入栈
|
||||
-- self.callList:Push(function ()
|
||||
-- local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf,self)
|
||||
-- self:RoleWalkEnd(eventPoint)
|
||||
-- end)
|
||||
|
||||
for i=1, #pathList-1 do --最后的点为起点,不处理
|
||||
local data = pathList[i]
|
||||
|
@ -321,16 +362,14 @@ function SingleFightPlayerView:RoleMove(pathList)
|
|||
TileMapView.SetCameraPos(v4)
|
||||
end
|
||||
end):OnComplete(function ()
|
||||
local eventPoint = self.parent.AsideTriggerJudge(data,self.isSelf)
|
||||
if eventPoint then
|
||||
self:RoleWalkEnd(eventPoint)
|
||||
return
|
||||
end
|
||||
self:StackPop()
|
||||
self.parent.AsideTriggerJudge(data,self.isSelf,self)
|
||||
--self:SetRoleHitTarget()
|
||||
if self.state == 0 then
|
||||
self:StackPop()
|
||||
end
|
||||
end):SetEase(Ease.Linear)
|
||||
end)
|
||||
end
|
||||
-- 退出第一个栈
|
||||
self:StackPop()
|
||||
self:PlayerMove()
|
||||
end
|
||||
|
@ -351,14 +390,21 @@ function SingleFightPlayerView:RoleWalkEnd(eventPoint)
|
|||
self.callList:Clear()
|
||||
self:PlayerIdle()
|
||||
if eventPoint then
|
||||
self.selectPointPos = eventPoint.pos
|
||||
LogGreen("eventPoint.pos:"..tostring(eventPoint.pos))
|
||||
local iconType = eventPoint.event.iconId or -1
|
||||
if iconType == -1 then
|
||||
if self.isSelf then
|
||||
self.selectPointPos = 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.state = 1
|
||||
self.eventPointDataPos = eventPoint.pos
|
||||
self:SetRoleLayer(self:IsRoleFront(self.selectPointPos))
|
||||
self:SetIconShow(eventPoint)
|
||||
else
|
||||
self:SetRoleHitTarget()
|
||||
|
@ -476,14 +522,11 @@ function SingleFightPlayerView:SetIconShow(_eventpoint)
|
|||
strList = string.split(str,"#")
|
||||
local num = math.random(1,#strList)
|
||||
self.context.text = strList[num]
|
||||
end
|
||||
|
||||
local boxPos = self.selectPointPos
|
||||
Timer.New(function()
|
||||
if self.isSelf then
|
||||
local boxPos = self.selectPointPos
|
||||
Timer.New(function()
|
||||
self:SetEffect(boxPos)
|
||||
end
|
||||
end,2):Start()
|
||||
end,1.5):Start()
|
||||
end
|
||||
self:NotBattleShow()
|
||||
elseif iconType == 7 then -- NPC, 不一样的BB
|
||||
self:SetWalkDir(WALK_DIR.JINGYA)
|
||||
|
@ -532,7 +575,8 @@ function SingleFightPlayerView:SetEffect(pos)
|
|||
local tartPos = boxEffectPos[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)
|
||||
Util.ClearTrailRender(self.parent.moneyEffect)
|
||||
self:SetBoxEffect(false, Vector3.zero)
|
||||
|
@ -540,9 +584,6 @@ function SingleFightPlayerView:SetEffect(pos)
|
|||
self.parent.moneyEffect:SetActive(true)
|
||||
end
|
||||
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
|
||||
self:SetBoxEffect(true, boxState)
|
||||
end
|
||||
|
@ -692,22 +733,23 @@ end
|
|||
function SingleFightPlayerView:NotBattleShow()
|
||||
if self.battleTimer then
|
||||
self.battleTimer:Stop()
|
||||
self.battleTimer = nil
|
||||
self.battleTimer = nil
|
||||
end
|
||||
if self.targetTimer then
|
||||
self.targetTimer:Stop()
|
||||
self.targetTimer = nil
|
||||
end
|
||||
self.battleTimer = Timer.New(function ()
|
||||
self.dialogueRoot.gameObject:SetActive(false)
|
||||
self.dialogueRoot.gameObject:SetActive(false)
|
||||
self.parent.BattleEnd(self.selectPointPos)
|
||||
self:SetRoleLayer(true)
|
||||
self:SetBattleState(false)
|
||||
self.targetTimer = Timer.New(function ()
|
||||
self.parent.LoadPointIcon(false)
|
||||
self.state = 0
|
||||
self.eventPointDataPos = nil
|
||||
self:SetRoleHitTarget()
|
||||
self.state = 0
|
||||
self.selectPointPos = nil
|
||||
self.eventPointPos = nil
|
||||
end, 0.5)
|
||||
self.targetTimer:Start()
|
||||
end, 1)
|
||||
|
@ -721,8 +763,6 @@ end
|
|||
|
||||
|
||||
function SingleFightPlayerView:OnClose()
|
||||
self.hitEffect = {}
|
||||
self.hurtNum = {}
|
||||
self.buffTipList = {}
|
||||
if self.playerLiveView then
|
||||
self.playerLiveView:OnClose()
|
||||
|
@ -736,7 +776,6 @@ function SingleFightPlayerView:OnClose()
|
|||
self.callbackTimer:Stop()
|
||||
self.callbackTimer = nil
|
||||
end
|
||||
self.callList = {}
|
||||
if self.hurtNumTimer then
|
||||
self.hurtNumTimer:Stop()
|
||||
self.hurtNumTimer = nil
|
||||
|
@ -745,5 +784,14 @@ function SingleFightPlayerView:OnClose()
|
|||
self.battleTimer:Stop()
|
||||
self.battleTimer = nil
|
||||
end
|
||||
--角色当前方向
|
||||
self.curDir = nil
|
||||
--当前选中点的位置
|
||||
self.selectPointPos = 0
|
||||
--角色停止行走时的朝向
|
||||
self.eventpoint = 0
|
||||
--当前触发的事件点
|
||||
self.eventPointPos = nil
|
||||
self.state = 0
|
||||
end
|
||||
return SingleFightPlayerView
|
Loading…
Reference in New Issue