LuckyBoxController.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using UI.LuckyBox;
  2. using FairyGUI;
  3. using ET;
  4. using System.Collections.Generic;
  5. using System;
  6. namespace GFGGame
  7. {
  8. public class LuckyBoxController
  9. {
  10. private UI_ComModel _comModel;
  11. private LuckyBoxCfg _luckyBoxCfg;
  12. private int _time = 8;
  13. private int _bgIndex = 0;
  14. private int _modelIndex = 0;
  15. public LuckyBoxController(GComponent comModel, int luckyBoxId)
  16. {
  17. _luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId);
  18. _comModel = UI_ComModel.Proxy(comModel);
  19. _comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(_luckyBoxCfg.resArr[0]);
  20. if (_luckyBoxCfg.resArr.Length > 1)
  21. {
  22. Timers.inst.Add(1, 0, UpdateTime);
  23. }
  24. }
  25. public void Dispose()
  26. {
  27. }
  28. private void UpdateTime(object param)
  29. {
  30. _time = _time - 1 == 0 ? 8 : _time - 1;
  31. _bgIndex = _bgIndex + 1 == _luckyBoxCfg.resArr.Length ? 0 : _bgIndex + 1;
  32. _modelIndex = _modelIndex + 1 == _luckyBoxCfg.suitShowArr.Length ? 0 : _modelIndex + 1;
  33. }
  34. public void OnHide()
  35. {
  36. UI_ComModel.ProxyEnd();
  37. }
  38. }
  39. }