Exemplo n.º 1
0
    /// <summary>
    /// Copies the values from another entry.
    /// </summary>
    /// <param name="other"></param>
    public override void CopyValues(ScrObjLibraryEntry other)
    {
        base.CopyValues(other);
        ItemEntry item = (ItemEntry)other;

        icon        = item.icon;
        description = item.description;

        itemCategory = item.itemCategory;
        weaponType   = item.weaponType;
        attackType   = item.attackType;
        keyType      = item.keyType;

        cost           = item.cost;
        maxCharge      = item.maxCharge;
        researchNeeded = item.researchNeeded;
        skillReq       = item.skillReq;

        power     = item.power;
        hitRate   = item.hitRate;
        critRate  = item.critRate;
        range.min = item.range.min;
        range.max = item.range.max;

        advantageType = new List <MovementType>();
        for (int i = 0; i < item.advantageType.Count; i++)
        {
            advantageType.Add(item.advantageType[i]);
        }
        boost = item.boost;
    }
Exemplo n.º 2
0
    /// <summary>
    /// Resets the values to default.
    /// </summary>
    public override void ResetValues()
    {
        base.ResetValues();

        icon        = null;
        description = "";

        itemCategory = ItemCategory.WEAPON;
        weaponType   = WeaponType.NONE;
        attackType   = AttackType.PHYSICAL;
        keyType      = KeyType.STAR;

        cost           = 0;
        maxCharge      = 0;
        researchNeeded = false;
        skillReq       = WeaponRank.NONE;

        power    = 0;
        hitRate  = 0;
        critRate = 0;
        range    = new WeaponRange(1, 1);

        advantageType = new List <MovementType>();
        boost         = new Boost();
    }
Exemplo n.º 3
0
 /// <summary>
 /// Creates an array with the basic weapon skills this class can use.
 /// </summary>
 /// <returns></returns>
 public WeaponRank[] GetWeaponSkill(int classLevel)
 {
     WeaponRank[] res = new WeaponRank[InventoryContainer.WPN_SKILLS];
     for (int i = 0; i < weaponSkills.Count; i++)
     {
         res[(int)weaponSkills[i]] = (WeaponRank)Mathf.Min((int)WeaponRank.S, classLevel);
     }
     return(res);
 }
Exemplo n.º 4
0
    /// <summary>
    /// Checks if an item can be used with the given skill value.
    /// </summary>
    /// <param name="skill"></param>
    /// <returns></returns>
    public bool CanEquip(WeaponRank skill)
    {
        if (itemCategory != ItemCategory.WEAPON || skill == 0)
        {
            return(false);
        }

        return(skill >= skillReq);
    }
    public void OnStart()
    {
        owned    = false;
        equipped = false;

        sprite = _sprite;

        Reset();

        rank   = WeaponRank.WOODEN;
        Damage = baseDamage;
        Heal   = baseHeal;
    }
    private void Steel()
    {
        rank = WeaponRank.STEEL;

        if (hasLimitedUse)
        {
            usesPerBattle++;
        }
        else
        {
            IncreaseDamage();
        }
    }
    private void SetupClassGains()
    {
        LevelGain level = gains[classList.GetPosition()];

        //Stats
        statsBoosts[0].transform.parent.gameObject.SetActive(level.bonusHp > 0);
        statsBoosts[0].text = "+" + level.bonusHp;
        statsBoosts[1].transform.parent.gameObject.SetActive(level.bonusDmg > 0);
        statsBoosts[1].text = "+" + level.bonusDmg;
        statsBoosts[2].transform.parent.gameObject.SetActive(level.bonusMnd > 0);
        statsBoosts[2].text = "+" + level.bonusMnd;
        statsBoosts[3].transform.parent.gameObject.SetActive(level.bonusSkl > 0);
        statsBoosts[3].text = "+" + level.bonusSkl;
        statsBoosts[4].transform.parent.gameObject.SetActive(level.bonusSpd > 0);
        statsBoosts[4].text = "+" + level.bonusSpd;
        statsBoosts[5].transform.parent.gameObject.SetActive(level.bonusDef > 0);
        statsBoosts[5].text = "+" + level.bonusDef;

        //Wpn skills
        for (int i = 0; i < wpnList.Count; i++)
        {
            Destroy(wpnList[i].gameObject);
        }
        wpnList.Clear();
        for (int i = 0; i < level.weaponSkills.Count; i++)
        {
            Transform t = Instantiate(wpnSkillTemplate, wpnSkillParent);
            t.GetComponentInChildren <Image>().sprite = wpnIcons.icons[(int)level.weaponSkills[i]];

            WeaponRank current = playerData.inventory[entryList.GetPosition()].wpnSkills[(int)level.weaponSkills[i]];
            WeaponRank next    = (current + 1);
            if (current != WeaponRank.NONE)
            {
                t.GetComponentInChildren <Text>().text = current + " > " + next;
            }
            else
            {
                t.GetComponentInChildren <Text>().text = "+ " + next;
            }

            t.gameObject.SetActive(true);
            wpnList.Add(t);
        }
        wpnSkillTemplate.gameObject.SetActive(false);

        //Skill
        skillGainIcon.sprite = level.skill.icon;
        skillGainName.text   = level.skill.entryName;
        skillGainDesc.text   = level.skill.description;
    }
