YotogiSkillSelectSpecialCondition.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Yotogis;
  5. public class YotogiSkillSelectSpecialCondition : MonoBehaviour
  6. {
  7. public Skill.Data.SpecialConditionType[] checkBoxTypes
  8. {
  9. get
  10. {
  11. List<Skill.Data.SpecialConditionType> list = new List<Skill.Data.SpecialConditionType>();
  12. foreach (YotogiSkillSelectSpecialCondition.CheckBoxButtonData checkBoxButtonData in this.checkBoxButtonDatas)
  13. {
  14. list.Add(checkBoxButtonData.type);
  15. }
  16. return list.ToArray();
  17. }
  18. }
  19. public Skill.Data.SpecialConditionType selectedType
  20. {
  21. get
  22. {
  23. return this.selectedType_;
  24. }
  25. set
  26. {
  27. YotogiSkillSelectSpecialCondition.CheckBoxButtonData checkBoxButtonData = null;
  28. foreach (YotogiSkillSelectSpecialCondition.CheckBoxButtonData checkBoxButtonData2 in this.checkBoxButtonDatas)
  29. {
  30. if (checkBoxButtonData2.type == value)
  31. {
  32. checkBoxButtonData = checkBoxButtonData2;
  33. break;
  34. }
  35. }
  36. for (int j = 0; j < this.checkBoxButtonDatas.Length; j++)
  37. {
  38. YotogiSkillSelectSpecialCondition.CheckBoxButtonData checkBoxButtonData3 = this.checkBoxButtonDatas[j];
  39. if (checkBoxButtonData3.checkBox.enabled)
  40. {
  41. bool flag = checkBoxButtonData3 == checkBoxButtonData;
  42. if (flag)
  43. {
  44. this.selectedType_ = checkBoxButtonData3.type;
  45. }
  46. checkBoxButtonData3.checkBox.check = (checkBoxButtonData3 == checkBoxButtonData);
  47. checkBoxButtonData3.checkBox.Button.GetComponent<BoxCollider>().enabled = !checkBoxButtonData3.checkBox.check;
  48. }
  49. }
  50. if (this.onChangeSelectedTypeEvent != null)
  51. {
  52. this.onChangeSelectedTypeEvent(this.selectedType_);
  53. }
  54. }
  55. }
  56. public void Awake()
  57. {
  58. foreach (YotogiSkillSelectSpecialCondition.CheckBoxButtonData checkBoxButtonData in this.checkBoxButtonDatas)
  59. {
  60. checkBoxButtonData.type = (Skill.Data.SpecialConditionType)Enum.Parse(typeof(Skill.Data.SpecialConditionType), checkBoxButtonData.specialConditionName);
  61. checkBoxButtonData.checkBox.check = false;
  62. checkBoxButtonData.checkBox.Button.GetComponent<BoxCollider>().enabled = !checkBoxButtonData.checkBox.check;
  63. checkBoxButtonData.checkBox.onClick.Add(new Action<WFCheckBox>(this.OnClickCheckBox));
  64. }
  65. this.SetTypeCheckBoxEnabled(Skill.Data.SpecialConditionType.Mask, false);
  66. }
  67. public void SetTypeCheckBoxEnabled(Skill.Data.SpecialConditionType type, bool enabled)
  68. {
  69. if (type != Skill.Data.SpecialConditionType.Null)
  70. {
  71. foreach (YotogiSkillSelectSpecialCondition.CheckBoxButtonData checkBoxButtonData in this.checkBoxButtonDatas)
  72. {
  73. if (checkBoxButtonData.type == type)
  74. {
  75. WFCheckBox checkBox = checkBoxButtonData.checkBox;
  76. if (!enabled)
  77. {
  78. checkBox.check = false;
  79. checkBoxButtonData.checkBox.Button.GetComponent<BoxCollider>().enabled = false;
  80. UTY.GetChildObject(checkBox.CheckMarkOffObject, "Button", false).GetComponent<UISprite>().color = new Color(0.5f, 0.5f, 0.5f, 0.68f);
  81. }
  82. else
  83. {
  84. checkBox.enabled = true;
  85. checkBoxButtonData.checkBox.Button.GetComponent<BoxCollider>().enabled = true;
  86. UTY.GetChildObject(checkBox.CheckMarkOffObject, "Button", false).GetComponent<UISprite>().color = new Color(1f, 1f, 1f, 0.68f);
  87. }
  88. break;
  89. }
  90. }
  91. }
  92. }
  93. private void OnClickCheckBox(WFCheckBox clickCheckBox)
  94. {
  95. if (clickCheckBox.check)
  96. {
  97. foreach (YotogiSkillSelectSpecialCondition.CheckBoxButtonData checkBoxButtonData in this.checkBoxButtonDatas)
  98. {
  99. checkBoxButtonData.checkBox.check = (checkBoxButtonData.checkBox == clickCheckBox);
  100. if (UTY.GetChildObject(checkBoxButtonData.checkBox.CheckMarkOffObject, "Button", false).GetComponent<UISprite>().color.r == 1f)
  101. {
  102. checkBoxButtonData.checkBox.Button.GetComponent<BoxCollider>().enabled = !checkBoxButtonData.checkBox.check;
  103. }
  104. }
  105. }
  106. int j;
  107. for (j = 0; j < this.checkBoxButtonDatas.Length; j++)
  108. {
  109. if (this.checkBoxButtonDatas[j].checkBox.check)
  110. {
  111. break;
  112. }
  113. }
  114. if (j + 1 > this.checkBoxButtonDatas.Length)
  115. {
  116. this.selectedType_ = Skill.Data.SpecialConditionType.Null;
  117. }
  118. else
  119. {
  120. this.selectedType_ = this.checkBoxButtonDatas[j].type;
  121. }
  122. if (this.onChangeSelectedTypeEvent != null)
  123. {
  124. this.onChangeSelectedTypeEvent(this.selectedType_);
  125. }
  126. }
  127. [SerializeField]
  128. private YotogiSkillSelectSpecialCondition.CheckBoxButtonData[] checkBoxButtonDatas;
  129. public Action<Skill.Data.SpecialConditionType> onChangeSelectedTypeEvent;
  130. private Skill.Data.SpecialConditionType selectedType_;
  131. [Serializable]
  132. private class CheckBoxButtonData
  133. {
  134. [SerializeField]
  135. public WFCheckBox checkBox;
  136. [SerializeField]
  137. public string specialConditionName;
  138. [NonSerialized]
  139. public Skill.Data.SpecialConditionType type;
  140. }
  141. }