DaoYouWidget.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System.Linq;
  2. using Core.Language;
  3. using Excel2Json;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using UnityEngine;
  7. namespace Fort23.Mono
  8. {
  9. [UIBinding(prefab = "DaoYouWidget")]
  10. public partial class DaoYouWidget : ItemWidgetBasic
  11. {
  12. private DaoyouModelConfig _daoyouModelConfig;
  13. public AccountFileInfo.DaoYouData _daoYouData;
  14. private void Init()
  15. {
  16. }
  17. public override void AddEvent()
  18. {
  19. }
  20. public override void DelEvent()
  21. {
  22. }
  23. public override void AddButtonEvent()
  24. {
  25. base.AddButtonEvent();
  26. }
  27. public void CustomInit(int configId)
  28. {
  29. _daoyouModelConfig = ConfigComponent.Instance.Get<DaoyouModelConfig>(configId);
  30. _daoYouData = AccountFileInfo.Instance.playerData.daoYouDatas.FirstOrDefault(dy => dy.id == configId);
  31. Text_Name.text = LanguageManager.Instance.Text(_daoyouModelConfig.name);
  32. Text_Level.text = _daoYouData.favorabilityLv.ToString();
  33. if (_daoYouData == null)
  34. {
  35. transform.Gray();
  36. Btn_Event.gameObject.SetActive(false);
  37. Icon_Emotion.gameObject.SetActive(false);
  38. }
  39. else
  40. {
  41. if (TimeHelper.ClientNow() - _daoYouData.emotionTime >= 60 * 60 * 1000)
  42. {
  43. _daoYouData.emotion = Random.Range(1, 4);
  44. _daoYouData.emotionValue = (int)(100 / (float)_daoYouData.emotion);
  45. _daoYouData.emotionTime = TimeHelper.ClientNow();
  46. }
  47. emotionConfig emotionConfig = ConfigComponent.Instance.Get<emotionConfig>(_daoYouData.emotion);
  48. Icon_Emotion.gameObject.SetActive(false);
  49. DaoyouLevelupConfig daoyouLevelupConfig = ConfigComponent.Instance.Get<DaoyouLevelupConfig>(_daoYouData.favorabilityLv);
  50. Text_DaoyouLvName.text = LanguageManager.Instance.Text(daoyouLevelupConfig.name);
  51. if (_daoYouData.favorabilityLv >= _daoyouModelConfig.EmotionLvforQuest
  52. && !EventSystemManager.Instance.BagIsEvent(_daoyouModelConfig.QuestID)
  53. && !EventSystemManager.Instance.IsEventTrigger(_daoyouModelConfig.QuestID))
  54. {
  55. Btn_Event.gameObject.SetActive(true);
  56. }
  57. else
  58. {
  59. Btn_Event.gameObject.SetActive(false);
  60. }
  61. transform.RecoverColor();
  62. }
  63. }
  64. }
  65. }