DaoYouWidget.cs 2.5 KB

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