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 weapon[] LoadWeapons(ContentManager content) { StreamReader sr; sr = new StreamReader(content.RootDirectory + "/world/weapons/weaponlist.txt"); int i_numWeap = Convert.ToInt32(sr.ReadLine()); weapon[] output = new weapon[i_numWeap]; for (int i = 0; i != i_numWeap; i++) { string name = sr.ReadLine(); StreamReader sr1 = new StreamReader(content.RootDirectory + "/world/weapons/" + name + ".gun"); { output[i].name = sr1.ReadLine(); //.ReadString(); output[i].inaccuracy = Convert.ToSingle(sr1.ReadLine()); //.ReadSingle(); output[i].mass = Convert.ToSingle(sr1.ReadLine()); //.ReadSingle(); string GunTexPath = sr1.ReadLine(); //.ReadString(); output[i].bolt_back = content.Load<Texture2D>("graphics/textures/weapons" + GunTexPath + "_boltback"); output[i].bolt_forward = content.Load<Texture2D>("graphics/textures/weapons" + GunTexPath + "_boltforeward"); output[i].muzzleFlash = new Texture2D[3]; for (int j = 0; j != 3; j++) { output[i].muzzleFlash[j] = content.Load<Texture2D>("graphics/textures/weapons/" + name + "/muzzleFlash/" + j.ToString()); ; } output[i].gripPos.X = Convert.ToSingle(sr1.ReadLine()); //.ReadSingle(); output[i].gripPos.Y = Convert.ToSingle(sr1.ReadLine()); //.ReadSingle(); string ClipTexPath = sr1.ReadLine(); //.ReadString(); output[i].clip = content.Load<Texture2D>("graphics/textures/weapons/" + ClipTexPath); output[i].clipPos.X = output[i].gripPos.X+Convert.ToSingle(sr1.ReadLine()); //.ReadSingle(); output[i].clipPos.Y = output[i].gripPos.Y+Convert.ToSingle(sr1.ReadLine()); //.ReadSingle(); output[i].muzzPos.X = output[i].gripPos.X + Convert.ToSingle(sr1.ReadLine()); //.ReadSingle(); output[i].muzzPos.Y = output[i].gripPos.Y + Convert.ToSingle(sr1.ReadLine()); //.ReadSingle(); output[i].actionPos.X = output[i].gripPos.X + Convert.ToSingle(sr1.ReadLine()); //.ReadSingle(); output[i].actionPos.Y = output[i].gripPos.Y + Convert.ToSingle(sr1.ReadLine()); //.ReadSingle(); output[i].clipSize = Convert.ToInt32(sr1.ReadLine()); //.ReadInt32(); output[i].ROFdelay = Convert.ToInt32(sr1.ReadLine()); //.ReadInt32(); //ClipSize.Text = Convert.ToString(clipSize); output[i].Pt = (ProjectileType)Enum.ToObject(typeof(ProjectileType), Convert.ToInt32(sr1.ReadLine())); output[i].Stance = (StanceType)Enum.ToObject(typeof(StanceType), Convert.ToInt32(sr1.ReadLine())); string auto = sr1.ReadLine(); if (auto == "True") { output[i].auto = true; } else { output[i].auto = false; } output[i].clipCurrent = output[i].clipSize; } sr1.Close(); } return output; }
public character(string Name, Vector2 Position, skill Skill, ControlType CType, CharType type) { controlType = CType; action = "idle"; special_tag = -1; Type = type; name = Name; B_baseProps = new Base(Position, 70f); f_currentFrame = 0; body = null; currentAnim = new Animation(); angle = 0; accuracy = 1; attrib = Skill; armor = 0; pointingRight = true; Primary_weap = Secondary_weap = SideArm_weap = current_weap = new weapon(); Inventory = new inventory(5, null); weaponInUse = "unarmed"; brain = new AInode(false); reordered = false; }
public static void assignWeapon(weapon w,int c,string slot) { character Char = world.levels[world.i_currentLvl].char_living[c]; switch (slot) { case "primary": if (Char.Primary_weap.name != null && Char.Primary_weap.name != "unarmed") { //Char.Inventory = itemFunc.createItem_INVEN(Char.Inventory, // itemFunc.createItemFromWeapon(w), // Vector2.Zero, // 0); } //Char = RemoveWeapon(Char,w.name); Char.Primary_weap = w; break; case "secondary": //Char = RemoveWeapon(Char, w.name); Char.Secondary_weap = w; break; case "sidearm": //Char = RemoveWeapon(Char, w.name); Char.SideArm_weap = w; break; } Char.current_weap = w; world.levels[world.i_currentLvl].char_living[c] = Char; }
public static weapon FindWeapon(string name) { weapon output = new weapon(); for (int i = 0; i != world.weapons.Length; i++) { if (world.weapons[i].name == name) { output = world.weapons[i]; } } return output; }
public static int FindAmmoType(character c, weapon w) { string target = ""; int output = -1; #region FindAmmoName switch (w.Pt) { case ProjectileType.AR223: target = "ammo_223"; break; case ProjectileType.AR762: target = "ammo_762"; break; case ProjectileType.CAR22: target = "ammo_22"; break; case ProjectileType.P357: target = "ammo_357"; break; case ProjectileType.P38: target = "ammo_38"; break; case ProjectileType.SG_pellet: target = "ammo_12"; break; case ProjectileType.SMG45: target = "ammo_45"; break; case ProjectileType.SMG9: target = "ammo_9"; break; case ProjectileType.SR308: target = "ammo_308"; break; case ProjectileType.SR50: target = "ammo_50"; break; } #endregion if (c.Inventory.items != null) { for (int i = 0; i != c.Inventory.items.Length; i++) { if (c.Inventory.items[i].gameTag == target) { if (c.Inventory.items[i].quality != 0) { output = i; } } } } return output; }