using UI.LuckyBox; using FairyGUI; using ET; using System.Collections.Generic; using System; using UnityEngine; 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) { int scale = 100; int direction = 1; if (_luckyBoxCfg.scaleArr.Length > 0) { scale = Math.Abs(_luckyBoxCfg.scaleArr[_modelIndex]); direction = _luckyBoxCfg.scaleArr[_modelIndex] >= 0 ? 1 : -1; } _dressUpObjUI.ResetSceneObj(scale, false, false, null, false); _dressUpObjUI.dressUpObj.PutOnSuitCfg(_luckyBoxCfg.suitShowArr[_modelIndex][0], true, new int[] { ConstDressUpItemType.BEI_JING }, false, false); _dressUpObjUI.UpdateWrapper(_comModel.m_holder); _dressUpObjUI.sceneObject.transform.localPosition = new Vector3(_luckyBoxCfg.suitShowArr[_modelIndex][1], _luckyBoxCfg.suitShowArr[_modelIndex][2], 0); _dressUpObjUI.sceneObject.transform.localScale = new Vector3(direction * scale, scale, scale); } if (_luckyBoxCfg.resArr.Length > 1 || _luckyBoxCfg.suitShowArr.Length > 1) { Timers.inst.Remove(UpdateTime); Timers.inst.Add(_turnTime, 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) { int scale = 100; int direction = 1; if (_luckyBoxCfg.scaleArr.Length > 0) { scale = Math.Abs(_luckyBoxCfg.scaleArr[_modelIndex]); direction = _luckyBoxCfg.scaleArr[_modelIndex] >= 0 ? 1 : -1; } _dressUpObjUI.ResetSceneObj(scale, false, false, null, false); _dressUpObjUI.dressUpObj.PutOnSuitCfg(_luckyBoxCfg.suitShowArr[_modelIndex][0], true, new int[] { ConstDressUpItemType.BEI_JING }, false, false); _dressUpObjUI.UpdateWrapper(_comModel.m_holder); _dressUpObjUI.sceneObject.transform.localPosition = new Vector3(_luckyBoxCfg.suitShowArr[_modelIndex][1], _luckyBoxCfg.suitShowArr[_modelIndex][2], 0); _dressUpObjUI.sceneObject.transform.localScale = new Vector3(direction * scale, scale, scale); } // } } 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; } } } }