This class represents armors. Armors have the code representing how the armor was made, what type of armor they are, and the attribute of the armor
Inheritance: ItemEquipment
示例#1
0
        public static bool CanEnchantItem(this EnumEnchantmentType instance, Item par1Item)
        {
            if (instance == EnumEnchantmentType.all)
            {
                return(true);
            }

            if (par1Item is ItemArmor)
            {
                if (instance == EnumEnchantmentType.armor)
                {
                    return(true);
                }

                ItemArmor itemarmor = (ItemArmor)par1Item;

                if (itemarmor.ArmorType == 0)
                {
                    return(instance == EnumEnchantmentType.armor_head);
                }

                if (itemarmor.ArmorType == 2)
                {
                    return(instance == EnumEnchantmentType.armor_legs);
                }

                if (itemarmor.ArmorType == 1)
                {
                    return(instance == EnumEnchantmentType.armor_torso);
                }

                if (itemarmor.ArmorType == 3)
                {
                    return(instance == EnumEnchantmentType.armor_feet);
                }
                else
                {
                    return(false);
                }
            }

            if (par1Item is ItemSword)
            {
                return(instance == EnumEnchantmentType.weapon);
            }

            if (par1Item is ItemTool)
            {
                return(instance == EnumEnchantmentType.digger);
            }

            if (par1Item is ItemBow)
            {
                return(instance == EnumEnchantmentType.bow);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
 private void SetStatsForArmorItem(ItemArmor itemArmor)
 {
     AddStat(itemArmor.armor, StatType.StatUp, "Defence");
     AddStat(itemArmor.magicResist, StatType.StatUp, "Magic resist");
     AddStat(itemArmor.requiredLevel, StatType.RequiredLevel);
     AddStat(itemArmor.requiredDexterity, StatType.RequiredSkill, "dexterity");
     AddStat(itemArmor.requiredMagic, StatType.RequiredSkill, "magic");
 }
示例#3
0
    /// <summary>
    /// Adds an Item to your Inventory.
    /// </summary>
    /// <param name="_ListOfItems"></param>
    /// <param name="_ItemID"></param>
    public void AddItem(List <Item> _ListOfItems, int _ItemID, int _AmountOfItemsToAdd)
    {
        // If the List we are peeking into is the List for Food...
        if (_ListOfItems == m_ItemManager.ItemsFood)
        {
            // Look at each of the Items within the List
            foreach (Item item in m_ItemManager.ItemsFood)
            {
                // Create a temporary Item to look for the ID
                ItemFood tmp = (ItemFood)item;

                // If the items ID matches the Id of the searched Item...
                if (tmp.m_FoodID == _ItemID)
                {
                    AddItemToSlot(ChangeSlotToAdd(tmp), tmp, _AmountOfItemsToAdd);
                    break;
                }
            }
        }

        // If the List we are peeking into is the List for Armor...
        if (_ListOfItems == m_ItemManager.ItemsArmor)
        {
            // Look at each of the Items within the List
            foreach (Item item in m_ItemManager.ItemsArmor)
            {
                // Create a temporary Item to look for the ID
                ItemArmor tmp = (ItemArmor)item;

                // If the items ID matches the Id of the searched Item...
                if (tmp.m_ArmorID == _ItemID)
                {
                    AddItemToSlot(ChangeSlotToAdd(tmp), tmp, _AmountOfItemsToAdd);
                    break;
                }
            }
        }

        // If the List we are peeking into is the List for Weapons...
        if (_ListOfItems == m_ItemManager.ItemsWeapon)
        {
            // Look at each of the Items within the List
            foreach (Item item in m_ItemManager.ItemsWeapon)
            {
                // Create a temporary Item to look for the ID
                ItemWeapon tmp = (ItemWeapon)item;

                // If the items ID matches the Id of the searched Item...
                if (tmp.m_WeaponID == _ItemID)
                {
                    AddItemToSlot(ChangeSlotToAdd(tmp), tmp, _AmountOfItemsToAdd);
                    break;
                }
            }
        }
    }
 public void ShowArmorPiece(ItemArmor armorItem)
 {
     foreach (var armorPiece in armorPieces)
     {
         if (armorPiece.name == armorItem.meshName)
         {
             armorPiece.SetActive(true);
         }
     }
 }
 public void HideArmorPiece(ItemArmor armorItem)
 {
     foreach (var armorPiece in armorPieces)
     {
         if (armorPiece.name == armorItem.meshName)
         {
             armorPiece.SetActive(false);
         }
     }
 }
示例#6
0
文件: Stats.cs 项目: exewin/Tact
    public void EquipArmor(Item item)
    {
        if (armor)
        {
            UnequipArmor();
        }

        inv.RemoveItem(item);
        armor = (ItemArmor)item;
        armorModel.SetActive(true);
    }
示例#7
0
文件: Stats.cs 项目: exewin/Tact
    public void UnequipArmor()
    {
        if (armor == null)
        {
            return;
        }

        inv.AddItem(armor);
        armorModel.SetActive(false);
        armor = null;
    }
示例#8
0
        public IItemArmor AddItemArmor(Guid guid, ItemArmorBlueprint blueprint, IContainer container)
        {
            if (blueprint == null)
            {
                throw new ArgumentNullException(nameof(blueprint));
            }
            IItemArmor item = new ItemArmor(guid, blueprint, container);

            _items.Add(item);
            return(item);
        }
示例#9
0
    // GetItemByIndex(ItemManager.ItemsFood, 1) == Apfel

    public Item GetItemByIndex(List <Item> _ListOFItems, int _Index)
    {
        if (_ListOFItems == m_ItemManager.ItemsFood)
        {
            foreach (Item item in m_ItemManager.ItemsFood)
            {
                ItemFood tmp = (ItemFood)item;

                if (tmp.m_FoodID == _Index)
                {
                    return(item);
                }
            }
        }

        if (_ListOFItems == m_ItemManager.ItemsArmor)
        {
            foreach (Item item in m_ItemManager.ItemsArmor)
            {
                ItemArmor tmp = (ItemArmor)item;

                if (tmp.m_ArmorID == _Index)
                {
                    return(item);
                }
            }
        }

        if (_ListOFItems == m_ItemManager.ItemsWeapon)
        {
            foreach (Item item in m_ItemManager.ItemsWeapon)
            {
                ItemWeapon tmp = (ItemWeapon)item;

                if (tmp.m_WeaponID == _Index)
                {
                    return(item);
                }
            }
        }

        // If there is no item found...
        return(null);
    }
示例#10
0
    public Item GetItemByName(List <Item> _ListOFItems, string _ItemName)
    {
        if (_ListOFItems == m_ItemManager.ItemsFood)
        {
            foreach (Item item in m_ItemManager.ItemsFood)
            {
                ItemFood tmp = (ItemFood)item;

                if (tmp.m_IName == _ItemName)
                {
                    return(item);
                }
            }
        }

        if (_ListOFItems == m_ItemManager.ItemsArmor)
        {
            foreach (Item item in m_ItemManager.ItemsArmor)
            {
                ItemArmor tmp = (ItemArmor)item;

                if (tmp.m_IName == _ItemName)
                {
                    return(item);
                }
            }
        }

        if (_ListOFItems == m_ItemManager.ItemsWeapon)
        {
            foreach (Item item in m_ItemManager.ItemsWeapon)
            {
                ItemWeapon tmp = (ItemWeapon)item;

                if (tmp.m_IName == _ItemName)
                {
                    return(item);
                }
            }
        }

        // If there is no item found...
        return(null);
    }
示例#11
0
    private void RemoveItem(List <Item> _ListOfItems, int _ItemID, int _AmountOfItemsToRemove)
    {
        if (_ListOfItems == m_ItemManager.ItemsFood)
        {
            foreach (Item item in _ListOfItems)
            {
                ItemFood tmp = (ItemFood)item;

                if (tmp.m_FoodID == _ItemID)
                {
                    RemoveItemFromSlot(ChangeSlotToRemove(tmp), tmp, _AmountOfItemsToRemove);
                    break;
                }
            }
        }

        if (_ListOfItems == m_ItemManager.ItemsArmor)
        {
            foreach (Item item in _ListOfItems)
            {
                ItemArmor tmp = (ItemArmor)item;

                if (tmp.m_ArmorID == _ItemID)
                {
                    RemoveItemFromSlot(ChangeSlotToRemove(tmp), tmp, _AmountOfItemsToRemove);
                    break;
                }
            }
        }

        if (_ListOfItems == m_ItemManager.ItemsWeapon)
        {
            foreach (Item item in _ListOfItems)
            {
                ItemWeapon tmp = (ItemWeapon)item;

                if (tmp.m_WeaponID == _ItemID)
                {
                    RemoveItemFromSlot(ChangeSlotToRemove(tmp), tmp, _AmountOfItemsToRemove);
                    break;
                }
            }
        }
    }
        public void HideBodyPart(ItemArmor item)
        {
            switch (item.equipmentSlot)
            {
            case ItemArmor.EquipmentSlot.Chest:
                chest.SetActive(false);
                break;

            case ItemArmor.EquipmentSlot.Head:
                head.SetActive(false);
                break;

            case ItemArmor.EquipmentSlot.Legs:
                pants.SetActive(false);
                break;

            case ItemArmor.EquipmentSlot.Feet:
                boots.SetActive(false);
                break;
            }
        }
        public void ShowBodyPart(ItemArmor armorPiece)
        {
            switch (armorPiece.equipmentSlot)
            {
            case ItemArmor.EquipmentSlot.Chest:
                chest.SetActive(true);
                break;

            case ItemArmor.EquipmentSlot.Head:
                head.SetActive(true);
                break;

            case ItemArmor.EquipmentSlot.Legs:
                pants.SetActive(true);
                break;

            case ItemArmor.EquipmentSlot.Feet:
                boots.SetActive(true);
                break;
            }
        }
示例#14
0
    // Use this for initialization
    private Inventory()
    {
        weapons = new List<ItemWeapon>();
        armors = new ArrayList();
        components = new ArrayList();
        items = new ArrayList();
        ores = new Dictionary<int, int>();

        equipedWeapon = null;
        equipedHelmet = null;
        equipedChest = null;
        equipedLegs = null;

        List<ItemBase.tOreType> exludedOres = ItemBase.getNonCraftingOres();
        foreach (ItemBase.tOreType oreType in Enum.GetValues(typeof(ItemBase.tOreType)))
        {
            if (exludedOres.Contains(oreType))
                continue;

            //Create all the ores beforehand w/ quantity=0
            ores[(int)oreType] = 0;
        }
    }
示例#15
0
    /// <summary>
    /// Equip the piece of chest armor passed in.
    /// Can be called with null to un-equip the item
    /// </summary>
    /// <param name="newChest"></param>
    public void inventoryEquipChest(ItemArmor newChest)
    {
        if (newChest == null)
        {
            equipedChest = null;
        }
        else if (newChest.armorPart == ItemArmor.tArmorPart.Chest)
        {
            equipedChest = newChest;
        }
        else
        {
            return;
        }

        calculateAndApplyStats();
    }
示例#16
0
    /// <summary>
    /// Equip the piece of chest armor passed in.
    /// Can be called with null to un-equip the item
    /// </summary>
    /// <param name="newHelmet"></param>
    public void inventoryEquipHelmet(ItemArmor newHelmet)
    {
        if (newHelmet == null)
        {
            equipedHelmet= null;
        }
        else if (newHelmet.armorPart == ItemArmor.tArmorPart.Head)
        {
            equipedHelmet = newHelmet;
        }
        else
        {
            return;
        }

        calculateAndApplyStats();
    }
示例#17
0
    private void OnItemFocusChangeCallback(object sender, ItemFocusChangeArgs args)
    {
        if (helpText != null)
        {
            UpdateHelpText(args.newItem);
        }

        if (args.newItem == null)
        {
            if (objectTitle != null)
            {
                objectTitle.enabled = false;
            }
            if (objectDescription != null)
            {
                objectDescription.enabled = false;
            }
            if (objectImage != null)
            {
                objectImage.enabled = false;
            }

            return;
        }
        else
        {
            if (objectTitle != null)
            {
                objectTitle.enabled = true;
            }
            if (objectDescription != null)
            {
                objectDescription.enabled = true;
            }
            if (objectImage != null)
            {
                objectImage.enabled = true;
            }
        }

        if (objectTitle != null)
        {
            objectTitle.text = args.newItem.Name;
        }

        if (objectDescription != null)
        {
            objectDescription.text  = args.newItem.Description;
            objectDescription.text += "\nWeight : " + args.newItem.Weigth;
            if (args.newItem is IUsable)
            {
                objectDescription.text += "\nUse : " + (args.newItem as IUsable).GetDescription();
            }
            if (args.newItem is ItemWeapon)
            {
                ItemWeapon weapItem = args.newItem as ItemWeapon;

                IWeapon weapon = weapItem.weaponPrefab.GetComponent <IWeapon>();
                if (weapon != null)
                {
                    if (weapon.GearStats != 0)
                    {
                        objectDescription.text += "<color=green>\nStats : ";
                        if (weapon.GearStats.Strength != 0)
                        {
                            objectDescription.text += weapon.GearStats.Strength + " STR | ";
                        }
                        if (weapon.GearStats.Stamina != 0)
                        {
                            objectDescription.text += weapon.GearStats.Stamina + " STA | ";
                        }
                        if (weapon.GearStats.Defense != 0)
                        {
                            objectDescription.text += weapon.GearStats.Defense + " DEF | ";
                        }
                        if (weapon.GearStats.Energy != 0)
                        {
                            objectDescription.text += weapon.GearStats.Energy + " ENG";
                        }
                        objectDescription.text += "</color>";
                    }

                    objectDescription.text += weapon.GetInventoryDescription();
                }
            }
            else if (args.newItem is ItemArmor)
            {
                ItemArmor item  = args.newItem as ItemArmor;
                Armor     armor = item.ArmorPrefab as Armor;

                objectDescription.text += "\n" + armor.Type.ToString() + " armor.\n";
                if (armor.ArmorValue != 0)
                {
                    objectDescription.text += "Armor : " + armor.ArmorValue + "\n";
                }

                if (armor.Stats != 0)
                {
                    objectDescription.text += "<color=green>Stats : ";
                    if (armor.Stats.Strength != 0)
                    {
                        objectDescription.text += armor.Stats.Strength + " STR | ";
                    }
                    if (armor.Stats.Stamina != 0)
                    {
                        objectDescription.text += armor.Stats.Stamina + " STA | ";
                    }
                    if (armor.Stats.Defense != 0)
                    {
                        objectDescription.text += armor.Stats.Defense + " DEF | ";
                    }
                    if (armor.Stats.Energy != 0)
                    {
                        objectDescription.text += armor.Stats.Energy + " ENG";
                    }
                    objectDescription.text += "</color>";
                }
            }
        }

        if (objectImage != null)
        {
            if (args.newItem.Image != null)
            {
                objectImage.sprite = args.newItem.Image;
            }
            else
            {
                objectImage.sprite = defaultSprite;
            }
        }
    }
示例#18
0
        public static bool VerEquipo()
        {
            ConsoleBuffer.ObteBuffer().PrintBackground();
            ConsoleBuffer.ObteBuffer().Print(1, 0, "EQUIPO");
            ConsoleBuffer.ObteBuffer().Print(1, 4, "ARMA");
            ItemWeapon weapon = Program.ObteJuego().pl.GetWeapon();

            if (weapon != null)
            {
                ConsoleBuffer.ObteBuffer().Print(7, 5, weapon.GetName());
                ConsoleBuffer.ObteBuffer().Print(7, 6, "HP-> " + weapon.ModifierHp());
                ConsoleBuffer.ObteBuffer().Print(7, 7, "ATT-> " + weapon.ModifierAtt());
                ConsoleBuffer.ObteBuffer().Print(7, 8, "DEF-> " + weapon.ModifierDef());
            }
            else
            {
                ConsoleBuffer.ObteBuffer().Print(7, 5, "Ninguna");
            }


            ConsoleBuffer.ObteBuffer().Print(1, 12, "ARMADURA");
            ItemArmor armor = Program.ObteJuego().pl.GetArmor();

            if (armor != null)
            {
                ConsoleBuffer.ObteBuffer().Print(7, 13, armor.GetName());
                ConsoleBuffer.ObteBuffer().Print(7, 14, "HP-> " + armor.ModifierHp());
                ConsoleBuffer.ObteBuffer().Print(7, 15, "ATT-> " + armor.ModifierAtt());
                ConsoleBuffer.ObteBuffer().Print(7, 16, "DEF-> " + armor.ModifierDef());
            }
            else
            {
                ConsoleBuffer.ObteBuffer().Print(7, 5, "Ninguna");
            }

            ConsoleBuffer.ObteBuffer().Print(101, 3, "Hp  -> " + Program.ObteJuego().pl.GetHealth() + "/" + Program.ObteJuego().pl.GetMHealth());
            ConsoleBuffer.ObteBuffer().Print(101, 5, "Att -> " + Program.ObteJuego().pl.GetAtt());
            ConsoleBuffer.ObteBuffer().Print(101, 7, "Def -> " + Program.ObteJuego().pl.GetDef());
            ConsoleBuffer.ObteBuffer().Print(101, 11, "Mana -> " + Program.ObteJuego().pl.GetMana() + "/" + Program.ObteJuego().pl.GetManaM());
            ConsoleBuffer.ObteBuffer().Print(101, 13, "Vel. -> " + Program.ObteJuego().pl.GetSpeed());

            ConsoleBuffer.ObteBuffer().Print(51, 4, "GEMAS");

            ItemGema[] gemas = Program.ObteJuego().pl.GetGemas();
            bool       check = true;

            for (int i = 0; i < gemas.Length; i++)
            {
                if (gemas[i] != null)
                {
                    check = false;
                    if (i < 2)
                    {
                        ConsoleBuffer.ObteBuffer().Print(55, 5 + i * 7, i.ToString() + ":");
                        ConsoleBuffer.ObteBuffer().Print(57, 6 + i * 7, gemas[i].GetName());
                        ConsoleBuffer.ObteBuffer().Print(57, 7 + i * 7, "HP-> " + gemas[i].ModifierHp());
                        ConsoleBuffer.ObteBuffer().Print(57, 8 + i * 7, "ATT-> " + gemas[i].ModifierAtt());
                        ConsoleBuffer.ObteBuffer().Print(57, 9 + i * 7, "DEF-> " + gemas[i].ModifierDef());
                    }
                    else
                    {
                        ConsoleBuffer.ObteBuffer().Print(78, 5, i.ToString() + ":");
                        ConsoleBuffer.ObteBuffer().Print(80, 6, gemas[i].GetName());
                        ConsoleBuffer.ObteBuffer().Print(80, 7, "HP-> " + gemas[i].ModifierHp());
                        ConsoleBuffer.ObteBuffer().Print(80, 8, "ATT-> " + gemas[i].ModifierAtt());
                        ConsoleBuffer.ObteBuffer().Print(80, 9, "DEF-> " + gemas[i].ModifierDef());
                    }
                }
            }

            if (check)
            {
                ConsoleBuffer.ObteBuffer().Print(57, 5, "No tienes gemas");
            }

            ConsoleBuffer.ObteBuffer().Print(1, ConsoleBuffer.ObteBuffer().height - 2, "Pulsa cualquier tecla para salir");
            ConsoleBuffer.ObteBuffer().PrintScreen();
            Console.ReadKey();
            return(true);
        }
示例#19
0
        public static bool GetStats()
        {
            ConsoleBuffer.ObteBuffer().PrintBackground();
            Item[] bagitem = Program.ObteJuego().pl.GetGemas();
            int    modh    = 0;
            int    moda    = 0;
            int    modd    = 0;

            for (int i = 0; i < bagitem.Length; i++)
            {
                if (bagitem[i] != null && bagitem[i].GetType() == typeof(ItemGema))
                {
                    ItemGema gema = (ItemGema)bagitem[i];
                    modh += gema.ModifierHp();
                    moda += gema.ModifierAtt();
                    modd += gema.ModifierDef();
                }
            }
            ItemWeapon weapon = Program.ObteJuego().pl.GetWeapon();

            if (weapon != null)
            {
                modh += weapon.ModifierHp();
                moda += weapon.ModifierAtt();
                modd += weapon.ModifierDef();
            }
            ItemArmor armor = Program.ObteJuego().pl.GetArmor();

            if (armor != null)
            {
                modh += armor.ModifierHp();
                moda += armor.ModifierAtt();
                modd += armor.ModifierDef();
            }
            ConsoleBuffer.ObteBuffer().Print(1, 0, "STATS");

            ConsoleBuffer.ObteBuffer().Print(2, 3, "Nvl. " + Program.ObteJuego().pl.GetLevel() + "  Exp. " + Program.ObteJuego().pl.Experiencia);

            if (modh == 0)
            {
                ConsoleBuffer.ObteBuffer().Print(2, 5, "VIDA (HP)-> " + Program.ObteJuego().pl.GetHealth() + "/" + Program.ObteJuego().pl.GetMHealth() + " --> Capacidad de aguante");
            }
            else
            {
                ConsoleBuffer.ObteBuffer().Print(2, 5, "VIDA (HP)-> " + Program.ObteJuego().pl.GetHealth() + "/" + Program.ObteJuego().pl.GetMHealth() + "+(" + modh + ") --> Capacidad de aguante");
            }

            if (moda == 0)
            {
                ConsoleBuffer.ObteBuffer().Print(2, 7, "ATAQUE (Att)-> " + Program.ObteJuego().pl.GetFlatAtt() + " --> Daño que inflinges");
            }
            else
            {
                ConsoleBuffer.ObteBuffer().Print(2, 7, "ATAQUE (Att)-> " + Program.ObteJuego().pl.GetFlatAtt() + "+(" + moda + ") --> Daño que inflinges");
            }

            if (modd == 0)
            {
                ConsoleBuffer.ObteBuffer().Print(2, 9, "DEFENSA (Def)-> " + Program.ObteJuego().pl.GetFlatDef() + " --> Daño que reduces");
            }
            else
            {
                ConsoleBuffer.ObteBuffer().Print(2, 9, "DEFENSA (Def)-> " + Program.ObteJuego().pl.GetFlatDef() + "+(" + modd + ") --> Daño que reduces");
            }

            ConsoleBuffer.ObteBuffer().Print(2, 13, "MANA (mana) -> " + Program.ObteJuego().pl.GetMana() + "/" + Program.ObteJuego().pl.GetManaM());

            ConsoleBuffer.ObteBuffer().Print(2, 15, "Velocidad (Vel.) -> " + Program.ObteJuego().pl.GetSpeed());

            ConsoleBuffer.ObteBuffer().SmallMap();
            ConsoleBuffer.ObteBuffer().PrintScreen();
            Console.ReadKey();
            return(true);
        }
示例#20
0
    //generic to equip any itemEquipment. will replace it in the appropriate spot.
    public void inventoryEquipItem(ItemEquipment itemToEquip)
    {
        //equip items if applicaple.
        if(itemToEquip is ItemWeapon)
        {
            equipedWeapon = (ItemWeapon)itemToEquip;
        }
        else if(itemToEquip is ItemArmor)
        {
            ItemArmor armorToEquip = itemToEquip as ItemArmor;
            switch (armorToEquip.armorPart)
            {
                case ItemArmor.tArmorPart.Chest:
                    equipedChest = armorToEquip;
                break;
                case ItemArmor.tArmorPart.Head:
                    equipedHelmet = armorToEquip;
                break;
                case ItemArmor.tArmorPart.Legs:
                    equipedLegs = armorToEquip;
                break;
            }
        }
        else
        {
            return; //change nothing if it was not equipable equipment....
        }

        calculateAndApplyStats();
    }
示例#21
0
 public ItemArmor(ItemArmor data) : base(data.ID, data.Identity, data.Name, ItemType.Armor, data.EquipType, data.Value, data.Description, data.Sprite, data.Tier, data.Multiplier, data.UniqueItemReference)
 {
     _defense = data.Defense;
 }
示例#22
0
    /// <summary>
    /// Equip the piece of armor passed in.
    /// Can be called with null to un-equip the item
    /// </summary>
    /// <param name="newLegs"></param>
    public void inventoryEquipLegs(ItemArmor newLegs)
    {
        if (newLegs == null)
        {
            equipedLegs = null;
        }
        else if (newLegs.armorPart == ItemArmor.tArmorPart.Legs)
        {
            equipedLegs = newLegs;
        }
        else
        {
            return;
        }

        calculateAndApplyStats();
    }
示例#23
0
 public static string generateArmorCode(ItemComponent.tAttributeType att, tOreType ore, ItemArmor.tArmorPart part)
 {
     return "" + (int)att + (int)ore + (int)part;
 }
示例#24
0
        public async Task <IActionResult> Arena(ArenaViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.GetUserAsync(User);

                if (user.Status != UserStatus.Stays)
                {
                    ModelState.AddModelError(string.Empty, "Aktualnie nie możesz walczyć na arenie.");
                }
                else if (model.UserName == user.UserName)
                {
                    ModelState.AddModelError(string.Empty, "Nie możesz walczyć ze sobą.");
                }
                else if (user.ActionPoints < 1)
                {
                    ModelState.AddModelError(string.Empty, "Nie masz siły na walkę na arenie.");
                }
                else
                {
                    var enemy = await _userManager.FindByNameAsync(model.UserName);

                    if (enemy == null)
                    {
                        ModelState.AddModelError(string.Empty, "Podany gracz nie istnieje.");
                    }
                    else if (user.PositionX != enemy.PositionX || user.PositionY != enemy.PositionY)
                    {
                        ModelState.AddModelError(string.Empty, "Tego gracza nie ma w tym miejscu.");
                    }
                    else if (enemy.Status != UserStatus.Stays)
                    {
                        ModelState.AddModelError(string.Empty, "Podany gracz jest teraz czymś zajęty.");
                    }
                    else if (user.HealthPoints < user.MaxHealthPoints * 0.25)
                    {
                        ModelState.AddModelError(string.Empty, "Jesteś rany. Ulecz się zanim podejmiesz walkę.");
                    }
                    else if (enemy.HealthPoints < enemy.MaxHealthPoints * 0.25)
                    {
                        ModelState.AddModelError(string.Empty, "Przeciwnik jest ranny. Nie możesz go zaatakować.");
                    }
                    else
                    {
                        var arenaResultViewModel = new ArenaResultViewModel()
                        {
                            User  = user,
                            Enemy = enemy
                        };

                        int userHealth  = user.HealthPoints;
                        int enemyHealth = enemy.HealthPoints;

                        int    i          = 0;
                        int    userScore  = 0;
                        int    enemyScore = 0;
                        Random rand       = new Random();

                        while (user.HealthPoints > 0 && enemy.HealthPoints > 0)
                        {
                            i++;
                            var roundInfo = string.Empty;

                            if (enemy.GetDodge() > rand.NextDouble() * 100)
                            {
                                roundInfo += "<div class=\"alert alert-success\" role=\"alert\">Spudłowałeś.</div>";
                            }
                            else
                            {
                                ItemWeapon weapon = null;
                                foreach (var used in _inventoryRepository.GetInventory(user.Id).Where(x => x.Used == true).ToList())
                                {
                                    var item = _itemRepository.GetItem(used.ItemId);
                                    if (item.Type == ItemType.Weapon)
                                    {
                                        weapon = (ItemWeapon)item.ItemType;
                                        break;
                                    }
                                }

                                var userAtt = rand.Next(user.GetDamage() - 1, user.GetDamage() + 2);
                                if (weapon != null)
                                {
                                    userAtt = rand.Next(user.GetDamage() + weapon.MinDamage, user.GetDamage() + weapon.MaxDamage);
                                }

                                if (user.GetCritical() >= rand.NextDouble() * 100)
                                {
                                    roundInfo += "<div class=\"alert alert-success\" role=\"alert\">Uderzenie krytyczne.</div>";
                                    userAtt   *= 2;
                                }

                                ItemArmor armor = null;
                                foreach (var used in _inventoryRepository.GetInventory(enemy.Id).Where(x => x.Used == true).ToList())
                                {
                                    var item = _itemRepository.GetItem(used.ItemId);
                                    if (item.Type == ItemType.Armor)
                                    {
                                        armor = (ItemArmor)item.ItemType;
                                        break;
                                    }
                                }

                                if (armor != null)
                                {
                                    userAtt -= (int)(userAtt * (rand.Next(0, armor.Resist + 1) / 100f));
                                }

                                enemy.HealthPoints -= userAtt;
                                userScore          += userAtt;
                                roundInfo          += $"<div class=\"alert alert-success\" role=\"alert\">Zadałeś {userAtt} obrażeń.</div>";

                                if (enemy.HealthPoints < 1)
                                {
                                    goto RoundEnd;
                                }
                            }

                            if (user.GetDodge() > rand.NextDouble() * 100)
                            {
                                roundInfo += "<div class=\"alert alert-danger\" role=\"alert\">Wróg spudłował.</div>";
                            }
                            else
                            {
                                ItemWeapon weapon = null;
                                foreach (var used in _inventoryRepository.GetInventory(enemy.Id).Where(x => x.Used == true).ToList())
                                {
                                    var item = _itemRepository.GetItem(used.ItemId);
                                    if (item.Type == ItemType.Weapon)
                                    {
                                        weapon = (ItemWeapon)item.ItemType;
                                        break;
                                    }
                                }

                                var enemyAtt = rand.Next(enemy.GetDamage() - 1, enemy.GetDamage() + 2);
                                if (weapon != null)
                                {
                                    enemyAtt = rand.Next(enemy.GetDamage() + weapon.MinDamage, enemy.GetDamage() + weapon.MaxDamage);
                                }

                                if (enemy.GetCritical() >= rand.NextDouble() * 100)
                                {
                                    roundInfo += "<div class=\"alert alert-danger\" role=\"alert\">Uderzenie krytyczne.</div>";
                                    enemyAtt  *= 2;
                                }

                                ItemArmor armor = null;
                                foreach (var used in _inventoryRepository.GetInventory(user.Id).Where(x => x.Used == true).ToList())
                                {
                                    var item = _itemRepository.GetItem(used.ItemId);
                                    if (item.Type == ItemType.Armor)
                                    {
                                        armor = (ItemArmor)item.ItemType;
                                        break;
                                    }
                                }

                                if (armor != null)
                                {
                                    enemyAtt -= (int)(enemyAtt * (rand.Next(0, armor.Resist + 1) / 100f));
                                }

                                user.HealthPoints -= enemyAtt;
                                enemyScore        += enemyAtt;
                                roundInfo         += $"<div class=\"alert alert-danger\" role=\"alert\">Wróg zadał Ci {enemyAtt} obrażeń.</div>";
                            }

                            goto RoundEnd;

RoundEnd:
                            arenaResultViewModel.FightInfo += $"<div class=\"card mb-3\"><div class=\"card-header\">Runda: {i}</div><div class=\"card-body\">{roundInfo}</div></div>";
                        }

                        var userReport = new ArenaReportViewModel()
                        {
                            Type       = ReportType.Defend,
                            User       = enemy,
                            Rounds     = i,
                            UserScore  = userScore,
                            EnemyScore = enemyScore,
                        };

                        var enemyReport = new ArenaReportViewModel()
                        {
                            Type       = ReportType.Attack,
                            User       = user,
                            Rounds     = i,
                            UserScore  = userScore,
                            EnemyScore = enemyScore,
                        };

                        var winExperience  = userScore > enemyScore ? user.Level * 5 : enemy.Level * 5;
                        var loseExperience = 5;

                        if (userScore > enemyScore)
                        {
                            arenaResultViewModel.ExperiencePoints = winExperience;
                            userReport.ExperiencePoints           = winExperience;
                            user.ExperiencePoints += winExperience;
                            user.AllExperience    += winExperience;

                            enemyReport.ExperiencePoints = loseExperience;
                            enemy.ExperiencePoints      += loseExperience;
                            enemy.AllExperience         += loseExperience;
                            enemy.HealthPoints           = (int)Math.Floor(enemy.MaxHealthPoints * 0.1);
                        }
                        else
                        {
                            arenaResultViewModel.ExperiencePoints = loseExperience;
                            userReport.ExperiencePoints           = loseExperience;
                            user.ExperiencePoints += loseExperience;
                            user.AllExperience    += loseExperience;
                            user.HealthPoints      = (int)Math.Floor(user.MaxHealthPoints * 0.1);

                            enemyReport.ExperiencePoints = winExperience;
                            enemy.ExperiencePoints      += winExperience;
                            enemy.AllExperience         += winExperience;
                        }

                        userReport.HealthPoints  = enemyHealth;
                        enemyReport.HealthPoints = userHealth;

                        var userReportHtml = await this.RenderViewAsync("ArenaReport", userReport);

                        var enemyReportHtml = await this.RenderViewAsync("ArenaReport", enemyReport);

                        var userMail = new Mail()
                        {
                            FromId  = "system",
                            ToId    = user.Id,
                            Type    = MailType.Received,
                            Title   = (userScore > enemyScore ? "[WYGRANA]" : "[PRZEGRANA]") + " Raport z walki",
                            Content = userReportHtml,
                            Status  = MailStatus.New
                        };

                        var enemyMail = new Mail()
                        {
                            FromId  = "system",
                            ToId    = enemy.Id,
                            Type    = MailType.Received,
                            Title   = (userScore < enemyScore ? "[WYGRANA]" : "[PRZEGRANA]") + " Raport z walki",
                            Content = enemyReportHtml,
                            Status  = MailStatus.New
                        };

                        var userInventory  = _inventoryRepository.GetInventory(user.Id).Where(x => x.Used == true);
                        var enemyInventory = _inventoryRepository.GetInventory(enemy.Id).Where(x => x.Used == true);

                        foreach (var inventory in userInventory.ToList())
                        {
                            inventory.Stamina--;
                            if (inventory.Stamina < 1)
                            {
                                inventory.Used = false;
                            }

                            _inventoryRepository.Update(inventory);
                        }

                        foreach (var inventory in enemyInventory.ToList())
                        {
                            inventory.Stamina--;
                            if (inventory.Stamina < 1)
                            {
                                inventory.Used = false;
                            }

                            _inventoryRepository.Update(inventory);
                        }

                        _mailRepository.Add(userMail);
                        _mailRepository.Add(enemyMail);

                        await _userManager.UpdateAsync(user);

                        await _userManager.UpdateAsync(enemy);

                        arenaResultViewModel.UserScore  = userScore;
                        arenaResultViewModel.EnemyScore = enemyScore;

                        return(View("ArenaResult", arenaResultViewModel));
                    }
                }
            }

            return(View());
        }
示例#25
0
 ///<summary>
 /// Returns the durability for a armor slot of for this type.
 ///</summary>
 public int GetDurability(int par1)
 {
     return(ItemArmor.GetMaxDamageArray()[par1] * MaxDamageFactor);
 }
示例#26
0
    private void OnGUI()
    {
        GUILayout.Label("RPG Armor Creator.", EditorStyles.boldLabel);
        GUILayout.Label("This tool has been created to build Armor Prefabs required for the RPG Dungeon Stalker.\n");

        //EditorGUILayout.LabelField("Armor field : ");

        showArmorFields = EditorGUILayout.Foldout(showArmorFields, "Armor fields");
        if (showArmorFields)
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Name");
                armorName = EditorGUILayout.TextField("", armorName);
                EditorGUILayout.PrefixLabel("Armor value");
                armorValue = EditorGUILayout.IntField(armorValue);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Description");
                armorDescription = EditorGUILayout.TextField("", armorDescription);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Armor type");
                armorType = (ArmorType)EditorGUILayout.EnumPopup(armorType);
                EditorGUILayout.PrefixLabel("Armor slot");
                armorSlot = (ArmorSlot.ArmorSlotHelper)EditorGUILayout.EnumPopup(armorSlot);
            }
            EditorGUILayout.EndHorizontal();

            showArmorStats = EditorGUILayout.Foldout(showArmorStats, "Stats");
            if (showArmorStats)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.PrefixLabel("Strength");
                    strength = EditorGUILayout.IntField(strength);
                    EditorGUILayout.PrefixLabel("Stamina");
                    stamina = EditorGUILayout.IntField(stamina);
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.PrefixLabel("Defense");
                    defense = EditorGUILayout.IntField(defense);
                    EditorGUILayout.PrefixLabel("Energy");
                    energy = EditorGUILayout.IntField(energy);
                }
                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel--;
            }
            EditorGUI.indentLevel--;
        }

        EditorGUILayout.Space();

        showItemFields = EditorGUILayout.Foldout(showItemFields, "Items fields");
        if (showItemFields)
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Quality");
                quality = (ItemQuality)EditorGUILayout.EnumPopup(quality);
                EditorGUILayout.PrefixLabel("Image");
                image = (Sprite)EditorGUILayout.ObjectField(image, typeof(Sprite), false);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Weight");
                weight = EditorGUILayout.IntField(weight);
                EditorGUILayout.PrefixLabel("CanDrop");
                EditorGUILayout.Toggle(canDrop);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUI.indentLevel--;
        }

        showPickableFields = EditorGUILayout.Foldout(showPickableFields, "Pickable fields");
        if (showPickableFields)
        {
            EditorGUI.indentLevel++;

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Pickup description");
                pickableDescription = EditorGUILayout.TextArea(pickableDescription);
                EditorGUILayout.PrefixLabel("Pickable model");
                pickableModel = (GameObject)EditorGUILayout.ObjectField(pickableModel, typeof(GameObject), false);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.LabelField("The model MUST contain a collider !");

            EditorGUI.indentLevel--;
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Files will be placed in Assets/Resources/(Armors|Items/Armors|Pickables/Armors).");

        if (GUILayout.Button("Create Armor"))
        {
            //Creating Armor ScriptableObject
            Armor newArmor = ScriptableObject.CreateInstance <Armor>();

            Utils.SetPrivateFieldValue <int>(newArmor, "armor", armorValue);
            Utils.SetPrivateFieldValue <string>(newArmor, "armorName", armorName);
            Utils.SetPrivateFieldValue <ArmorSlot>(newArmor, "slot", (ArmorSlot)((int)armorSlot));
            Utils.SetPrivateFieldValue <ArmorType>(newArmor, "type", armorType);
            Utils.SetPrivateFieldValue <CharStats>(newArmor, "stats", new CharStats((uint)strength, (uint)defense, (uint)stamina, (uint)energy));

            //Creating Armor Item
            GameObject newItem = new GameObject("Item" + armorName);
            ItemArmor  item    = newItem.AddComponent <ItemArmor>();
            Utils.SetPrivateFieldValue <Sprite>(item, "image", image);
            Utils.SetPrivateFieldValue <string>(item, "itemName", armorName);
            Utils.SetPrivateFieldValue <string>(item, "actionName", "Equip");
            Utils.SetPrivateFieldValue <string>(item, "useDescription", "Equip Armor.");
            Utils.SetPrivateFieldValue <string>(item, "description", armorDescription);
            Utils.SetPrivateFieldValue <uint>(item, "weight", (uint)weight);
            Utils.SetPrivateFieldValue <ItemType>(item, "type", ItemType.Armors);
            Utils.SetPrivateFieldValue <ItemQuality>(item, "quality", quality);
            Utils.SetPrivateFieldValue <bool>(item, "canDrop", canDrop);

            //Creating Pickable
            GameObject newPickable = new GameObject("Pickable" + armorName, typeof(Rigidbody), typeof(Pickable));
            Rigidbody  rb          = newPickable.GetComponent <Rigidbody>();
            rb.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
            Pickable pickable = newPickable.GetComponent <Pickable>();
            pickable.actionName  = "Pickup - " + armorName;
            pickable.description = pickableDescription;

            //Attaching model to pickable
            if (pickableModel != null)
            {
                GameObject model = GameObject.Instantiate(pickableModel);
                model.transform.SetParent(newPickable.transform, false);
            }

            //Saving prefabs
            GameObject itemPrefab     = PrefabUtility.CreatePrefab("Assets/Resources/Items/Armors/" + newItem.name + ".prefab", newItem);
            GameObject pickablePrefab = PrefabUtility.CreatePrefab("Assets/Resources/Pickables/Armors/" + newPickable.name + ".prefab", newPickable);

            //Linkage
            Utils.SetPrivateFieldValue <GameObject>(newArmor, "itemPrefab", itemPrefab);
            Utils.SetPrivateFieldValue <ScriptableObject>(itemPrefab.GetComponent <ItemArmor>(), "armorPrefab", newArmor);
            Utils.SetPrivateFieldValue <GameObject>(itemPrefab.GetComponent <ItemArmor>(), "dropPrefab", pickablePrefab);
            Utils.SetPrivateFieldValue <GameObject>(pickablePrefab.GetComponent <Pickable>(), "pickedItemPrefab", itemPrefab);

            //Saving ScriptableObject
            AssetDatabase.CreateAsset(newArmor, "Assets/Resources/Armors/Armor" + armorName + ".asset");

            //Cleaning temp gameObjects
            GameObject.DestroyImmediate(newItem);
            GameObject.DestroyImmediate(newPickable);
        }
    }
