Пример #1
0
    void SetBaseStats(Fighter f)
    {
        Weapon w = f.Weapon;

        bool magic = false;

        if (w != null)
        {
            magic = w.type == Weapon.WeaponType.Anima_Tome || w.type == Weapon.WeaponType.Dark_Tome || w.type == Weapon.WeaponType.Light_Tome;
        }

        int   str   = 0;
        float evade = 0;
        float crit  = 0;
        float acc   = 0;

        if (w != null)
        {
            if (!magic)
            {
                str = StatsCalc.PhysicalAttack(f.Unit.stats.strength, w.might, 1, 1, StatsCalc.SupportBonus(f), false);
            }
            else
            {
                str = StatsCalc.MagicalAttack(f.Unit.stats.magic, w.might, 1, 1, StatsCalc.SupportBonus(f));
            }

            evade = StatsCalc.Avoid(f.Unit.stats.speed, f.Unit.stats.luck, new Cell.TerrainBonus(), StatsCalc.SupportBonus(f));
            crit  = StatsCalc.CriticalChance(StatsCalc.CriticalRate(w.crit, f.Unit.stats.skill, StatsCalc.SupportBonus(f), StatsCalc.ClassCrit(f.Unit.unitClass)), 0);
            acc   = StatsCalc.Accuracy(StatsCalc.HitRate(w.hit, f.Unit.stats.skill, f.Unit.stats.luck, StatsCalc.SupportBonus(f)), StatsCalc.Avoid(f.Unit.stats.speed, f.Unit.stats.luck, new Cell.TerrainBonus(), StatsCalc.SupportBonus(f)), 1);
        }

        baseAtk = str;
        baseAcc = acc;
        baseCrt = crit;
        baseEva = evade;
    }
Пример #2
0
        public Offensive(Fighter attacker, Fighter defender, bool repeated = false)
        {
            Attacker = attacker;
            Defender = defender;

            Seed = StatsCalc.Seed(new Vector2Int[2] {
                attacker.Position(), defender.Position()
            });
            Rand = new System.Random(Seed);

            IsPhysical = Attacker.Weapon.isPhysical;

            AtkStat = IsPhysical ? Attacker.Unit.stats.strength : Attacker.Unit.stats.magic;
            DefStat = IsPhysical ? Defender.Unit.stats.defense : Defender.Unit.stats.resistance;

            Cell = Map.UnitTile(Attacker);

            Support1 = StatsCalc.SupportBonus(Attacker);
            Support2 = StatsCalc.SupportBonus(Defender);

            TriangleBonus = StatsCalc.TriangleBonus(Attacker, Defender);
            TerrainBonus1 = StatsCalc.TerrainBonus(Map.UnitTile(Attacker));
            TerrainBonus2 = StatsCalc.TerrainBonus(Map.UnitTile(Defender));

            Speed1 = Attacker.Unit.stats.speed;
            Speed2 = Defender.Unit.stats.speed;

            Wgt1 = Attacker.Weapon.weight;
            Wgt2 = Defender.Weapon.weight;

            Con1 = Attacker.Unit.stats.constitution;
            Con2 = Defender.Unit.stats.constitution;

            Attack  = AtkStat;
            Defense = DefStat;

            Spd1 = StatsCalc.AttackSpeed(Speed1, Wgt1, Con1);
            Spd2 = StatsCalc.AttackSpeed(Speed2, Wgt2, Con2);

            Atk = StatsCalc.PhysicalAttack(Attack, Attacker.Weapon.might, TriangleBonus, StatsCalc.WeaponEffectiveness(Attacker.Weapon, Defender), Support1, false);
            Def = StatsCalc.PhysicalDefense(TerrainBonus2, Defense, Support2);

            HitRate = StatsCalc.HitRate(Attacker.Weapon.hit, Attacker.Unit.stats.skill, Attacker.Unit.stats.luck, Support1);
            Avoid   = StatsCalc.Avoid(Speed2, Defender.Unit.stats.luck, TerrainBonus2, Support2);
            Acc     = StatsCalc.Accuracy(HitRate, Avoid, TriangleBonus);

            CritRate   = StatsCalc.CriticalRate(Attacker.Weapon.crit, Attacker.Unit.stats.skill, Support1, StatsCalc.ClassCrit(Attacker.Unit.unitClass));
            CritEvade  = StatsCalc.CriticalEvade(Defender.Unit.stats.luck, Support2);
            CritChance = StatsCalc.CriticalChance(CritRate, CritEvade);

            if (StatsCalc.ClassCriticalModifier.ContainsKey(Attacker.Unit.unitClass))
            {
                CritChance += StatsCalc.ClassCriticalModifier[Attacker.Unit.unitClass];
            }

            if (repeated)
            {
                CritChance += Attacker.Unit.stats.pursuitCriticalCoefficient;
            }

            Hit  = Rand.Next(0, 100) <= Acc;
            Crit = Rand.Next(0, 100) <= CritChance;

            Damage = Crit ? StatsCalc.CriticalDamage(StatsCalc.Damage(Atk, Def)) : StatsCalc.Damage(Atk, Def);

            if (Attacker.LastTarget == Defender)
            {
                Attacker.RepeatedTarget++;
            }
            else
            {
                Attacker.LastTarget     = Defender;
                Attacker.RepeatedTarget = 0;
            }
        }
