示例#1
0
    protected void GeneratePotion()
    {
        coinPrice = 0;
        switch (RandomEvClass.RandomEv(new float[3] {
            40f, 35f, 25f
        }))
        {
        case 0:
            potionSize = "small";
            healingPer = 20;
            coinPrice += 5;
            break;

        case 1:
            potionSize = "medium";
            healingPer = 40;
            coinPrice += 10;
            break;

        case 2:
            potionSize = "big";
            healingPer = 50;
            coinPrice += 15;
            break;
        }

        switch (rarity)
        {
        case Rarity.Common:
            healingPer += 5;
            coinPrice  += 5;
            break;

        case Rarity.Uncommon:
            healingPer += 10;
            coinPrice  += 10;
            break;

        case Rarity.Rare:
            healingPer += 15;
            coinPrice  += 15;
            break;

        case Rarity.Legendary:
            healingPer += 25;
            coinPrice  += 20;
            break;
        }
        foreach (Sprite sp in InventoryScript.Instance.Armor)
        {
            if (sp.name == "Health_Potion_" + potionSize)
            {
                sprite = sp;
            }
        }
    }
    private void OnEnable()
    {
        ButtonShowPopUpMenu.SetActive(false);
        CurrentUpgrades = new UpgradeScriptableClass[3];

        string firstUpgrade  = "";
        string secondUpgrade = "";
        string thirdUpgrade  = "";

        float[] RandomUpgrades = new float[allUpgrades.Length];
        for (int i = 0; i <= RandomUpgrades.Length - 1; i++)
        {
            RandomUpgrades[i] = allUpgrades[i].probability;
        }

        //1 - upgrade
        bool T = false;
        int  R = 0;

        do
        {
            R                  = RandomEvClass.RandomEv(RandomUpgrades);
            firstUpgrade       = allUpgrades[R].upgradeName;
            CurrentUpgrades[0] = allUpgrades[R];
            T                  = true;
        } while (!T);
        //2 - upgrade
        T = false;
        do
        {
            R = RandomEvClass.RandomEv(RandomUpgrades);
            if (allUpgrades[R].upgradeName != firstUpgrade)
            {
                secondUpgrade      = allUpgrades[R].upgradeName;
                CurrentUpgrades[1] = allUpgrades[R];
                T = true;
            }
        } while (!T);
        //3 - upgrade
        T = false;
        do
        {
            R = RandomEvClass.RandomEv(RandomUpgrades);
            if ((allUpgrades[R].upgradeName != firstUpgrade) && (allUpgrades[R].upgradeName != secondUpgrade))
            {
                thirdUpgrade       = allUpgrades[R].upgradeName;
                CurrentUpgrades[2] = allUpgrades[R];
                T = true;
            }
        } while (!T);

        UpdateIconAndText();
    }
    public void TakeDamage(TargetCharacter character, float damageFromAnotherChar, DamageType type)
    {
        missAttack = false;
        switch (type)
        {
        case DamageType.Physical:
            if (armor > 0)
            {
                damageFromAnotherChar -= damageFromAnotherChar / 100 * armor;
            }
            if (armor > 100)
            {
                damageFromAnotherChar = 0;
            }
            if (mainBattleScript.MagicEffectManager.CheckMagicEffect(currentCharacter, MagicEffectType.Ice))
            {
                damageFromAnotherChar *= 1.5f;
            }
            //Check miss
            if (RandomEvClass.RandomEv(new float[2] {
                agility, 100 - agility
            }) == 0)
            {
                lastDamage = 0;
                missAttack = true;
                return;
            }
            animator.SetBool("Hit", true);
            break;

        case DamageType.Lightning:
            if (armor > 0)
            {
                damageFromAnotherChar += damageFromAnotherChar * armor / 100;
            }
            if (mainBattleScript.MagicEffectManager.CheckMagicEffect(currentCharacter, MagicEffectType.Ice))
            {
                damageFromAnotherChar /= 1.25f;
            }
            if (mainBattleScript.MagicEffectManager.CheckMagicEffect(currentCharacter, MagicEffectType.Water))
            {
                damageFromAnotherChar *= 2;
            }
            animator.SetBool("LightningHit", true);
            break;

        case DamageType.Fire:
            mainBattleScript.MagicEffectManager.Clear(currentCharacter, MagicEffectType.Water);
            ///
            if (mainBattleScript.MagicEffectManager.CheckMagicEffect(currentCharacter, MagicEffectType.Ice))
            {
                mainBattleScript.MagicEffectManager.Clear(currentCharacter, MagicEffectType.Ice);
                mainBattleScript.MagicEffectManager.AddMagicEffect(currentCharacter, MagicEffectType.Water, agility, 4, false);
            }
            ///
            mainBattleScript.MagicEffectManager.AddMagicEffect(currentCharacter, MagicEffectType.Fire, damageFromAnotherChar, 4, false);
            ///
            animator.SetBool("FireHit", true);
            break;

        case DamageType.Ice:
            mainBattleScript.MagicEffectManager.Clear(currentCharacter, MagicEffectType.Fire);
            mainBattleScript.MagicEffectManager.Clear(currentCharacter, MagicEffectType.Healing);

            if (mainBattleScript.MagicEffectManager.CheckMagicEffect(currentCharacter, MagicEffectType.Water))
            {
                damageFromAnotherChar *= 1.25f;
            }
            mainBattleScript.MagicEffectManager.AddMagicEffect(currentCharacter, MagicEffectType.Ice, agility, 4, false);
            mainBattleScript.MagicEffectManager.Clear(currentCharacter, MagicEffectType.Water);
            ///
            animator.SetBool("IceHit", true);
            break;

        case DamageType.Water:
            mainBattleScript.MagicEffectManager.Clear(currentCharacter, MagicEffectType.Fire);
            damageFromAnotherChar /= 10;
            mainBattleScript.MagicEffectManager.AddMagicEffect(currentCharacter, MagicEffectType.Water, agility, 4, false);
            ///
            animator.SetBool("WaterHit", true);
            break;
        }
        healthPoint -= damageFromAnotherChar;
        lastDamage   = damageFromAnotherChar;
    }
