示例#1
0
    void OnSetChaClass(params object[] param)
    {
        excel_cha_class chaClass = param[0] as excel_cha_class;

        if (chaClass == null)
        {
            return;
        }
        if (btnTriggers == null)
        {
            return;
        }
        for (int i = 0; i < chaClass.skillIDs.Length && i < btnTriggers.Length; ++i)
        {
            int skillID = chaClass.skillIDs[i];
            excel_skill_list skillList = excel_skill_list.Find(skillID);
            if (skillList == null)
            {
                Debug.LogError("UIFight技能初始化失败,未找到ID为" + skillID + "的技能数据");
                continue;
            }

            EventTriggerListener listener = btnTriggers[i];

            GameObject   go           = listener.gameObject;
            SkillBtnData skillBtnData = new SkillBtnData();
            Transform    joystick     = go.transform.Find("Joystick");
            if (joystick != null)
            {
                skillBtnData.joystick = joystick.transform;
            }
            Transform joystickBG = go.transform.Find("Joystick_BG");
            if (joystickBG != null)
            {
                skillBtnData.joystickBG = joystickBG.gameObject;
            }
            skillBtnData.btnImage  = go.GetComponent <Image>();
            skillBtnData.maxRadius = 64.0f;
            skillBtnData.opType    = (SkillPreOpType)skillList.skillPreOpType;
            skillBtnData.opData1   = skillList.skillPreOpData1;
            skillBtnData.opData2   = skillList.skillPreOpData2;
            skillBtnData.skillID   = skillID;
            skillDatas.Add(go, skillBtnData);

            listener.onDrag        += OnSkillBtnDrag;
            listener.onPointerDown += OnSkillBtnPress;
            listener.onPointerUp   += OnSkillBtnRelease;
        }
    }
示例#2
0
    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);
    }
示例#3
0
    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);
        }
    }
示例#4
0
    public static SkillResult UseSkill(SkillHandle handle)
    {
        if (handle.caster == null || handle.caster.IsCannotFlag(CannotFlag.CannotSkill))
        {
            return(SkillResult.InvalidCaster);
        }
        Skill lastSkill = handle.caster.GetSkill();

        if (lastSkill != null)
        {
            SkillStage stage = lastSkill.mCurStage;
            if (stage != null)
            {
                if (SkillStage.IsStageTrait(SkillStageTrait.WaitBreakStage, stage.mStageInfo))
                {
                    if (stage.mStageEnd == null)
                    {
                        WaitBreakStage onStageEnd = new WaitBreakStage();
                        onStageEnd.nextSkillHandle = handle;
                        stage.SetBreak(SkillBreakType.OtherSkill, false, onStageEnd.OnStageEnd);
                    }

                    return(SkillResult.CannotBreak);
                }
                if (!SkillStage.IsStageTrait(SkillStageTrait.BreakSelf, stage.mStageInfo) &&
                    lastSkill.SkillID == handle.skillID)
                {
                    return(SkillResult.CannotBreak);
                }
                if (!SkillStage.IsStageTrait(SkillStageTrait.SkillBreak, stage.mStageInfo))
                {
                    return(SkillResult.CannotBreak);
                }
            }
        }

        excel_skill_list skillExcel = excel_skill_list.Find(handle.skillID);

        if (skillExcel == null)
        {
            return(SkillResult.ExcelNotExist);
        }
        Character target = handle.caster.mScene.FindCharacter(handle.skillTargetID);

        SkillTargetType targetType = (SkillTargetType)skillExcel.targetType;

        if (targetType != SkillTargetType.All)
        {
            if (target == null)
            {
                return(SkillResult.InvalidTarget);
            }
            if (targetType == SkillTargetType.Enemy && !CampSystem.IsEnemy(handle.caster, target))
            {
                return(SkillResult.InvalidTarget);
            }
            if (targetType == SkillTargetType.Friend && !CampSystem.IsFriend(handle.caster, target))
            {
                return(SkillResult.InvalidTarget);
            }
        }
        if (target == null && skillExcel.maxDistance > 0.0f)
        {
            return(SkillResult.InvalidTarget);
        }

        SkillContext context = new SkillContext();

        context.mSkillID      = handle.skillID;
        context.mOwner        = handle.caster;
        context.SkillTargetID = handle.skillTargetID;
        if (!handle.autoTargetPos)
        {
            context.TargetPos = handle.targetPos;
        }
        else
        {
            context.TargetPos = target == null ? Vector3.zero : target.Position;
        }
        Skill skill = new Skill(handle.skillID, context);

        handle.caster.SetSkill(skill);
        skill.mSkillEnd = handle.skillEndMethod;

        ReqSkill notifyMsg = new ReqSkill();

        notifyMsg.skillID       = handle.skillID;
        notifyMsg.casterID      = handle.caster.gid;
        notifyMsg.targetID      = handle.skillTargetID;
        notifyMsg.autoTargetPos = handle.autoTargetPos;
        notifyMsg.targetPos     = Vector3Packat.FromVector3(handle.targetPos);
        notifyMsg.position      = Vector3Packat.FromVector3(handle.caster.Position);
        notifyMsg.direction     = Vector3Packat.FromVector3(handle.caster.Direction);

        for (int i = 0; i < handle.caster.mScene.GetPlayerCount(); ++i)
        {
            Player player = handle.caster.mScene.GetPlayerByIndex(i);
            NetWork.NotifyMessage(player.UserID, STC.STC_SkillNotify, notifyMsg);
        }

        return(SkillResult.Success);
    }