Ejemplo n.º 1
0
    public static CalculationAttributes operator *(CalculationAttributes a, float b)
    {
        CalculationAttributes result = new CalculationAttributes();

        result.hp   = Mathf.CeilToInt(a.hp * b);
        result.pAtk = Mathf.CeilToInt(a.pAtk * b);
        result.pDef = Mathf.CeilToInt(a.pDef * b);
        result.mAtk = Mathf.CeilToInt(a.mAtk * b);
        result.mDef = Mathf.CeilToInt(a.mDef * b);
        result.spd  = Mathf.CeilToInt(a.spd * b);
        result.eva  = Mathf.CeilToInt(a.eva * b);
        result.acc  = Mathf.CeilToInt(a.acc * b);

        result.exp_hpRate          = a.exp_hpRate * b;
        result.exp_pAtkRate        = a.exp_pAtkRate * b;
        result.exp_pDefRate        = a.exp_pDefRate * b;
        result.exp_mAtkRate        = a.exp_mAtkRate * b;
        result.exp_mDefRate        = a.exp_mDefRate * b;
        result.exp_spdRate         = a.exp_spdRate * b;
        result.exp_evaRate         = a.exp_evaRate * b;
        result.exp_accRate         = a.exp_accRate * b;
        result.exp_critChance      = a.exp_critChance * b;
        result.exp_critDamageRate  = a.exp_critDamageRate * b;
        result.exp_blockChance     = a.exp_blockChance * b;
        result.exp_blockDamageRate = a.exp_blockDamageRate * b;
        return(result);
    }
Ejemplo n.º 2
0
    public CalculationAttributes Clone()
    {
        CalculationAttributes result = new CalculationAttributes();

        result.hp   = hp;
        result.pAtk = pAtk;
        result.pDef = pDef;
        result.mAtk = mAtk;
        result.mDef = mDef;
        result.spd  = spd;
        result.eva  = eva;
        result.acc  = acc;

        result.exp_hpRate   = exp_hpRate;
        result.exp_pAtkRate = exp_pAtkRate;
        result.exp_pDefRate = exp_pDefRate;
        result.exp_mAtkRate = exp_mAtkRate;
        result.exp_mDefRate = exp_mDefRate;
        result.exp_spdRate  = exp_spdRate;
        result.exp_evaRate  = exp_evaRate;
        result.exp_accRate  = exp_accRate;

        result.exp_critChance      = exp_critChance;
        result.exp_critDamageRate  = exp_critDamageRate;
        result.exp_blockChance     = exp_blockChance;
        result.exp_blockDamageRate = exp_blockDamageRate;
        return(result);
    }
Ejemplo n.º 3
0
    public static CalculationAttributes operator -(CalculationAttributes a, CalculationAttributes b)
    {
        CalculationAttributes result = a.Clone();

        result.hp   -= b.hp;
        result.pAtk -= b.pAtk;
        result.pDef -= b.pDef;
        result.mAtk -= b.mAtk;
        result.mDef -= b.mDef;
        result.spd  -= b.spd;
        result.eva  -= b.eva;
        result.acc  -= b.acc;

        result.exp_hpRate   -= b.exp_hpRate;
        result.exp_pAtkRate -= b.exp_pAtkRate;
        result.exp_pDefRate -= b.exp_pDefRate;
        result.exp_mAtkRate -= b.exp_mAtkRate;
        result.exp_mDefRate -= b.exp_mDefRate;
        result.exp_spdRate  -= b.exp_spdRate;
        result.exp_evaRate  -= b.exp_evaRate;
        result.exp_accRate  -= b.exp_accRate;

        result.exp_critChance     -= b.exp_critChance;
        result.exp_critDamageRate -= b.exp_critDamageRate;

        result.exp_blockChance     -= b.exp_blockChance;
        result.exp_blockDamageRate -= b.exp_blockDamageRate;
        return(result);
    }
