private void Awake() { badgePool = GetComponent <BadgePool>(); float badgeSize = firstSlot.GetComponent <RectTransform>().rect.width; float badgeGridWidth = maskBadgeGrid.GetComponent <RectTransform>().rect.width; badgeSize = badgeGridWidth / nbBadgeRow; float badgePoolCount = badgePool.badges.Count; int col = 0; int row = 0; int count = 0; while (count < badgePoolCount && row < nbBadgeRow) { BadgeSlot newBadgeSlot = Instantiate(badgeSlot, firstSlot.transform.position, firstSlot.transform.rotation); newBadgeSlot.transform.SetParent(maskBadgeGrid.transform); newBadgeSlot.transform.position = new Vector3(firstSlot.transform.position.x + badgeSize * col, firstSlot.transform.position.y - badgeSize * row, badgeSlot.transform.position.z); newBadgeSlot.badge = badgePool.badges[count]; count++; if ((col % nbBadgeColumn) == 4) { row++; col = -1; } col++; } Destroy(firstSlot); }
public bool ValidateBadgeSlotEquiped(string arg) { string[] tokens = arg.Split(','); uint bookID = uint.Parse(tokens[0]); uint slotID = uint.Parse(tokens[1]); BadgeBook books = MainPlayer.Instance.badgeSystemInfo.GetBadgeBookByBookId(bookID); if (books == null) { Debug.LogError("ValidateBadgeSlotEquiped, error book ID:" + bookID); } BadgeSlot slot = books.slot_list.Find((s) => s.id == slotID); if (slot == null) { Debug.LogError("ValidateBadgeSlotEquiped, error slot ID:" + bookID + " " + slotID); } return(slot.status == BadgeSlotStatus.UNLOCK && slot.badge_id != 0); }
public BadgeSlot CreateBadgeSlot() { BadgeSlot slot = new BadgeSlot(); return(slot); }