DaoYouWidget.cs 3.0 KB

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