//Default ctor public Item(Map map, GraphicsDevice device, ItemType type, int index, Vector2 position, int currentTile, int width, int height, bool placed = true, Entity owner = null, ItemProperties properties = null) { this.map = map; Type = type; this.position = position; CurrentTile = currentTile; Width = width; Height = height; IsPlaced = placed; Owner = owner; Properties = properties; InitializeItem(); Properties.Name += " " + index.ToString(); CreateTexture(device); }
//Initializes Item properties private void InitializeItem() { if (!IsPlaced && Owner == null) { throw new ArgumentException("Cannot create an unobtainable item"); } if (Properties == null) { Properties = new ItemProperties(); float potence = (map.TileCount) / (map.TileCount - Math.Max(1f, CurrentTile)); switch (Type) { case ItemType.Armor: Properties.Name = "BETTER RESISTANCE"; Properties.Adjective = "Resilient"; Properties.ArmorBonus = 2f * potence; break; case ItemType.Weapon: Properties.Name = "STRONGER PUNCH"; Properties.Adjective = "Strong"; Properties.StrengthBonus = 4f * potence; break; case ItemType.Speed: Properties.Name = "FASTER MOVEMENT"; Properties.Adjective = "Fast"; Properties.SpeedBonus = (potence - 1f) / 3; break; case ItemType.HP: Properties.Name = "MORE HP"; Properties.Adjective = "Healthly"; Properties.HPBonus = (int)(10 * potence); break; } } }