public LootBoxElement(int width, int height, GraphicsDevice device, GUI gui, string rarity, LootBox loot) : base(width,
                                                                                                                         height, device, gui)
        {
            using (FileStream fileStream = new FileStream("Content/Lootbox/" + rarity + ".png", FileMode.Open))
            {
                Texture = Texture2D.FromStream(Game1.self.GraphicsDevice, fileStream);
                fileStream.Dispose();
            }

            Scale   = new Vector2((float)width / (float)Texture.Width, (float)height / (float)Texture.Height);
            Lootbox = loot;

            if (rarity.Equals("common"))
            {
                this.rarity = Rarity.common;
            }
            else if (rarity.Equals("uncommon"))
            {
                this.rarity = Rarity.uncommon;
            }
            else if (rarity.Equals("rare"))
            {
                this.rarity = Rarity.rare;
            }
            Tooltip = new Tooltip(400, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true, 300);

            Tooltip.Text = "Name:    " + Lootbox.Name + "\n" + "Rarity:    " + rarity + "\n" + "Cost:    " + Lootbox.Cost;
        }
        public LootBoxElement(int width, int height, GraphicsDevice device, GUI gui, string rarity, LootBox loot) : base(width,
                                                                                                                         height, device, gui)
        {
            Lootbox = loot;

            if (rarity.Equals("common"))
            {
                AssetManager z = Game.Activity.Assets;
                z.Open("Loots/Common.png");

                using (var fileStream = Game.Activity.Assets.Open("Loots/Common.png"))
                {
                    Texture = Texture2D.FromStream(Game1.self.GraphicsDevice, fileStream);
                    fileStream.Dispose();
                }
                this.rarity = Rarity.common;
            }
            else if (rarity.Equals("uncommon"))
            {
                using (var fileStream = Game.Activity.Assets.Open("Loots/Uncommon.png"))
                {
                    Texture = Texture2D.FromStream(Game1.self.GraphicsDevice, fileStream);
                    fileStream.Dispose();
                }
                this.rarity = Rarity.uncommon;
            }
            else if (rarity.Equals("rare"))
            {
                using (var fileStream = Game.Activity.Assets.Open("Loots/Rare.png"))
                {
                    Texture = Texture2D.FromStream(Game1.self.GraphicsDevice, fileStream);
                    fileStream.Dispose();
                }
                this.rarity = Rarity.rare;
            }

            Scale   = new Vector2((float)width / (float)Texture.Width, (float)height / (float)Texture.Height);
            Tooltip = new Tooltip(400, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true, 300);

            Tooltip.Text = "Name:    " + Lootbox.Name + "\n" + "Rarity:    " + rarity + "\n" + "Cost:    " + Lootbox.Cost;
        }
Exemplo n.º 3
0
 public Item(string name, string description, int value, int weight, int id, Rarity r)
 {
     if (!name.Equals(null) && !description.Equals(null) && value >= 0 && weight >= 0 && !r.Equals(null))
     {
         Name        = name;
         Description = description;
         Value       = value;
         Weight      = weight;
         ID          = id;
         Rarity      = r;
     }
     else
     {
         throw new System.ArgumentException("An Item can't be constructed by null arguments or negative integers");
     }
 }