| | |
| | | { |
| | | public List<SelectBuffIcon> IconList; |
| | | |
| | | private string iconPath = "UI/Endless/BuffIcon/BuffIcon_"; |
| | | |
| | | /// <summary> |
| | | /// buff是否选中完成 |
| | | /// </summary> |
| | | private bool isCompleted; |
| | | |
| | | public event Action<int> BuffSelectCompleted; |
| | | |
| | | /// <summary> |
| | |
| | | private int SelectedIndex = -1; |
| | | |
| | | public Button SelectBtn; |
| | | |
| | | public GameObject EffectPrefabObject; |
| | | |
| | | private GameObject effectObj; |
| | | |
| | | private Vector3[] effectPosArr = { new Vector3(-21.6f, 0, 6.6f), new Vector3(0, 0, 6.6f), new Vector3(21.6f, 0, 6.6f) }; |
| | | |
| | | // Start is called before the first frame update |
| | | private void Start() |
| | |
| | | SelectBtn.onClick.AddListener(OnClickSelectBtn); |
| | | } |
| | | |
| | | private void OnDisable() |
| | | private void OnEnable() |
| | | { |
| | | Reset(); |
| | | } |
| | | |
| | | private void Reset() |
| | | { |
| | | isCompleted = false; |
| | | SelectedIndex = -1; |
| | | |
| | | for (int i = 0; i < IconList.Count; ++i) |
| | | { |
| | | IconList[i].Reset(); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void OnDisable() |
| | | { |
| | | if (effectObj != null) |
| | | Destroy(effectObj); |
| | | } |
| | | |
| | | public void OnClick(int index) |
| | |
| | | |
| | | SelectedIndex = index; |
| | | IconList[index].SetState(true); |
| | | |
| | | //PlayEffect(); |
| | | } |
| | | |
| | | |
| | | private void PlayEffect() |
| | | { |
| | | if (effectObj == null) |
| | | { |
| | | effectObj = Instantiate(EffectPrefabObject); |
| | | GameObject particleSystemObject = GameObject.Find("ParticleSystemObject"); |
| | | effectObj.transform.SetParent(particleSystemObject.transform, false); |
| | | effectObj.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); |
| | | } |
| | | effectObj.transform.localPosition = effectPosArr[SelectedIndex]; |
| | | ParticleSystem ps = effectObj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | ps.Play(); |
| | | } |
| | | |
| | | private void StopEffect() |
| | | { |
| | | if (effectObj != null) |
| | | { |
| | | ParticleSystem ps = effectObj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | ps.Stop(); |
| | | ps.Clear(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | int index = SelectedIndex; |
| | | |
| | | AudioSourceManager.Ins.Play(AudioEnum.UI); |
| | | |
| | | HideBuffUI(); |
| | | |
| | | IconList[index].Fly(); |
| | | EndlessRandomTower.instance.SetCountDown(true,true); |
| | | |
| | | if (BuffSelectCompleted != null) |
| | | BuffSelectCompleted(index); |
| | |
| | | |
| | | public void ShowBuffUI() |
| | | { |
| | | EndlessMaskUI.instance.Show(); |
| | | gameObject.SetActive(true); |
| | | AudioSourceManager.Ins?.Play(AudioEnum.ChooseBuff); |
| | | } |
| | | |
| | | public void HideBuffUI() |
| | | { |
| | | EndlessMaskUI.instance.Hide(); |
| | | StopEffect(); |
| | | gameObject.SetActive(false); |
| | | } |
| | | |
| | |
| | | IconList[i].SetName(list[i].Config.name); |
| | | IconList[i].SetEffect(list[i].Config.brief); |
| | | IconList[i].SetRare(list[i].Config.rare); |
| | | IconList[i].SetIsGold(list[i].EffectType == EndlessBuffEffectType.GoldAdd); |
| | | } |
| | | } |
| | | } |