示例#4
0
    protected void GenerateArmor()
    {
        armorType = (ArmorType)Random.Range(0, 3);
        int minArmor = 0;

        coinPrice = 0;
        switch (rarity)
        {
        case Rarity.Common:
            minArmor   = 1;
            material   = Material.Iron;
            coinPrice += 5;
            break;

        case Rarity.Uncommon:
            minArmor = 5;
            material = (Material)RandomEvClass.RandomEv(new float[2] {
                60f, 40f
            });
            coinPrice += 15;
            break;

        case Rarity.Rare:
            minArmor   = 10;
            material   = (Material)(RandomEvClass.RandomEv(new float[2] {
                60f, 40f
            }) + 1);
            coinPrice += 35;
            break;

        case Rarity.Legendary:
            minArmor   = 15;
            material   = Material.Gold;
            coinPrice += 50;
            break;
        }
        switch (material)
        {
        case Material.Iron:
            minArmor  += 1;
            coinPrice += 5;
            break;

        case Material.Silver:
            minArmor  += 5;
            coinPrice += 15;
            break;

        case Material.Gold:
            minArmor  += 10;
            coinPrice += 25;
            break;
        }

        if (minArmor <= 0)
        {
            minArmor = 1;
        }

        int maxArmor = minArmor + 5;

        armor = Random.Range(minArmor, maxArmor);


        foreach (Sprite sp in InventoryScript.Instance.Armor)
        {
            if (sp.name == material.ToString() + "_" + armorType)
            {
                sprite = sp;
            }
        }
    }
