private void ParseItemJson()
    {
        items = new List <Item>();
        TextAsset  itemText  = Resources.Load <TextAsset>("Items");
        string     itemsJson = itemText.text;
        JSONObject jo        = new JSONObject(itemsJson);

        Debug.Log(jo.list.Count);
        foreach (var temp in jo.list)
        {
            string            typeStr     = temp["itemType"].str;
            Item.ItemTypes    type        = (Item.ItemTypes)System.Enum.Parse(typeof(Item.ItemTypes), typeStr);
            int               id          = (int)temp["id"].n;
            string            name        = temp["name"].str;
            Item.QualityTypes qualityType = (Item.QualityTypes)System.Enum.Parse(typeof(Item.QualityTypes), temp["quality"].str);
            string            description = temp["description"].str;
            int               capacity    = (int)temp["capacity"].n;
            int               buyPrice    = (int)temp["buyPrice"].n;
            int               sellPrice   = (int)temp["sellPrice"].n;
            string            spritePath  = temp["spritePath"].str;
            Item              item        = null;
            switch (type)
            {
            case Item.ItemTypes.Consumable:
            {
                int hp = (int)temp["hp"].n;
                int mp = (int)temp["mp"].n;
                item = new Consumable(hp, mp, id, name, type, qualityType, description, capacity, buyPrice, sellPrice, spritePath);
                break;
            }

            case Item.ItemTypes.Weapon:
            {
                int damage = (int)temp["damage"].n;
                Weapon.WeaponTypes weaponType = (Weapon.WeaponTypes)System.Enum.Parse(typeof(Weapon.WeaponTypes), temp["weaponType"].str);
                item = new Weapon(damage, weaponType, id, name, type, qualityType, description, capacity, buyPrice, sellPrice, spritePath);
                break;
            }

            case Item.ItemTypes.Equipment:
            {
                int strength  = (int)temp["strength"].n;
                int intellect = (int)temp["intellect"].n;
                int agility   = (int)temp["agility"].n;
                int stamina   = (int)temp["stamina"].n;
                Equipment.EquipmentTypes equipmentType = (Equipment.EquipmentTypes)System.Enum.Parse(typeof(Equipment.EquipmentTypes), temp["equipmentType"].str);
                item = new Equipment(strength, intellect, agility, stamina, equipmentType, id, name, type, qualityType, description, capacity, buyPrice, sellPrice, spritePath);
                break;
            }

            case Item.ItemTypes.Material:
            {
                item = new Material(id, name, type, qualityType, description, capacity, buyPrice, sellPrice, spritePath);
                break;
            }
            }
            items.Add(item);
        }
    }
Example #2
0
 public void SetDamageType(Weapon.WeaponTypes in_damageType)
 {
     damageType = in_damageType;
     if (in_damageType == Weapon.WeaponTypes.piercing)
     {
         isPenetrating = true;
     }
 }
Example #3
0
    public static Skill AddWeaponSkill(string name, string icon, Weapon.WeaponTypes weapon)
    {
        WeaponSkill w = new WeaponSkill();

        w.WeaponType = weapon;

        return(AddSkill(name, icon, w));
    }
Example #4
0
 // Pick the ammo of a weapon.
 public void PickAmmo(Weapon.WeaponTypes type, int amount)
 {
     weapons[(int)type].AddAmmo(amount);
     if (currentWeapon == (int)type)
     {
         OnWeaponAmmoChanged(weapons[currentWeapon].ammo, weapons[currentWeapon].maxPower, weapons[currentWeapon].power);   // Delegate. Implemented by Game.cs
     }
     OnItemPicked();
 }
Example #5
0
 public void SubtractAmmo(Weapon.WeaponTypes weaponType)
 {
     foreach (KeyValuePair <Weapon, int> w in this.Weapons.ToList())
     {
         if (w.Key.WeaponType == weaponType && w.Value > 0)
         {
             this.Weapons[w.Key]--;
         }
     }
 }
Example #6
0
        public int GetAmmo(Weapon.WeaponTypes weaponType)
        {
            foreach (KeyValuePair <Weapon, int> w in this.Weapons)
            {
                if (w.Key.WeaponType == weaponType && w.Value > 0)
                {
                    return(w.Value);
                }
            }

            return(0);
        }