Exemplo n.º 8
0
    /// <summary>
    /// Removes all broken and dropped weapons without any charges.
    /// Also moves the items upward to fill out the gaps in the inventory.
    /// </summary>
    public void CleanupInventory()
    {
        int pos = 0;

        for (int i = 0; i < INVENTORY_SIZE; i++)
        {
            if (string.IsNullOrEmpty(inventory[pos].uuid))
            {
                InventoryTuple tup = inventory[pos];
                inventory.RemoveAt(pos);
                inventory.Add(tup);
            }
            else
            {
                pos++;
            }
        }
        for (int i = 0; i < INVENTORY_SIZE; i++)
        {
            inventory[i].index = i;
        }

        if (!string.IsNullOrEmpty(inventory[0].uuid))
        {
            WeaponRank skill = GetWpnSkill(inventory[0]);
            if (!inventory[0].CanEquip(skill) || inventory[0].currentCharges <= 0)
            {
                InventoryTuple tup = GetFirstUsableItemTuple(ItemCategory.WEAPON);
                if (!string.IsNullOrEmpty(tup.uuid))
                {
                    inventory.RemoveAt(tup.index);
                    inventory.Insert(0, tup);
                }
                else if (!inventory[0].CanEquip(skill))
                {
                    tup = GetFirstEmptyItemTuple();
                    if (tup != null)
                    {
                        inventory.RemoveAt(tup.index);
                        inventory.Insert(0, tup);
                    }
                }
            }
        }
        for (int i = 0; i < INVENTORY_SIZE; i++)
        {
            inventory[i].index = i;
        }
    }
Exemplo n.º 9
0
 /// <summary>
 /// Checks if an item can be used with the given skill value.
 /// </summary>
 /// <param name="skill"></param>
 /// <returns></returns>
 public bool CanUse(WeaponRank skill)
 {
     if (itemCategory == ItemCategory.CONSUME)
     {
         return(true);
     }
     else if (skill == WeaponRank.NONE)
     {
         return(false);
     }
     else
     {
         return(skill >= skillReq);
     }
 }
