using UI.LuckyBox; using FairyGUI; using ET; using System.Collections.Generic; using System; namespace GFGGame { public class LuckyBoxController { private GComponent _com; private UI_ComModel _comModel; private DressUpObjUI _dressUpObjUI; private LuckyBoxCfg _luckyBoxCfg; private const int _turnTime = 8; private int _curTime = _turnTime; private int _bgIndex = 0; private int _modelIndex = 0; public LuckyBoxController(GComponent comModel) { _dressUpObjUI = new DressUpObjUI("SceneDressUp"); _com = comModel; } public void OnShown(int luckyBoxId) { _comModel = UI_ComModel.Proxy(_com); _curTime = _turnTime; _luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId); _comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(_luckyBoxCfg.resArr[_bgIndex]); if (_luckyBoxCfg.suitShowArr.Length > 0) { _dressUpObjUI.ResetSceneObj(100, false, false, null, false); _dressUpObjUI.dressUpObj.PutOnSuitCfg(_luckyBoxCfg.suitShowArr[_modelIndex][0], true, new int[] { ConstDressUpItemType.BEI_JING }, false, false); _dressUpObjUI.UpdateWrapper(_comModel.m_holder); } if (_luckyBoxCfg.resArr.Length > 1 || _luckyBoxCfg.suitShowArr.Length > 1) { Timers.inst.Remove(UpdateTime); Timers.inst.Add(1, 0, UpdateTime); } } private void UpdateTime(object param) { _curTime = _curTime - 1 == 0 ? _turnTime : _curTime - 1; if (_curTime == _turnTime) { _bgIndex = _bgIndex + 1 == _luckyBoxCfg.resArr.Length ? 0 : _bgIndex + 1; _modelIndex = _modelIndex + 1 == _luckyBoxCfg.suitShowArr.Length ? 0 : _modelIndex + 1; if (_luckyBoxCfg.resArr.Length > 1) { _comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(_luckyBoxCfg.resArr[_bgIndex]); } if (_luckyBoxCfg.suitShowArr.Length > 0) { _dressUpObjUI.ResetSceneObj(100, false, false, null, false); _dressUpObjUI.dressUpObj.PutOnSuitCfg(_luckyBoxCfg.suitShowArr[_modelIndex][0], true, new int[] { ConstDressUpItemType.BEI_JING }, false, false); _dressUpObjUI.UpdateWrapper(_comModel.m_holder); } } } public void OnHide() { UI_ComModel.ProxyEnd(); Timers.inst.Remove(UpdateTime); _bgIndex = 0; _modelIndex = 0; _dressUpObjUI.ResetSceneObj(0, false, false, null, false); } public void Dispose() { if (_dressUpObjUI != null) { _dressUpObjUI.Dispose(); _dressUpObjUI = null; } } } }