【御剑行】提交
parent
660a88b965
commit
81a3db0446
|
|
@ -306,7 +306,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Padding:
|
||||
m_Left: 0
|
||||
m_Left: 300
|
||||
m_Right: 0
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ GameObject:
|
|||
- component: {fileID: 5592663840833343251}
|
||||
- component: {fileID: 6156725674730646753}
|
||||
m_Layer: 0
|
||||
m_Name: roadPre
|
||||
m_Name: RiceSinglePlayerView
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
|
@ -33,11 +33,11 @@ RectTransform:
|
|||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 0, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 9500, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
m_SizeDelta: {x: 10000, y: 100}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!222 &5592663840833343251
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -107,9 +107,9 @@ RectTransform:
|
|||
m_Father: {fileID: 2310722302838262445}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -4500, y: 100}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 0, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 100}
|
||||
m_SizeDelta: {x: 100, y: 300}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6862682349730503354
|
||||
|
|
|
|||
|
|
@ -713,7 +713,7 @@ RectTransform:
|
|||
m_Children:
|
||||
- {fileID: 7256087387444435487}
|
||||
m_Father: {fileID: 53418342384090642}
|
||||
m_RootOrder: 0
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
|
|
@ -831,7 +831,7 @@ RectTransform:
|
|||
m_Children:
|
||||
- {fileID: 4124323309039852058}
|
||||
m_Father: {fileID: 53418342384090642}
|
||||
m_RootOrder: 1
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
|
|
@ -1374,7 +1374,7 @@ MonoBehaviour:
|
|||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: "\u52A0\u901F"
|
||||
m_Text: "\u91CD\u7F6E"
|
||||
--- !u!1 &6177522903402240212
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1453,7 +1453,7 @@ MonoBehaviour:
|
|||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: "\u91CD\u7F6E"
|
||||
m_Text: "\u6682\u505C"
|
||||
--- !u!1 &6230307248981530427
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1862,7 +1862,7 @@ RectTransform:
|
|||
m_Children:
|
||||
- {fileID: 3687531706935594584}
|
||||
m_Father: {fileID: 53418342384090642}
|
||||
m_RootOrder: 2
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
|
|
@ -2126,9 +2126,9 @@ RectTransform:
|
|||
m_LocalPosition: {x: 0, y: 0, z: -60.942368}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 7246928682069637843}
|
||||
- {fileID: 48288159580647049}
|
||||
- {fileID: 4257523531844688773}
|
||||
- {fileID: 7246928682069637843}
|
||||
- {fileID: 6904406165868908363}
|
||||
m_Father: {fileID: 3631581760418750615}
|
||||
m_RootOrder: 3
|
||||
|
|
|
|||
|
|
@ -1,10 +1,23 @@
|
|||
require("Base/Stack")
|
||||
-- local PlayerView = require("Modules/YuJianXing/RiceSinglePlayerView")
|
||||
local RiceCtrlView = {}
|
||||
local riceCtrl = "RiceCtrl"
|
||||
local bgNameList = {}
|
||||
local playerDataList = {}
|
||||
|
||||
--此处也是用new的方式创建
|
||||
function RiceCtrlView:New()
|
||||
local b = {}
|
||||
b.Ctrl = poolManager:LoadAsset(riceCtrl, PoolManager.AssetType.GameObject)
|
||||
b.Ctrl.name = "riceCtrl"
|
||||
b.Ctrl.transform:SetParent(UIManager.uiRoot.transform.parent)
|
||||
b.Ctrl.transform.position = Vector3(-100, -100, -100)
|
||||
b.gameObject = b.Ctrl
|
||||
b.transform = b.Ctrl.transform
|
||||
setmetatable(b, { __index = RiceCtrlView })
|
||||
return b
|
||||
end
|
||||
|
||||
--设置数据
|
||||
function RiceCtrlView:Awake(_bgList,_playerList)
|
||||
if _bgList then
|
||||
bgNameList = _bgList
|
||||
|
|
@ -14,31 +27,22 @@ function RiceCtrlView:Awake(_bgList,_playerList)
|
|||
end
|
||||
self.speed = 0
|
||||
self.bgItemList = {}
|
||||
self.playerList = {}
|
||||
self.playerRoadList = {}
|
||||
self.spLoader = SpriteLoader.New()
|
||||
UIManager.camera.clearFlags = CameraClearFlags.Depth
|
||||
self.Ctrl = poolManager:LoadAsset(riceCtrl, PoolManager.AssetType.GameObject)
|
||||
self.Ctrl.name = "riceCtrl"
|
||||
self.Ctrl.transform:SetParent(UIManager.uiRoot.transform.parent)
|
||||
self.Ctrl.transform.position = Vector3(-100, -100, -100)
|
||||
self.bgList = Util.GetGameObject(self.Ctrl.gameObject,"Canvas/BgList")
|
||||
self.imgPre = Util.GetGameObject(self.bgList,"imgPre")
|
||||
self.camara = Util.GetGameObject(self.Ctrl.gameObject,"Camera")
|
||||
self.roadList = Util.GetGameObject(self.Ctrl.gameObject,"Canvas/RoadList")
|
||||
|
||||
FixedUpdateBeat:Add(self.OnUpdate, self)--长按方法注册
|
||||
--加载背景--并不滚动,有几个加载几个
|
||||
self:SetBg()
|
||||
self:SetPlayer()
|
||||
return self.Ctrl
|
||||
end
|
||||
|
||||
function RiceCtrlView:SetGameState(_state)
|
||||
self.isRunning = _state
|
||||
for i,v in ipairs(self.playerList) do
|
||||
v:SetSinglePlayerState(self.isRunning)
|
||||
end
|
||||
Util.SetLocalPosition(self.camara.transform, 0, 0, -10)
|
||||
end
|
||||
|
||||
--设置背景图
|
||||
function RiceCtrlView:SetBg()
|
||||
for i = 1, #bgNameList do
|
||||
local go = {}
|
||||
|
|
@ -51,22 +55,55 @@ function RiceCtrlView:SetBg()
|
|||
end
|
||||
end
|
||||
|
||||
--加载玩家
|
||||
function RiceCtrlView:SetPlayer()
|
||||
for i = 1, 4 do--#playerDataList do
|
||||
self.playerList[i] = {}
|
||||
self.playerList[i] = SubUIManager.Open(SubUIConfig.PlayerRiceView,self.roadList.transform,i)--playerDataList[i])
|
||||
self.playerRoadList[i] = {}
|
||||
self.playerRoadList[i] = SubUIManager.Open(SubUIConfig.PlayerRiceView,self.roadList.transform,i)--playerDataList[i])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--设置游戏状态
|
||||
function RiceCtrlView:SetGameState(_state)
|
||||
self.isRunning = _state
|
||||
for i,v in ipairs(self.playerRoadList) do
|
||||
v:SetSinglePlayerState(_state)
|
||||
end
|
||||
end
|
||||
|
||||
--重置游戏
|
||||
function RiceCtrlView:ResetGame()
|
||||
self.isRunning = false
|
||||
for i,v in ipairs(self.playerRoadList) do
|
||||
v:ResetSinglePlayer()
|
||||
end
|
||||
Util.SetLocalPosition(self.camara.transform, 0, 0, -10)
|
||||
end
|
||||
|
||||
function RiceCtrlView:OnUpdate()
|
||||
if self.isRunning then
|
||||
local x = 0
|
||||
for i,v in ipairs(self.playerRoadList) do
|
||||
if x < v:GetCurPosX() then
|
||||
x = v:GetCurPosX()
|
||||
end
|
||||
end
|
||||
Util.SetLocalPosition(self.camara.transform, x/276, 0, -10)
|
||||
end
|
||||
end
|
||||
|
||||
--卸载地图
|
||||
function RiceCtrlView:Dispose()
|
||||
FixedUpdateBeat:Remove(self.OnUpdate, self)
|
||||
self.speed = 0
|
||||
for i,v in ipairs(self.bgItemList) do
|
||||
destroy(v.gameObject)
|
||||
end
|
||||
for i,v in ipairs(self.playerList) do
|
||||
for i,v in ipairs(self.playerRoadList) do
|
||||
SubUIManager.Close(v)
|
||||
end
|
||||
|
||||
--卸载地图
|
||||
if self.Ctrl then
|
||||
poolManager:UnLoadAsset(riceCtrl, self.Ctrl, PoolManager.AssetType.GameObject)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,12 @@ end
|
|||
|
||||
function RiceSinglePlayerView:InitComponent()
|
||||
self.gameObject:GetComponent("RectTransform").sizeDelta = Vector2.New(10000,100)
|
||||
self.player = Util.GetGameObject(self.gameObject,"Player")
|
||||
self.playerTrans = self.player:GetComponent("RectTransform")
|
||||
self.playerTrans.localPosition = Vector2.New(0,100)
|
||||
self.curPosX = self.playerTrans.localPosition.x
|
||||
self.speed = 10
|
||||
FixedUpdateBeat:Add(self.OnUpdate, self)--长按方法注册
|
||||
end
|
||||
|
||||
--绑定事件(用于子类重写)
|
||||
|
|
@ -23,16 +29,32 @@ end
|
|||
function RiceSinglePlayerView:RemoveListener()
|
||||
end
|
||||
|
||||
--设置游戏状态
|
||||
function RiceSinglePlayerView:SetSinglePlayerState(_state)
|
||||
self.isRunning = _state
|
||||
end
|
||||
|
||||
function RiceSinglePlayerView:Update()
|
||||
--重置游戏
|
||||
function RiceSinglePlayerView:ResetSinglePlayer()
|
||||
self.isRunning = false
|
||||
self.playerTrans.localPosition = Vector2.New(0,100)
|
||||
self.curPosX = self.playerTrans.localPosition.x
|
||||
end
|
||||
|
||||
|
||||
--upDate
|
||||
function RiceSinglePlayerView:OnUpdate()
|
||||
if self.isRunning then
|
||||
LogGreen(self.data.."的speed:"..tostring(self.speed))
|
||||
-- LogGreen(self.data.." curPosX:"..tostring(self.curPosX))
|
||||
self.curPosX = self.curPosX + self.speed + self.data
|
||||
self.player.transform.localPosition = Vector2.New(self.curPosX,100)
|
||||
end
|
||||
end
|
||||
|
||||
function RiceSinglePlayerView:GetCurPosX()
|
||||
return self.curPosX
|
||||
end
|
||||
|
||||
--界面打开时调用(用于子类重写)
|
||||
function RiceSinglePlayerView:OnOpen(_data)
|
||||
self.data = _data
|
||||
|
|
@ -47,6 +69,7 @@ end
|
|||
|
||||
--界面销毁时调用(用于子类重写)
|
||||
function RiceSinglePlayerView:OnDestroy()
|
||||
FixedUpdateBeat:Remove(self.OnUpdate, self)
|
||||
end
|
||||
|
||||
return RiceSinglePlayerView
|
||||
|
|
@ -11,26 +11,50 @@ function this.Initialize()
|
|||
this.curBetList = 0 --当前竞猜数据
|
||||
end
|
||||
|
||||
--初始化地图
|
||||
function this.OpenMap()
|
||||
if not this.riceCtrl then
|
||||
this.riceCtrl = riceCtrl:New()
|
||||
this.riceCtrl:Awake(bgList)
|
||||
end
|
||||
if this.timer then
|
||||
this.timer:Stop()
|
||||
this.timer = nil
|
||||
end
|
||||
end
|
||||
|
||||
--销毁地图--正常
|
||||
function this.CloseMap()
|
||||
if this.riceCtrl then
|
||||
this.timer = Timer.New(function ()
|
||||
this.riceCtrl:Dispose()
|
||||
this.riceCtrl = nil
|
||||
end,1)
|
||||
this.timer:Start()
|
||||
end
|
||||
end
|
||||
--销毁地图--立刻
|
||||
function this.DestroyMap()
|
||||
if this.riceCtrl then
|
||||
this.riceCtrl:Dispose()
|
||||
this.riceCtrl = nil
|
||||
end
|
||||
end
|
||||
|
||||
--更新服务器信息
|
||||
function this.UpdataServerData(msg)
|
||||
-- body
|
||||
end
|
||||
|
||||
function this.InitMap()
|
||||
this.riceCtrl = riceCtrl:Awake(bgList)
|
||||
LogRed(tostring(this.riceCtrl.name))
|
||||
end
|
||||
|
||||
--修改游戏状态
|
||||
function this.SetGameState(_state)
|
||||
this.riceCtrl:SetGameState(_state)
|
||||
end
|
||||
|
||||
function this.DestroyMap()
|
||||
-- riceCtrl:SetGameState(false)--结束比赛
|
||||
if this.riceCtrl then
|
||||
Timer.New(function ()
|
||||
this.riceCtrl:Dispose()
|
||||
end,5):Start()
|
||||
end
|
||||
--重置游戏
|
||||
function this.ResetGame()
|
||||
this.riceCtrl:ResetGame()
|
||||
end
|
||||
|
||||
|
||||
return YuJianXingManager
|
||||
|
|
@ -22,8 +22,9 @@ function YuJianXingPanel:InitComponent()
|
|||
|
||||
--testBtn
|
||||
self.start = Util.GetGameObject(self.gameObject, "Button (4)")
|
||||
-- self.speedUp = Util.GetGameObject(self.gameObject, "Button (3)")
|
||||
-- self.speedDown = Util.GetGameObject(self.gameObject, "Button (2)")
|
||||
self.speedUp = Util.GetGameObject(self.gameObject, "Button (3)")
|
||||
self.speedDown = Util.GetGameObject(self.gameObject, "Button (2)")
|
||||
self.speedDown:SetActive(false)
|
||||
self.reset = Util.GetGameObject(self.gameObject, "Button (1)")
|
||||
end
|
||||
|
||||
|
|
@ -60,6 +61,9 @@ function YuJianXingPanel:BindEvent()
|
|||
Util.AddOnceClick(self.reset,function ()
|
||||
YuJianXingManager.SetGameState(false)
|
||||
end)
|
||||
Util.AddOnceClick(self.speedUp,function ()
|
||||
YuJianXingManager.ResetGame()
|
||||
end)
|
||||
end
|
||||
|
||||
--添加事件监听(用于子类重写)
|
||||
|
|
@ -79,16 +83,17 @@ end
|
|||
|
||||
-- 打开,重新打开时回调
|
||||
function YuJianXingPanel:OnShow()
|
||||
YuJianXingManager.InitMap()
|
||||
YuJianXingManager.OpenMap()
|
||||
end
|
||||
|
||||
--界面关闭时调用(用于子类重写)
|
||||
function YuJianXingPanel:OnClose()
|
||||
YuJianXingManager.DestroyMap()
|
||||
YuJianXingManager.CloseMap()
|
||||
end
|
||||
|
||||
--界面销毁时调用(用于子类重写)
|
||||
function YuJianXingPanel:OnDestroy()
|
||||
YuJianXingManager.DestroyMap()
|
||||
end
|
||||
|
||||
return YuJianXingPanel
|
||||
|
|
@ -39,6 +39,7 @@ function JumpView:OnOpen(jumpId,isRewardItemPop,parent)
|
|||
self.info.text=GetLanguageStrById(self.jumpSData.Title)
|
||||
self.btnSureText.text = Language[10556]
|
||||
Util.AddOnceClick(self.btnSure, function()
|
||||
YuJianXingManager.DestroyMap()
|
||||
self:GoToJumpData()
|
||||
if parent then
|
||||
parent:ClosePanel()
|
||||
|
|
|
|||
Loading…
Reference in New Issue