示例#27
0
        public static bool LookAtBag()
        {
            Item[] bag = Program.pl.GetBag();
            for (int i = 0; i < bag.Length; i++)
            {
                int ii = i;
                int x  = 0;
                if (ii >= 5)
                {
                    ii -= 5;
                    x   = 1;
                }
                if (bag[i] != null)
                {
                    if (bag[i].GetType() == typeof(ItemArmor))
                    {
                        ItemArmor equipo = (ItemArmor)bag[i];
                        Program.buffer.Print(1 + 50 * x, 2 + ii * 3, equipo.GetName());
                        string texto = "";
                        if (equipo.ModifierHp() < 0)
                        {
                            texto += "HP(" + equipo.ModifierHp() + ") ";
                        }
                        else
                        {
                            texto += "HP(+" + equipo.ModifierHp() + ") ";
                        }

                        if (equipo.ModifierDef() < 0)
                        {
                            texto += "DEF(" + equipo.ModifierDef() + ") ";
                        }
                        else
                        {
                            texto += "DEF(+" + equipo.ModifierDef() + ") ";
                        }

                        if (equipo.GetAvoidPercInt() < 0)
                        {
                            texto += "DEF PROB.(" + equipo.GetAvoidPercInt() + ")";
                        }
                        else
                        {
                            texto += "DEF PROB.(+" + equipo.GetAvoidPercInt() + ")";
                        }

                        Program.buffer.Print(5 + 50 * x, 3 + ii * 3, texto);
                    }
                    else if (bag[i].GetType() == typeof(ItemWeapon))
                    {
                        ItemWeapon equipo = (ItemWeapon)bag[i];
                        Program.buffer.Print(1 + 50 * x, 2 + ii * 3, equipo.GetName());
                        string texto = "";
                        if (equipo.ModifierAtt() < 0)
                        {
                            texto += "ATT(" + equipo.ModifierAtt() + ") ";
                        }
                        else
                        {
                            texto += "ATT(+" + equipo.ModifierAtt() + ") ";
                        }

                        if (equipo.ModifierAttM() < 0)
                        {
                            texto += "ATT M.(" + equipo.ModifierAttM() + ") ";
                        }
                        else
                        {
                            texto += "ATT M.(+" + equipo.ModifierAttM() + ") ";
                        }

                        if (equipo.GetHitPercInt() < 0)
                        {
                            texto += "ATT PROB.(" + equipo.GetHitPercInt() + ")";
                        }
                        else
                        {
                            texto += "ATT PROB.(+" + equipo.GetHitPercInt() + ")";
                        }

                        Program.buffer.Print(5 + 50 * x, 3 + ii * 3, texto);
                    }
                    else if (bag[i].GetType() == typeof(ItemGema))
                    {
                        ItemGema equipo = (ItemGema)bag[i];
                        Program.buffer.Print(1 + 50 * x, 2 + ii * 3, equipo.GetName());
                        string texto = "";
                        if (equipo.ModifierHp() < 0)
                        {
                            texto += "HP(" + equipo.ModifierHp() + ") ";
                        }
                        else
                        {
                            texto += "HP(+" + equipo.ModifierHp() + ") ";
                        }

                        if (equipo.ModifierAttM() < 0)
                        {
                            texto += "ATT M.(" + equipo.ModifierAttM() + ") ";
                        }
                        else
                        {
                            texto += "ATT M.(+" + equipo.ModifierAttM() + ") ";
                        }

                        if (equipo.ModifierManaM() < 0)
                        {
                            texto += "MANA M.(" + equipo.ModifierManaM() + ")";
                        }
                        else
                        {
                            texto += "MANA M.(+" + equipo.ModifierManaM() + ")";
                        }

                        Program.buffer.Print(5 + 50 * x, 3 + ii * 3, texto);
                    }
                    else if (bag[i].GetType() == typeof(ItemPocion))
                    {
                        ItemPocion consumable = (ItemPocion)bag[i];
                        Program.buffer.Print(1 + 50 * x, 2 + ii * 3, consumable.GetName());
                        if (consumable.GetPocionType() == ItemPocion.PocionType.hp)
                        {
                            Program.buffer.Print(1 + 50 * x, 3 + ii * 3, "    +" + consumable.GetFlatCant().ToString() + "% HP");
                        }
                        else
                        {
                            Program.buffer.Print(1 + 50 * x, 3 + ii * 3, "    +" + consumable.GetFlatCant().ToString() + "% Mana");
                        }
                    }
                    else
                    {
                        Program.buffer.Print(1 + 50 * x, 2 + ii * 3, bag[i].GetName());
                    }
                }
            }
            Program.buffer.PrintBackground();
            Program.buffer.Print(1, Program.buffer.height - 2, "Pulsa cualquier boton para salir");
            Program.buffer.Print(1, 0, "MOCHILA");
            Program.SmallMap();
            Program.buffer.PrintScreen();
            Console.ReadKey();
            return(true);
        }