示例#1
0
        public void FillEquippables()
        {
            if (hero.Inventory.MainHandWeapon != null)
            {
                IWeapon mWeapon = hero.Inventory.MainHandWeapon;
                string mwName = hero.Inventory.MainHandWeapon.GetType().Name;
                try
                {
                    if (mWeapon.AttackPoints <= 60)
                    {
                        mainHandTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier1_" + mwName);
                    }
                    if (mWeapon.AttackPoints > 60 && mWeapon.AttackPoints <= 100)
                    {
                        mainHandTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier2_" + mwName);
                    }
                    else if (mWeapon.AttackPoints > 100)
                    {
                        mainHandTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier3_" + mwName);
                    }
                    else
                    {
                        mainHandTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier1_" + mwName);
                    }
                }
                catch
                {
                    mainHandTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_PlaceHolder");
                }
                mainHandSprite = new ItemSprite((Item)hero.Inventory.MainHandWeapon, mainHandTexture) { Position = new Vector2(190, 300) };
            }
            if (hero.Inventory.OffHand != null)
            {
                string mwName = hero.Inventory.OffHand.GetType().Name;
                try
                {
                    if (hero.Inventory.OffHand is IWeapon)
                    {
                        IWeapon mWeapon = (IWeapon)hero.Inventory.OffHand;

                        if (mWeapon != null && mWeapon.AttackPoints <= 60)
                        {
                            offHandTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier1_" + mwName);
                        }
                        if (mWeapon != null && (mWeapon.AttackPoints > 60 && mWeapon.AttackPoints <= 100))
                        {
                            offHandTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier2_" + mwName);
                        }
                        else if (mWeapon != null && mWeapon.AttackPoints > 100)
                        {
                            offHandTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier3_" + mwName);
                        }
                        else
                        {
                            offHandTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier1_" + mwName);
                        }
                    }
                    else
                    {
                        offHandTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_" + mwName);
                    }

                }
                catch
                {
                    offHandTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_PlaceHolder");
                }
                offHandSprite = new ItemSprite((Item)hero.Inventory.OffHand, offHandTexture) { Position = new Vector2(190, 360) };
            }
            if (hero.Inventory.BodyArmor != null)
            {
                string mwName = hero.Inventory.BodyArmor.GetType().Name;
                try
                {
                    bodyArmorTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_" + mwName);
                    if (hero is Monk) bodyArmorTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Robe");
                    if (hero is Ninja) bodyArmorTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Jerkin");
                }
                catch
                {
                    bodyArmorTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_PlaceHolder");
                }
                bodyArmorSprite = new ItemSprite((Item)hero.Inventory.BodyArmor, bodyArmorTexture) { Position = new Vector2(190, 60) };
            }
            if (hero.Inventory.Helmet != null)
            {
                string mwName = hero.Inventory.Helmet.GetType().Name;
                try
                {
                    helmeTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_" + mwName);
                    if (hero is Monk) helmeTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Hat");
                    if (hero is Ninja) helmeTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Hood");

                }
                catch
                {
                    helmeTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_PlaceHolder");
                }
                helmetSprite = new ItemSprite((Item)hero.Inventory.Helmet, helmeTexture) { Position = new Vector2(190, 120) };
            }
            if (hero.Inventory.Gloves != null)
            {
                string mwName = hero.Inventory.Gloves.GetType().Name;
                try
                {
                    glovesTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_" + mwName);
                }
                catch
                {
                    glovesTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_PlaceHolder");
                }
                glovesSprite = new ItemSprite((Item)hero.Inventory.Gloves, glovesTexture) { Position = new Vector2(190, 240) };
            }
            if (hero.Inventory.Boots != null)
            {
                string mwName = hero.Inventory.Boots.GetType().Name;
                try
                {
                    bootsTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_" + mwName);
                }
                catch
                {
                    bootsTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_PlaceHolder");
                }
                bootsSprite = new ItemSprite((Item)hero.Inventory.Boots, bootsTexture) { Position = new Vector2(190, 180) };
            }
        }
