DaoYouWidget.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. transform.Gray();
  43. Btn_Event.gameObject.SetActive(false);
  44. Icon_Emotion.gameObject.SetActive(false);
  45. }
  46. else
  47. {
  48. if (TimeHelper.ClientNow() - _daoYouData.emotionTime >= 60 * 60 * 1000)
  49. {
  50. _daoYouData.emotion = Random.Range(1, 4);
  51. _daoYouData.emotionValue = (int)(100 / (float)_daoYouData.emotion);
  52. _daoYouData.emotionTime = TimeHelper.ClientNow();
  53. }
  54. emotionConfig emotionConfig = ConfigComponent.Instance.Get<emotionConfig>(_daoYouData.emotion);
  55. Icon_Emotion.gameObject.SetActive(false);
  56. DaoyouLevelupConfig daoyouLevelupConfig = ConfigComponent.Instance.Get<DaoyouLevelupConfig>(_daoYouData.favorabilityLv);
  57. Text_DaoyouLvName.text = LanguageManager.Instance.Text(daoyouLevelupConfig.name);
  58. if (_daoYouData.favorabilityLv >= _daoyouModelConfig.EmotionLvforQuest
  59. && !EventSystemManager.Instance.BagIsEvent(_daoyouModelConfig.QuestID)
  60. && !EventSystemManager.Instance.IsEventTrigger(_daoyouModelConfig.QuestID))
  61. {
  62. Btn_Event.gameObject.SetActive(true);
  63. }
  64. else
  65. {
  66. Btn_Event.gameObject.SetActive(false);
  67. }
  68. transform.RecoverColor();
  69. }
  70. }
  71. }
  72. }