public static void createItem(item New, Vector2 pos, float z,int level) { try { item[] old = world.levels[level].items; world.levels[level].items = new item[old.Length + 1]; for (int i = 0; i != old.Length; i++) { world.levels[level].items[i] = old[i]; } New.B_base.f_elasticity = .50f; New.B_base.v_position = pos; New.B_base.f_Position_Z = z; world.levels[level].items[old.Length] = New; } catch { world.levels[level].items = new item[1]; New.B_base.f_elasticity = .50f; New.B_base.v_position = pos; New.B_base.f_Position_Z = z; world.levels[level].items[0] = New; } }
public static void killItem(int toKill,int level) { item[] lower = new item[toKill]; item[] upper = new item[world.levels[level].items.Length - (toKill + 1)]; for (int i = 0; i != world.levels[level].items.Length; i++) { if (i != toKill) { if (i < toKill) { lower[i] = world.levels[level].items[i]; } if (i > toKill) { upper[i - (toKill + 1)] = world.levels[level].items[i]; } } } world.levels[level].items = new item[world.levels[level].items.Length - 1]; for (int i = 0; i != world.levels[level].items.Length; i++) { if (i < lower.Length) { world.levels[level].items[i] = lower[i]; } else { world.levels[level].items[i] = upper[i - lower.Length]; } } }
public static item[] killItem_INVEN(item[] input, int toKill) { item[] lower = new item[toKill]; item[] upper = new item[input.Length - (toKill + 1)]; for (int i = 0; i != input.Length; i++) { if (i != toKill) { if (i < toKill) { lower[i] = input[i]; } if (i > toKill) { upper[i - (toKill + 1)] = input[i]; } } } input = new item[lower.Length + upper.Length]; for (int i = 0; i != input.Length; i++) { if (i < lower.Length) { input[i] = lower[i]; } else { input[i] = upper[i - lower.Length]; } } return input; }
public static inventory createItem_INVEN(inventory input, item New, Vector2 pos, float z) { try { item[] old = input.items; input.items = new item[old.Length + 1]; for (int i = 0; i != old.Length; i++) { input.items[i] = old[i]; } New.B_base.f_elasticity = .50f; New.B_base.v_position = pos; New.B_base.f_Position_Z = z; input.items[old.Length] = New; input.CurWeight += New.weight; } catch { input.items = new item[1]; New.B_base.f_elasticity = .50f; New.B_base.v_position = pos; New.B_base.f_Position_Z = z; input.items[0] = New; input.CurWeight += New.weight; } return input; }
public static item createItemFromWeapon(weapon w) { item output = new item(); for (int i = 0; i != world.weapons.Length; i++) { if (world.items[i].name == w.name) { output = world.items[i]; output.quality = w.wear; } } return output; }
public static item[] loadItems(ContentManager content) { StreamReader sr; BasePath = content.RootDirectory; sr = new StreamReader(content.RootDirectory + "/world/items/itemlist.txt"); int i_numitems = Convert.ToInt32(sr.ReadLine()); item[] output = new item[i_numitems]; for (int i = 0; i != i_numitems; i++) { string name = sr.ReadLine(); StreamReader sr1 = new StreamReader(content.RootDirectory + "/world/items/" + name + ".ANITEM"); { output[i].name = sr1.ReadLine(); output[i].gameTag = sr1.ReadLine(); output[i].special = sr1.ReadLine(); output[i].quality = Convert.ToSingle(sr1.ReadLine()); output[i].texture = content.Load<Texture2D>("graphics/textures/items/" + sr1.ReadLine()); output[i].icon = content.Load<Texture2D>("graphics/textures/items/" + sr1.ReadLine()); @output[i].description = sr1.ReadLine().Replace("\\n", "\n"); output[i].type = (itemType)Enum.ToObject(typeof(itemType), Convert.ToInt32(sr1.ReadLine())); output[i].usable = Convert.ToBoolean(sr1.ReadLine()); output[i].weight = Convert.ToSingle(sr1.ReadLine()); } sr1.Close(); } sr.Close(); return output; }
public inventory(float MaxWeight, item[] Items) { maxWeight = MaxWeight; CurWeight = 0; try { items = new item[Items.Length]; for (int i = 0; i != Items.Length; i++) { items[i] = Items[i]; CurWeight += Items[i].B_base.f_mass; } } catch { items = new item[0]; CurWeight = 0; } }
public static void equipFood(int c, item food) { PlayCharEat(); character Char = world.levels[world.i_currentLvl].char_living[c]; float healing = .25f; if (food.special == "heal") { healing = (food.quality/100)*2; } Char.attrib.hun_current *= 1 - (food.quality / 100); if (world.levels[world.i_currentLvl].char_living[c].controlType == ControlType.player_current) UI.addMessage("Hunger decreased by " + food.quality.ToString() + "%"); Char.attrib.hp_current *= (1 + ((food.quality / 100) * healing)); if (world.levels[world.i_currentLvl].char_living[c].controlType == ControlType.player_current) UI.addMessage("Healed by " + (food.quality * healing).ToString() + "%"); world.levels[world.i_currentLvl].char_living[c] = Char; }