示例#2
0
        private void EquipSlot(ItemSprite spr)
        {
            this.bagItemsVisualization.Clear();

            if (spr.mItem is IWeapon)
            {
                if (spr.mItem is IOffhand && !(this.hero.Inventory.MainHandWeapon is TwoHandedWeapon))
                {
                    if (!this.handsButtonPositionSet)
                    {
                        this.mainHandButton.SetPosition(new Vector2(this.mouse.X + 10, this.mouse.Y + 10));
                        this.offHandButton.SetPosition(new Vector2(this.mouse.X + 10, this.mouse.Y + 36));
                        this.handsButtonPositionSet = true;
                    }
                    this.selectedItem = (Item)spr.mItem;
                    this.itemSpritesCurrentlyUpdateable = false;
                    this.handSelectionVisible = true;
                }
                else if ((spr.mItem is TwoHandedWeapon && this.hero.Inventory.OffHand == null)
                    || (this.hero.Inventory.MainHandWeapon is TwoHandedWeapon))
                {
                    this.hero.ReplaceMainHand((Item)spr.mItem, this.MGame.Engine.HeroType);
                }

            }
            else if (spr.mItem is BodyArmor)
            {
                hero.ReplaceBodyArmor((Item)spr.mItem);
            }
            else if (spr.mItem is Helmet)
            {
                hero.ReplaceHelmet((Item)spr.mItem);
            }
            else if (spr.mItem is Shield
                && (this.hero.Inventory.MainHandWeapon is OneHandedWeapon || this.hero.Inventory.MainHandWeapon == null))
            {
                hero.ReplaceOffHand((Item)spr.mItem);
            }
            else if (spr.mItem is Boots)
            {
                hero.ReplaceBoots((Item)spr.mItem);
            }
            else if (spr.mItem is Gloves)
            {
                hero.ReplaceGloves((Gloves)spr.mItem);
            }
            else if (spr.mItem is HealingPotion)
            {
                var hp = (HealingPotion)spr.mItem;
                hero.ApplyHealthPoints(hp);
                hero.Inventory.RemoveItemFromBag((Item)spr.mItem);
            }
            else if (spr.mItem is ManaPotion)
            {
                var mp = (ManaPotion)spr.mItem;
                hero.ApplyManaPoints(mp);
                hero.Inventory.RemoveItemFromBag((Item)spr.mItem);
            }
            FillBag();
            FillEquippables();
        }
示例#3
0
        public void FillBag()
        {
            bagItemsVisualization.Clear();
            int currentlyInBag = hero.Inventory.Bag.Count;
            for (int i = 0; i < currentlyInBag; i++)
            {
                var it = hero.Inventory.Bag[i];
                string itName = it.GetType().Name;
                Texture2D itemTexture;
                try
                {
                    if (it is Weapon)
                    {
                        Weapon itTier = it as Weapon;
                        if (itTier.AttackPoints <= 60)
                        {
                            itemTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier1_" + itName);
                        }
                        if (itTier.AttackPoints > 60 && itTier.AttackPoints <= 100)
                        {
                            itemTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier2_" + itName);
                        }
                        else if (itTier.AttackPoints > 100)
                        {
                            itemTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier3_" + itName);
                        }
                        else
                        {
                            itemTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Tier1_" + itName);
                        }
                    }

                    else
                    {
                        itemTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_" + itName);
                        if (it is BodyArmor)
                        {
                            if (hero is Monk) itemTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Robe");
                            if (hero is Ninja) itemTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Jerkin");
                        }
                        if (it is Helmet)
                        {
                            if (hero is Monk)
                                itemTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Hat");
                            if (hero is Ninja)
                                itemTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_Hood");
                        }
                    }

                }
                catch
                {
                    itemTexture = MGame.Content.Load<Texture2D>("Sprites/Inventory/Inv_PlaceHolder");
                }
                var itemSprite = new ItemSprite(it, itemTexture);
                int row = i / 6;
                int col = i % 6;
                itemSprite.Position = new Vector2(350 + col * 60, 60 + (row * 60));
                bagItemsVisualization.Add(itemSprite);
            }
        }