DaoYouWidget.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. Icon_Daoyou.icon_name = _daoyouModelConfig.bodyIcon;
  32. Text_Name.text = LanguageManager.Instance.Text(_daoyouModelConfig.name);
  33. if (_daoYouData != null)
  34. {
  35. Text_Level.text = _daoYouData.favorabilityLv.ToString();
  36. }
  37. else
  38. {
  39. Text_Level.text = 0 + "";
  40. }
  41. if (_daoYouData == null)
  42. {
  43. Slider_Emotion.fillAmount = 1;
  44. }
  45. else
  46. {
  47. Slider_Emotion.fillAmount = _daoYouData.emotionValue / 100;
  48. }
  49. if (_daoYouData == null)
  50. {
  51. transform.Gray();
  52. Btn_Event.gameObject.SetActive(false);
  53. Icon_Emotion.gameObject.SetActive(false);
  54. }
  55. else
  56. {
  57. if (TimeHelper.ClientNow() - _daoYouData.emotionTime >= 60 * 60 * 1000)
  58. {
  59. _daoYouData.emotion = Random.Range(1, 4);
  60. _daoYouData.emotionValue = (int)(100 / (float)_daoYouData.emotion);
  61. _daoYouData.emotionTime = TimeHelper.ClientNow();
  62. }
  63. emotionConfig emotionConfig = ConfigComponent.Instance.Get<emotionConfig>(_daoYouData.emotion);
  64. Icon_Emotion.gameObject.SetActive(false);
  65. DaoyouLevelupConfig daoyouLevelupConfig =
  66. ConfigComponent.Instance.Get<DaoyouLevelupConfig>(_daoYouData.favorabilityLv);
  67. Text_DaoyouLvName.text = LanguageManager.Instance.Text(daoyouLevelupConfig.name);
  68. if (_daoYouData.favorabilityLv >= _daoyouModelConfig.EmotionLvforQuest
  69. && EventSystemManager.Instance.BagIsEvent(_daoyouModelConfig.EventCompleteforQuest)
  70. && !EventSystemManager.Instance.BagIsEvent(_daoyouModelConfig.QuestID)
  71. && !EventSystemManager.Instance.IsEventCompleted(_daoyouModelConfig.QuestID))
  72. {
  73. Btn_Event.gameObject.SetActive(true);
  74. }
  75. else
  76. {
  77. Btn_Event.gameObject.SetActive(false);
  78. }
  79. transform.RecoverColor();
  80. }
  81. }
  82. }
  83. }