FacilityUIPreviewParams.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using System;
  2. using I2.Loc;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class FacilityUIPreviewParams : MonoBehaviour
  6. {
  7. public void Show(int id)
  8. {
  9. this.SetupRecipeDefaultEffect(id);
  10. }
  11. public void UpdateAdditionalParams(Facility.FacilityParameter parameter)
  12. {
  13. this.SetupRecipeAdditionalEffect(parameter);
  14. }
  15. public void UpdateAdditionalParamsComparison(Facility.FacilityParameter previous, Facility.FacilityParameter next)
  16. {
  17. this.SetupRecipeAdditionalEffectComparison(previous, next);
  18. }
  19. public void ResetDefaultParam()
  20. {
  21. this.m_ParentDefaultEffect.ResetList();
  22. }
  23. public void ResetAdditionalParam()
  24. {
  25. this.m_ParentAdditionalEffect.ResetList();
  26. }
  27. private void SetupRecipeDefaultEffect(int id)
  28. {
  29. Facility.PowerUpRecipe recipe = FacilityDataTable.GetFacilityPowerUpRecipe(id);
  30. this.m_ParentDefaultEffect.Show<Text>(recipe.parameter.Length, delegate(int i, Text text)
  31. {
  32. Facility.FacilityParameter parameter = recipe.parameter;
  33. int num = parameter[i];
  34. if (num <= 0)
  35. {
  36. text.gameObject.SetActive(false);
  37. }
  38. string parameterName = parameter.GetParameterName(i);
  39. text.text = string.Format("{0} +{1}", parameterName, num);
  40. Image componentInChildren = text.GetComponentInChildren<Image>();
  41. componentInChildren.enabled = (i % 2 == 0);
  42. Localize component = text.GetComponent<Localize>();
  43. if (component != null)
  44. {
  45. component.TermArgs = new Localize.ArgsPair[]
  46. {
  47. Localize.ArgsPair.Create(num.ToString())
  48. };
  49. component.SetTerm("SceneFacilityManagement/パラメータ/" + parameterName);
  50. }
  51. });
  52. }
  53. private void SetupRecipeAdditionalEffect(Facility.FacilityParameter parameter)
  54. {
  55. int itemCount = 0;
  56. this.m_ParentAdditionalEffect.Show<Text>(parameter.Length, delegate(int i, Text text)
  57. {
  58. if (parameter[i] <= 0)
  59. {
  60. text.gameObject.SetActive(false);
  61. return;
  62. }
  63. itemCount++;
  64. string parameterName = parameter.GetParameterName(i);
  65. int num = parameter[i];
  66. text.text = string.Format("{0} +{1}", parameterName, num);
  67. Image componentInChildren = text.GetComponentInChildren<Image>();
  68. componentInChildren.enabled = (itemCount % 2 == 1);
  69. Localize component = text.GetComponent<Localize>();
  70. if (component != null)
  71. {
  72. component.TermArgs = new Localize.ArgsPair[]
  73. {
  74. Localize.ArgsPair.Create(num.ToString())
  75. };
  76. component.SetTerm("SceneFacilityManagement/パラメータ/" + parameterName);
  77. }
  78. });
  79. }
  80. private void SetupRecipeAdditionalEffectComparison(Facility.FacilityParameter previous, Facility.FacilityParameter next)
  81. {
  82. Facility.FacilityParameter compatison = next - previous;
  83. int itemCount = 0;
  84. this.m_ParentAdditionalEffect.Show<Text>(next.Length, delegate(int i, Text text)
  85. {
  86. if (previous[i] == 0 && next[i] == 0)
  87. {
  88. text.gameObject.SetActive(false);
  89. return;
  90. }
  91. itemCount++;
  92. string parameterName = next.GetParameterName(i);
  93. int num = next[i];
  94. text.text = string.Format("{0} +{1}", parameterName, num);
  95. Image componentInChildren = text.GetComponentInChildren<Image>();
  96. componentInChildren.enabled = (itemCount % 2 == 1);
  97. if (compatison[i] == 0)
  98. {
  99. text.color = Color.white;
  100. }
  101. else if (compatison[i] < 0)
  102. {
  103. text.color = Color.magenta;
  104. }
  105. else if (compatison[i] > 0)
  106. {
  107. text.color = Color.cyan;
  108. }
  109. Localize component = text.GetComponent<Localize>();
  110. if (component != null)
  111. {
  112. component.TermArgs = new Localize.ArgsPair[]
  113. {
  114. Localize.ArgsPair.Create(num.ToString())
  115. };
  116. component.SetTerm("SceneFacilityManagement/パラメータ/" + parameterName);
  117. }
  118. });
  119. }
  120. [SerializeField]
  121. private uGUIListViewer m_ParentDefaultEffect;
  122. [SerializeField]
  123. private uGUIListViewer m_ParentAdditionalEffect;
  124. }