/// <summary> /// 更新已解锁护符栏 /// </summary> private void CreateBadgeGrid() { List <ItemInfo> badgeInfo = new List <ItemInfo>(new ItemInfo[40]); foreach (ItemInfo temp in BadgeMgr.Instance.badgeUnlocked.Values) { badgeInfo[(temp.id - 21)] = temp; } for (int i = 0; i < badgeGridList.Count; ++i) { Destroy(badgeGridList[i].gameObject); badgeGridList[i].transform.SetParent(null); } badgeGridList.Clear(); for (int i = 0; i < badgeInfo.Count; ++i) { ItemCell cell = ResMgr.Instance.Load <GameObject>("ItemCell").GetComponent <ItemCell>(); cell.transform.SetParent(badgeGrid.transform); cell.InitInfo(badgeInfo[i]); if (BadgeMgr.Instance.GetEquipedState(badgeInfo[i])) { cell.ItemOn(); } else { cell.ItemOff(); } badgeGridList.Add(cell); } }
/// <summary> /// 发挥功能 /// </summary> private void BadgeOnOff() { if (seleObj.GetComponentInParent <ItemCell>().GetItemInfo() != null) { ItemCell father = seleObj.GetComponentInParent <ItemCell>(); //最后一个是特殊,固有 if (father.GetItemInfo().id == 60) { return; } //交给BadgeMgr判断 BadgeMgr.Instance.BadgeOnOrOff(father.GetItemInfo()); //判断现在所选中badge的状态 if (BadgeMgr.Instance.EquipedJudge) { father.ItemOn(); } else { father.ItemOff(); } MusicMgr.Instance.PlaySound("UIBadge_Euqip", false); //发生改变,重写选择框路径字典,并且告诉其他三个栏目要更新信息 if (BadgeMgr.Instance.ListChanged) { CreateBadgeGrid(); CreateEquipedGrid(); CreateGrooves(); CreateSeleGrid(); seleObj.GetComponent <Image>().enabled = true; } return; } if (seleObj.transform.parent.name == "ArrowLeft") { EventCenter.Instance.EventTrigger <int>("PanelChange", -1); } if (seleObj.transform.parent.name == "ArrowRight") { EventCenter.Instance.EventTrigger <int>("PanelChange", 1); } }