123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using UnityEngine;
- using System.Collections;
- public class PowerIconContainer : MonoBehaviour {
- public PowerIcon[] powerIcons;
- public PowerIcon[] crystalPowerIcons;
- public GameObject radioIcon;
- public SwapBtn swapBtn;
- public bool isMenu;
- void Awake()
- {
- int i=0;
- BattleController battleController = GameObject.FindObjectOfType<BattleController>();
- for(i=0; i<powerIcons.Length; i++)
- {
- powerIcons[i].init(battleController);
- }
- for(i=0; i<crystalPowerIcons.Length; i++)
- {
- crystalPowerIcons[i].init(battleController);
- }
- }
- public void SetCraft(Craft craft)
- {
- int i=0;
- if (craft != null)
- {
- if(isMenu)
- {
- for(i=0; i<powerIcons.Length; i++)
- {
- powerIcons[i].SetPower(null);
- powerIcons[i].Hide ();
- }
- for(i=0; i<crystalPowerIcons.Length; i++)
- {
- crystalPowerIcons[i].SetPower(null);
- crystalPowerIcons[i].Hide();
- }
- }
- else
- {
- for(i=0; i<powerIcons.Length; i++)
- {
- powerIcons[i].Show ();
- powerIcons[i].SetPower(craft.GetPowerManager().GetPowerByIndex(i+1));
- }
- for (i = 0; i < crystalPowerIcons.Length; i++) {
- crystalPowerIcons [i].Show ();
- crystalPowerIcons [i].SetPower (craft.GetPowerManager ().GetCrystalPowerByIndex (i));
- }
- }
- radioIcon.SetActive (true);
- swapBtn.SetCraft (craft);
- swapBtn.gameObject.SetActive (true);
- }
- else
- {
- for(i=0; i<powerIcons.Length; i++)
- {
- powerIcons[i].SetPower(null);
- powerIcons[i].Hide();
- }
- for(i=0; i<crystalPowerIcons.Length; i++)
- {
- crystalPowerIcons[i].SetPower(null);
- crystalPowerIcons[i].Hide();
- }
- radioIcon.SetActive(false);
- swapBtn.gameObject.SetActive(false);
- }
- }
- public void Show()
- {
- transform.localScale = new Vector3(1f, 1f, 1f);
- radioIcon.SetActive(true);
- swapBtn.gameObject.SetActive(true);
- }
- public void Hide()
- {
- transform.localScale = Vector3.zero;
- radioIcon.SetActive(false);
- swapBtn.gameObject.SetActive(false);
- }
- }
|