PowerIconContainer.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using UnityEngine;
  2. using System.Collections;
  3. public class PowerIconContainer : MonoBehaviour {
  4. public PowerIcon[] powerIcons;
  5. public PowerIcon[] crystalPowerIcons;
  6. public GameObject radioIcon;
  7. public SwapBtn swapBtn;
  8. public bool isMenu;
  9. void Awake()
  10. {
  11. int i=0;
  12. BattleController battleController = GameObject.FindObjectOfType<BattleController>();
  13. for(i=0; i<powerIcons.Length; i++)
  14. {
  15. powerIcons[i].init(battleController);
  16. }
  17. for(i=0; i<crystalPowerIcons.Length; i++)
  18. {
  19. crystalPowerIcons[i].init(battleController);
  20. }
  21. }
  22. public void SetCraft(Craft craft)
  23. {
  24. int i=0;
  25. if (craft != null)
  26. {
  27. if(isMenu)
  28. {
  29. for(i=0; i<powerIcons.Length; i++)
  30. {
  31. powerIcons[i].SetPower(null);
  32. powerIcons[i].Hide ();
  33. }
  34. for(i=0; i<crystalPowerIcons.Length; i++)
  35. {
  36. crystalPowerIcons[i].SetPower(null);
  37. crystalPowerIcons[i].Hide();
  38. }
  39. }
  40. else
  41. {
  42. for(i=0; i<powerIcons.Length; i++)
  43. {
  44. powerIcons[i].Show ();
  45. powerIcons[i].SetPower(craft.GetPowerManager().GetPowerByIndex(i+1));
  46. }
  47. for (i = 0; i < crystalPowerIcons.Length; i++) {
  48. crystalPowerIcons [i].Show ();
  49. crystalPowerIcons [i].SetPower (craft.GetPowerManager ().GetCrystalPowerByIndex (i));
  50. }
  51. }
  52. radioIcon.SetActive (true);
  53. swapBtn.SetCraft (craft);
  54. swapBtn.gameObject.SetActive (true);
  55. }
  56. else
  57. {
  58. for(i=0; i<powerIcons.Length; i++)
  59. {
  60. powerIcons[i].SetPower(null);
  61. powerIcons[i].Hide();
  62. }
  63. for(i=0; i<crystalPowerIcons.Length; i++)
  64. {
  65. crystalPowerIcons[i].SetPower(null);
  66. crystalPowerIcons[i].Hide();
  67. }
  68. radioIcon.SetActive(false);
  69. swapBtn.gameObject.SetActive(false);
  70. }
  71. }
  72. public void Show()
  73. {
  74. transform.localScale = new Vector3(1f, 1f, 1f);
  75. radioIcon.SetActive(true);
  76. swapBtn.gameObject.SetActive(true);
  77. }
  78. public void Hide()
  79. {
  80. transform.localScale = Vector3.zero;
  81. radioIcon.SetActive(false);
  82. swapBtn.gameObject.SetActive(false);
  83. }
  84. }