/// <summary> /// 新增BUFF,回傳該BUFF的位置。 /// </summary> /// <param name="_element"></param> /// <returns></returns> public void AddBuff(MyUIElementData _element) { int position = 0; //尋找陣列 for (; position < Buffers.Length; position++) { //無資料的位置 if (ElementsUI[position] == null) { //新增物件 if (Buffers[position] == null) { Buffers[position] = GameObject.Instantiate(Base); Buffers[position].SetActive(true); var trans = Buffers[position].GetComponent <RectTransform>(); trans.localPosition = new Vector3( trans.sizeDelta.x * position % columns, trans.sizeDelta.y * position / columns, 0); } //新增資料 ElementsUI[position] = Buffers[position].GetComponent <MyUIElementPresent>(); ElementsUI[position].Element = _element; } } //溢位 if (position == Buffers.Length) { moreBuff.Add(_element); } }
/// <summary> /// 遊戲進行中更改資料,如指向的位置比原先資料量數還多則直接忽略 /// </summary> /// <param name="_index"></param> /// <param name="_newElement"></param> public void ChangeElement(int _index, MyUIElementData _newElement) { if (myElements.Count > _index) { return; } MyUIElements[_index].Element = _newElement; }
/// <summary> /// 直接更改該位置的技能資料 /// </summary> /// <param name="_index"></param> /// <param name="_data"></param> public void ChangeSkill(int _index, MyUIElementData _data) { if (_index >= Persents.Length) { return; } Persents[_index].Element = _data; }
/// <summary> /// 開始讀取套裝資料與其事件 /// </summary> public void LoadData() { List <MyUIElementData> list = new List <MyUIElementData>(); for (int i = 0; i < initialSetList.Length; i++) { MeatBallSet set = MeatBallSetFactory.Instance.GetSet(initialSetList[i]); MyUIElementData setElement = set.NewElement; setElement.ButtonClickEvent = (_index, _extraData) => { //給貢丸換套裝 GameLogicManager.Instance.ChangeMainMeatBallSet( MeatBallSetFactory.Instance.GetSetObject(set.Type)); //登入下方按鈕填入技能 MyUIElementData hatElement = null; MyUIElementData suitElement = null; MyUIElementData gloveElement = null; MyUIElementData weaponElement = null; if (set.Hat.Skill != null) { hatElement = set.Hat.Skill.NewElementData; } if (set.Suit.Skill != null) { suitElement = set.Suit.Skill.NewElementData; } if (set.Glove.Skill != null) { gloveElement = set.Glove.Skill.NewElementData; } if (set.Weapon.Skill != null) { weaponElement = set.Weapon.Skill.NewElementData; } SkillsUI.ChangeSkill((int)MeatBall.SetPartType.Hat, hatElement); SkillsUI.ChangeSkill((int)MeatBall.SetPartType.Suit, suitElement); SkillsUI.ChangeSkill((int)MeatBall.SetPartType.Glove, gloveElement); SkillsUI.ChangeSkill((int)MeatBall.SetPartType.Weapon, weaponElement); }; list.Add(setElement); } SetSelectElements = list; }
public void DeleteBuff(MyUIElementData _element) { int position = 0; for (; position < Buffers.Length; position++) { if (ElementsUI[position].Element == _element) { ElementsUI[position].Element = null; Buffers[position].SetActive(false); break; } } if (position == Buffers.Length) { for (int i = 0; i < moreBuff.Count; i++) { if (moreBuff[position] == _element) { moreBuff[position] = null; break; } } } for (int index = 0; index < moreBuff.Count; index++) { if (moreBuff[index] != null) { moreBuff.RemoveAt(index); for (int j = 0; j < Buffers.Length; j++) { if (ElementsUI[j] == null) { ElementsUI[j].Element = _element; } } } } }