コード例 #1
0
        private static AttackInformation MagicFrom(MagicDefinition magic, FDCreature subject, FDCreature target, GameField field)
        {
            bool isHit = FDRandom.BoolFromRate(magic.HittingRate);

            int changedHp = 0;

            if (isHit)
            {
                OccupationDefinition occupation = DefinitionStore.Instance.GetOccupationDefinition(target.Definition.Occupation);
                double hitRate = 1.0f;

                if (occupation != null)
                {
                    hitRate = (100 - occupation.MagicDefendRate) / 100.0f;
                }

                switch (magic.Type)
                {
                case MagicType.Attack:
                    changedHp = -FDRandom.IntFromSpan(magic.Span) + magic.ApInvoledRate * subject.Data.CalculatedAp / 100;
                    changedHp = (int)(changedHp * hitRate);
                    changedHp = Math.Min(0, changedHp);
                    break;

                case MagicType.Recover:
                    changedHp = FDRandom.IntFromSpan(magic.Span);
                    changedHp = Math.Max(0, changedHp);
                    break;

                case MagicType.Offensive:
                    TakeOffensiveEffect(magic, target);
                    break;

                case MagicType.Defensive:
                    TakeDefensiveEffect(magic, target);
                    break;

                default:
                    break;
                }
            }

            AttackInformation info = new AttackInformation(target.Data.Hp, target.Data.Hp + changedHp, false);

            target.Data.UpdateHp(changedHp);

            return(info);
        }
コード例 #2
0
        private static AttackInformation AttackFrom(FDCreature subject, FDCreature target, GameField field)
        {
            bool isHit      = FDRandom.BoolFromRate(subject.Data.CalculatedHit - target.Data.CalculatedEv);
            bool isCritical = FDRandom.BoolFromRate(commonCriticalAttackRate);

            int reduceHp = 0;

            if (isHit)
            {
                FDPosition      pos        = subject.Position;
                ShapeDefinition shape      = field.GetShapeAt(pos.X, pos.Y);
                int             adjustedAp = subject.Data.CalculatedAp * (100 + shape.AdjustedAp) / 100;

                FDPosition      targetPos   = target.Position;
                ShapeDefinition targetShape = field.GetShapeAt(targetPos.X, targetPos.Y);
                int             adjustedDp  = target.Data.CalculatedDp * (100 + shape.AdjustedDp) / 100;

                int attackMax = adjustedAp - adjustedDp;
                int attackMin = (int)(attackMax * 0.9f);
                reduceHp = FDRandom.IntFromSpan(attackMin, attackMax);
                reduceHp = (reduceHp < 0) ? 0 : reduceHp;

                if (isCritical)
                {
                    reduceHp *= 2;
                }

                // Poisoned
                AttackItemDefinition attackItem = subject.Data.GetAttackItem();
                if (attackItem != null)
                {
                    bool isPoisoned = FDRandom.BoolFromRate(attackItem.GetPoisonRate());
                    if (isPoisoned)
                    {
                        target.Data.SetEffect(CreatureData.CreatureEffects.Poisoned);
                    }
                }
            }

            AttackInformation info = new AttackInformation(target.Data.Hp, target.Data.Hp - reduceHp, isCritical);

            target.Data.UpdateHp(-reduceHp);

            return(info);
        }
コード例 #3
0
    public static byte[] NativeDecodeToBytes(byte[] data)
    {
        if (null == data || data.Length < 1)
        {
            return(new byte[1]);
        }
        byte[] encodeKey = BakeByte(data[0]);
        byte[] preOr1    = new byte[data.Length - 2];
        byte   orderSeed = data[1];

        Array.Copy(data, 2, preOr1, 0, preOr1.Length);
        byte[] preOr2 = FDRandom.ReOrder(preOr1, orderSeed);
        for (int i = 0; i < (preOr2.Length + 0.1f) / 12.0f; ++i)
        {
            for (int j = 0; j < 12 && i * 12 + j < preOr2.Length; ++j)
            {
                preOr2[i * 12 + j] = (byte)(preOr2[i * 12 + j] ^ encodeKey[j]);
            }
        }
        return(preOr2);
    }
コード例 #4
0
    public static byte[] NativeEncodeToBytes(byte[] data)
    {
        byte tag       = (byte)FDRandom.Range(0, 256);
        byte orderseed = (byte)FDRandom.Range(0, 256);

        byte[] encodeKey = BakeByte(tag);

        for (int i = 0; i < (data.Length + 0.1f) / 12.0f; ++i)
        {
            for (int j = 0; j < 12 && i * 12 + j < data.Length; ++j)
            {
                data[i * 12 + j] = (byte)(data[i * 12 + j] ^ encodeKey[j]);
            }
        }
        byte[] prebase64_1 = new byte[data.Length + 2];
        byte[] prebase64_2 = FDRandom.DisOrder(data, orderseed);
        prebase64_1[0] = tag;
        prebase64_1[1] = orderseed;
        prebase64_2.CopyTo(prebase64_1, 2);
        return(prebase64_1);
    }
コード例 #5
0
 private void SetValue(bool iValue)
 {
     m_fValue = iValue ? FDRandom.Range(0, 100) : FDRandom.Range(-100, -1);
 }
コード例 #6
0
 private void SetValue(int iValue)
 {
     m_iCut1 = FDRandom.Range(iValue > 0 ? -10 * iValue - 10 : 10 * iValue - 10, iValue > 0 ? 10 * iValue + 10 : -10 * iValue + 10);
     m_iCut2 = iValue - m_iCut1;
 }
コード例 #7
0
 private void SetValue(float fValue)
 {
     m_fCut1 = FDRandom.Range(-1.0f, 2.0f) * fValue;
     m_fCut2 = fValue - m_fCut1;
 }
コード例 #8
0
        public static FightInformation DealWithAttack(FDCreature subject, FDCreature target, GameField field, bool canFightBack)
        {
            AttackInformation attack1 = AttackFrom(subject, target, field);
            AttackInformation attack2 = null;
            AttackInformation back1   = null;
            AttackInformation back2   = null;

            int exp1     = CalculateAttackExp(subject, target, attack1);
            int backExp1 = 0;

            if (target.Data.Hp > 0)
            {
                bool isDoubleHit = FDRandom.BoolFromRate(commonDoubleAttackRate);

                if (isDoubleHit)
                {
                    attack2 = AttackFrom(subject, target, field);
                    exp1   += CalculateAttackExp(subject, target, attack2);
                }

                if (exp1 > 0)
                {
                    // Gain Experience
                }
            }
            else
            {
                // Gain Experience
            }

            // Fight back
            if (canFightBack && target.Data.Hp > 0)
            {
                back1    = AttackFrom(target, subject, field);
                backExp1 = CalculateAttackExp(target, subject, back1);

                bool isDoubleHit = FDRandom.BoolFromRate(commonDoubleAttackRate);
                if (subject.Data.Hp > 0 && isDoubleHit)
                {
                    back2     = AttackFrom(target, subject, field);
                    backExp1 += CalculateAttackExp(target, subject, back1);

                    if (subject.Data.Hp > 0)
                    {
                        // Gain Experience
                    }
                    else
                    {
                        // Gain Experience
                    }
                }
                else
                {
                    // Gain Experience
                }
            }
            else
            {
                // Gain Experience
            }

            FightInformation fighting = new FightInformation(attack1, attack2, back1, back2);

            return(fighting);
        }