void ChoiceItemSelected(VisualElement element, object obj) { SoundManager.Instance.PlaySoundEffect(SoundType.SOFT_CLICK); AvatarItem item = obj as AvatarItem; int index = item.Index; for (int i = 0; i < ChoiceButtonList.ListItems.Count; i++) { AvatarListItem listItem = ChoiceButtonList.ListItems[i] as AvatarListItem; if (i == index) { listItem.GetItem.Equipped = true; listItem.Equip(); //Debug.Log("now item " + i + " is equipped"); } else { listItem.GetItem.Equipped = false; listItem.Unequip(); //Debug.Log("now item " + i + " is unequipped"); } } if (displayAvatarChoice != null) { displayAvatarChoice(item); } }
public void SetRoom(string name, Point3 location, IEnumerable <RdlActor> actors) { this.Location = location; PlaceNameLabel.Text = name; foreach (var actor in actors) { if (_actors.ContainsKey(actor.ID)) { _actors[actor.ID] = actor; } else { _actors.Add(actor.ID, actor); } } // Remove any actors not in the current location. var removes = _actors.Where(a => new Point3(a.Value.Properties.GetValue <int>("X"), a.Value.Properties.GetValue <int>("Y"), a.Value.Properties.GetValue <int>("Z")) != this.Location).Select(a => a.Value.ID).ToList(); foreach (var id in removes) { _actors.Remove(id); } ctlItems.Children.Clear(); foreach (var actor in _actors.Values) { ObjectType type = (ObjectType)Enum.Parse(typeof(ObjectType), actor.Properties.GetValue <string>("ObjectType"), true); if (type == ObjectType.Mobile || type == ObjectType.Player) { AvatarListItem avatarItem = AvatarListItem.Create(actor); avatarItem.Action += Action; ctlItems.Children.Add(avatarItem); } else if (type == ObjectType.Actor) { ItemListItem listItem = ItemListItem.Create(actor); listItem.Action += Action; ctlItems.Children.Add(listItem); } } }
void PopulateChoiceButtons() { //Debug.Log(_page); List <AvatarItem> avatarItems; if (_page != (int)AvatarItemType.FACE && _page != (int)AvatarItemType.HAIR) { avatarItems = Database.Instance.GetAvatarItemList((AvatarItemType)_page); } else { if (_page == (int)AvatarItemType.FACE) { avatarItems = Database.Instance.GetCurrentFaceList(); } else { avatarItems = Database.Instance.GetCurrentHairList(); } } bool foundEquipped = false; for (int i = 0; i < avatarItems.Count; i++) { avatarItems[i].Index = i; AvatarListItem avatarChoiceItem = Instantiate(ChoiceButtonPrefab, Vector3.zero, Quaternion.identity) as AvatarListItem; avatarChoiceItem.Setup(avatarItems[i]); ChoiceButtonList.AddListElement(avatarChoiceItem); if (avatarItems[i].Equipped) { avatarChoiceItem.Equip(); foundEquipped = true; } } if (!foundEquipped) { avatarItems[0].Equipped = true; AvatarListItem listItem = ChoiceButtonList.ListItems[0] as AvatarListItem; listItem.Equip(); } }