FacilityUIPreviewParams.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. public class FacilityUIPreviewParams : MonoBehaviour
  5. {
  6. public void Show(int id)
  7. {
  8. this.SetupRecipeDefaultEffect(id);
  9. }
  10. public void UpdateAdditionalParams(Facility.FacilityParameter parameter)
  11. {
  12. this.SetupRecipeAdditionalEffect(parameter);
  13. }
  14. public void UpdateAdditionalParamsComparison(Facility.FacilityParameter previous, Facility.FacilityParameter next)
  15. {
  16. this.SetupRecipeAdditionalEffectComparison(previous, next);
  17. }
  18. public void ResetDefaultParam()
  19. {
  20. this.m_ParentDefaultEffect.ResetList();
  21. }
  22. public void ResetAdditionalParam()
  23. {
  24. this.m_ParentAdditionalEffect.ResetList();
  25. }
  26. private void SetupRecipeDefaultEffect(int id)
  27. {
  28. Facility.PowerUpRecipe recipe = FacilityDataTable.GetFacilityPowerUpRecipe(id);
  29. this.m_ParentDefaultEffect.Show<Text>(recipe.parameter.Length, delegate(int i, Text text)
  30. {
  31. Facility.FacilityParameter parameter = recipe.parameter;
  32. int num = parameter[i];
  33. if (num <= 0)
  34. {
  35. text.gameObject.SetActive(false);
  36. }
  37. string parameterName = parameter.GetParameterName(i);
  38. text.text = string.Format("{0} +{1}", parameterName, num);
  39. Image componentInChildren = text.GetComponentInChildren<Image>();
  40. componentInChildren.enabled = (i % 2 == 0);
  41. });
  42. }
  43. private void SetupRecipeAdditionalEffect(Facility.FacilityParameter parameter)
  44. {
  45. int itemCount = 0;
  46. this.m_ParentAdditionalEffect.Show<Text>(parameter.Length, delegate(int i, Text text)
  47. {
  48. if (parameter[i] <= 0)
  49. {
  50. text.gameObject.SetActive(false);
  51. return;
  52. }
  53. itemCount++;
  54. string parameterName = parameter.GetParameterName(i);
  55. int num = parameter[i];
  56. text.text = string.Format("{0} +{1}", parameterName, num);
  57. Image componentInChildren = text.GetComponentInChildren<Image>();
  58. componentInChildren.enabled = (itemCount % 2 == 1);
  59. });
  60. }
  61. private void SetupRecipeAdditionalEffectComparison(Facility.FacilityParameter previous, Facility.FacilityParameter next)
  62. {
  63. Facility.FacilityParameter compatison = next - previous;
  64. int itemCount = 0;
  65. this.m_ParentAdditionalEffect.Show<Text>(next.Length, delegate(int i, Text text)
  66. {
  67. if (previous[i] == 0 && next[i] == 0)
  68. {
  69. text.gameObject.SetActive(false);
  70. return;
  71. }
  72. itemCount++;
  73. string parameterName = next.GetParameterName(i);
  74. int num = next[i];
  75. text.text = string.Format("{0} +{1}", parameterName, num);
  76. Image componentInChildren = text.GetComponentInChildren<Image>();
  77. componentInChildren.enabled = (itemCount % 2 == 1);
  78. if (compatison[i] == 0)
  79. {
  80. text.color = Color.white;
  81. }
  82. else if (compatison[i] < 0)
  83. {
  84. text.color = Color.magenta;
  85. }
  86. else if (compatison[i] > 0)
  87. {
  88. text.color = Color.cyan;
  89. }
  90. });
  91. }
  92. [SerializeField]
  93. private uGUIListViewer m_ParentDefaultEffect;
  94. [SerializeField]
  95. private uGUIListViewer m_ParentAdditionalEffect;
  96. }