Пример #3
0
    void StatusMenu(Fighter f)
    {
        Weapon w = null;

        if (hovered.GetType() != typeof(Weapon))
        {
            if (f.Weapon != null)
            {
                w = f.Weapon;
            }
        }
        else
        {
            w = (Weapon)hovered;
        }

        if (w == null)
        {
            w = ScriptableObject.CreateInstance <Weapon>();
        }

        type.text = w.type.ToString().Replace('_', ' ');

        bool magic = w.type == Weapon.WeaponType.Anima_Tome || w.type == Weapon.WeaponType.Dark_Tome || w.type == Weapon.WeaponType.Light_Tome;

        int   str   = 0;
        float acc   = StatsCalc.Accuracy(StatsCalc.HitRate(w.hit, f.Unit.stats.skill, f.Unit.stats.luck, StatsCalc.SupportBonus(f)), StatsCalc.Avoid(f.Unit.stats.speed, f.Unit.stats.luck, new Cell.TerrainBonus(), StatsCalc.SupportBonus(f)), 1);
        float crit  = StatsCalc.CriticalChance(StatsCalc.CriticalRate(w.crit, f.Unit.stats.skill, StatsCalc.SupportBonus(f), StatsCalc.ClassCrit(f.Unit.unitClass)), 0);
        float evade = StatsCalc.Avoid(f.Unit.stats.speed, f.Unit.stats.luck, new Cell.TerrainBonus(), StatsCalc.SupportBonus(f));

        if (!magic)
        {
            str = StatsCalc.PhysicalAttack(f.Unit.stats.strength, w.might, 1, 1, StatsCalc.SupportBonus(f), false);
        }
        else
        {
            str = StatsCalc.MagicalAttack(f.Unit.stats.magic, w.might, 1, 1, StatsCalc.SupportBonus(f));
        }

        atk.text      = "ATK: " + str;
        this.acc.text = "ACC: " + (int)acc;
        crt.text      = "CRT: " + (int)crit;
        eva.text      = "EVA: " + (int)evade;

        #region atk
        if (str > baseAtk)
        {
            atkAr.color = inc;
            atkAr.transform.localScale = Vector3.one;
            _atkAr.gameObject.SetActive(true);
        }
        else if (str < baseAtk)
        {
            atkAr.color = dec;
            atkAr.transform.localScale = new Vector3(1, -1, 1);
            _atkAr.gameObject.SetActive(true);
        }
        else
        {
            _atkAr.gameObject.SetActive(false);
        }
        #endregion
        #region acc
        if (acc > baseAcc)
        {
            accAr.color = inc;
            accAr.transform.localScale = Vector3.one;
            _accAr.gameObject.SetActive(true);
        }
        else if (acc < baseAcc)
        {
            accAr.color = dec;
            accAr.transform.localScale = new Vector3(1, -1, 1);
            _accAr.gameObject.SetActive(true);
        }
        else
        {
            _accAr.gameObject.SetActive(false);
        }
        #endregion
        #region crt
        if (crit > baseCrt)
        {
            crtAr.color = inc;
            crtAr.transform.localScale = Vector3.one;
            _crtAr.gameObject.SetActive(true);
        }
        else if (crit < baseCrt)
        {
            crtAr.color = dec;
            crtAr.transform.localScale = new Vector3(1, -1, 1);
            _crtAr.gameObject.SetActive(true);
        }
        else
        {
            _crtAr.gameObject.SetActive(false);
        }
        #endregion
        #region eva
        if (evade > baseEva)
        {
            evaAr.color = inc;
            evaAr.transform.localScale = Vector3.one;
            _evaAr.gameObject.SetActive(true);
        }
        else if (evade < baseEva)
        {
            evaAr.color = dec;
            evaAr.transform.localScale = new Vector3(1, -1, 1);
            _evaAr.gameObject.SetActive(true);
        }
        else
        {
            _evaAr.gameObject.SetActive(false);
        }
        #endregion
    }