Beispiel #1
0
        private void ChangeItem(Combatant character, ItemEquipType type)
        {
            if (_changingItem)
            {
                return;
            }
            _changingItem = true;

            var dialog = new ChangeItemDialog();

            dialog.Bounds = new UniRectangle(
                new UniScalar(0.5f, 0 - 100), new UniScalar(0.5f, 0 - 200),
                200, 400
                );
            var items     = new List <Item>();
            var inventory = ((SRPGGame)Game).Inventory;

            foreach (var item in inventory)
            {
                switch (type)
                {
                case ItemEquipType.Armor:
                    if (character.CanEquipArmor(item))
                    {
                        items.Add(item);
                    }
                    break;

                case ItemEquipType.Weapon:
                    if (character.CanEquipWeapon(item))
                    {
                        items.Add(item);
                    }
                    break;

                case ItemEquipType.Accessory:
                    items.Add(item);
                    break;
                }
            }
            dialog.SetItems(items);
            _characterInfoDialog.Children.Add(dialog);
            dialog.BringToFront();

            dialog.ItemSelected += i =>
            {
                inventory.Remove(i);
                inventory.Add(character.EquipItem(i));
                SetCharacter(character);
                dialog.Close();
                _changingItem = false;
            };

            dialog.ItemCancelled += () =>
            {
                dialog.Close();
                _changingItem = false;
            };
        }