Ejemplo n.º 1
0
        /*_______________Consumicion______________*/
        public bool ConsumeItem(int num)
        {
            bool control = false;

            if (bag[num].GetType().BaseType == typeof(ItemConsumable))
            {
                if (bag[num].GetType() == typeof(ItemPocion))
                {
                    ItemPocion item = (ItemPocion)bag[num];
                    item.Consumir();
                    if (item.GetPocionType() == ItemPocion.PocionType.hp)
                    {
                        if (hp < GetMHealth())
                        {
                            Program.buffer.InsertText("Has tomado " + bag[num].GetName() + " y has recuperado " + item.GetRecoveryStat() + " de vida");
                        }
                        else
                        {
                            Program.buffer.InsertText("Has tomado " + bag[num].GetName() + " y te has recuperado el máximo de vida");
                        }
                    }
                    else
                    {
                        if (mana < manaM)
                        {
                            Program.buffer.InsertText("Has tomado " + bag[num].GetName() + " y has recuperado " + item.GetRecoveryStat() + " de maná");
                        }
                        else
                        {
                            Program.buffer.InsertText("Has tomado " + bag[num].GetName() + " y te has recuperado el máximo de maná");
                        }
                    }
                    bag[num] = null;
                    control  = true;
                }
                else if (bag[num].GetType() == typeof(ItemScroll))
                {
                    ItemScroll item = (ItemScroll)bag[num];
                    item.Consumir();
                    bag[num] = null;
                    control  = true;
                }
                if (!control)
                {
                    throw new NotImplementedException("Error con el objeto de tipo " + bag[num].GetType().Name);
                }
            }
            else
            {
                Program.buffer.InsertText(bag[num].GetName() + " no se puede consumir");
            }
            Item.Ordenar(bag);
            return(control);
        }
Ejemplo n.º 2
0
        public Player()
        {
            for (int i = 0; i < 5; i++)
            {
                bag[i] = new ItemPocion("Poción de vida", 50, ItemPocion.PocionType.hp);
            }
            armadura = new ItemArmor("Armadura Simple", 5, 3, 45);

            hpM   = 24;
            hp    = GetMHealth();
            att   = 7;
            def   = 5;
            speed = 5;
            mana  = 10;
            manaM = 10;
            money = 0;
        }