Changed a lot of Actions.cs and a few other things to be more easily
extendable.
This commit is contained in:
107
Item.cs
Normal file
107
Item.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
public abstract class Item
|
||||
{
|
||||
public string? Description {get; set;}
|
||||
public int ItemDamageModifier {get; set;} = 0;
|
||||
public int ItemDamageReduction {get; set;} = 0;
|
||||
public string? ActionEnable {get; set;}
|
||||
public string? IsEquippedBy {get; set;}
|
||||
|
||||
public static void EquipItem(Character character, Item item)
|
||||
{
|
||||
if (character.equipedItems.Count == 0)
|
||||
{
|
||||
ColoredConsole.WriteLine($"{character.name} has equipped {item.Description}", ConsoleColor.Yellow);
|
||||
Thread.Sleep(1500);
|
||||
item.IsEquippedBy = character.name;
|
||||
character.equipedItems.Insert(0, item);
|
||||
GameState.Instance.heroInventory.Remove(item);
|
||||
character.CharacterEnabledActions[0] = Convert.ToString(item.ActionEnable);
|
||||
CheckEquipped(character, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
ColoredConsole.WriteLine($"{character.name} has unequipped {character.equipedItems[0].Description}.", ConsoleColor.Yellow);
|
||||
ColoredConsole.WriteLine($"{character.name} has equipped {item.Description}", ConsoleColor.Yellow);
|
||||
Thread.Sleep(1500);
|
||||
item.IsEquippedBy = character.name;
|
||||
foreach (Item equipped in character.equipedItems)
|
||||
{
|
||||
GameState.Instance.heroInventory.Add(equipped);
|
||||
}
|
||||
character.equipedItems.Clear();
|
||||
character.equipedItems.Insert(0, item);
|
||||
GameState.Instance.heroInventory.Remove(item);
|
||||
character.CharacterEnabledActions[0] = Convert.ToString(item.ActionEnable);
|
||||
CheckEquipped(character, item);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public static void UnequipItem(Character character, Item item)
|
||||
{
|
||||
ColoredConsole.WriteLine($"{character.name} has unequipped {item.Description}.", ConsoleColor.Yellow);
|
||||
Thread.Sleep(1500);
|
||||
GameState.Instance.heroInventory.Insert(0, item);
|
||||
character.equipedItems.Clear();
|
||||
character.CharacterEnabledActions.Insert(0, "Punch");
|
||||
character.CharacterEnabledActions.Remove(item.ActionEnable);
|
||||
return;
|
||||
}
|
||||
|
||||
public static void CheckEquipped(Character character, Item item)
|
||||
{
|
||||
if (character.name == "Vin Fletcher")
|
||||
{
|
||||
if (item.Description == "Vin's Bow")
|
||||
{
|
||||
character.CharacterEnabledActions[0] = "Quick Shot";
|
||||
return;
|
||||
}
|
||||
else return;
|
||||
}
|
||||
if (character.name != "Vin Fletcher")
|
||||
{
|
||||
if (item.Description == "Hero's Sword")
|
||||
{
|
||||
character.CharacterEnabledActions[0] = "Hero's Sword";
|
||||
return;
|
||||
}
|
||||
else return;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class Sword : Item
|
||||
{
|
||||
public Sword()
|
||||
{
|
||||
Description = "Hero's Sword";
|
||||
ItemDamageModifier = 2;
|
||||
ActionEnable = "Sword Attack";
|
||||
}
|
||||
}
|
||||
|
||||
class Armor : Item
|
||||
{
|
||||
public Armor()
|
||||
{
|
||||
Description = "Armor";
|
||||
ItemDamageReduction = 1;
|
||||
}
|
||||
}
|
||||
|
||||
class Bow : Item
|
||||
{
|
||||
public Bow()
|
||||
{
|
||||
Description = "Vin's Bow";
|
||||
ItemDamageModifier = 2;
|
||||
ActionEnable = "Bow Shot";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user