Exemplo n.º 10
0
 public WeaponRank[] GetWpnSkillFromLevel(int[] classLevels)
 {
     WeaponRank[] ranks = new WeaponRank[InventoryContainer.WPN_SKILLS];
     for (int i = 0; i < classLevels.Length; i++)
     {
         for (int level = 0; level < classLevels[i]; level++)
         {
             for (int wpn = 0; wpn < classes[i].weaponSkills.Count; wpn++)
             {
                 ranks[(int)classes[i].weaponSkills[wpn]]++;
             }
         }
     }
     return(ranks);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Returns the first item in the inventory the player can use matching the weapon type.
 /// Returns an empty tuple if there is no item that can be used.
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public InventoryTuple GetFirstUsableItemTuple(WeaponType type)
 {
     for (int i = 0; i < inventory.Count; i++)
     {
         if (string.IsNullOrEmpty(inventory[i].uuid) || inventory[i].weaponType != type)
         {
             continue;
         }
         WeaponRank skill = GetWpnSkill(inventory[i]);
         if (inventory[i].CanUse(skill) && inventory[i].currentCharges > 0)
         {
             return(inventory[i]);
         }
     }
     return(new InventoryTuple(null));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Returns the first item in the inventory the player can use matching the item category and have
 /// enough range to be used.
 /// </summary>
 /// <param name="category"></param>
 /// <param name="range"></param>
 /// <returns></returns>
 public void EquipFirstInRangeItem(ItemCategory category, int range)
 {
     for (int i = 0; i < inventory.Count; i++)
     {
         if (string.IsNullOrEmpty(inventory[i].uuid))
         {
             continue;
         }
         WeaponRank skill = GetWpnSkill(inventory[i]);
         if (inventory[i].itemCategory == category && inventory[i].CanEquip(skill) && inventory[i].InRange(range))
         {
             EquipItem(i);
             return;
         }
     }
 }
Exemplo n.º 13
0
    /// <summary>
    /// Returns a list of all usable items for the given category and the player's skills.
    /// </summary>
    /// <param name="category"></param>
    /// <returns></returns>
    public List <InventoryTuple> GetAllUsableItemTuple(ItemCategory category)
    {
        List <InventoryTuple> list = new List <InventoryTuple>();

        for (int i = 0; i < inventory.Count; i++)
        {
            if (string.IsNullOrEmpty(inventory[i].uuid))
            {
                continue;
            }
            WeaponRank skill = GetWpnSkill(inventory[i]);
            if (inventory[i].itemCategory == category && inventory[i].CanUse(skill) && inventory[i].currentCharges > 0)
            {
                list.Add(inventory[i]);
            }
        }
        return(list);
    }
Exemplo n.º 14
0
    private void ButtonSetup()
    {
        inventoryButtons.ResetButtons();
        InventoryTuple tuple = selectedCharacter.value.inventory.GetTuple(inventoryIndex.value);
        WeaponRank     skill = selectedCharacter.value.inventory.GetWpnSkill(tuple);

        if (tuple.itemCategory == ItemCategory.WEAPON && tuple.CanUse(skill))
        {
            inventoryButtons.AddButton("EQUIP", 0);
        }
        else if (tuple.itemCategory == ItemCategory.CONSUME && tuple.attackType != AttackType.KEY)
        {
            inventoryButtons.AddButton("USE", 1);
        }
        inventoryButtons.AddButton("DROP", 2);

        itemMenuPosition.value = inventoryButtons.GetPosition();
    }
    public Sprite GetWeaponSprite(ItemData weapon, WeaponRank rank)
    {
        if (weapon.isSword)
        {
            return(swordSprites[(int)rank]);
        }

        switch (weapon.type)
        {
        case WeaponType.MELEE:
            return(axeSprites[(int)rank]);

        case WeaponType.RANGED:
            return(bowSprites[(int)rank]);

        case WeaponType.STAFF:
            return(staffSprites[(int)rank]);
        }

        return(null);
    }
Exemplo n.º 16
0
    public InventoryTuple(ItemEntry item, int index = -1, int charges = -1)
    {
        this.index = index;
        itemz      = item;

        if (item == null)
        {
            return;
        }

        uuid = item.uuid;

        icon      = item.icon;
        repColor  = item.repColor;
        entryName = item.entryName;

        UpdateBonus();

        currentCharges = (charges == -1) ? maxCharge : charges;
        range.min      = item.range.min;
        range.max      = item.range.max;

        skillReq = item.skillReq;
        boost    = new Boost();
        boost.AddBoost(item.boost);

        itemCategory  = item.itemCategory;
        weaponType    = item.weaponType;
        attackType    = item.attackType;
        keyType       = item.keyType;
        advantageType = new List <MovementType>();
        for (int i = 0; i < item.advantageType.Count; i++)
        {
            advantageType.Add(item.advantageType[i]);
        }
    }
Exemplo n.º 17
0
 /// <summary>
 /// Adds the selected inventory tuple to the inventory if there's room.
 /// Returns true if successful, false if there was no room.
 /// </summary>
 /// <param name="pickup"></param>
 /// <returns></returns>
 public bool AddItem(InventoryTuple pickup)
 {
     if (string.IsNullOrEmpty(inventory[0].uuid))
     {
         WeaponRank rank = GetWpnSkill(pickup);
         if (rank != WeaponRank.NONE && rank >= pickup.skillReq)
         {
             inventory[0] = pickup;
             Debug.Log("Equipped  " + rank);
             return(true);
         }
     }
     for (int i = 1; i < inventory.Count; i++)
     {
         if (string.IsNullOrEmpty(inventory[i].uuid))
         {
             inventory[i] = pickup;
             pickup.index = i;
             Debug.Log("Added the item to position " + i);
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 18
0
    /// <summary>
    /// Displays the inventory page. Contains information on the inventory, weaponskills and constitution.
    /// </summary>
    /// <param name="tactics"></param>
    private void ShowInventoryStats(TacticsMove tactics)
    {
        if (tactics == null)
        {
            return;
        }
        StatsContainer     stats     = tactics.stats;
        InventoryContainer inventory = tactics.inventory;

        menuView.SetActive(true);
        statsObject.SetActive(false);
        basicObject.SetActive(false);
        inventoryObject.SetActive(true);
        characterName.text = stats.charData.entryName;

        ClassWheel wheel = (stats.charData.faction == Faction.ENEMY) ? enemyClassWheel : playerClassWheel;

        WeaponRank[] ranks = wheel.GetWpnSkillFromLevel(stats.classLevels);
        int          pos   = 0;

        for (int i = 0; i < weaponSkillIcons.Length; i++)
        {
            while (pos < ranks.Length && ranks[pos] == WeaponRank.NONE)
            {
                pos++;
            }
            if (pos >= ranks.Length)
            {
                weaponSkillIcons[i].transform.parent.gameObject.SetActive(false);
            }
            else
            {
                weaponSkillIcons[i].transform.parent.gameObject.SetActive(true);
                weaponSkillIcons[i].sprite = weaponTypeIcons.icons[pos];
                weaponSkillRating[i].text  = ranks[pos].ToString();
            }
            pos++;
        }

        // Set up inventory list
        for (int i = 0; i < 5; i++)
        {
            if (i >= InventoryContainer.INVENTORY_SIZE || string.IsNullOrEmpty(inventory.GetTuple(i).uuid))
            {
                inventoryFields[i].color = Color.yellow;
                inventoryFields[i].text  = "---";
                inventoryValues[i].text  = " ";
            }
            else
            {
                InventoryTuple tuple = inventory.GetTuple(i);
                WeaponRank     skill = inventory.GetWpnSkill(tuple);
                inventoryFields[i].color = (tuple.droppable) ? Color.green :
                                           (tuple.CanUse(skill)) ? Color.yellow : Color.grey;
                inventoryFields[i].text = tuple.entryName;
                inventoryValues[i].text = (tuple.maxCharge >= 0) ? tuple.currentCharges.ToString() : " ";
                if (tuple.itemCategory == ItemCategory.CONSUME && tuple.maxCharge == 1)
                {
                    inventoryValues[i].text = " ";
                }
            }
        }

        UpdateSelection();
    }
Exemplo n.º 19
0
    private void Bronze()
    {
        rank = WeaponRank.BRONZE;

        IncreaseDamage();
    }
        public static WeaponProperties GenerateRandomWeaponProperties(string categoryName, WeaponPropertiesTemplate template)
        {
            float chance = Random.value;

            float multiplier = 1f;

            WeaponRank rank = WeaponRank.Common;

            if (chance <= template.CommonRankChance)
            {
                multiplier = template.CommonRankMultiplier;

                rank = WeaponRank.Common;
            }
            else if (chance > template.CommonRankChance && chance <= template.UncommonRankChance)
            {
                multiplier = template.UncommonRankChance;

                rank = WeaponRank.Uncommon;
            }
            else if (chance > template.UncommonRankChance && chance <= template.RareRankChance)
            {
                multiplier = template.RareRankMultiplier;

                rank = WeaponRank.Rare;
            }
            else if (chance > template.RareRankChance && chance <= template.EpicRankChance)
            {
                multiplier = template.EpicRankMultiplier;

                rank = WeaponRank.Epic;
            }
            else if (chance > template.EpicRankChance && chance <= template.LegendaryRankChance)
            {
                multiplier = template.LegendaryRankMultiplier;

                rank = WeaponRank.Legendary;
            }

            for (int i = 0; i < template.Categories.Count; i++)
            {
                WeaponProperties category = template.Categories[i];

                if (category != null)
                {
                    if (!string.IsNullOrEmpty(category.CategoryName) || !string.IsNullOrWhiteSpace(category.CategoryName))
                    {
                        if (string.Compare(category.CategoryName, categoryName) == 0)
                        {
                            return(new WeaponProperties()
                            {
                                CategoryName = categoryName,

                                Rank = rank,

                                Damage = Random.Range(category.Damage, category.Damage * multiplier),
                                Accuracy = Random.Range(category.Accuracy, Mathf.Max(0f, category.Accuracy - ((category.Accuracy * multiplier) - category.Accuracy))),
                                Recoil = Random.Range(category.Recoil, Mathf.Max(0f, category.Recoil - ((category.Recoil * multiplier) - category.Recoil))),
                                FireRate = Random.Range(category.FireRate, Mathf.Max(0f, category.FireRate - ((category.FireRate * multiplier) - category.FireRate))),

                                ProjectilesPerShot = Mathf.RoundToInt(Random.Range(category.ProjectilesPerShot, category.ProjectilesPerShot * multiplier)),
                                MagazineSize = Mathf.RoundToInt(Random.Range(category.MagazineSize, category.MagazineSize * multiplier)),
                            });
                        }
                    }
                }
            }

            return(new WeaponProperties());
        }
Exemplo n.º 21
0
    /// <summary>
    /// Checks if the character can equip the target item.
    /// </summary>
    /// <param name="weapon"></param>
    /// <returns></returns>
    public bool CanEquip(InventoryTuple weapon)
    {
        WeaponRank rank = GetWpnSkill(weapon);

        return(rank != WeaponRank.NONE && weapon.skillReq <= rank);
    }
Exemplo n.º 22
0
    private void Gold()
    {
        rank = WeaponRank.GOLD;

        IncreaseDamage();
    }