Ejemplo n.º 4
0
    public CalculationAttributes GetTotalAttributes()
    {
        var result = new CalculationAttributes();

        //result += attributes.CreateCalculationAttributes(1, Const.MaxLevel);

        // If this is character item, applies rate attributes
        //result.hp += Mathf.CeilToInt(result.hpRate * result.hp);
        //result.pAtk += Mathf.CeilToInt(result.pAtkRate * result.pAtk);
        //result.pDef += Mathf.CeilToInt(result.pDefRate * result.pDef);
        //result.mAtk += Mathf.CeilToInt(result.mAtkRate * result.mAtk);
        //result.mDef += Mathf.CeilToInt(result.mDefRate * result.mDef);
        //result.spd += Mathf.CeilToInt(result.spdRate * result.spd);
        //result.eva += Mathf.CeilToInt(result.evaRate * result.eva);
        //result.acc += Mathf.CeilToInt(result.accRate * result.acc);

        //result.hp += Mathf.CeilToInt(result._hpRate * result.hp);
        //result.pAtk += Mathf.CeilToInt(result._pAtkRate * result.pAtk);
        //result.pDef += Mathf.CeilToInt(result._pDefRate * result.pDef);
        //result.mAtk += Mathf.CeilToInt(result._mAtkRate * result.mAtk);
        //result.mDef += Mathf.CeilToInt(result._mDefRate * result.mDef);
        //result.spd += Mathf.CeilToInt(result._spdRate * result.spd);
        //result.eva += Mathf.CeilToInt(result._evaRate * result.eva);
        //result.acc += Mathf.CeilToInt(result._accRate * result.acc);
        return(result);
    }
Ejemplo n.º 5
0
    //public Attributes Clone()
    //{
    //    Attributes result = new Attributes();
    //    result.hp = hp.Clone();
    //    result.pAtk = pAtk.Clone();
    //    result.pDef = pDef.Clone();
    //    result.mAtk = mAtk.Clone();
    //    result.mDef = mDef.Clone();
    //    result.spd = spd.Clone();
    //    result.eva = eva.Clone();
    //    result.acc = acc.Clone();
    //    return result;
    //}

    /// <summary>
    /// 获取未计算之前的属性,用于展示面板
    /// </summary>
    /// <param name="currentLevel"></param>
    /// <param name="maxLevel"></param>
    /// <returns></returns>
    public CalculationAttributes GetCreateCalculationAttributes(int maxLevel = Const.MaxLevel)
    {
        CalculationAttributes result = new CalculationAttributes();

        result.hp                  = hp.Calculate(level, maxLevel);
        result.pAtk                = pAtk.Calculate(level, maxLevel);
        result.pDef                = pDef.Calculate(level, maxLevel);
        result.mAtk                = mAtk.Calculate(level, maxLevel);
        result.mDef                = mDef.Calculate(level, maxLevel);
        result.spd                 = spd.Calculate(level, maxLevel);
        result.eva                 = eva.Calculate(level, maxLevel);
        result.acc                 = acc.Calculate(level, maxLevel);
        result.exp_hpRate          = exp_hpRate;
        result.exp_pAtkRate        = exp_pAtkRate;
        result.exp_pDefRate        = exp_pDefRate;
        result.exp_mAtkRate        = exp_mAtkRate;
        result.exp_mDefRate        = exp_mDefRate;
        result.exp_spdRate         = exp_spdRate;
        result.exp_evaRate         = exp_evaRate;
        result.exp_accRate         = exp_accRate;
        result.exp_critChance      = exp_critChance;
        result.exp_critDamageRate  = exp_critDamageRate;
        result.exp_blockChance     = exp_blockChance;
        result.exp_blockDamageRate = exp_blockDamageRate;
        return(result);
    }