Example #7
0
        public bool HasAmmo(Weapon.WeaponTypes weaponType)
        {
            foreach (KeyValuePair <Weapon, int> w in this.Weapons)
            {
                if (w.Key.WeaponType == weaponType && w.Value > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #8
0
    public void Damage(float in_damage, Weapon.WeaponTypes in_damageType)
    {
        float damageMultiplier = 1;

        if (in_damageType == Weapon.WeaponTypes.normal && armorType == ArmorTypes.normal)
        {
            damageMultiplier = Utility.dmg_normalVNormal;
        }
        else if (in_damageType == Weapon.WeaponTypes.normal && armorType == ArmorTypes.medium)
        {
            damageMultiplier = Utility.dmg_normalVMedium;
        }
        else if (in_damageType == Weapon.WeaponTypes.normal && armorType == ArmorTypes.heavy)
        {
            damageMultiplier = Utility.dmg_normalVHeavy;
        }
        else if (in_damageType == Weapon.WeaponTypes.piercing && armorType == ArmorTypes.normal)
        {
            damageMultiplier = Utility.dmg_pierceVNormal;
        }
        else if (in_damageType == Weapon.WeaponTypes.piercing && armorType == ArmorTypes.medium)
        {
            damageMultiplier = Utility.dmg_pierceVMedium;
        }
        else if (in_damageType == Weapon.WeaponTypes.piercing && armorType == ArmorTypes.heavy)
        {
            damageMultiplier = Utility.dmg_pierceVHeavy;
        }
        else if (in_damageType == Weapon.WeaponTypes.heavy && armorType == ArmorTypes.normal)
        {
            damageMultiplier = Utility.dmg_heavyVNormal;
        }
        else if (in_damageType == Weapon.WeaponTypes.heavy && armorType == ArmorTypes.medium)
        {
            damageMultiplier = Utility.dmg_heavyVMedium;
        }
        else if (in_damageType == Weapon.WeaponTypes.heavy && armorType == ArmorTypes.heavy)
        {
            damageMultiplier = Utility.dmg_heavyVHeavy;
        }

        if (isDestructible)
        {
            currentHealth -= in_damage * damageMultiplier;
        }
    }
Example #9
0
    public static Weapon AddWeapon(string name, string icon, Weapon.WeaponTypes weaponType, int minValue, int maxValue)
    {
        Weapon weap = new Weapon();

        weap.Name          = name;
        weap.InventoryIcon = Resources.Load(icon) as Texture;
        //  weap.MaleEquipmentLayer = Resources.Load(maleLayer) as Texture;
        //  weap.FemaleEquipmentLayer = Resources.Load(femaleLayer) as Texture;
        weap.Location   = Equipment.EquipmentLocation.Weapon;
        weap.WeaponType = weaponType;
        weap.MinDamage  = minValue;
        weap.MaxDamage  = maxValue;

        Equipments.Add(name, weap);

        return(weap);
    }
Example #10
0
 // Picks a weapon.
 public void PickWeapon(Weapon.WeaponTypes type)
 {
     // If the weapon was not picked before, equip the weapon.
     if (!weapons[(int)type].IsPicked())
     {
         weapons[currentWeapon].gameObject.SetActive(false);
         currentWeapon = (int)type;
         weapons[currentWeapon].SetPicked(true);
         weapons[currentWeapon].gameObject.SetActive(true);
         weapons[currentWeapon].OnVampibotEffect = DoVampibotEffect;                        // For the vampire power up.
         weapons[currentWeapon].accuracyCapacity = XenatekManager.xenatek.accuracyCapacity; // Set the accuracy capacity.
         OnWeaponSwitched(currentWeapon, weapons);                                          // Delegate. Implemented by Game.cs
     }
     // In any case, add some ammo when the weapon is picked.
     weapons[(int)type].AddInitAmmo();
     OnWeaponAmmoChanged(weapons[currentWeapon].ammo, weapons[currentWeapon].maxPower, weapons[currentWeapon].power);   // Delegate. Implemented by Game.cs
     OnItemPicked();
 }
Example #11
0
    public BasicWeaponAttack( string name, string icon, Weapon.WeaponTypes wep )
        : base()
    {
        Purchase = -1;
        Upgrade = -1;
        Cooldown = 0;

        this.SkillType = SkillTypes.Active;
        Name = name;
        IconImage = icon;
        SkillWeapon = wep;

        Range = 4;

        AnimType = ActiveAnimationTypes.Meele;
        if (wep == Weapon.WeaponTypes.Bow)
        {
            AnimType = ActiveAnimationTypes.Ranged;
            Range = 10;
        }
    }
Example #12
0
    public BasicWeaponAttack(string name, string icon, Weapon.WeaponTypes wep)
        : base()
    {
        Purchase = -1;
        Upgrade  = -1;
        Cooldown = 0;

        this.SkillType = SkillTypes.Active;
        Name           = name;
        IconImage      = icon;
        SkillWeapon    = wep;

        Range = 4;

        AnimType = ActiveAnimationTypes.Meele;
        if (wep == Weapon.WeaponTypes.Bow)
        {
            AnimType = ActiveAnimationTypes.Ranged;
            Range    = 10;
        }
    }
Example #13
0
 public bool IsWielding(Weapon.WeaponTypes weapon)
 {
     return((LeftHand != null && LeftHand.WeaponType == weapon) || (RightHand != null && RightHand.WeaponType == weapon));
 }
Example #14
0
 private void SetProjectileProperty(ref Projectile in_Projectile, float in_StartSpeed, float in_EndSpeed, float in_BoostDelay, Weapon.WeaponTypes in_damageType)
 {
     in_Projectile.SetStartSpeed(in_StartSpeed);
     in_Projectile.SetEndSpeed(in_EndSpeed);
     in_Projectile.SetDamage(damage);
     in_Projectile.SetDamageTag(damageTag);
     in_Projectile.SetMaxRange(maxRange);
     in_Projectile.SetBoostDelay(in_BoostDelay);
     in_Projectile.SetDamageType(in_damageType);
 }
Example #15
0
 public void Shoot(Weapon.WeaponTypes weapon)
 {
     //weaponObject.Shoot(weapon, ref this);
 }