public bool dequip(Character c) { if (c.inventory.Count == Character.INVENTORYSIZE) { return false; } else { switch (type) { case (ArmourType.CHEST): { Armour oldchest = c.chest; c.inventory.Add(new ItemStack(oldchest)); c.chest = null; return true; } case (ArmourType.HELM): { Armour oldhelm = c.helm; c.inventory.Add(new ItemStack(oldhelm)); c.helm = null; return true; } case (ArmourType.GLOVES): { Armour oldgloves = c.gloves; c.inventory.Add(new ItemStack(oldgloves)); c.gloves = null; return true; } case (ArmourType.BOOTS): { Armour oldboots = c.boots; c.inventory.Add(new ItemStack(oldboots)); c.boots = null; return true; } case (ArmourType.LEGS): { Armour oldlegs = c.legs; c.inventory.Add(new ItemStack(oldlegs)); c.legs = null; return true; } } return true; } }
private void OKButton_Click(object sender, RoutedEventArgs e) { Button b = sender as Button; b.IsEnabled = false; string name = nameBox.Text; if (name.Equals("")) { MessageBox.Show("Please enter a character name"); b.IsEnabled = true; return; } if (name.Contains(';') || name.Contains(' ') || name.Contains('\\') || name.Contains('\n') || name.Contains('\t')) { MessageBox.Show("Character name contains invalid characters"); b.IsEnabled = true; return; } if (classSelect.SelectedItem.Equals(null)) { MessageBox.Show("Please select a class"); b.IsEnabled = true; return; } if (abilitiesToSelect != 0) { MessageBox.Show("Please select " + Ability.initialAbilityLimit + " abilities"); b.IsEnabled = true; return; } Class selectedClass = ClassSet.getClass((ClassType)Enum.Parse(typeof(ClassType), (string)classSelect.SelectedItem, false)); Character newChar = Character.createNewCharacter(name, selectedClass, selectedAbilities); newChar.submitCharacter(characterTransferComplete); _createdChar = newChar; }
public bool dequip(Character c) { if (c.inventory.Count == Character.INVENTORYSIZE) { return false; } else { Weapon oldWeapon = c.weapon; c.inventory.Add(new ItemStack(oldWeapon)); c.weapon = null; c.calculateStats(); return true; } }
public bool useItem(Character c, bool inBattle) { if (item is Consumable) { Consumable potion = item as Consumable; potion.consume(c); if (stackSize > 1) { stackSize--; } else { c.inventory.Remove(this); } return true; } if (!inBattle && item is Weapon) { Weapon weapon = item as Weapon; if (c.weapon == null) { c.weapon = weapon; c.inventory.Remove(this); c.calculateStats(); return true; } else { ICollection<ItemStack> inventory = c.inventory; inventory.Remove(this); ItemStack oldWeapon = new ItemStack(c.weapon); inventory.Add(oldWeapon); c.weapon = weapon; c.calculateStats(); return true; } } if (!inBattle && item is Armour) { Armour armour = item as Armour; switch (armour.type) { case (ArmourType.CHEST): { if (c.chest == null) { c.chest = armour; c.inventory.Remove(this); c.calculateStats(); return true; } else { ICollection<ItemStack> inventory = c.inventory; inventory.Remove(this); ItemStack oldChest = new ItemStack(c.chest); inventory.Add(oldChest); c.chest = armour; c.calculateStats(); return true; } } case (ArmourType.HELM): { if (c.helm == null) { c.helm = armour; c.inventory.Remove(this); c.calculateStats(); return true; } else { ICollection<ItemStack> inventory = c.inventory; inventory.Remove(this); ItemStack oldHelm = new ItemStack(c.helm); inventory.Add(oldHelm); c.helm = armour; c.calculateStats(); return true; } } case (ArmourType.GLOVES): { if (c.gloves == null) { c.gloves = armour; c.inventory.Remove(this); c.calculateStats(); return true; } else { ICollection<ItemStack> inventory = c.inventory; inventory.Remove(this); ItemStack oldgloves = new ItemStack(c.gloves); inventory.Add(oldgloves); c.gloves = armour; c.calculateStats(); return true; } } case (ArmourType.BOOTS): { if (c.boots == null) { c.boots = armour; c.inventory.Remove(this); c.calculateStats(); return true; } else { ICollection<ItemStack> inventory = c.inventory; inventory.Remove(this); ItemStack oldboots = new ItemStack(c.boots); inventory.Add(oldboots); c.boots = armour; c.calculateStats(); return true; } } case (ArmourType.LEGS): { if (c.legs == null) { c.legs = armour; c.inventory.Remove(this); c.calculateStats(); return true; } else { ICollection<ItemStack> inventory = c.inventory; inventory.Remove(this); ItemStack oldlegs = new ItemStack(c.legs); inventory.Add(oldlegs); c.legs = armour; c.calculateStats(); return true; } } } } return false; }
public void consume(Character c) { if (type == ConsumableType.health) { if (c.currentHealth + amountRegenerated >= c.maxHealth) { c.currentHealth = c.maxHealth; } else { c.currentHealth += amountRegenerated; } } else if (type == ConsumableType.mana) { if (c.currentMana + amountRegenerated >= c.maxMana) { c.currentMana = c.maxMana; } else { c.currentMana += amountRegenerated; } } }
private void updateCharPane(Character c) { string details = String.Format("Name:{0} \nClass:{1} \nLevel:{2}\nHealth:{3}\nMana:{4}\nMoney:{5}\n" + "Strength:{6} \nAgility:{7} \nIntelligence:{8}\nSpeed:{9}", c.name, c.type.ToString(), c.level, c.maxHealth, c.maxMana, c.money, c.strength, c.agility, c.intelligence, c.speed); CharacterBox.Text = details; Ability[] abilities = c.abilities.Values.ToArray(); for (int i = 0; i < 5; i++) { ColumnDefinition col = new ColumnDefinition(); col.Width = new GridLength(Ability.iconSize); abilityGrid.ColumnDefinitions.Add(col); } for (int i = 0; i <= (abilities.LongCount() - 1) / 5; i++) { RowDefinition row = new RowDefinition(); row.Height = new GridLength(Ability.iconSize); abilityGrid.RowDefinitions.Add(row); } for (int i = 0; i < abilities.LongCount(); i++) { Ability a = abilities[i]; Image icon = new Image(); icon.Source = new BitmapImage(a.icon); ToolTip t = new ToolTip(); t.Background = new SolidColorBrush(Colors.Brown); t.Content = a.name + ":\n" + a.description; ToolTipService.SetToolTip(icon, t); Grid.SetRow(icon, i / 5); Grid.SetColumn(icon, i % 5); abilityGrid.Children.Add(icon); } ItemStack[] inventory = c.inventory.ToArray(); string inventoryString = ""; for (int i = 0; i < inventory.LongCount(); i++) { inventoryString += inventory[i].item.name + ": " + inventory[i].stackSize + "\n"; } if (c.weapon != null) { inventoryString += c.weapon.name + "\n"; } if (c.chest != null) { inventoryString += c.chest.name + "\n"; } if (c.helm != null) { inventoryString += c.helm.name + "\n"; } if (c.gloves != null) { inventoryString += c.gloves.name + "\n"; } if (c.boots != null) { inventoryString += c.boots.name + "\n"; } if (c.legs != null) { inventoryString += c.legs.name + "\n"; } inventoryLabel.Content = inventoryString; Class _class = c.charClass; charImage.Source = new BitmapImage(_class.imageSrc); Character.currentCharacter = c; createCharButton.IsEnabled = false; playCharButton.IsEnabled = true; deleteCharButton.IsEnabled = true; }
public Battle(Character p1, Dictionary<String, Creep> dictionary) { this.char_1 = p1; this.char_2 = generateCreep(dictionary); playersTurn = false; }