Ejemplo n.º 6
0
 public CalculationAttributes GetItemAttributes()
 {
     if (CharacterData != null)
     {
         var result = new CalculationAttributes();
         //result += CharacterData.CreateCalculationAttributes(Level, MaxLevel);
         if (GameDatabase != null)
         {
             result += GameDatabase.characterBaseAttributes;
         }
         if (ExtrAttributesData != null)
         {
             result += ExtrAttributesData;
         }
         result += EquipmentBonus;
         return(result);
     }
     if (EquipmentData != null)
     {
         var result = new CalculationAttributes();
         //result += EquipmentData.CreateCalculationAttributes(Level, MaxLevel);
         //result += EquipmentData.CreateExtraCalculationAttributes();
         return(result);
     }
     Debug.LogError("属性 null 不属于 char or equip");
     return(null);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取带着装备的属性
        /// </summary>
        /// <returns></returns>
        public CalculationAttributes GetCalculationAttributesWithProp()
        {
            CalculationAttributes result = Character.GetAttributes(level).GetCreateCalculationAttributes();
            Dictionary <string, IPlayerHasEquips> hasEquips = IPlayerHasEquips.GetHeroEquipses(guid);

            foreach (IPlayerHasEquips playerHasEquips in hasEquips.Values)
            {
                result += playerHasEquips.IEquipment.GetAttributes().GetCreateCalculationAttributes();
            }
            return(result);
        }
Ejemplo n.º 8
0
        public static CalculationAttributes GetTowerExtraAttributes(bool IsBos)
        {
            CalculationAttributes extraAttributes = new CalculationAttributes();
            int playerlevel = IPlayer.CurrentPlayer.Level;
            int towerLevel  = IPlayer.CurrentPlayer.TowerCurrentLevel;
            int totalWeight = (playerlevel * 10 + towerLevel * 15 + 5) * 50;

            extraAttributes.SetExtraAtt(totalWeight);

            return(extraAttributes);
        }
Ejemplo n.º 9
0
    public CalculationAttributes GetAllCalculationAttributes()
    {
        CalculationAttributes skillCalculationAttributes = GetCalculationAttributes();

        foreach (var buff in buffs.Values)
        {
            skillCalculationAttributes += buff.SelfAttributes;
        }

        foreach (var cskill in skills.Values)
        {
            skillCalculationAttributes += cskill.SelfAttributes;
        }

        return(skillCalculationAttributes);
    }
Ejemplo n.º 10
0
    public void SetupInfo(CalculationAttributes data)
    {
        if (data == null)
        {
            data = new CalculationAttributes();
        }

        if (textHp != null)
        {
            textHp.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_HP, data.hp) : RPGLanguageManager.FormatNumber(data.hp);
            if (hideInfoIfEmpty && containerHp != null)
            {
                containerHp.SetActive(Mathf.Abs(data.hp) > 0);
            }
        }

        if (textPAtk != null)
        {
            textPAtk.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_PATK, data.pAtk) : RPGLanguageManager.FormatNumber(data.pAtk);
            if (hideInfoIfEmpty && containerPAtk != null)
            {
                containerPAtk.SetActive(Mathf.Abs(data.pAtk) > 0);
            }
        }

        if (textPDef != null)
        {
            textPDef.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_PDEF, data.pDef) : RPGLanguageManager.FormatNumber(data.pDef);
            if (hideInfoIfEmpty && containerPDef != null)
            {
                containerPDef.SetActive(Mathf.Abs(data.pDef) > 0);
            }
        }

        if (textMAtk != null)
        {
            textMAtk.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_MATK, data.mAtk) : RPGLanguageManager.FormatNumber(data.mAtk);
            if (hideInfoIfEmpty && containerMAtk != null)
            {
                containerMAtk.SetActive(Mathf.Abs(data.mAtk) > 0);
            }
        }

        if (textMDef != null)
        {
            textMDef.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_MDEF, data.mDef) : RPGLanguageManager.FormatNumber(data.mDef);
            if (hideInfoIfEmpty && containerMDef != null)
            {
                containerMDef.SetActive(Mathf.Abs(data.mDef) > 0);
            }
        }

        if (textSpd != null)
        {
            textSpd.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_SPD, data.spd) : RPGLanguageManager.FormatNumber(data.spd);
            if (hideInfoIfEmpty && containerSpd != null)
            {
                containerSpd.SetActive(Mathf.Abs(data.spd) > 0);
            }
        }

        if (textEva != null)
        {
            textEva.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_EVA, data.eva) : RPGLanguageManager.FormatNumber(data.eva);
            if (hideInfoIfEmpty && containerEva != null)
            {
                containerEva.SetActive(Mathf.Abs(data.eva) > 0);
            }
        }

        if (textAcc != null)
        {
            textAcc.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_ACC, data.acc) : RPGLanguageManager.FormatNumber(data.acc);
            if (hideInfoIfEmpty && containerAcc != null)
            {
                containerAcc.SetActive(Mathf.Abs(data.acc) > 0);
            }
        }

        if (textHpRate != null)
        {
            textHpRate.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_HP_RATE, data.exp_hpRate, true) : RPGLanguageManager.FormatNumber(data.exp_hpRate, true);
            if (hideInfoIfEmpty && containerHpRate != null)
            {
                containerHpRate.SetActive(Mathf.Abs(data.exp_hpRate) > 0);
            }
        }

        if (textPAtkRate != null)
        {
            textPAtkRate.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_PATK_RATE, data.exp_pAtkRate, true) : RPGLanguageManager.FormatNumber(data.exp_pAtkRate, true);
            if (hideInfoIfEmpty && containerPAtkRate != null)
            {
                containerPAtkRate.SetActive(Mathf.Abs(data.exp_pAtkRate) > 0);
            }
        }

        if (textPDefRate != null)
        {
            textPDefRate.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_PDEF_RATE, data.exp_pDefRate, true) : RPGLanguageManager.FormatNumber(data.exp_pDefRate, true);
            if (hideInfoIfEmpty && containerPDefRate != null)
            {
                containerPDefRate.SetActive(Mathf.Abs(data.exp_pDefRate) > 0);
            }
        }

        if (textMAtkRate != null)
        {
            textMAtkRate.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_MATK_RATE, data.exp_mAtkRate, true) : RPGLanguageManager.FormatNumber(data.exp_mAtkRate, true);
            if (hideInfoIfEmpty && containerMAtkRate != null)
            {
                containerMAtkRate.SetActive(Mathf.Abs(data.exp_mAtkRate) > 0);
            }
        }

        if (textMDefRate != null)
        {
            textMDefRate.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_MDEF_RATE, data.exp_mDefRate, true) : RPGLanguageManager.FormatNumber(data.exp_mDefRate, true);
            if (hideInfoIfEmpty && containerMDefRate != null)
            {
                containerMDefRate.SetActive(Mathf.Abs(data.exp_mDefRate) > 0);
            }
        }

        if (textSpdRate != null)
        {
            textSpdRate.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_SPD_RATE, data.exp_spdRate, true) : RPGLanguageManager.FormatNumber(data.exp_spdRate, true);
            if (hideInfoIfEmpty && containerSpdRate != null)
            {
                containerSpdRate.SetActive(Mathf.Abs(data.exp_spdRate) > 0);
            }
        }

        if (textEvaRate != null)
        {
            textEvaRate.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_EVA_RATE, data.exp_evaRate, true) : RPGLanguageManager.FormatNumber(data.exp_evaRate, true);
            if (hideInfoIfEmpty && containerEvaRate != null)
            {
                containerEvaRate.SetActive(Mathf.Abs(data.exp_evaRate) > 0);
            }
        }

        if (textAccRate != null)
        {
            textAccRate.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_ACC_RATE, data.exp_accRate, true) : RPGLanguageManager.FormatNumber(data.exp_accRate, true);
            if (hideInfoIfEmpty && containerAccRate != null)
            {
                containerAccRate.SetActive(Mathf.Abs(data.exp_accRate) > 0);
            }
        }

        if (textCritChance != null)
        {
            textCritChance.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_CRIT_CHANCE, data.exp_critChance, true) : RPGLanguageManager.FormatNumber(data.exp_critChance, true);
            if (hideInfoIfEmpty && containerCritChance != null)
            {
                containerCritChance.SetActive(Mathf.Abs(data.exp_critChance) > 0);
            }
        }

        if (textCritDamageRate != null)
        {
            textCritDamageRate.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_CRIT_DAMAGE_RATE, data.exp_critDamageRate, true) : RPGLanguageManager.FormatNumber(data.exp_critDamageRate, true);
            if (hideInfoIfEmpty && containerCritDamageRate != null)
            {
                containerCritDamageRate.SetActive(Mathf.Abs(data.exp_critDamageRate) > 0);
            }
        }

        if (textBlockChance != null)
        {
            textBlockChance.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_BLOCK_CHANCE, data.exp_blockChance, true) : RPGLanguageManager.FormatNumber(data.exp_blockChance, true);
            if (hideInfoIfEmpty && containerBlockChance != null)
            {
                containerBlockChance.SetActive(Mathf.Abs(data.exp_blockChance) > 0);
            }
        }

        if (textBlockDamageRate != null)
        {
            textBlockDamageRate.text = useFormatForInfo ? RPGLanguageManager.FormatInfo(GameText.TITLE_ATTRIBUTE_BLOCK_DAMAGE_RATE, data.exp_blockDamageRate, true) : RPGLanguageManager.FormatNumber(data.exp_blockDamageRate, true);
            if (hideInfoIfEmpty && containerBlockDamageRate != null)
            {
                containerBlockDamageRate.SetActive(Mathf.Abs(data.exp_blockDamageRate) > 0);
            }
        }
    }
Ejemplo n.º 11
0
    public static float FightFormula(int pAtk, int mAtk, int acc, float critChance, float critDamageRate, CalculationAttributes ReceiverAttributes, int hitCount = 1, int fixDamage = 0)
    {
        if (hitCount <= 0)
        {
            hitCount = 1;
        }
        var gameDb = GameInstance.GameDatabase;
        var pDmg   = pAtk - ReceiverAttributes.pDef;
        var mDmg   = mAtk - ReceiverAttributes.mDef;

        if (pDmg < 0)
        {
            pDmg = 0;
        }
        if (mDmg < 0)
        {
            mDmg = 0;
        }
        var totalDmg   = pDmg + mDmg;
        var isCritical = false;
        var isBlock    = false;

        totalDmg += Mathf.CeilToInt(totalDmg * Random.Range(gameDb.minAtkVaryRate, gameDb.maxAtkVaryRate)) + fixDamage;
        return(totalDmg);
    }