コード例 #1
0
ファイル: SkillHit.cs プロジェクト: midgithub/ProjectC
    static void AddHitCount(Character cha, SkillContext context, excel_skill_hit hitExcel)
    {
        Dictionary <Character, int> hitmap;

        if (!context.mChaHitCount.TryGetValue(hitExcel.id, out hitmap))
        {
            hitmap = new Dictionary <Character, int>();
            context.mChaHitCount.Add(hitExcel.id, hitmap);

            hitmap.Add(cha, 1);
            return;
        }

        int hitCount = 0;

        if (!hitmap.TryGetValue(cha, out hitCount))
        {
            hitmap.Add(cha, 1);
            return;
        }
        int maxHitCount = (int)hitExcel.targetMaxHitCnt;

        if (maxHitCount > 0 && hitCount > maxHitCount)
        {
            return;
        }
        ++hitCount;
        hitmap[cha] = hitCount;
    }
コード例 #2
0
ファイル: SkillHit.cs プロジェクト: midgithub/ProjectC
    static bool IsMayHit(Character cha, SkillContext context, excel_skill_hit hitExcel)
    {
        Dictionary <Character, int> hitmap;

        if (!context.mChaHitCount.TryGetValue(hitExcel.id, out hitmap))
        {
            return(true);
        }

        int hitCount = 0;

        if (!hitmap.TryGetValue(cha, out hitCount))
        {
            return(true);
        }
        int maxHitCount = (int)hitExcel.targetMaxHitCnt;

        if (maxHitCount <= 0)
        {
            return(true);
        }
        if (hitCount > maxHitCount)
        {
            return(false);
        }
        return(true);
    }
コード例 #3
0
ファイル: SkillHit.cs プロジェクト: midgithub/ProjectC
    static void DisplayHit(bool display, excel_skill_hit hitExcel, GameObject go)
    {
        if (!display)
        {
            return;
        }
        GameObject displayGO = new GameObject("Hit");

        displayGO.transform.position   = go.transform.position;
        displayGO.transform.rotation   = go.transform.rotation;
        displayGO.transform.localScale = go.transform.localScale;
        SkillHitDisplay hitDisplay = displayGO.AddComponent <SkillHitDisplay>();

        hitDisplay.mHitExcel = hitExcel;
    }
コード例 #4
0
ファイル: SkillHit.cs プロジェクト: midgithub/ProjectC
    static int CalcDamage(Character src, Character target, excel_skill_hit hitExcel, excel_skill_list skillList)
    {
        // 参数;
        float param = 350.0f;

        if (hitExcel.hurtType == (int)SkillHurtType.PhyDamage)
        {
            // 攻击力;
            float atk = (float)src.GetAtb(AtbType.PhyAtk);
            // 面板伤害 = 技能基础伤害 + 攻击力 + 技能伤害加成(%);
            float panelDamage = skillList.phyDamage + src.GetAtb(AtbType.PhyAtk) + atk * (float)skillList.phyPct * 0.0001f;
            // 防御力;
            float def = (float)target.GetAtb(AtbType.PhyDef);
            // 穿透;
            float pen = (float)src.GetAtb(AtbType.PhyPen);
            // 防御穿透比;
            float penPct = src.GetAtbPct(AtbType.PhyPenPct);
            // 伤害上下浮动;
            float ud = MathLib.Mathf.RandRange(-1.0f, 1.0f);
            // 伤害 = 面板伤害 / ( (防御力 - 穿透) * (1 - 防御穿透比) / 参数 + 1) + [-1, 1];
            float damage = panelDamage / ((def - pen) * (1.0f - penPct) / param + 1.0f) + ud;

            return((int)MathLib.Mathf.Max(1.0f, damage));
        }
        else if (hitExcel.hurtType == (int)SkillHurtType.MagDamage)
        {
            // 攻击力;
            float atk = (float)src.GetAtb(AtbType.MagAtk);
            // 面板伤害 = 技能基础伤害 + 攻击力 + 技能伤害加成(%);
            float panelDamage = skillList.magDamage + src.GetAtb(AtbType.MagAtk) + atk * (float)skillList.magPct * 0.0001f;
            // 防御力;
            float def = (float)target.GetAtb(AtbType.MagDef);
            // 穿透;
            float pen = (float)src.GetAtb(AtbType.MagPen);
            // 防御穿透比;
            float penPct = src.GetAtbPct(AtbType.MagPenPct);
            // 伤害上下浮动;
            float ud = MathLib.Mathf.RandRange(-1.0f, 1.0f);
            // 伤害 = 面板伤害 / ( (防御力 - 穿透) * (1 - 防御穿透比) / 参数 + 1) + [-1, 1];
            float damage = panelDamage / ((def - pen) * (1.0f - penPct) / param + 1.0f) + ud;

            return((int)MathLib.Mathf.Max(1.0f, damage));
        }
        return(0);
    }
