示例#1
0
        private void ItemButton1_Click(object sender, EventArgs e)
        {
            switch (active)
            {
            case Armour a:
                a.active = !a.active;
                Render();
                break;

            case Jewelry j:
                j.Player = player;
                j.Active = !j.Active;
                Render();
                break;

            case Ammo a:
                SelectItem selectItem = new SelectItem(player.troop.weapons.Where(w => w is RangedWeapon rw && rw.AmmoType == a.ammoType).Select(w => w as Item).ToList(), true);
                selectItem.ShowDialog();
                RangedWeapon r = selectItem.Selected as RangedWeapon;
                if (r is null)
                {
                    break;
                }
                r.AddAmo(a);
                Render();
                break;

            case Food f:
                f.UseFood(player);
                Render();
                if (mainGame != null)
                {
                    player.actionPoints.RawValue -= 0.5;
                }
                break;

            default:
                throw new NotImplementedException("This type of item does not support button 1");
            }
        }