探索提交
parent
7bb3325c99
commit
83b5a04ac6
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d485bc627bd653c45932afdcb03de1bb
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName: lz4/prefabs/map/singlefightplayerview
|
||||
assetBundleVariant: unity3d
|
|
@ -0,0 +1,510 @@
|
|||
require("Base/Stack")
|
||||
require("Modules/Map/Logic/TileMapController")
|
||||
require("Modules/Map/Logic/TileMapView")
|
||||
require("Modules/Map/Config/MapConfig")
|
||||
require("Modules/Map/View/MapPointView")
|
||||
|
||||
local mapIconConfig = ConfigManager.GetConfig(ConfigName.MainMapIconConfig)
|
||||
local iconAction = require("Modules/Fight/View/FightMapIconShowView")
|
||||
|
||||
local this = {}
|
||||
--地图id
|
||||
local mapIdList = {
|
||||
[1] = 5002,
|
||||
[2] = 5003,
|
||||
[3] = 5005,
|
||||
[4] = 4002,
|
||||
[5] = 5004,
|
||||
}
|
||||
|
||||
|
||||
-- 临时可生成怪的区域
|
||||
local monsterArea = {
|
||||
[5005] = {
|
||||
x_pos = {min = 8, max = 28},
|
||||
y_pos = {min = 8, max = 14},
|
||||
},
|
||||
[4002] = {
|
||||
x_pos = {min = 8, max = 24},
|
||||
y_pos = {min = 9, max = 23},
|
||||
},
|
||||
[5002] = {
|
||||
x_pos = {min = 9, max = 32},
|
||||
y_pos = {min = 8, max = 16},
|
||||
},
|
||||
[5003] = {
|
||||
x_pos = {min = 8, max = 28},
|
||||
y_pos = {min = 8, max = 14},
|
||||
},
|
||||
[5004] = {
|
||||
x_pos = {min = 8, max = 27},
|
||||
y_pos = {min = 8, max = 15},
|
||||
},
|
||||
}
|
||||
|
||||
--自己角色的出生点
|
||||
local startUV = {
|
||||
[5005] = {u = 15, v = 10},
|
||||
[4002] = {u = 15, v = 15},
|
||||
[5002] = {u = 15, v = 15},
|
||||
[5003] = {u = 15, v = 10},
|
||||
[5004] = {u = 15, v = 10},
|
||||
}
|
||||
|
||||
-- 允许出现的事件点的图标数量
|
||||
local iconNum = 9
|
||||
-- 地图图标的上限值
|
||||
local maxIcon = 9
|
||||
|
||||
local mapCtrl = "MapCtrl"
|
||||
local effectPath = "c_xy_0012_skeff_slidesk_ballistic"
|
||||
|
||||
-- 当前关卡地图编号
|
||||
local m_curMapId = 1011
|
||||
local m_orginLayer = 0
|
||||
local m_parent
|
||||
this.isClose = false
|
||||
--root FightPointPassMainPanel.gameObject FightPointPassMainPanel脚本
|
||||
function this:InitComponent(root, parent)
|
||||
Log("初始化地图资源")
|
||||
m_orginLayer = 0
|
||||
m_parent = parent
|
||||
-- 地图点击拖动
|
||||
this.root = root
|
||||
this.dragCtrl = Util.GetGameObject(root, "Bg/Ctrl")
|
||||
this.effectRoot = Util.GetGameObject(root, "effectRoot")
|
||||
this.buffTip = Util.GetGameObject(this.effectRoot, "money")
|
||||
-- 箱子
|
||||
this.boxEffect = Util.GetGameObject(root, "boxRoot/UI_effect_GuaJi_Box_BaoDian")
|
||||
this.playerViews = {}
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
function this:AddListener()
|
||||
|
||||
end
|
||||
|
||||
function this:RemoveListener()
|
||||
|
||||
end
|
||||
|
||||
function this:Init()
|
||||
this.isClose = false
|
||||
this.isCanUseIconList = 0
|
||||
-- 初始化加载地图块数据
|
||||
this:LoadMapData()
|
||||
-- 加载一个小人
|
||||
local tempconfig = ConfigManager.GetConfigData(ConfigName.ChallengeMapConfig,m_curMapId)
|
||||
if not this.playerViews[0] then
|
||||
--Log(m_curMapId)
|
||||
if ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.guajigongneng) then
|
||||
iconNum = 20
|
||||
local randomNum = 8--math.random(2,3)
|
||||
PlayerManager.GetFightMapPlayerNPCData(randomNum,function(NPCList)
|
||||
if this.isClose then
|
||||
return
|
||||
end
|
||||
--Log("NPCList:"..LengthOfTable(NPCList))
|
||||
local index = 1
|
||||
local area = monsterArea[m_curMapId]
|
||||
local suv = startUV[m_curMapId]
|
||||
for k,v in pairs(NPCList) do
|
||||
local index1 = math.random(area.x_pos.min,suv.u - 3)
|
||||
local index2 = math.random(suv.u + 3,area.x_pos.max)
|
||||
local index3 = math.random(1,2)
|
||||
local index4 = math.random(area.y_pos.min,area.y_pos.max)
|
||||
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)
|
||||
else
|
||||
iconNum = 4
|
||||
end
|
||||
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
|
||||
|
||||
-- 设置相机初始化位置
|
||||
local v4 = this.playerViews[0].transform.localPosition
|
||||
v4.z = -50
|
||||
TileMapView.SetCameraPos(v4)
|
||||
-- 初始化两个地图标志
|
||||
this.LoadMapIcon()
|
||||
this.SetPlayerViewWalk()
|
||||
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
|
||||
index = math.floor((curChapter - 1) % 5 + 1)
|
||||
-- --Log(curChapter)
|
||||
-- --Log(index)
|
||||
m_curMapId = mapIdList[index]
|
||||
-- LogPink("#mapIdList:"..#mapIdList.." m_curMapId:"..m_curMapId.." curChapter:"..curChapter.." index:"..index.." State:"..tostring(FightPointPassManager.isOpenNewChapter))
|
||||
TileMapView.AwakeInit(this.mapRoot, m_curMapId, nil, Vector2.New(180, 180))
|
||||
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)
|
||||
|
||||
-- 设置不点击
|
||||
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
|
||||
|
||||
--加载图标icon
|
||||
function this.LoadMapIcon()
|
||||
this.iconList = {}
|
||||
this.selectIconList = {}
|
||||
--FightPointPassManager.isBeginFight = false
|
||||
for i = 1, iconNum do
|
||||
this.LoadPointIcon(false)
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
end,1.5)
|
||||
this.startTimer:Start()
|
||||
end
|
||||
|
||||
this.isCanUseIconList = 0
|
||||
function this.RequestIconList()
|
||||
--Log(" this.isCanUseIconList:".. tostring(this.isCanUseIconList))
|
||||
if this.isCanUseIconList == 0 then
|
||||
this.isCanUseIconList = 1
|
||||
--Log(" this.iconList:".. tostring(this.iconList))
|
||||
return this.iconList
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function this.ReleaseIconList()
|
||||
this.isCanUseIconList = 0
|
||||
end
|
||||
|
||||
function this.AsideTriggerJudge(data,isSelf,_userData)
|
||||
--Log("data:"..tostring(data).." pos:"..tostring(Map_UV2Pos(data.u - 1, data.v).. " isSelf:"..tostring(isSelf).. " Self:"..tostring(_userData).. " Self:".." "..tostring(_userData.userId)))
|
||||
local isGetIconList = false
|
||||
local iconList = this.iconList
|
||||
if not this.threads then
|
||||
this.threads = {}
|
||||
end
|
||||
if this.threads[_userData.userId] then
|
||||
coroutine.stop(this.threads[_userData.userId])
|
||||
this.threads[_userData.userId] = nil
|
||||
end
|
||||
this.threads[_userData.userId] = coroutine.start(function()
|
||||
while(not isGetIconList) do
|
||||
if this.isClose and this.isClose == true then
|
||||
coroutine.stop(this.threads[_userData.userId])
|
||||
this.threads[_userData.userId] = nil
|
||||
this.ReleaseIconList()
|
||||
coroutine.yield()
|
||||
end
|
||||
--Log("没有得到访问权")
|
||||
iconList = this.RequestIconList()
|
||||
if iconList and LengthOfTable(iconList) > 0 then
|
||||
isGetIconList = true
|
||||
else
|
||||
--Log("等待中")
|
||||
coroutine.wait(0.1)
|
||||
end
|
||||
end
|
||||
--Log("得到了访问权")
|
||||
|
||||
-- for k,v in pairs(iconList) do
|
||||
-- --Log("iconList k:"..tostring(k))
|
||||
-- end
|
||||
|
||||
local selfPos = Map_UV2Pos(data.u, data.v)
|
||||
--Log("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
|
||||
--Log("posList pos:"..tostring(pos))
|
||||
if iconList[pos] and this.HasSelectIconList(pos,_userData.userId) then
|
||||
this.RemoveSelectIconList(_userData.eventPointPos)
|
||||
this.AddSelectIconList(pos,_userData.userId)
|
||||
--Log("发送了消息")
|
||||
Game.GlobalEvent:DispatchEvent(GameEvent.GuaJi.getEvent,{goData = _userData, event = iconList[pos], pos = pos})
|
||||
coroutine.stop(this.threads[_userData.userId])
|
||||
this.threads[_userData.userId] = nil
|
||||
this.ReleaseIconList()
|
||||
coroutine.yield()
|
||||
elseif FightPointPassManager.talkingTime == 0 or (GetTimeStamp() - FightPointPassManager.talkingTime >= 60) then
|
||||
if isSelf and this.playerViews and LengthOfTable(this.playerViews) > 1 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 then
|
||||
FightPointPassManager.talkingTime = GetTimeStamp()
|
||||
--Log("发送了消息")
|
||||
Game.GlobalEvent:DispatchEvent(GameEvent.GuaJi.getEvent,{goData = _userData,event = v,pos = pos})
|
||||
coroutine.stop(this.threads[_userData.userId])
|
||||
this.threads[_userData.userId] = nil
|
||||
this.ReleaseIconList()
|
||||
coroutine.yield()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--Log("周围没有事件")
|
||||
if this.threads[_userData.userId] then
|
||||
coroutine.stop( this.threads[_userData.userId])
|
||||
this.threads[_userData.userId] = nil
|
||||
end
|
||||
this.ReleaseIconList()
|
||||
coroutine.yield()
|
||||
end)
|
||||
end
|
||||
|
||||
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)
|
||||
if this.selectIconList[pos] then
|
||||
this.selectIconList[pos] = nil
|
||||
end
|
||||
end
|
||||
|
||||
--- 生成一个图标, 传入校验权重值rand, 是否使用动画
|
||||
function this.LoadPointIcon(useAnim)
|
||||
if LengthOfTable(this.iconList) >= iconNum then
|
||||
return
|
||||
end
|
||||
-- 随机一个坐标
|
||||
local area = monsterArea[m_curMapId]
|
||||
--Log("area.x_pos.min:"..tostring(area.x_pos.min).." area.x_pos.max:"..tostring(area.x_pos.max))
|
||||
local u = math.random(area.x_pos.min, area.x_pos.max)
|
||||
--Log("area.y_pos.min:"..tostring(area.y_pos.min).." area.y_pos.max:"..tostring(area.y_pos.max))
|
||||
local v = math.random(area.y_pos.min, area.y_pos.max)
|
||||
--Log("u:"..tostring(u).." v:"..tostring(v))
|
||||
local pos = Map_UV2Pos(u, v)
|
||||
|
||||
local mapPointId = math.random(1,maxIcon)
|
||||
-- 随机出来的位置已经有图标,则再次随机
|
||||
if this.iconList[pos] or pos == 1285 or this.IsHaveBitchNear(pos) then
|
||||
this.LoadPointIcon()
|
||||
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
|
||||
|
||||
---------------------------------------------------------------------------------------------设置特效层级
|
||||
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 =================================
|
||||
|
||||
-- 删除一个图标
|
||||
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
|
||||
|
||||
--- =============== 行动中的表现处理 =====================================================
|
||||
|
||||
-- 退出战斗状态
|
||||
function this.BattleEnd(selectPointPos,isSelf)
|
||||
--Log("战斗结束回调")
|
||||
-- 删点前隐藏那个东西
|
||||
if this.iconList[selectPointPos] then
|
||||
this.iconList[selectPointPos]:ShowDialogue(false)
|
||||
end
|
||||
-- 删除图标
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
--- ==================== 角色行走 =====================================
|
||||
function this.OnClickTile(u, v)
|
||||
--Log("UIManager.width is -- " .. UIManager.width .. " and Height is " .. UIManager.height)
|
||||
local v2 = RectTransformUtility.WorldToScreenPoint(TileMapView.GetCamera(), TileMapView.GetLiveTilePos(u, v))
|
||||
v2 = v2 / math.min(Screen.width/1080, Screen.height/1920)
|
||||
--Log(string.format("当前点击坐标(%s, %s)", u, v))
|
||||
--Log(string.format("转换后的屏幕坐标是(%s, %s)", v2.x, v2.y))
|
||||
end
|
||||
|
||||
|
||||
-- 停止一切该死的行为
|
||||
function this.StopAction()
|
||||
for k,v in pairs(this.playerViews) do
|
||||
v:StopAction()
|
||||
end
|
||||
if this.moneyEffect then
|
||||
this.moneyEffect.gameObject:SetActive(false)
|
||||
end
|
||||
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
|
||||
|
||||
--- ======================================================================
|
||||
function this.OnGameOver()
|
||||
-- Log("OnGameOver")
|
||||
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
|
||||
end
|
||||
if this.mapRoot then -- 避免不是主动退出
|
||||
-- Log("注销一次地图资源")
|
||||
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
|
||||
|
||||
this.mapRoot = nil
|
||||
this.moneyEffect = nil
|
||||
end
|
||||
|
||||
function this:OnClose()
|
||||
-- Log("关闭挂机:OnClose")
|
||||
if this.startTimer then
|
||||
this.startTimer:Stop()
|
||||
end
|
||||
this.startTimer = nil
|
||||
this.StopAction()
|
||||
this.OnGameOver()
|
||||
end
|
||||
|
||||
function this:Dispose()
|
||||
if this.startTimer then
|
||||
this.startTimer:Stop()
|
||||
end
|
||||
this.startTimer = nil
|
||||
this.StopAction()
|
||||
this.OnGameOver()
|
||||
end
|
||||
|
||||
return this
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fad1407de48c2e848a3e9cd2245f5e60
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,869 @@
|
|||
SingleFightPlayerView = {}
|
||||
local mapIconConfig = ConfigManager.GetConfig(ConfigName.MainMapIconConfig)
|
||||
local iconAction = require("Modules/Fight/View/FightMapIconShowView")
|
||||
local GlobalSysConfig = ConfigManager.GetConfig(ConfigName.GlobalSystemConfig)
|
||||
-- 角色对话气泡位置
|
||||
local m_roleTextPos = {
|
||||
[3] = {pos = Vector3.New(172, 200, 0), angleOffset = 180}, -- 角色朝左, 气泡在右
|
||||
[4] = {pos = Vector3.New(-177, 204, 0), angleOffset = 0} -- 反之
|
||||
}
|
||||
|
||||
local namePos = {
|
||||
[1] = {pos = Vector3.New(-1.86, 185.3, 0)}, -- 角色朝左,气泡在左
|
||||
[2] = {pos = Vector3.New(-1.86, 273.5, 0)} -- 反之
|
||||
}
|
||||
-- 老头对话气泡位置
|
||||
local m_oldManTextPos = {
|
||||
[3] = {pos = Vector3.New(-176, 130, 0), angleOffset = 0}, -- 角色朝左,气泡在左
|
||||
[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.goData
|
||||
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
|
||||
b.transform = gameObject.transform
|
||||
setmetatable(b, { __index = SingleFightPlayerView })
|
||||
return b
|
||||
end
|
||||
|
||||
local sortingorder = 0
|
||||
local hitRootPath = "UI_Map_XunBaoEffect_hit"
|
||||
local npc1 = "live2d_npc_map_boy"
|
||||
local npc2 = "live2d_npc_map_nv"
|
||||
-- 飘血资源
|
||||
local hurtRes = "FloatingText"
|
||||
function SingleFightPlayerView:InitComponent()
|
||||
self.root = Util.GetGameObject(self.gameObject, "root")
|
||||
self.ui = Util.GetGameObject(self.root, "ui")
|
||||
self.roleRoot = Util.GetGameObject(self.ui,"roleRoot")
|
||||
Util.GetGameObject(self.ui, "lizi effect").gameObject:SetActive(false)
|
||||
self.battleEffect = Util.GetGameObject(self.ui, "quickBattleEffect")
|
||||
self.bLeaderIsIdle = true
|
||||
-- 临时代码
|
||||
self.dialogueRoot = Util.GetGameObject(self.ui, "Dialogue")
|
||||
self.context = Util.GetGameObject(self.dialogueRoot, "Text"):GetComponent("Text")
|
||||
|
||||
-- buff特效
|
||||
self.buffEffectRoot = Util.GetGameObject(self.roleRoot, "effectRoot")
|
||||
Util.SetParticleScale(self.buffEffectRoot, 2)
|
||||
-- 攻击buff
|
||||
self.buffAttack = Util.GetGameObject(self.buffEffectRoot, "r_MapEffect_NewEvent_011")
|
||||
self.buffAttack:SetActive(false)
|
||||
-- 防御buff
|
||||
self.buffDefend = Util.GetGameObject(self.buffEffectRoot, "r_MapEffect_NewEvent_012")
|
||||
self.buffEffectRoot:SetActive(false)
|
||||
|
||||
-- 隐藏一堆东西
|
||||
Util.GetGameObject(self.ui,"arrow"):SetActive(false)
|
||||
Util.GetGameObject(self.ui,"pos"):SetActive(false)
|
||||
Util.GetGameObject(self.ui,"blood"):SetActive(false)
|
||||
Util.GetGameObject(self.ui,"optionCancelBtn"):SetActive(false)
|
||||
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
|
||||
self.m_roleFaceDir = Vector2.New(-1, 0)
|
||||
--角色停止行走时的朝向
|
||||
self.eventpoint = 0
|
||||
--当前触发的事件点
|
||||
self.eventPointPos = nil
|
||||
self.nameDi = Util.GetGameObject(self.ui, "nemeDi")
|
||||
self.name = Util.GetGameObject(self.nameDi, "name"):GetComponent("Text")
|
||||
--修行标识
|
||||
self.PracticeIcon = Util.GetGameObject(self.name.gameObject, "Icon")
|
||||
self.PracticeIcon:SetActive(false)
|
||||
|
||||
self.hurtNum = {}
|
||||
end
|
||||
|
||||
function SingleFightPlayerView:OnOpen(parent)
|
||||
self.parent = parent
|
||||
self.hitEffect = poolManager:LoadAsset(hitRootPath, PoolManager.AssetType.GameObject)
|
||||
self.hitEffect.transform:SetParent(parent.effectRoot.transform)
|
||||
self.hitEffect.transform.localScale = Vector3.one
|
||||
self.hitEffect:SetActive(false)
|
||||
|
||||
if not self.buffTipList then
|
||||
self.buffTipList = {}
|
||||
end
|
||||
-- buff飘字
|
||||
for i = 1, 3 do
|
||||
if not self.buffTipList[i] then
|
||||
self.buffTipList[i] = newObjToParent(parent.buffTip, parent.effectRoot)
|
||||
self.buffTipList[i].transform.localScale = Vector3.New(1.2, 1.2, 1.2)
|
||||
self.buffTipList[i]:SetActive(false)
|
||||
end
|
||||
end
|
||||
|
||||
if not self.hurtNum then
|
||||
self.hurtNum = {}
|
||||
end
|
||||
for i = 1, 3 do
|
||||
self.hurtNum[i] = poolManager:LoadAsset(hurtRes, PoolManager.AssetType.GameObject)
|
||||
-- 设置父级
|
||||
self.hurtNum[i].transform:SetParent(parent.effectRoot.transform)
|
||||
self.hurtNum[i].transform.localScale = Vector3.New(0.5, 0.5, 0.5)
|
||||
Util.GetGameObject(self.hurtNum[i], "anim"):GetComponent("Canvas").sortingOrder = parent.GetCurLayer()
|
||||
self.hurtNum[i]:SetActive(false)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function SingleFightPlayerView:SetData(u,v,isSelf,data)
|
||||
self.isclose = false
|
||||
self._PlayTimeStamp = 0
|
||||
if isSelf then
|
||||
self.ui:GetComponent("Canvas").worldCamera = TileMapView.GetCamera()
|
||||
end
|
||||
self.isSelf = isSelf
|
||||
|
||||
local v3 = TileMapView.GetLiveTilePos(u, v)
|
||||
self.gameObject.transform.localPosition = Vector3(v3.x, v3.y, v3.z - 10)
|
||||
self.gameObject.transform.localScale = Vector3.one * 1.5
|
||||
|
||||
if self.playerLiveView then
|
||||
self.playerLiveView:OnClose()
|
||||
self.playerLiveView = nil
|
||||
end
|
||||
|
||||
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,sortingorder)
|
||||
self.playerLiveView:RemoveTitleCanvas()
|
||||
self.nameDi.gameObject:SetActive(false)
|
||||
--如果修行开启设置修行标识
|
||||
if ActTimeCtrlManager.SingleFuncState(108) then
|
||||
self.PracticeIcon:SetActive(true)
|
||||
PracticeManager.SetPracticeIcon(self.PracticeIcon,PracticeManager.PracticeLevel)
|
||||
end
|
||||
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 or data.roleUid or data.id
|
||||
self.playerLiveView = PlayerLiveView:New(self.roleRoot,2, {
|
||||
skin = data.userSkin,
|
||||
sex = data.sex,
|
||||
ride = data.userMount,
|
||||
designation = data.userTitle,
|
||||
},sortingorder)
|
||||
self.playerLiveView:SetNameHeight(1.5)
|
||||
self.playerLiveView:RemoveTitleCanvas()
|
||||
if data.userMount == 0 then
|
||||
self.nameDi.transform.localPosition = namePos[1].pos
|
||||
else
|
||||
self.nameDi.transform.localPosition = namePos[2].pos
|
||||
end
|
||||
self.name.text = data.userName or data.name
|
||||
self.nameDi.gameObject:SetActive(true)
|
||||
local _lv = data.lv or data.level or data.userLevel
|
||||
if _lv and _lv >= GlobalSysConfig[108].OpenRules[2] then
|
||||
self.PracticeIcon:SetActive(true)
|
||||
PracticeManager.SetPracticeIcon(self.PracticeIcon,data.practiceLevel)
|
||||
end
|
||||
end
|
||||
self.playerLiveView:OnOpen(GetPlayerRoleSingleConFig().Scale2)
|
||||
self.playerLiveView:OnSortingOrderChange(sortingorder)
|
||||
if isSelf then
|
||||
self.playerLiveView:SetSelfTag()
|
||||
self.playerLiveView:SetEffectScale(2)
|
||||
end
|
||||
self.playerLiveView.name = "npc"
|
||||
|
||||
--角色当前的uv
|
||||
self.roleCurPos = TileMapView.GetMapData():GetMapData(u, v)
|
||||
-- LogWarn(self.roleCurPos.u.."||"..self.roleCurPos.v)
|
||||
|
||||
self.bLeaderIsIdle = true
|
||||
self:SetWalkDir(WALK_DIR.LAUCH)
|
||||
self:HideSomeTrash()
|
||||
self:OnSortingOrderChange(self.parent.GetCurLayer())
|
||||
|
||||
--当前状态
|
||||
self.state = 0
|
||||
PlayUIAnim(self.gameObject)
|
||||
end
|
||||
|
||||
function SingleFightPlayerView:SetWalkDir(dir)
|
||||
if self.playerLiveView then
|
||||
self.playerLiveView:SetWalkDir(dir)
|
||||
end
|
||||
end
|
||||
|
||||
function SingleFightPlayerView:SetBattleState(state)
|
||||
self.buffEffectRoot.gameObject:SetActive(state)
|
||||
end
|
||||
|
||||
function SingleFightPlayerView:HideSomeTrash()
|
||||
for i = 1, 3 do
|
||||
self.buffTipList[i]:SetActive(false)
|
||||
end
|
||||
end
|
||||
|
||||
function SingleFightPlayerView:OnSortingOrderChange(orginLayer)
|
||||
Util.AddParticleSortLayer(self.hitEffect, orginLayer - sortingorder)
|
||||
if #self.hurtNum > 0 then -- 初始化完成
|
||||
for i = 1, 3 do
|
||||
Util.GetGameObject(self.hurtNum[i], "anim"):GetComponent("Canvas").sortingOrder = orginLayer - sortingorder
|
||||
end
|
||||
end
|
||||
sortingorder = orginLayer
|
||||
end
|
||||
|
||||
-- 撞击事件结束后的回调
|
||||
function SingleFightPlayerView:hitCallBack(pos)
|
||||
self:SetWalkDir(WALK_DIR.IDLE_FRONT)
|
||||
self.state = 0
|
||||
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)
|
||||
end, 0.5)
|
||||
self.targetTimer:Start()
|
||||
end
|
||||
|
||||
-- 随机一个位置给大爷走走
|
||||
function SingleFightPlayerView:SetRoleHitTarget()
|
||||
if self.thread then
|
||||
coroutine.stop(self.thread)
|
||||
self.thread=nil
|
||||
end
|
||||
self.thread = coroutine.start(function()
|
||||
--LogGreen("随机一个位置给大爷走走")
|
||||
--local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf)
|
||||
--self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf)
|
||||
local pos
|
||||
while not pos do
|
||||
if self.isclose then
|
||||
coroutine.yield()
|
||||
end
|
||||
coroutine.wait(0.01)
|
||||
pos = self:SelectTargetPos()
|
||||
end
|
||||
--LogGreen("选中的点:"..tostring(pos).." "..tostring(self.userId))
|
||||
local pathlist = self:SetRoleWalk(pos)
|
||||
self:RoleMove(pathlist)
|
||||
end)
|
||||
end
|
||||
|
||||
-- 选择一个目标位置, 就近原则
|
||||
function SingleFightPlayerView:SelectTargetPos()
|
||||
local iconList = self.parent.RequestIconList()
|
||||
--LogGreen("iconList:"..tostring(iconList))
|
||||
if iconList and LengthOfTable(iconList) > 0 then
|
||||
--LogGreen("iconList:"..tostring(LengthOfTable(iconList)))
|
||||
local selectIconList = {}
|
||||
local minDis = 999
|
||||
for i, v in pairs(iconList) do
|
||||
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)
|
||||
minDis = minDis <= dis and minDis or dis
|
||||
local data = {}
|
||||
data.dis = dis
|
||||
data.x_axis = targetU
|
||||
data.pos = i
|
||||
selectIconList[#selectIconList + 1] = data
|
||||
end
|
||||
end
|
||||
|
||||
-- 取出目标值. 相等则要x最小的
|
||||
if #selectIconList > 1 then
|
||||
table.sort(selectIconList, function (a, b)
|
||||
if a.dis == b.dis then
|
||||
return a.x_axis < b.x_axis
|
||||
else
|
||||
return a.dis < b.dis
|
||||
end
|
||||
end )
|
||||
end
|
||||
|
||||
-- 万一图标还没生出来
|
||||
local targetPos = 0
|
||||
--LogGreen("#selectIconList:"..#selectIconList.." self.uid:"..self.userId)
|
||||
if #selectIconList > 1 then
|
||||
self.parent.AddSelectIconList(selectIconList[1].pos,self.userId)
|
||||
targetPos = self:GetTargetPos(selectIconList[1].pos)
|
||||
self.parent.RemoveSelectIconList(self.eventPointPos)
|
||||
else
|
||||
self.parent.ReleaseIconList()
|
||||
return
|
||||
end
|
||||
self.parent.ReleaseIconList()
|
||||
return targetPos
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取当前图标的目标值,传入图标的坐标值, 就近原则
|
||||
function SingleFightPlayerView:GetTargetPos(iconPos)
|
||||
local u0, v0 = Map_Pos2UV(iconPos)
|
||||
local posList = {
|
||||
[1] = Vector2.New(u0, v0 - 1), -- 上
|
||||
[2] = Vector2.New(u0, v0 + 1), -- 下
|
||||
[3] = Vector2.New(u0 - 1, v0), -- 左
|
||||
[4] = Vector2.New(u0 + 1, v0), -- 右
|
||||
}
|
||||
local newList = {}
|
||||
|
||||
for i = 1, 4 do
|
||||
local dis = math.abs(self.roleCurPos.u - posList[i].x) + math.abs(self.roleCurPos.v - posList[i].y)
|
||||
local data = {}
|
||||
data.dis = dis
|
||||
data.axis = posList[i]
|
||||
data.index = i
|
||||
newList[#newList + 1] = data
|
||||
end
|
||||
|
||||
if #newList > 1 then
|
||||
table.sort(newList, function (a, b)
|
||||
if a.dis == b.dis then
|
||||
return a.axis.x < b.axis.x
|
||||
else
|
||||
return a.dis < b.dis
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local pos = posList[newList[1].index]
|
||||
return pos
|
||||
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
|
||||
end
|
||||
|
||||
function SingleFightPlayerView:RoleMove(pathList)
|
||||
if not pathList or #pathList == 0 then
|
||||
self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf,self)
|
||||
return
|
||||
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]
|
||||
local v3 = TileMapView.GetLiveTilePos(data.u, data.v)
|
||||
self.callList:Push(function ()
|
||||
self:SetRoleDirAction(data.u, data.v)
|
||||
self.roleCurPos = data
|
||||
local speed = 0.5
|
||||
self.gameObject.transform:DOLocalMove(Vector3(v3.x, v3.y, v3.z - 10), speed, false):OnStart(function () end):OnUpdate(function() --TODO:测试速度
|
||||
if self.isSelf and not self.isclose then
|
||||
self:PlayStepSound()
|
||||
local v4 = self.gameObject.transform.localPosition
|
||||
v4.z = TileMapView.ViewCameraPos.z
|
||||
TileMapView.SetCameraPos(v4)
|
||||
end
|
||||
end):OnComplete(function ()
|
||||
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
|
||||
|
||||
function SingleFightPlayerView:PlayerMove()
|
||||
self.bLeaderIsIdle = false
|
||||
end
|
||||
function SingleFightPlayerView:PlayStepSound()
|
||||
local curTimeStamp = GetTimeStamp()
|
||||
if curTimeStamp - self._PlayTimeStamp >= 0.3 then
|
||||
self._PlayTimeStamp = curTimeStamp
|
||||
SoundManager.PlaySound(SoundConfig.Sound_FootStep.. 8) --math.random(1,7))
|
||||
end
|
||||
end
|
||||
|
||||
-- 角色行走结束
|
||||
function SingleFightPlayerView:RoleWalkEnd(eventPoint)
|
||||
self.callList:Clear()
|
||||
self:PlayerIdle()
|
||||
if self.eventPointPos then
|
||||
local iconType = self.eventPointPos.iconId or -1
|
||||
if iconType == -1 then
|
||||
self.selectPointPos = Map_UV2Pos(self.eventPointPos.roleCurPos.u,self.eventPointPos.roleCurPos.v)
|
||||
else
|
||||
self.selectPointPos = eventPoint.pos
|
||||
end
|
||||
--LogGreen("eventPoint.pos:"..tostring(self.selectPointPos))
|
||||
-- 检测方向
|
||||
self:SetRoleDir(self.roleCurPos.u * 256 + self.roleCurPos.v, self.selectPointPos)
|
||||
-- 设置角色纵深
|
||||
self:SetRoleLayer(self:IsRoleFront(self.selectPointPos))
|
||||
self:SetIconShow(eventPoint)
|
||||
else
|
||||
self:SetRoleHitTarget()
|
||||
end
|
||||
end
|
||||
|
||||
---检查角色与图标的纵深关系
|
||||
function SingleFightPlayerView:IsRoleFront(pos)
|
||||
local v0 = self.roleCurPos.v
|
||||
local u, v = Map_Pos2UV(pos)
|
||||
return v0 >= v
|
||||
end
|
||||
|
||||
|
||||
function SingleFightPlayerView:PlayerIdle()
|
||||
self.bLeaderIsIdle = true
|
||||
if self.SkeletonGraphic and self.SkeletonGraphic.AnimationState then
|
||||
self.SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
||||
self.SkeletonGraphic.transform.localEulerAngles = Vector3.zero
|
||||
end
|
||||
self.curDir = nil
|
||||
end
|
||||
|
||||
-- 角色停止行走时的朝向
|
||||
function SingleFightPlayerView:SetRoleDir(rolePos, iconPos)
|
||||
local u0, v0 = Map_Pos2UV(rolePos)
|
||||
local u, v = Map_Pos2UV(iconPos)
|
||||
if v0 == v then
|
||||
if u0 > u then
|
||||
self.m_roleFaceDir = Vector2.New(-1, 0)
|
||||
--LogGreen("他要朝左左左左左")
|
||||
self.eventpoint = 3
|
||||
else
|
||||
self.m_roleFaceDir = Vector2.New(1, 0)
|
||||
--LogGreen("他要朝右右右右")
|
||||
self.eventpoint = 4
|
||||
end
|
||||
else
|
||||
if v0 > v then
|
||||
self.m_roleFaceDir = Vector2.New(0, 1)
|
||||
--LogGreen("他要朝上上上上")
|
||||
self.eventpoint = 2
|
||||
else
|
||||
self.m_roleFaceDir = Vector2.New(0, -1)
|
||||
--LogGreen("他要朝下下下下下下")
|
||||
self.eventpoint = 1
|
||||
end
|
||||
end
|
||||
self:SetWalkDir(self.eventpoint)
|
||||
end
|
||||
|
||||
---设置角色纵深
|
||||
---@param isFront 设置是否角色在前
|
||||
function SingleFightPlayerView:SetRoleLayer(isFront)
|
||||
local z_axis = isFront and -10 or 10
|
||||
local v3 = self.gameObject.transform.localPosition
|
||||
self.gameObject.transform.localPosition = Vector3(v3.x, v3.y, z_axis)
|
||||
end
|
||||
|
||||
-- 角色相关
|
||||
function SingleFightPlayerView:SetRoleDirAction(u, v, isBack)
|
||||
local dU = isBack and self.roleCurPos.u - u or u - self.roleCurPos.u
|
||||
local dV = isBack and self.roleCurPos.v - v or v - self.roleCurPos.v
|
||||
|
||||
if dU > 0 then
|
||||
self:SetWalkDir(WALK_DIR.RUN_RIGHT)
|
||||
elseif dU < 0 then
|
||||
self:SetWalkDir(WALK_DIR.RUN_LEFT)
|
||||
elseif dV < 0 then
|
||||
self:SetWalkDir(WALK_DIR.RUN_UP)
|
||||
elseif dV > 0 then
|
||||
self:SetWalkDir(WALK_DIR.RUN_DOWN)
|
||||
end
|
||||
end
|
||||
|
||||
function SingleFightPlayerView:StackPop()
|
||||
if self.callList:Count() > 0 then
|
||||
self.callList:Pop()()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 设置遇到图标时的表现
|
||||
function SingleFightPlayerView:SetIconShow(_eventpoint)
|
||||
local iconType = self.eventPointPos.iconId or -1
|
||||
--LogGreen("iconType:"..iconType)
|
||||
local index = (self.eventpoint == 4 or self.eventpoint == 1) and 4 or 3
|
||||
if iconType == -1 then
|
||||
--显示对话框
|
||||
self.dialogueRoot.gameObject:SetActive(true)
|
||||
self.dialogueRoot.transform.localEulerAngles = Vector3.New(0, m_roleTextPos[index].angleOffset, 0)
|
||||
self.context.transform.localEulerAngles = Vector3.New(0, m_roleTextPos[index].angleOffset, 0)
|
||||
self.dialogueRoot.transform.localPosition = m_roleTextPos[index].pos
|
||||
local str = ""
|
||||
local strList = {}
|
||||
if self.isSelf then
|
||||
str = ConfigManager.GetConfigData(ConfigName.SpecialConfig,111).Value
|
||||
else
|
||||
str = ConfigManager.GetConfigData(ConfigName.SpecialConfig,112).Value
|
||||
end
|
||||
strList = string.split(str,"#")
|
||||
self.context.text = strList[FightPointPassManager.randomNum] or Language[12322]
|
||||
self:NotBattleShow()
|
||||
elseif iconType == 8 or iconType == 11 then -- 宝箱
|
||||
self:SetWalkDir(WALK_DIR.JINGYA)
|
||||
if self.isSelf then
|
||||
self.dialogueRoot.gameObject:SetActive(true)
|
||||
self.dialogueRoot.transform.localEulerAngles = Vector3.New(0, m_roleTextPos[index].angleOffset, 0)
|
||||
self.context.transform.localEulerAngles = Vector3.New(0, m_roleTextPos[index].angleOffset, 0)
|
||||
self.dialogueRoot.transform.localPosition = m_roleTextPos[index].pos
|
||||
local str = ""
|
||||
local strList = {}
|
||||
str = ConfigManager.GetConfigData(ConfigName.MainMapIconConfig,iconType).Desc
|
||||
strList = string.split(str,"#")
|
||||
local num = math.random(1,#strList)
|
||||
self.context.text = strList[num]
|
||||
local boxPos = self.selectPointPos
|
||||
Timer.New(function()
|
||||
if self.state == 1 then
|
||||
self:SetEffect(boxPos)
|
||||
end
|
||||
end,1.5):Start()
|
||||
end
|
||||
self:NotBattleShow()
|
||||
elseif iconType == 7 then -- NPC, 不一样的BB
|
||||
self:SetWalkDir(WALK_DIR.JINGYA)
|
||||
if self.isSelf then
|
||||
local str, str1 = ""
|
||||
local strList,strList1 = {}
|
||||
str = ConfigManager.GetConfigData(ConfigName.MainMapIconConfig,iconType).Desc
|
||||
str1 = ConfigManager.GetConfigData(ConfigName.MainMapIconConfig,iconType).DescNPC
|
||||
strList = string.split(str,"#")
|
||||
strList1 = string.split(str1,"#")
|
||||
local num = math.random(1,#strList)
|
||||
|
||||
self.dialogueRoot.gameObject:SetActive(true)
|
||||
self.dialogueRoot.transform.localEulerAngles = Vector3.New(0, m_roleTextPos[index].angleOffset, 0)
|
||||
self.context.transform.localEulerAngles = Vector3.New(0, m_roleTextPos[index].angleOffset, 0)
|
||||
self.dialogueRoot.transform.localPosition = m_roleTextPos[index].pos
|
||||
self.context.text = strList[num]
|
||||
|
||||
-- 设置老头
|
||||
local oldManAngle = Vector3.New(0, m_oldManTextPos[index].angleOffset, 0)
|
||||
self.eventPointPos:SetDialogueDir(m_oldManTextPos[index].pos, oldManAngle)
|
||||
self.eventPointPos:ShowDialogue(false)
|
||||
self.eventPointPos:SetDialogueStr(strList1[num])
|
||||
Timer.New(function()
|
||||
if self.dialogueRoot then
|
||||
if self.dialogueRoot.gameObject then
|
||||
self.dialogueRoot.gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
if self.state == 1 then
|
||||
self.eventPointPos:ShowDialogue(true)
|
||||
self:NotBattleShow()
|
||||
end
|
||||
end,1):Start()
|
||||
else
|
||||
self:NotBattleShow()
|
||||
end
|
||||
self:NotBattleShow()
|
||||
else -- 战斗
|
||||
-- 设置战斗状态
|
||||
self:EnterBattle()
|
||||
self.dialogueRoot.gameObject:SetActive(false)
|
||||
self:private_ShakeByTimes(_eventpoint, self.m_roleFaceDir, mapIconConfig[iconType].HurtNum,1,function()
|
||||
self:hitCallBack(_eventpoint.pos)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
-- 宝箱特效的位置
|
||||
local boxEffectPos = {
|
||||
[1] = Vector3.New(44, 140, 0),
|
||||
[2] = Vector3.New(35, 188, 0),
|
||||
[3] = Vector3.New(169, 168, 0),
|
||||
}
|
||||
|
||||
function SingleFightPlayerView:SetEffect(pos)
|
||||
local boxState = FightPointPassManager.GetBoxState()
|
||||
boxState = boxState == 0 and 1 or boxState
|
||||
local tartPos = boxEffectPos[boxState]
|
||||
|
||||
--LogGreen("boxState:" ..boxState)
|
||||
if self.parent.moneyEffect then
|
||||
self.parent.moneyEffect:GetComponent("RectTransform").anchoredPosition = SetObjPosByUV(pos)
|
||||
Util.ClearTrailRender(self.parent.moneyEffect)
|
||||
self:SetBoxEffect(false, Vector3.zero)
|
||||
self.parent.moneyEffect:SetActive(true)
|
||||
self.parent.moneyEffect:GetComponent("RectTransform"):DOAnchorPos(Vector2.New(tartPos.x + 88, tartPos.y + 359), 0.6, false):OnComplete(function ()
|
||||
self:SetBoxEffect(true, boxState)
|
||||
if self.parent.moneyEffect then
|
||||
self.parent.moneyEffect:SetActive(false)
|
||||
end
|
||||
end)
|
||||
end
|
||||
SoundManager.PlaySound(SoundConfig.Sound_FightArea_Gold)
|
||||
end
|
||||
|
||||
-- 设置宝箱特效s
|
||||
function SingleFightPlayerView:SetBoxEffect(isShow, state)
|
||||
if not isShow then
|
||||
if self.parent.boxEffect then
|
||||
self.parent.boxEffect:SetActive(false)
|
||||
end
|
||||
else
|
||||
self.parent.boxEffect.transform.localPosition = boxEffectPos[state]
|
||||
self.parent.boxEffect:SetActive(true)
|
||||
end
|
||||
end
|
||||
|
||||
function SingleFightPlayerView:private_ShakeByTimes(_point, roleFaceDir, shakeTime, index, func)
|
||||
local point = _point.event
|
||||
local icon = point.go
|
||||
local start = index
|
||||
local iconType = point.iconId
|
||||
local leftNum = math.floor(start % 2)
|
||||
-- 主动打击者
|
||||
local go = leftNum == 1 and self.roleRoot or icon
|
||||
|
||||
-- 受击对象
|
||||
local hurtGo = leftNum ~= 1 and self.roleRoot or Util.GetGameObject(icon, "root")
|
||||
|
||||
local isReverse = leftNum == 0
|
||||
local objPos = isReverse and self.roleCurPos.u * 256 + self.roleCurPos.v or _point.pos
|
||||
|
||||
local end_callBack = function() -- 受击结束动画
|
||||
self.hitEffect:SetActive(false)
|
||||
--LogGreen("end_callBack:"..start)
|
||||
if start >= shakeTime then
|
||||
-- 执行最终回调
|
||||
func()
|
||||
return
|
||||
else
|
||||
start = start + 1
|
||||
self:private_ShakeByTimes(_point, roleFaceDir, shakeTime, start, func)
|
||||
end
|
||||
end
|
||||
|
||||
local mid_callBack = function() -- 打击时间点
|
||||
--LogGreen("mid_callBack:")
|
||||
self:private_BloodBlood(objPos, start, iconType, isReverse, 0)
|
||||
self:pravite_PlayHitEffect(objPos)
|
||||
if point then
|
||||
point:SetPointAnimation(iconType, 2)
|
||||
end
|
||||
--整个东西缩一下
|
||||
self:PlayScale(hurtGo, 0.7)
|
||||
if self.isSelf then
|
||||
SoundManager.PlaySound(SoundConfig.Sound_FightArea_Attack[math.random(1, #SoundConfig.Sound_FightArea_Attack)])
|
||||
end
|
||||
end
|
||||
|
||||
local func = function()
|
||||
self:pravite_ShakeObjOnce(go, isReverse, roleFaceDir, end_callBack, mid_callBack)
|
||||
end
|
||||
if self.callbackTimer then
|
||||
self.callbackTimer:Stop()
|
||||
self.callbackTimer = nil
|
||||
end
|
||||
self.callbackTimer = Timer.New(function ()
|
||||
func()
|
||||
end, 0.2)
|
||||
self.callbackTimer:Start()
|
||||
end
|
||||
|
||||
-- 怪物被打得吐血
|
||||
--- @param showType 参数为0时表示为掉血,参数大于0时表示为补血
|
||||
function SingleFightPlayerView:private_BloodBlood(objPos, index, iconType, isMonster, showType, func)
|
||||
local i = math.floor(index % 3 + 1)
|
||||
|
||||
-- 吐血随机值
|
||||
local hurtNum, isCritical = iconAction.pravite_GetHurtValue(isMonster, iconType, showType)
|
||||
local v2 = SetObjPosByUV(objPos)
|
||||
self.hurtNum[i]:GetComponent("RectTransform").anchoredPosition3D = Vector3.New(v2.x, v2.y, 0) + Vector3.New(0, 120, 0)
|
||||
Util.GetGameObject(self.hurtNum[i], "anim/Image"):SetActive(false)
|
||||
Util.GetGameObject(self.hurtNum[i], "anim/anim"):GetComponent("Text").text = iconAction.DecodeHurt(hurtNum, isCritical, showType)
|
||||
self.hurtNum[i]:SetActive(true)
|
||||
|
||||
-- if self.hurtNumTimer then
|
||||
-- self.hurtNumTimer:Stop()
|
||||
-- self.hurtNumTimer = nil
|
||||
-- end
|
||||
-- self.hurtNumTimer =
|
||||
Timer.New(function()
|
||||
if self.hurtNum[i] then
|
||||
self.hurtNum[i]:SetActive(false)
|
||||
end
|
||||
if func then func() end
|
||||
end, 1.5):Start()
|
||||
-- self.hurtNumTimer
|
||||
end
|
||||
|
||||
-- 震动动画
|
||||
function SingleFightPlayerView:pravite_ShakeObjOnce(go, isReverse, roleFaceDir, func, mid_func)
|
||||
if self.isclose then
|
||||
return
|
||||
end
|
||||
--LogGreen("pravite_ShakeObjOnce:"..go.name.." isReverse:"..tostring(isReverse).." roleFaceDir:"..tostring(roleFaceDir))
|
||||
local offSet = isReverse and 90 or 120
|
||||
offSet = offSet / math.min(Screen.width/1080, Screen.height/1920)
|
||||
|
||||
if not IsNull(go) then
|
||||
local originPos = go:GetComponent("RectTransform").anchoredPosition
|
||||
local value = isReverse and -1 or 1
|
||||
local targetPos = originPos + Vector2.New(offSet * roleFaceDir.x * value, offSet * roleFaceDir.y * value)
|
||||
go:GetComponent("RectTransform"):DOAnchorPos(targetPos, 0.1, false):OnComplete(function ()
|
||||
if mid_func then mid_func() end
|
||||
go:GetComponent("RectTransform"):DOAnchorPos(originPos, 0.1, false):OnComplete(function ()
|
||||
if func then func() end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
-- 缩放
|
||||
function SingleFightPlayerView:PlayScale(go, scale)
|
||||
if self.isclose then
|
||||
return
|
||||
end
|
||||
if go then
|
||||
local originScale = go.transform.localScale
|
||||
go.transform:DOScale(originScale * scale, 0.1):OnComplete(function ()
|
||||
go.transform:DOScale(originScale, 0.1)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
-- 受击特效
|
||||
function SingleFightPlayerView:pravite_PlayHitEffect(pos)
|
||||
--local u, v = Map_Pos2UV(pos)
|
||||
--local v2 = RectTransformUtility.WorldToScreenPoint(TileMapView.GetCamera(), TileMapView.GetLiveTilePos(u, v))
|
||||
--v2 = v2 / math.min(Screen.width/1080, Screen.height/1920)
|
||||
--LogGreen("self.hitEffect:")
|
||||
self.hitEffect.transform.localPosition = SetObjPosByUV(pos)
|
||||
self.hitEffect:SetActive(true)
|
||||
end
|
||||
|
||||
|
||||
-- 不是战斗的表现
|
||||
function SingleFightPlayerView:NotBattleShow()
|
||||
if self.battleTimer then
|
||||
self.battleTimer:Stop()
|
||||
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.parent.BattleEnd(self.selectPointPos)
|
||||
self:SetRoleLayer(true)
|
||||
self:SetBattleState(false)
|
||||
self.targetTimer = Timer.New(function ()
|
||||
self.parent.LoadPointIcon(false)
|
||||
self:SetRoleHitTarget()
|
||||
self.state = 0
|
||||
self.selectPointPos = nil
|
||||
self.eventPointPos = nil
|
||||
end, 0.5)
|
||||
self.targetTimer:Start()
|
||||
end, 1)
|
||||
self.battleTimer:Start()
|
||||
end
|
||||
|
||||
-- 进入战斗状态
|
||||
function SingleFightPlayerView:EnterBattle()
|
||||
self:SetBattleState(true)
|
||||
end
|
||||
|
||||
function SingleFightPlayerView:StopAction()
|
||||
self.callList:Clear()
|
||||
self:SetWalkDir(WALK_DIR.IDLE_FRONT)
|
||||
self.hitEffect:SetActive(false)
|
||||
for i = 1, #self.hurtNum do
|
||||
self.hurtNum[i].gameObject:SetActive(false)
|
||||
end
|
||||
if self.targetTimer then
|
||||
self.targetTimer:Stop()
|
||||
self.targetTimer = nil
|
||||
end
|
||||
if self.callbackTimer then
|
||||
self.callbackTimer:Stop()
|
||||
self.callbackTimer = nil
|
||||
end
|
||||
-- if self.hurtNumTimer then
|
||||
-- self.hurtNumTimer:Stop()
|
||||
-- self.hurtNumTimer = nil
|
||||
-- end
|
||||
if self.battleTimer then
|
||||
self.battleTimer:Stop()
|
||||
self.battleTimer = nil
|
||||
end
|
||||
|
||||
--LogGreen("停止协程")
|
||||
if self.thread then
|
||||
coroutine.stop(self.thread)
|
||||
self.thread = nil
|
||||
end
|
||||
end
|
||||
|
||||
function SingleFightPlayerView:OnClose()
|
||||
self.isclose = true
|
||||
self.dialogueRoot.gameObject:SetActive(false)
|
||||
self:StopAction()
|
||||
self.hurtNum = {}
|
||||
self.buffTipList = {}
|
||||
if self.playerLiveView then
|
||||
self.playerLiveView:OnClose()
|
||||
self.playerLiveView = nil
|
||||
end
|
||||
|
||||
--角色当前方向
|
||||
self.curDir = nil
|
||||
--当前选中点的位置
|
||||
self.selectPointPos = 0
|
||||
--角色停止行走时的朝向
|
||||
self.eventpoint = 0
|
||||
--当前触发的事件点
|
||||
self.eventPointPos = nil
|
||||
self.state = 0
|
||||
end
|
||||
return SingleFightPlayerView
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f6f2693984a35f74d8e0311299f459a4
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue