コード例 #1
0
    void normalAttack()
    {
        BaseHero target = null;

        foreach (BaseHero hero in GameData.g_listHero)
        {
            if (hero.group != group)
            {
                target = hero;
            }
        }
        if (target != null)
        {
            HeroAction action = new HeroAction();
            action.action = HeroActionType.Attack;
            action.args   = new object[] { target };
            actions.Enqueue(action);

            uint  randAttack = GameData.g_srand.Next((uint)(attackMax - attackMin));
            Fix64 reduce     = (attackMin + randAttack) / 100;

            if (armor >= Fix64.Zero)
            {
                Fix64 percent = (target.armor / 100 * 6) / (100 + target.armor / 100 * 6);
                reduce = reduce * (Fix64.One - percent);
            }
            else
            {
                Fix64 deeper = (Fix64)2 - Fix64.Pow((Fix64)0.94, (int)(Fix64.Abs(target.armor) / 100));
                reduce = reduce * deeper;
            }

            target.ReduceHP(reduce);
            target.BeAttack(this);
        }
    }