YotogiSkillSelectSpecialCondition.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. checkBoxButtonData.checkBox.Button.GetComponent<BoxCollider>().enabled = !checkBoxButtonData.checkBox.check;
  101. }
  102. }
  103. int j;
  104. for (j = 0; j < this.checkBoxButtonDatas.Length; j++)
  105. {
  106. if (this.checkBoxButtonDatas[j].checkBox.check)
  107. {
  108. break;
  109. }
  110. }
  111. if (j + 1 > this.checkBoxButtonDatas.Length)
  112. {
  113. this.selectedType_ = Skill.Data.SpecialConditionType.Null;
  114. }
  115. else
  116. {
  117. this.selectedType_ = this.checkBoxButtonDatas[j].type;
  118. }
  119. if (this.onChangeSelectedTypeEvent != null)
  120. {
  121. this.onChangeSelectedTypeEvent(this.selectedType_);
  122. }
  123. }
  124. [SerializeField]
  125. private YotogiSkillSelectSpecialCondition.CheckBoxButtonData[] checkBoxButtonDatas;
  126. public Action<Skill.Data.SpecialConditionType> onChangeSelectedTypeEvent;
  127. private Skill.Data.SpecialConditionType selectedType_;
  128. [Serializable]
  129. private class CheckBoxButtonData
  130. {
  131. [SerializeField]
  132. public WFCheckBox checkBox;
  133. [SerializeField]
  134. public string specialConditionName;
  135. [NonSerialized]
  136. public Skill.Data.SpecialConditionType type;
  137. }
  138. }