public Player(string name, byte age, Gender gender, Inventory inventory) { this.Name = name; this.Age = age; this.Gender = gender; this.inventory = inventory; }
public Chest(string name, Inventory content) : base(name) { Content = content; description = String.Format("There is {0} laying on the ground", Name.ToLower()); message = "Time to loot:\nCONTENT"; symbol = 'x'; }
/// <summary> /// Initializes a new instance of the <see cref="Game.Being"/> class. /// </summary> /// <param name='name'> /// Name. /// </param> /// <param name='ch'> /// Ch. /// </param> /// <param name='bagsize'> /// Bagsize. /// </param> public Being(string name, Characteristics ch, Characteristics currentCh, int bagsize) { this.Name = name; this.Characteristics = ch; this.CurrentCharacteristics = currentCh; this.bag = new Inventory(bagsize); this.equiped = new Inventory(bagsize); this.Body = new Body( new string[0]); this.symbol = 'B'; }
public void OnOpen(Inventory inventory, int initIndex) { for (int y = 0; y < inventory.Y; y++) { for (int x = 0; x < inventory.X; x++) { Slot s = inventory.getSlot(x, y); if (s == null) { continue; } string texture = Inventory.MagicCubes.ContainsKey(s.item) ? Inventory.MagicCubes[s.item] : VanillaChunk.staticBlock[VanillaChunk.byteToString[s.item]].getItemTexture(); GUI.SetBlockAt(initIndex + x + y * inventory.X, texture, s.amount); } } }
public Tank(TankGame game, Vector2 tankPosition, float turretAngle) : base(game) { this.game = game; this.tankPosition = tankPosition; turretPosition = new Vector2(tankPosition.X + 40, tankPosition.Y + 25); this.turretAngle = turretAngle; health = 200; turnTime = 0; moveLimit = 0; originalTurretDirection = new Vector2(0, 1); turretDirection = new Vector2((float)(Math.Cos(-turretAngle) * originalTurretDirection.X - Math.Sin(-turretAngle) * originalTurretDirection.Y), (float)(Math.Sin(-turretAngle) * originalTurretDirection.X + Math.Cos(-turretAngle) * originalTurretDirection.Y)); bullet = new Bullet(game); type = BulletType.BasicBullet; inventory = new Inventory(game); damageClouds = null; timer = 0.0f; currentTankState = TankState.Normal; }
public static Player LoadPlayerFromXml(string playername) { string path = filePath + "players/" + playername.ToLower() + "/player.xml"; XmlDocument doc = new XmlDocument(); doc.Load(path); XmlNode root = doc.DocumentElement; // get attributes of player - name and positions string name = root.Attributes["name"].Value; int x = int.Parse(root.Attributes["x"].Value); int y = int.Parse(root.Attributes["y"].Value); string dungeonName = root.Attributes["currentDungeon"].Value; Characteristics ch = new Characteristics(0,0,0,0); Characteristics cch = new Characteristics(0,0,0,0); Inventory bag = new Inventory(0); Inventory equiped = new Inventory(0); string[] b = new string[6]; foreach (XmlNode node in root.ChildNodes) { string nodeName = node.Name; switch (nodeName) { case "Characteristics": { ch = LoadCharacteristicsFromXml((XmlElement)node); break; } case "CurrentCharacteristics": { cch = LoadCharacteristicsFromXml((XmlElement)node); break; } case "Bag": { bag = LoadInventoryFromXml((XmlElement)node); break; } case "Equiped": { equiped = LoadInventoryFromXml((XmlElement)node); break; } case "Body": { b = LoadBodyFromXML((XmlElement)node); break; } } } Player p = new Player(name, ch, cch, bag.maxsize, x, y); p.bag = bag; p.equiped = equiped; p.SetBody(new Body(b)); p.SetCurrentDungeon(dungeonName); lua.DoFile(filePath + "players/" + p.Name.ToLower() + "/config.lua"); return p; }
public static Inventory LoadInventoryFromXml(XmlElement node) { int bagsize = int.Parse(node.GetAttribute("maxsize")); Inventory inv = new Inventory(bagsize); foreach (XmlNode child in node.ChildNodes) { XmlElement childElement = (XmlElement)child; string name = childElement.Name; switch(name) { case "Item": { inv.Add(LoadItemFromXml(childElement)); break; } case "Equipment": { inv.Add(LoadEquipmentFromXml(childElement)); break; } case "Weapon": { inv.Add(LoadWeaponFromXml(childElement)); break; } } } return inv; }
public static Being LoadBeingFromXml(XmlElement node) { // get name of being string name = node.Attributes["name"].Value; string symbol = node.Attributes["symbol"].Value; Characteristics ch = new Characteristics(0,0,0,0); Characteristics cch = new Characteristics(0,0,0,0); Inventory bag = new Inventory(0); Inventory equiped = new Inventory(0); string[] b = new string[6]; foreach (XmlNode subnode in node.ChildNodes) { string nodeName = subnode.Name; switch (nodeName) { case "Characteristics": { ch = LoadCharacteristicsFromXml((XmlElement)subnode); break; } case "CurrentCharacteristics": { cch = LoadCharacteristicsFromXml((XmlElement)subnode); break; } case "Bag": { bag = LoadInventoryFromXml((XmlElement)subnode); break; } case "Equiped": { equiped = LoadInventoryFromXml((XmlElement)subnode); break; } case "Body": { b = LoadBodyFromXML((XmlElement)subnode); break; } } } Being being = new Being(name, ch, cch, bag.maxsize); being.bag = bag; being.equiped = equiped; being.SetBody(new Body(b)); being.SetSymbol(symbol); return being; }