int requiredOre(BaseItem item) { if (item.GetType().Equals(typeof(WeaponItem))) { return(3); } else if (item.GetType().Equals(typeof(ArmorItem))) { armorType t = ((ArmorItem)item).type; if (t.Equals(armorType.helmet)) { return(2); } if (t.Equals(armorType.chest)) { return(4); } if (t.Equals(armorType.legs)) { return(3); } if (t.Equals(armorType.shield)) { return(3); } } return(-1); }
// Set the type of armor public void setArmorType(armorType a) { if (this.iTypeMain == itemType.ARMOR || this.iTypeSub == itemType.ARMOR) { this.aType = a; } return; }
// Set the type of weapon public void setWeaponType(weaponType w) { if (this.iTypeMain == itemType.WEAPON || this.iTypeSub == itemType.WEAPON) { this.wType = w; this.aType = armorType.WEAPON; } return; }
// Get all armor of a given armor type public List <Item> getArmor(armorType a) { List <Item> armors = new List <Item>(); for (int i = 0; i < this.inventory.Count; i++) { if (this.inventory[i].getArmorType() == a && this.inventory[i].getAmt() > 0) { armors.Add(this.inventory[i]); } } return(armors); }
public override void Import(ClientEffect importObject, IEnumerable<FieldInfo> getters) { base.Import(importObject, getters); this.armor = Utility.GetArmorType(importObject.reserved[4]); this.change = new ChangeList(); var change = new Change(); change.stat = modifiersenum.PHYSICAL_DEFENSE; change.value = Int32.Parse(importObject.reserved[1]); change.delta = Int32.Parse(importObject.reserved[0]); change.func = StatFunc.PERCENT; this.change.Add(change); }
public override void Import(ClientEffect importObject, IEnumerable <FieldInfo> getters) { base.Import(importObject, getters); this.armor = Utility.GetArmorType(importObject.reserved[4]); this.change = new ChangeList(); var change = new Change(); change.stat = modifiersenum.PHYSICAL_DEFENSE; change.value = Int32.Parse(importObject.reserved[1]); change.delta = Int32.Parse(importObject.reserved[0]); change.func = StatFunc.PERCENT; this.change.Add(change); }
public ArmorItem(int id, string name, int armor, float reduction, string title, int amount, int worth) { this.id = id; this.name = name; this.armor = armor; this.reduction = reduction; this.title = title; this.amount = amount; this.worth = worth; modelpath = "Items/Models/" + name; path = "Items/Sprites/" + name + "sprite"; if (name.Contains("helmet")) { type = armorType.helmet; } else if (name.Contains("plate")) { type = armorType.chest; } else if (name.Contains("legs")) { type = armorType.legs; } else if (name.Contains("shield")) { type = armorType.shield; } else if (name.Contains("cape")) { type = armorType.cape; } desc = ""; desc += "Armor: " + armor; if (reduction > 0.0f) { desc += "\nDmg. Reduction: " + (int)(reduction * 100) + "%"; } sellDesc = desc + "\nSells for: " + ((int)(worth * 0.75f)) + "g"; buyDesc = desc + "\nBuy for: " + ((int)(worth)) + "g"; }
private List <Item> getEmptyEquips(jankFile input) { List <Item> equips = new List <Item>(); // Determine how many items to read string s = input.ReadLine(); string[] split = s.Split(' '); int items = 0; int.TryParse(split[split.Length - 1], out items); for (int i = 0; i < items; i++) { string name = "", path = "", des = ""; int quantity = 0; Sprite icon; itemType main, sub; // Name s = input.ReadLine(); split = s.Split(' '); for (int j = 1; j < split.Length; j++) { name += split[j]; if (j != split.Length - 1) { name += " "; } } // Description s = input.ReadLine(); split = s.Split(' '); for (int j = 1; j < split.Length; j++) { des += split[j]; if (j != split.Length - 1) { des += " "; } } // Quantity s = input.ReadLine(); split = s.Split(' '); int.TryParse(split[split.Length - 1], out quantity); // Path s = input.ReadLine(); split = s.Split(' '); for (int j = 1; j < split.Length; j++) { path += split[j]; if (j != split.Length - 1) { path += " "; } } icon = getSprite(Resources.LoadAll <Sprite>(path), name); s = input.ReadLine(); split = s.Split(' '); main = determineItem(split[split.Length - 1]); s = input.ReadLine(); split = s.Split(' '); sub = determineItem(split[split.Length - 1]); // Make weapon so far Item entry = new Item(main, sub, icon, path, name, des, -1, -1, quantity); // Read in main type first switch (main) { case itemType.ARMOR: s = input.ReadLine(); split = s.Split(' '); armorType a = determineArmor(split[split.Length - 1]); s = input.ReadLine(); split = s.Split(' '); int[] stats = new int[7]; for (int k = 0; k < stats.Length; k++) { int.TryParse(split[k + 1], out stats[k]); } entry.setArmorType(a); entry.setStats(stats); break; case itemType.WEAPON: s = input.ReadLine(); split = s.Split(' '); weaponType w = determineWeapon(split[split.Length - 1]); s = input.ReadLine(); split = s.Split(' '); stats = new int[7]; for (int k = 0; k < stats.Length; k++) { int.TryParse(split[k + 1], out stats[k]); } entry.setWeaponType(w); entry.setStats(stats); break; default: // Just implementing weapon for now break; } // Empty weapon and armor so no need to check for second type equips.Add(entry); input.ReadLine(); } return(equips); }
// Fills out hash table for items private void fillItemList() { this.itemList = new Hashtable(); jankFile itemTxt = new jankFile(Resources.Load <TextAsset>(@"ItemList")); List <string> sheetP = new List <string>(); List <Sprite[]> sheets = new List <Sprite[]>(); // Determine number of spritesheets string s = itemTxt.ReadLine(); string[] split = s.Split(' '); int paths = 0; int.TryParse(split[split.Length - 1], out paths); // Read paths for spritesheets for (int i = 0; i < paths; i++) { string sheetPath = itemTxt.ReadLine(); Sprite[] sheet = Resources.LoadAll <Sprite>(@sheetPath); sheets.Add(sheet); sheetP.Add(sheetPath); } itemTxt.ReadLine(); // Count the number of items to read s = itemTxt.ReadLine(); split = s.Split(' '); int itemAmt = 0; int.TryParse(split[split.Length - 1], out itemAmt); // Read in each item and place in hash itemTxt.ReadLine(); for (int i = 0; i < itemAmt; i++) { string name = "", path = "", des = ""; Sprite icon; itemType main, sub; // Name s = itemTxt.ReadLine(); split = s.Split(' '); for (int j = 1; j < split.Length; j++) { name += split[j]; if (j != split.Length - 1) { name += " "; } } // Description s = itemTxt.ReadLine(); split = s.Split(' '); for (int j = 1; j < split.Length; j++) { des += split[j]; if (j != split.Length - 1) { des += " "; } } // Path s = itemTxt.ReadLine(); split = s.Split(' '); int pathNum = 0; int.TryParse(split[split.Length - 1], out pathNum); path = sheetP[pathNum]; icon = getSprite(sheets[pathNum], name); // Price s = itemTxt.ReadLine(); split = s.Split(' '); int price = 0; int.TryParse(split[split.Length - 1], out price); // Types s = itemTxt.ReadLine(); split = s.Split(' '); main = (itemType)System.Enum.Parse(typeof(itemType), split[split.Length - 1]); s = itemTxt.ReadLine(); split = s.Split(' '); sub = (itemType)System.Enum.Parse(typeof(itemType), split[split.Length - 1]); // Make item so far Item entry = new Item(main, sub, icon, path, name, des, i, price, 1); // Read in main type first switch (main) { case itemType.ARMOR: s = itemTxt.ReadLine(); split = s.Split(' '); armorType a = (armorType)System.Enum.Parse(typeof(armorType), split[split.Length - 1]); s = itemTxt.ReadLine(); split = s.Split(' '); int[] stats = new int[7]; for (int k = 0; k < stats.Length; k++) { int.TryParse(split[k + 1], out stats[k]); } entry.setArmorType(a); entry.setStats(stats); break; case itemType.WEAPON: s = itemTxt.ReadLine(); split = s.Split(' '); weaponType w = (weaponType)System.Enum.Parse(typeof(weaponType), split[split.Length - 1]); s = itemTxt.ReadLine(); split = s.Split(' '); stats = new int[7]; for (int k = 0; k < stats.Length; k++) { int.TryParse(split[k + 1], out stats[k]); } entry.setWeaponType(w); entry.setStats(stats); entry.setSubType(itemType.ARMOR); entry.setArmorType(armorType.WEAPON); break; case itemType.FIELD: s = itemTxt.ReadLine(); split = s.Split(' '); fieldType f = (fieldType)System.Enum.Parse(typeof(fieldType), split[split.Length - 1]); entry.setFieldType(f); break; case itemType.BATTLE: s = itemTxt.ReadLine(); split = s.Split(' '); battleType b = (battleType)System.Enum.Parse(typeof(battleType), split[split.Length - 1]); s = itemTxt.ReadLine(); split = s.Split(' '); status statusMod = (status)System.Enum.Parse(typeof(status), split[split.Length - 1]); s = itemTxt.ReadLine(); split = s.Split(' '); int range = 0; int.TryParse(split[split.Length - 1], out range); s = itemTxt.ReadLine(); split = s.Split(' '); stat st = (stat)System.Enum.Parse(typeof(stat), split[split.Length - 1]); s = itemTxt.ReadLine(); split = s.Split(' '); int scalar = 0; int.TryParse(split[split.Length - 1], out scalar); s = itemTxt.ReadLine(); split = s.Split(' '); bool tAlly = true; bool.TryParse(split[split.Length - 1], out tAlly); entry.setBattleType(b); entry.setStatus(statusMod); entry.setModifiers(range, st, scalar, tAlly); break; default: // Nothing happens if it's a key item break; } this.itemList.Add(i, entry); itemTxt.ReadLine(); } }
public armorItem(string name, string description, double value, double weight, int a, bool s, armorType aT) { this.name = name; this.description = description; this.value = value; this.weight = weight; this.ac = a; this.disadvantage = s; this.type = aT; }
//In: type of unit to be created, owner of created unit //Out: unit of specified details public Unit(unitType type, Player p) { hp = 100; owner = p; t = type; moved = true; acted = true; //switch to set stats based on given type switch (type) { //infantry case unitType.trooper: cost = 100; movementSpeed = 2; armor = 0.3; armorT = armorType.infantry; moveT = moveType.foot; primaryAttack = new Attack(Attack.Name.rifle); //assault rifle secondaryAttack = new Attack(Attack.Name.flameThrower); //flame thrower break; case unitType.demolitionSquad: cost = 200; movementSpeed = 1; armor = 0.35; armorT = armorType.infantry; moveT = moveType.foot; primaryAttack = new Attack(Attack.Name.mortar); //mortar secondaryAttack = new Attack(Attack.Name.bazooka); //bazooka break; case unitType.samTrooper: cost = 200; movementSpeed = 1; armor = 0.3; armorT = armorType.infantry; moveT = moveType.foot; primaryAttack = new Attack(Attack.Name.samLauncher); //sam launcher secondaryAttack = new Attack(Attack.Name.rifle); //rifle break; //Vehicles case unitType.halftrack: cost = 400; movementSpeed = 9; armor = 0.4; armorT = armorType.armor; moveT = moveType.tread; primaryAttack = new Attack(Attack.Name.hmg); //Heavy Machine Gun secondaryAttack = new Attack(Attack.Name.hitNRun); //Hit and Run - no counter attack break; case unitType.flameTank: cost = 500; movementSpeed = 7; armor = 0.45; armorT = armorType.armor; moveT = moveType.tread; primaryAttack = new Attack(Attack.Name.flameThrower); //flame launcher secondaryAttack = new Attack(Attack.Name.lightCannon); //light cannon break; case unitType.heavyTank: cost = 700; movementSpeed = 6; armor = 0.5; armorT = armorType.armor; moveT = moveType.tread; primaryAttack = new Attack(Attack.Name.heavyCannon); //heavy cannon secondaryAttack = new Attack(Attack.Name.lmg); //lmg break; case unitType.flakCannon: cost = 600; movementSpeed = 7; armor = 0.4; armorT = armorType.armor; moveT = moveType.tread; primaryAttack = new Attack(Attack.Name.flakCannon); //flak cannon secondaryAttack = new Attack(Attack.Name.lmg); //lmg break; case unitType.artillery: cost = 700; movementSpeed = 6; armor = 0.4; armorT = armorType.armor; moveT = moveType.tread; primaryAttack = new Attack(Attack.Name.bombardment); //bombardment - AoE secondaryAttack = new Attack(Attack.Name.lmg); //lmg break; //aircraft case unitType.helicopter: cost = 700; movementSpeed = 8; armor = 0.4; armorT = armorType.air; moveT = moveType.air; primaryAttack = new Attack(Attack.Name.RocketPods); //Rocket Pods secondaryAttack = new Attack(Attack.Name.Minigun); //minigun break; //demons case unitType.imp: cost = 100; movementSpeed = 7; armor = 0.3; armorT = armorType.demon; moveT = moveType.foot; primaryAttack = new Attack(Attack.Name.fireball); //fireball secondaryAttack = new Attack(Attack.Name.claws); //claws break; case unitType.harpy: cost = 100; movementSpeed = 7; armor = 0.3; armorT = armorType.air; moveT = moveType.air; primaryAttack = new Attack(Attack.Name.claws); //claws secondaryAttack = new Attack(Attack.Name.skyDive); //sky dive - no counter attack break; case unitType.behemoth: cost = 100; movementSpeed = 6; armor = 0.6; armorT = armorType.demon; moveT = moveType.foot; primaryAttack = new Attack(Attack.Name.demonBlade); //Demonic Blade secondaryAttack = new Attack(Attack.Name.darkPulse); //Dark Pulse - AoE centered on unit break; case unitType.hellCannon: cost = 100; movementSpeed = 5; armor = 0.4; armorT = armorType.demon; moveT = moveType.foot; primaryAttack = new Attack(Attack.Name.siegeCannon); //siege cannon - AoE secondaryAttack = new Attack(Attack.Name.exhaustVent); //exhaust vent break; } movementPoints = movementSpeed; }