2021-04-15 15:51:24 +08:00
|
|
|
|
require("Base/Stack")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
require("Modules/Map/Logic/TileMapController")
|
|
|
|
|
require("Modules/Map/Logic/TileMapView")
|
|
|
|
|
require("Modules/Map/Config/MapConfig")
|
|
|
|
|
require("Modules/Map/View/MapPointView")
|
2021-04-15 15:51:24 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local mapIconConfig = ConfigManager.GetConfig(ConfigName.MainMapIconConfig)
|
|
|
|
|
local iconAction = require("Modules/Fight/View/FightMapIconShowView")
|
|
|
|
|
|
|
|
|
|
local this = {}
|
2021-04-15 15:51:24 +08:00
|
|
|
|
--地图id
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local mapIdList = {
|
2020-08-24 17:17:21 +08:00
|
|
|
|
[1] = 5002,
|
|
|
|
|
[2] = 5003,
|
|
|
|
|
[3] = 5005,
|
|
|
|
|
[4] = 4002,
|
2020-08-25 16:06:06 +08:00
|
|
|
|
[5] = 5004,
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
2021-04-15 15:51:24 +08:00
|
|
|
|
|
|
|
|
|
--初始化相机位置
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local InitCamPos = {
|
|
|
|
|
[4002] = {pos = Vector3.New(27.5, -27.5, -50)},
|
2020-08-24 17:17:21 +08:00
|
|
|
|
[5005] = {pos = Vector3.New(20, -15, -50)},
|
2020-06-13 11:47:13 +08:00
|
|
|
|
[5002] = {pos = Vector3.New(27.5, -27.5, -50)},
|
2020-06-19 21:44:27 +08:00
|
|
|
|
[5003] = {pos = Vector3.New(27.5, -18, -50)},
|
2020-08-24 17:17:21 +08:00
|
|
|
|
[5004] = {pos = Vector3.New(27.5, -18, -50)},
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
2021-04-15 15:51:24 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 临时可生成怪的区域
|
|
|
|
|
local monsterArea = {
|
2020-08-24 17:17:21 +08:00
|
|
|
|
[5005] = {
|
|
|
|
|
x_pos = {min = 10, max = 28},
|
|
|
|
|
y_pos = {min = 8, max = 14},
|
2020-05-25 19:16:23 +08:00
|
|
|
|
},
|
|
|
|
|
[4002] = {
|
|
|
|
|
x_pos = {min = 10, max = 20},
|
|
|
|
|
y_pos = {min = 10, max = 15},
|
|
|
|
|
},
|
2020-06-13 11:47:13 +08:00
|
|
|
|
[5002] = {
|
2020-07-17 15:55:20 +08:00
|
|
|
|
x_pos = {min = 9, max = 28},
|
2020-06-13 11:47:13 +08:00
|
|
|
|
y_pos = {min = 8, max = 16},
|
|
|
|
|
},
|
2020-06-19 21:44:27 +08:00
|
|
|
|
[5003] = {
|
2020-07-25 16:02:38 +08:00
|
|
|
|
x_pos = {min = 9, max = 27},
|
2020-06-19 21:44:27 +08:00
|
|
|
|
y_pos = {min = 8, max = 14},
|
|
|
|
|
},
|
2020-08-24 17:17:21 +08:00
|
|
|
|
[5004] = {
|
|
|
|
|
x_pos = {min = 9, max = 27},
|
|
|
|
|
y_pos = {min = 8, max = 14},
|
|
|
|
|
},
|
2020-05-25 19:16:23 +08:00
|
|
|
|
}
|
2021-04-15 15:51:24 +08:00
|
|
|
|
|
|
|
|
|
--自己角色的出生点
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local startUV = {
|
2020-08-24 17:17:21 +08:00
|
|
|
|
[5005] = {u = 11, v = 8},
|
2020-05-25 19:16:23 +08:00
|
|
|
|
[4002] = {u = 15, v = 15},
|
2020-06-13 11:47:13 +08:00
|
|
|
|
[5002] = {u = 15, v = 15},
|
2020-06-19 21:44:27 +08:00
|
|
|
|
[5003] = {u = 15, v = 10},
|
2020-08-24 17:17:21 +08:00
|
|
|
|
[5004] = {u = 15, v = 10},
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
2021-04-15 15:51:24 +08:00
|
|
|
|
|
|
|
|
|
-- 允许出现的事件点的图标数量
|
|
|
|
|
local iconNum = 9
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 地图图标的上限值
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local maxIcon = 9
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-04-15 15:51:24 +08:00
|
|
|
|
local mapCtrl = "MapCtrl"
|
|
|
|
|
local effectPath = "c_xy_0012_skeff_slidesk_ballistic"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
-- 当前关卡地图编号
|
|
|
|
|
local m_curMapId = 1011
|
2021-04-19 11:58:22 +08:00
|
|
|
|
local m_orginLayer = 0
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local m_parent
|
2021-04-19 11:58:22 +08:00
|
|
|
|
this.isClose = false
|
2021-04-15 15:51:24 +08:00
|
|
|
|
--root FightPointPassMainPanel.gameObject FightPointPassMainPanel脚本
|
2020-05-09 13:31:21 +08:00
|
|
|
|
function this:InitComponent(root, parent)
|
|
|
|
|
m_parent = parent
|
|
|
|
|
-- 地图点击拖动
|
2021-04-15 15:51:24 +08:00
|
|
|
|
this.root = root
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.dragCtrl = Util.GetGameObject(root, "Bg/Ctrl")
|
|
|
|
|
this.effectRoot = Util.GetGameObject(root, "effectRoot")
|
2021-04-15 15:51:24 +08:00
|
|
|
|
this.buffTip = Util.GetGameObject(this.effectRoot, "money")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 箱子
|
|
|
|
|
this.boxEffect = Util.GetGameObject(root, "boxRoot/UI_effect_GuaJi_Box_BaoDian")
|
2021-04-15 15:51:24 +08:00
|
|
|
|
this.playerViews = {}
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-04-15 15:51:24 +08:00
|
|
|
|
local str = ConfigManager.GetConfigData(ConfigName.SpecialConfig,111).Value
|
|
|
|
|
local strList = string.split(str,"#")
|
|
|
|
|
if strList and #strList > 0 then
|
|
|
|
|
local num = math.random(1,#strList)
|
|
|
|
|
FightPointPassManager.randomNum = num
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-04-15 15:51:24 +08:00
|
|
|
|
function this:AddListener()
|
2021-04-17 21:04:09 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:RemoveListener()
|
2021-04-17 21:04:09 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:Init()
|
2021-04-19 11:58:22 +08:00
|
|
|
|
this.isClose = false
|
|
|
|
|
this.isCanUseIconList = 0
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 初始化加载地图块数据
|
|
|
|
|
this:LoadMapData()
|
|
|
|
|
-- 加载一个小人
|
2021-04-15 15:51:24 +08:00
|
|
|
|
local tempconfig = ConfigManager.GetConfigData(ConfigName.ChallengeMapConfig,m_curMapId)
|
|
|
|
|
if not this.playerViews[0] then
|
|
|
|
|
--LogGreen(m_curMapId)
|
2021-04-15 21:05:27 +08:00
|
|
|
|
if ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.guajigongneng) then
|
2021-04-20 14:52:02 +08:00
|
|
|
|
iconNum = 12
|
|
|
|
|
local randomNum = math.random(2,4)
|
2021-04-15 21:05:27 +08:00
|
|
|
|
PlayerManager.GetFightMapPlayerNPCData(randomNum,function(NPCList)
|
|
|
|
|
--LogGreen("NPCList:"..LengthOfTable(NPCList))
|
|
|
|
|
local index = 1
|
|
|
|
|
for k,v in pairs(NPCList) do
|
|
|
|
|
local index1 = math.random(6,12)
|
|
|
|
|
local index2 = math.random(19,38)
|
|
|
|
|
local index3 = math.random(1,2)
|
|
|
|
|
local index4 = math.random(2,19)
|
|
|
|
|
this.playerViews[index] = SubUIManager.Open(SubUIConfig.SingleFightPlayerView,this.mapRoot.transform,this)
|
|
|
|
|
this.playerViews[index]:SetData((index3 == 1 and index1 or index2),index4,false,v)
|
|
|
|
|
index = index + 1
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
iconNum = 4
|
2021-04-15 15:51:24 +08:00
|
|
|
|
this.playerViews[0] = SubUIManager.Open(SubUIConfig.SingleFightPlayerView,this.mapRoot.transform,this)
|
|
|
|
|
this.playerViews[0]:SetData(startUV[m_curMapId].u,startUV[m_curMapId].v,true)
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 初始化两个地图标志
|
|
|
|
|
this.LoadMapIcon()
|
2021-04-15 15:51:24 +08:00
|
|
|
|
this.SetPlayerViewWalk()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:LoadMapData()
|
|
|
|
|
UIManager.camera.clearFlags = CameraClearFlags.Depth
|
|
|
|
|
-- 所有物体的根节点
|
|
|
|
|
this.mapRoot = poolManager:LoadAsset(mapCtrl, PoolManager.AssetType.GameObject)
|
|
|
|
|
this.mapRoot.name = mapCtrl
|
|
|
|
|
this.mapRoot.transform:SetParent(UIManager.uiRoot.transform.parent)
|
|
|
|
|
this.mapRoot.transform.position = Vector3.New(0, 0, -100)
|
|
|
|
|
|
|
|
|
|
TileMapView.fogSize = 2
|
|
|
|
|
local curChapter = FightPointPassManager.GetCurChapterIndex()
|
|
|
|
|
local index = 1
|
2020-08-24 17:17:21 +08:00
|
|
|
|
index = math.floor((curChapter - 1) % 5 + 1)
|
2021-04-15 15:51:24 +08:00
|
|
|
|
-- --Log(curChapter)
|
|
|
|
|
-- --Log(index)
|
2020-05-25 19:16:23 +08:00
|
|
|
|
m_curMapId = mapIdList[index]
|
2021-01-26 17:08:39 +08:00
|
|
|
|
-- LogPink("#mapIdList:"..#mapIdList.." m_curMapId:"..m_curMapId.." curChapter:"..curChapter.." index:"..index.." State:"..tostring(FightPointPassManager.isOpenNewChapter))
|
2020-05-25 19:16:23 +08:00
|
|
|
|
TileMapView.AwakeInit(this.mapRoot, m_curMapId, nil, Vector2.New(180, 180))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
TileMapView.isShowFog = false
|
|
|
|
|
TileMapController.IsShieldDrag = function()
|
|
|
|
|
--当栈中有逻辑,则拖动可以打断镜头跟随
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
TileMapController.OnClickTile = this.OnClickTile
|
|
|
|
|
TileMapController.Init(this.mapRoot, this.dragCtrl)
|
|
|
|
|
|
|
|
|
|
TileMapView.Init()
|
|
|
|
|
|
|
|
|
|
-- 设置镜头的尺寸
|
|
|
|
|
TileMapView.SetMapScale(Screen.height / 1920)
|
|
|
|
|
|
|
|
|
|
-- 设置相机初始化位置
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local camInitPos = InitCamPos[m_curMapId].pos
|
2020-05-09 13:31:21 +08:00
|
|
|
|
TileMapView.SetCameraPos(camInitPos)
|
|
|
|
|
|
|
|
|
|
-- 设置不点击
|
|
|
|
|
this.dragCtrl:SetActive(false)
|
|
|
|
|
|
|
|
|
|
-- 挂机特效
|
|
|
|
|
this.moneyEffect = poolManager:LoadAsset(effectPath, PoolManager.AssetType.GameObject)
|
|
|
|
|
this.moneyEffect.transform:SetParent(this.effectRoot.transform)
|
|
|
|
|
this.moneyEffect.transform.localScale = Vector3.one
|
|
|
|
|
this.moneyEffect.transform.localPosition = Vector3.New(0, 0, 0)
|
|
|
|
|
this.moneyEffect:SetActive(false)
|
|
|
|
|
|
|
|
|
|
Util.AddParticleSortLayer(this.moneyEffect, m_parent.sortingOrder - m_orginLayer)
|
|
|
|
|
Util.AddParticleSortLayer(this.boxEffect, m_parent.sortingOrder - m_orginLayer)
|
|
|
|
|
m_orginLayer = m_parent.sortingOrder
|
|
|
|
|
this.boxEffect:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
2021-04-15 15:51:24 +08:00
|
|
|
|
--加载图标icon
|
2020-05-09 13:31:21 +08:00
|
|
|
|
function this.LoadMapIcon()
|
|
|
|
|
this.iconList = {}
|
2021-04-15 15:51:24 +08:00
|
|
|
|
this.selectIconList = {}
|
2021-04-19 11:58:22 +08:00
|
|
|
|
--FightPointPassManager.isBeginFight = false
|
2020-05-09 13:31:21 +08:00
|
|
|
|
for i = 1, iconNum do
|
2021-04-15 15:51:24 +08:00
|
|
|
|
this.LoadPointIcon(false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-04-15 15:51:24 +08:00
|
|
|
|
function this.SetPlayerViewWalk()
|
|
|
|
|
if this.startTimer then
|
|
|
|
|
this.startTimer:Stop()
|
|
|
|
|
this.startTimer = nil
|
|
|
|
|
end
|
|
|
|
|
this.startTimer = Timer.New(function ()
|
|
|
|
|
for k,v in pairs(this.playerViews) do
|
|
|
|
|
v:SetRoleHitTarget()
|
|
|
|
|
end
|
2021-04-20 14:52:02 +08:00
|
|
|
|
end,1.5)
|
2021-04-15 15:51:24 +08:00
|
|
|
|
this.startTimer:Start()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
this.isCanUseIconList = 0
|
|
|
|
|
function this.RequestIconList()
|
2021-04-19 11:58:22 +08:00
|
|
|
|
LogGreen(" this.isCanUseIconList:".. tostring(this.isCanUseIconList))
|
2021-04-15 15:51:24 +08:00
|
|
|
|
if this.isCanUseIconList == 0 then
|
|
|
|
|
this.isCanUseIconList = 1
|
2021-04-19 11:58:22 +08:00
|
|
|
|
LogGreen(" this.iconList:".. tostring(this.iconList))
|
2021-04-15 15:51:24 +08:00
|
|
|
|
return this.iconList
|
|
|
|
|
end
|
|
|
|
|
return nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.ReleaseIconList()
|
|
|
|
|
this.isCanUseIconList = 0
|
|
|
|
|
end
|
|
|
|
|
|
2021-04-17 21:04:09 +08:00
|
|
|
|
function this.AsideTriggerJudge(data,isSelf,_userData)
|
|
|
|
|
--LogGreen("data:"..tostring(data).." pos:"..tostring(Map_UV2Pos(data.u - 1, data.v)))
|
2021-04-15 15:51:24 +08:00
|
|
|
|
local isGetIconList = false
|
|
|
|
|
local iconList = this.iconList
|
2021-04-19 11:58:22 +08:00
|
|
|
|
if not this.threads then
|
|
|
|
|
this.threads = {}
|
|
|
|
|
end
|
2021-04-20 14:52:02 +08:00
|
|
|
|
if this.threads[_userData.userId] then
|
|
|
|
|
coroutine.stop(this.threads[_userData.userId])
|
|
|
|
|
this.threads[_userData.userId] = nil
|
2021-04-19 11:58:22 +08:00
|
|
|
|
end
|
|
|
|
|
this.threads[_userData.userId] = coroutine.start(function()
|
2021-04-17 21:04:09 +08:00
|
|
|
|
while(not isGetIconList) do
|
2021-04-20 14:52:02 +08:00
|
|
|
|
if this.isClose and this.isClose == true then
|
|
|
|
|
coroutine.stop(this.threads[_userData.userId])
|
|
|
|
|
this.threads[_userData.userId] = nil
|
|
|
|
|
this.ReleaseIconList()
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-04-17 21:04:09 +08:00
|
|
|
|
--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
|
2021-04-15 15:51:24 +08:00
|
|
|
|
|
|
|
|
|
local selfPos = Map_UV2Pos(data.u, data.v)
|
|
|
|
|
--LogGreen("selfPos:"..tostring(selfPos))
|
|
|
|
|
local posList = {}
|
|
|
|
|
posList[1] = Map_UV2Pos(data.u - 1, data.v)
|
|
|
|
|
posList[2] = Map_UV2Pos(data.u + 1, data.v)
|
|
|
|
|
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
|
2021-04-17 21:04:09 +08:00
|
|
|
|
--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})
|
2021-04-19 11:58:22 +08:00
|
|
|
|
coroutine.stop(this.threads[_userData.userId])
|
2021-04-17 21:04:09 +08:00
|
|
|
|
this.ReleaseIconList()
|
|
|
|
|
return
|
2021-04-15 15:51:24 +08:00
|
|
|
|
elseif FightPointPassManager.talkingTime == 0 or (GetTimeStamp() - FightPointPassManager.talkingTime >= 60) then
|
2021-04-19 11:58:22 +08:00
|
|
|
|
if isSelf and this.playerViews and LengthOfTable(this.playerViews) > 1 then
|
2021-04-15 15:51:24 +08:00
|
|
|
|
for k,v in pairs(this.playerViews) do
|
2021-04-19 11:58:22 +08:00
|
|
|
|
if not v.isSelf and Map_UV2Pos(v.roleCurPos.u, v.roleCurPos.v) == pos and v.state == 0 then
|
2021-04-15 15:51:24 +08:00
|
|
|
|
FightPointPassManager.talkingTime = GetTimeStamp()
|
2021-04-17 21:04:09 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.GuaJi.getEvent,{goData = _userData,event = v,pos = pos})
|
2021-04-19 11:58:22 +08:00
|
|
|
|
coroutine.stop(this.threads[_userData.userId])
|
2021-04-17 21:04:09 +08:00
|
|
|
|
this.ReleaseIconList()
|
|
|
|
|
return
|
2021-04-15 15:51:24 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-04-19 11:58:22 +08:00
|
|
|
|
coroutine.stop(this.threads[_userData.userId])
|
2021-04-17 21:04:09 +08:00
|
|
|
|
this.ReleaseIconList()
|
|
|
|
|
end)
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-04-17 21:04:09 +08:00
|
|
|
|
function this.HasSelectIconList(pos,uid)
|
|
|
|
|
if this.selectIconList[pos] and this.selectIconList[pos] ~= uid then
|
|
|
|
|
return false
|
|
|
|
|
else
|
|
|
|
|
return true
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-04-17 21:04:09 +08:00
|
|
|
|
function this.AddSelectIconList(pos,uid)
|
|
|
|
|
this.selectIconList[pos] = uid
|
2021-04-15 15:51:24 +08:00
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-04-15 15:51:24 +08:00
|
|
|
|
function this.RemoveSelectIconList(pos)
|
|
|
|
|
if this.selectIconList[pos] then
|
|
|
|
|
this.selectIconList[pos] = nil
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 生成一个图标, 传入校验权重值rand, 是否使用动画
|
2021-04-15 15:51:24 +08:00
|
|
|
|
function this.LoadPointIcon(useAnim)
|
|
|
|
|
if LengthOfTable(this.iconList) >= iconNum then
|
|
|
|
|
return
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 随机一个坐标
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local area = monsterArea[m_curMapId]
|
2021-04-15 15:51:24 +08:00
|
|
|
|
--LogGreen("area.x_pos.min:"..tostring(area.x_pos.min).." area.x_pos.max:"..tostring(area.x_pos.max))
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local u = math.random(area.x_pos.min, area.x_pos.max)
|
2021-04-15 15:51:24 +08:00
|
|
|
|
--LogGreen("area.y_pos.min:"..tostring(area.y_pos.min).." area.y_pos.max:"..tostring(area.y_pos.max))
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local v = math.random(area.y_pos.min, area.y_pos.max)
|
2021-04-15 15:51:24 +08:00
|
|
|
|
--LogGreen("u:"..tostring(u).." v:"..tostring(v))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local pos = Map_UV2Pos(u, v)
|
|
|
|
|
|
2021-04-15 15:51:24 +08:00
|
|
|
|
local mapPointId = math.random(1,maxIcon)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 随机出来的位置已经有图标,则再次随机
|
|
|
|
|
if this.iconList[pos] or pos == 1285 or this.IsHaveBitchNear(pos) then
|
2021-04-15 15:51:24 +08:00
|
|
|
|
this.LoadPointIcon()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
|
|
|
|
local pointView = MapPointView.New(u, v, mapPointId)
|
|
|
|
|
if pointView then
|
|
|
|
|
pointView.go.transform:SetParent(Util.GetTransform(this.mapRoot, "uiObj#"))
|
|
|
|
|
|
|
|
|
|
local targetPos = TileMapView.GetLiveTilePos(u, v) * 100
|
|
|
|
|
-- 完了这玩意还能从天而降
|
|
|
|
|
if useAnim then
|
|
|
|
|
pointView.go:GetComponent("RectTransform").anchoredPosition3D = Vector3.New(targetPos.x, 1000, 0)
|
|
|
|
|
pointView.go:GetComponent("RectTransform"):DOAnchorPos(targetPos, 0.5, false):OnComplete(function ()
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
pointView.go:GetComponent("RectTransform").anchoredPosition3D = targetPos
|
|
|
|
|
end
|
|
|
|
|
pointView:SetPointAnimation(pointView.iconId, 1)
|
|
|
|
|
pointView.go.transform.localScale = Vector3.one
|
|
|
|
|
|
|
|
|
|
-- 额外尺寸设置
|
|
|
|
|
if pointView.iconId == MapIconType.ICON_GOLD_BOX or pointView.iconId == MapIconType.ICON_NEW_BOX then
|
|
|
|
|
pointView.go.transform.localScale = Vector3.New(1.3, 1.3, 1.3)
|
|
|
|
|
elseif pointView.iconId == MapIconType.ICON_SUPPLY then
|
|
|
|
|
pointView.go.transform.localScale = Vector3.New(0.8, 0.8, 0.8)
|
|
|
|
|
end
|
|
|
|
|
pointView:OnShow()
|
|
|
|
|
pointView:ShowAtkNum(0, false)
|
|
|
|
|
pointView:ShowFreshTime(false)
|
|
|
|
|
pointView:ShowDialogue(false)
|
|
|
|
|
this.iconList[pos] = pointView
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-04-15 15:51:24 +08:00
|
|
|
|
---------------------------------------------------------------------------------------------设置特效层级
|
|
|
|
|
function this:OnSortingOrderChange(orginLayer)
|
|
|
|
|
if this.moneyEffect then
|
|
|
|
|
Util.AddParticleSortLayer(this.moneyEffect, m_parent.sortingOrder - m_orginLayer)
|
|
|
|
|
Util.AddParticleSortLayer(this.boxEffect, m_parent.sortingOrder - m_orginLayer)
|
|
|
|
|
for k,v in pairs(this.playerViews) do
|
|
|
|
|
v:OnSortingOrderChange(m_parent.sortingOrder)
|
|
|
|
|
end
|
|
|
|
|
m_orginLayer = m_parent.sortingOrder
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
function this.GetCurLayer()
|
|
|
|
|
return m_orginLayer
|
|
|
|
|
end
|
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
---============== Point Icon Handle =================================
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 删除一个图标
|
|
|
|
|
function this.DeletePointIcon(pos)
|
|
|
|
|
if this.iconList[pos] then
|
|
|
|
|
this.iconList[pos]:OnRemovePoint()
|
|
|
|
|
this.iconList[pos] = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 检测当前图标附近是否有图标
|
|
|
|
|
function this.IsHaveBitchNear(pos)
|
|
|
|
|
local haveBitch = false
|
|
|
|
|
local targetU, targetV = Map_Pos2UV(pos)
|
|
|
|
|
for i, v in pairs(this.iconList) do
|
|
|
|
|
local u0, v0 = Map_Pos2UV(i)
|
|
|
|
|
if math.abs(u0 - targetU) + math.abs(v0 - targetV) <= 2 then
|
|
|
|
|
haveBitch = true
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return haveBitch
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- =============== 行动中的表现处理 =====================================================
|
|
|
|
|
|
|
|
|
|
-- 退出战斗状态
|
2021-04-15 15:51:24 +08:00
|
|
|
|
function this.BattleEnd(selectPointPos,isSelf)
|
|
|
|
|
--LogGreen("战斗结束回调")
|
|
|
|
|
-- 删点前隐藏那个东西
|
|
|
|
|
if this.iconList[selectPointPos] then
|
|
|
|
|
this.iconList[selectPointPos]:ShowDialogue(false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2021-04-15 15:51:24 +08:00
|
|
|
|
-- 删除图标
|
|
|
|
|
this.DeletePointIcon(selectPointPos)
|
|
|
|
|
this.RemoveSelectIconList(selectPointPos)
|
|
|
|
|
local str = ConfigManager.GetConfigData(ConfigName.SpecialConfig,111).Value
|
|
|
|
|
local strList = string.split(str,"#")
|
|
|
|
|
if strList and #strList > 0 then
|
|
|
|
|
local num = math.random(1,#strList)
|
|
|
|
|
FightPointPassManager.randomNum = num
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- ==================== 角色行走 =====================================
|
|
|
|
|
function this.OnClickTile(u, v)
|
2021-04-15 15:51:24 +08:00
|
|
|
|
--Log("UIManager.width is -- " .. UIManager.width .. " and Height is " .. UIManager.height)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local v2 = RectTransformUtility.WorldToScreenPoint(TileMapView.GetCamera(), TileMapView.GetLiveTilePos(u, v))
|
|
|
|
|
v2 = v2 / math.min(Screen.width/1080, Screen.height/1920)
|
2021-04-15 15:51:24 +08:00
|
|
|
|
--Log(string.format("当前点击坐标(%s, %s)", u, v))
|
|
|
|
|
--Log(string.format("转换后的屏幕坐标是(%s, %s)", v2.x, v2.y))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-04-19 11:58:22 +08:00
|
|
|
|
|
|
|
|
|
-- 停止一切该死的行为
|
|
|
|
|
function this.StopAction()
|
|
|
|
|
for k,v in pairs(this.playerViews) do
|
|
|
|
|
v:StopAction()
|
|
|
|
|
end
|
|
|
|
|
this.moneyEffect.gameObject:SetActive(false)
|
|
|
|
|
if this.threads then
|
|
|
|
|
for k,v in pairs(this.threads) do
|
|
|
|
|
coroutine.stop(v)
|
|
|
|
|
this.threads[k] = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
this.threads = {}
|
|
|
|
|
this.ReleaseIconList()
|
|
|
|
|
this.isClose = true
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--- ======================================================================
|
|
|
|
|
function this.OnGameOver()
|
2021-04-15 15:51:24 +08:00
|
|
|
|
for i, v in pairs(this.playerViews) do
|
|
|
|
|
if v then
|
|
|
|
|
SubUIManager.Close(v)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
this.playerViews = {}
|
|
|
|
|
for i, v in pairs(this.iconList) do
|
|
|
|
|
if v then
|
|
|
|
|
v:Dispose()
|
|
|
|
|
this.iconList[i] = nil
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
if this.mapRoot then -- 避免不是主动退出
|
2021-04-15 15:51:24 +08:00
|
|
|
|
--Log("注销一次地图资源")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
poolManager:UnLoadAsset(mapCtrl, this.mapRoot, PoolManager.AssetType.GameObject)
|
|
|
|
|
poolManager:UnLoadAsset(effectPath, this.moneyEffect, PoolManager.AssetType.GameObject)
|
|
|
|
|
UIManager.camera.clearFlags = CameraClearFlags.Skybox
|
|
|
|
|
TileMapView.Exit()
|
|
|
|
|
TileMapController.Exit()
|
|
|
|
|
end
|
2021-04-15 15:51:24 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.mapRoot = nil
|
|
|
|
|
this.moneyEffect = nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnClose()
|
2021-04-19 11:58:22 +08:00
|
|
|
|
if this.startTimer then
|
|
|
|
|
this.startTimer:Stop()
|
|
|
|
|
end
|
|
|
|
|
this.startTimer = nil
|
|
|
|
|
this.StopAction()
|
|
|
|
|
this.OnGameOver()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:Dispose()
|
|
|
|
|
if this.startTimer then
|
|
|
|
|
this.startTimer:Stop()
|
|
|
|
|
end
|
|
|
|
|
this.startTimer = nil
|
2021-04-19 11:58:22 +08:00
|
|
|
|
this.StopAction()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.OnGameOver()
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return this
|