コード例 #5
0
ファイル: SkillHit.cs プロジェクト: midgithub/ProjectC
    static void OnHit(Character src, Character target, excel_skill_hit hitExcel)
    {
        excel_skill_list skillList = excel_skill_list.Find(hitExcel.skillID);

        if (skillList == null)
        {
            Debug.LogError("判定表[" + hitExcel.id + "]的所属技能错误!");
            return;
        }
        int hurt  = CalcDamage(src, target, hitExcel, skillList);
        int oldHP = target.HP;

        target.HP = target.HP - hurt;
        if (hitExcel.hurtType == (int)SkillHurtType.PhyDamage)
        {
            if (src != target)
            {
                FightUtility.SendHpChg(src, target.gid, hurt, HPChgType.PhyDamage);
            }
            FightUtility.SendHpChg(target, target.gid, hurt, HPChgType.PhyDamage);
        }
        else if (hitExcel.hurtType == (int)SkillHurtType.MagDamage)
        {
            if (src != target)
            {
                FightUtility.SendHpChg(src, target.gid, hurt, HPChgType.MagDamage);
            }
            FightUtility.SendHpChg(target, target.gid, hurt, HPChgType.MagDamage);
        }
        else if (hitExcel.hurtType == (int)SkillHurtType.Cure)
        {
            if (src != target)
            {
                FightUtility.SendHpChg(src, target.gid, hurt, HPChgType.Cure);
            }
            FightUtility.SendHpChg(target, target.gid, hurt, HPChgType.Cure);
        }
    }
コード例 #6
0
ファイル: SkillHit.cs プロジェクト: midgithub/ProjectC
    public static void Hit(Character cha, int hitID, SkillContext context)
    {
        excel_skill_hit hitExcel = excel_skill_hit.Find(hitID);

        if (hitExcel == null)
        {
            return;
        }

        SkillHitShape   type       = (SkillHitShape)hitExcel.hitType;
        SkillTargetType targetType = (SkillTargetType)hitExcel.targetType;

        float data1  = (float)hitExcel.hitData1 * 0.001f;
        float data2  = (float)hitExcel.hitData2 * 0.001f;
        float height = (float)hitExcel.hitData3 * 0.001f;

        bool hitMultiple = hitExcel.hitType >= 3;

        List <Character> targets = new List <Character>();

        if (!hitMultiple)
        {
            Character skillTarget = context.SkillTarget;
            if (skillTarget == null)
            {
                return;
            }
            if (!IsMayHit(skillTarget, context, hitExcel))
            {
                return;
            }
            if (!CheckTargetType(cha, skillTarget, targetType))
            {
                return;
            }
            targets.Add(skillTarget);
        }
        else
        {
            Scene scn = cha.mScene;
            for (int i = 0; i < scn.GetCharacterCount(); ++i)
            {
                Character c = scn.GetCharacterByIndex(i);
                if (c == null)
                {
                    continue;
                }
                if (!IsMayHit(c, context, hitExcel))
                {
                    return;
                }
                if (!CheckTargetType(cha, c, targetType))
                {
                    continue;
                }
                targets.Add(c);
            }
        }

        Vector3 srcPosition = context.mOwner.Position;
        Vector3 srcForward  = context.mOwner.Direction;

        int hitCount = 0;

        for (int i = 0; i < targets.Count; ++i)
        {
            Character target = targets[i];
            switch (type)
            {
            case SkillHitShape.FanSingle:
            case SkillHitShape.FanMultiple:
            {
                if (Hit_Fan(srcPosition, srcForward, target, data1, data2 * 1000.0f, height))
                {
                    ++hitCount;
                    context.mHitTarget = target;
                    OnHit(context.mOwner, target, hitExcel);
                    AddHitCount(target, context, hitExcel);
                }
            }
            break;

            case SkillHitShape.RectSingle:
            case SkillHitShape.RectMultiple:
            {
                if (Hit_Rect(srcPosition, srcForward, target, data1, data2, height))
                {
                    ++hitCount;
                    context.mHitTarget = target;
                    OnHit(context.mOwner, target, hitExcel);
                    AddHitCount(target, context, hitExcel);
                }
            }
            break;

            case SkillHitShape.CircleSingle:
            case SkillHitShape.CircleMultiple:
            {
                if (Hit_Circle(srcPosition, target, data1, height))
                {
                    ++hitCount;
                    context.mHitTarget = target;
                    OnHit(context.mOwner, target, hitExcel);
                    AddHitCount(target, context, hitExcel);
                }
            }
            break;
            }
            if (hitExcel.maxHitCount > 0 && hitCount > hitExcel.maxHitCount)
            {
                break;
            }
        }
    }