示例#5
0
    protected void GenerateWeapon()
    {
        weaponType = (WeaponType)Random.Range(0, 2);
        int minDamage = 0;

        coinPrice = 0;
        switch (rarity)
        {
        case Rarity.Common:
            minDamage  = 5;
            material   = Material.Iron;
            coinPrice += 5;
            break;

        case Rarity.Uncommon:
            minDamage = 15;
            material  = (Material)RandomEvClass.RandomEv(new float[2] {
                60f, 40f
            });
            coinPrice += 15;
            break;

        case Rarity.Rare:
            minDamage  = 25;
            material   = (Material)(RandomEvClass.RandomEv(new float[2] {
                60f, 40f
            }) + 1);
            coinPrice += 35;
            break;

        case Rarity.Legendary:
            minDamage  = 45;
            material   = Material.Gold;
            coinPrice += 50;
            break;
        }
        switch (material)
        {
        case Material.Iron:
            minDamage += 5;
            coinPrice += 5;
            break;

        case Material.Silver:
            minDamage += 10;
            coinPrice += 15;
            break;

        case Material.Gold:
            minDamage += 25;
            coinPrice += 25;
            break;
        }
        if (weaponType == WeaponType.Knife)
        {
            minDamage -= 10;
        }

        if (minDamage <= 0)
        {
            minDamage = 1;
        }

        int maxDamage = minDamage + 10;

        damage = Random.Range(minDamage, maxDamage);


        int temp = 0;

        if (weaponType == WeaponType.Knife)
        {
            temp = Random.Range(1, 4);
        }
        else if (weaponType == WeaponType.Sword)
        {
            temp = Random.Range(1, 5);
        }
        foreach (Sprite sp in InventoryScript.Instance.Knifes)
        {
            if (sp.name == material.ToString() + "_" + weaponType + "_" + temp.ToString())
            {
                sprite = sp;
            }
        }
    }
示例#6
0
    public void EnemyLogic(Actions prevPlayerAbility)
    {
        float attackChance          = 1;
        float armorBuffChance       = 1;
        float healingChance         = 1;
        float lightningAttackChance = 1;
        float fireAttackChance      = 1;

        //float noThing = 0;
        if (enemyScript.HealthPoint <= enemyScript.MaxHealthPoint / 3)
        {
            attackChance          += 5;
            armorBuffChance       += 30;
            healingChance         += 30;
            lightningAttackChance += 10;
            fireAttackChance      += 10;
        }
        if ((enemyScript.HealthPoint <= enemyScript.MaxHealthPoint / 2) && (enemyScript.HealthPoint > enemyScript.MaxHealthPoint / 3))
        {
            attackChance          += 25;
            armorBuffChance       += 25;
            healingChance         += 25;
            lightningAttackChance += 15;
            fireAttackChance      += 15;
        }
        if (enemyScript.HealthPoint > enemyScript.MaxHealthPoint / 2)
        {
            attackChance          += 40;
            armorBuffChance       += 5;
            healingChance         += 5;
            lightningAttackChance += 30;
            fireAttackChance      += 30;
        }


        switch (prevPlayerAbility)
        {
        case Actions.ArmorBuff:
            attackChance          /= 2;
            lightningAttackChance *= 1.5f;
            break;

        case Actions.FireAttack:
            healingChance    *= 1.2f;
            fireAttackChance *= 1.5f;
            break;

        case Actions.Healing:
            attackChance    /= 1.2f;
            armorBuffChance *= 2;
            healingChance   *= 2;
            break;

        case Actions.LightningAttack:
            armorBuffChance /= 2;
            healingChance   *= 1.5f;
            break;

        case Actions.PhysicalAttack:
            attackChance    *= 1.5f;
            armorBuffChance *= 2;
            break;
        }

        if (enemyScript.Armor < 50)
        {
            armorBuffChance /= 10;
        }
        if (playerScript.HealthPoint <= enemyScript.Damage)
        {
            lightningAttackChance *= 2;
            fireAttackChance      *= 2;
        }
        enemyScript.ChtoDelat = RandomEvClass.RandomEv(new float[5] {
            attackChance, armorBuffChance,
            healingChance, lightningAttackChance, fireAttackChance
        }) + 1;
        if (enemyScript.HealthPoint <= 0)
        {
            enemyScript.ChtoDelat = 0;
        }
    }