| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- local SUIAlignPanel = {}
- local humancost
- local function ForTest()
- if CS.UnityEngine.Input.GetKeyDown(CS.UnityEngine.KeyCode.Space) then
- humancost:SetCostSuccess(true)
- end
- end
- -- using for Gaming
- local function GetAlignArea()
- local dataRelay = require("Base/DataRelay.lua")
- local ALIGN_AREA = dataRelay:GetCache(dataRelay.KEY_TYPE.ALIGN_AREA, nil)
- local tTransformPose = CS.zwn_common_data.single.zwn_transform_pose
- local nAreaNowX = tTransformPose[5].x - tTransformPose[6].x
- local nAreaNowY = tTransformPose[5].y - tTransformPose[11].y
- ALIGN_AREA = math.abs(nAreaNowX * nAreaNowY);
- dataRelay:SetCache(dataRelay.KEY_TYPE.ALIGN_AREA, ALIGN_AREA)
- end
- local function CostChange()
- ForTest()
- local costChange = humancost.Cost_Change
- if costChange then
- local sSoundPath
- local nAreaNum = humancost.Area_Num
- if nAreaNum == -1 then
- -- 没有人
- sSoundPath = "Audios/Align/keepDistance.mp3"
- elseif nAreaNum == 0 then
- -- 对齐成功
- sSoundPath = "Audios/Align/alignSuccess.mp3"
- elseif nAreaNum == 1 then
- -- 向右一点
- sSoundPath = "Audios/Align/goRight.mp3"
- elseif nAreaNum == 2 then
- -- 向左一点
- sSoundPath = "Audios/Align/goLeft.mp3"
- elseif nAreaNum == 3 then
- -- 向后一点
- sSoundPath = "Audios/Align/goBack.mp3"
- elseif nAreaNum == 4 then
- -- 向前一点
- sSoundPath = "Audios/Align/goAlong.mp3"
- end
- require("Base/SMusicManager.lua"):PlaySound(sSoundPath)
- humancost:SetCostChange(false)
- end
- if humancost.Cost_Success then
- GetAlignArea()
- humancost:human_end()
- humancost:SetCostSuccess(false)
- local SUIPreparePanel = require("UI/SUIPreparePanel.lua")
- SUIPreparePanel.SetRootPanelActive(true)
- SUIAlignPanel.SetRootPanelActive(false)
- -- require("Base/UIHelper.lua"):SwitchUI("UI/SUIPreparePanel.lua", "UI/SUIAlignPanel.lua")
- end
- end
- local function CheckAlignData()
- CostChange()
- end
- local function HalfBody()
- print("SUIAlignPanel.HalfBody")
- local rootPanel = SUIAlignPanel.rootPanel
- local zwnHumancost = rootPanel.transform:Find("ZWNHumancost02").gameObject
- humancost = zwnHumancost:GetComponent("humancost")
- humancost:halfbody()
- end
- local function RegisterButtonQuit()
- print("SUIAlignPanel.RegisterButtonQuit")
- local panelQuit = SUIAlignPanel.rootPanel.transform:Find("Panel_Quit").gameObject
- require("Base/UIHelper.lua"):RegisterButtonQuit(panelQuit, false, "UI/SUITeachPanel.lua", "UI/SUIAlignPanel.lua")
- end
- local function RefreshUI()
- HalfBody()
- end
- local function InitData()
- end
- local function InitAllData()
- InitData()
- RefreshUI()
- end
- function SUIAlignPanel.SetRootPanelActive(bShow)
- SUIAlignPanel.rootPanel:SetActive(bShow)
- if bShow then
- InitAllData()
- return
- end
- end
- function SUIAlignPanel.Awake(luaRoot)
- SUIAlignPanel.luaRoot = luaRoot
- local canvas = CS.UnityEngine.GameObject.Find("Canvas")
- SUIAlignPanel._rootCanvas = canvas
- local prefabPanelAlign = LoadResource("Prefabs/UI/SUIAlignPanel.prefab")
- local rootPanel = CS.UnityEngine.GameObject.Instantiate(prefabPanelAlign, SUIAlignPanel._rootCanvas.transform)
- SUIAlignPanel.rootPanel = rootPanel
- end
- function SUIAlignPanel.Start()
- print("SUIAlignPanel.Start")
- RegisterButtonQuit()
- end
- function SUIAlignPanel.Update()
- if not SUIAlignPanel.rootPanel.activeSelf then
- return
- end
- CheckAlignData()
- end
- function SUIAlignPanel.OnDestroy()
- CS.UnityEngine.GameObject.Destroy(SUIAlignPanel.rootPanel)
- print("SUIAlignPanel.OnDestroy")
- end
- return SUIAlignPanel
|