コード例 #1
0
ファイル: SkillMgr.cs プロジェクト: wangzeping1998/-
    //技能计时、判断和伤害
    public void AttackDamage(EntityBase entity, int skillId)
    {
        SkillCfg   skillData      = resSvc.GetSkillCfg(skillId);
        List <int> skillActionLst = skillData.skillActionLst;

        long timeSum = 0;

        //计算多段伤害
        for (int i = 0; i < skillActionLst.Count; i++)
        {
            SkillActionCfg sac   = resSvc.GetSkillActionCfg(skillActionLst[i]);
            int            index = i;
            timeSum += sac.delayTime;
            if (sac.delayTime > 0)
            {
                //有延迟
                int taskId = timerSvc.AddTimeTask((id) =>
                {
                    AttackAction(entity, skillData, index);
                    entity.RemoveActionTask(id);
                }, timeSum /*延迟时间*/);
                entity.AddActionTask(taskId);
            }
            else
            {
                //无延迟
                AttackAction(entity, skillData, index);
            }
        }
    }
コード例 #2
0
ファイル: SkillMgr.cs プロジェクト: yoyo-sincerely/DarkGod
    /// <summary>
    /// 技能伤害数值
    /// </summary>
    public void AttackDamage(EntityBase entity, int skillID)
    {
        SkillCfg   skillData = resSvc.GetSkillCfg(skillID);
        List <int> actonLst  = skillData.skillActionLst;
        int        sum       = 0; // 总伤害

        for (int i = 0; i < actonLst.Count; i++)
        {
            SkillActionCfg skillAction = resSvc.GetSkillActionCfg(actonLst[i]);
            sum += skillAction.delayTime;
            int index = i;
            if (sum > 0)
            {
                int actID = timeSvc.AddTimeTask((int tid) => {
                    if (entity != null)
                    {
                        SkillAction(entity, skillData, index);
                        entity.RmvActionCB(tid); // 移除技能伤害的回调 ID
                    }
                }, sum);
                // 添加技能伤害的回调 ID
                entity.skActionCBLst.Add(actID);
            }
            else   // 瞬时技能,不需要延迟
            {
                SkillAction(entity, skillData, index);
            }
        }
    }
コード例 #3
0
    //技能伤害
    public void AttackDamage(EntityBase entity, int skillID, Vector3 blackAirPos)
    {
        SkillCfg   skillData  = resSvc.GetSkillCfgData(skillID);
        List <int> actionList = skillData.skillActionList;

        int sum = 0;

        for (int i = 0; i < actionList.Count; i++)
        {
            SkillActionCfg skillAction = resSvc.GetSkillActionData(actionList[i]);
            sum += skillAction.delayTime;
            int index = i;
            if (sum > 0)//延迟伤害,比如火圈范围持续伤害
            {
                int attackid = timeSvc.AddTimeTask((int tid) =>
                {
                    if (entity != null) //多个攻击同时打过来,已经死亡就会报空
                    {
                        SkillAction(entity, skillData, index, blackAirPos);
                        entity.RemoveActionCallBake(tid);
                    }
                    if (skillData.ID == 302)//黑气技能,无限循环存在
                    {
                        LoopSkill(entity, skillData, index, sum, blackAirPos);
                    }
                }, sum * 1.0f / 1000);
                entity.skillActionCallBackList.Add(attackid);
            }
            else//瞬间伤害
            {
                SkillAction(entity, skillData, index, Vector3.zero);
            }
        }
    }
コード例 #4
0
    public virtual void AttackDamage(EntityBase entity, int skillID)
    {
        SkillCfg skillData      = resSvc.GetSkillCfg(skillID);
        var      skillActionLst = skillData.skillActionLst;

        int sum = 0;

        for (int i = 0; i < skillActionLst.Count; i++)
        {
            SkillActionCfg skillActionCfg = resSvc.GetSkillActionCfg(skillActionLst[i]);
            sum += skillActionCfg.delayTime;
            int index = i;
            if (sum > 0)
            {
                int actid = timerSvc.AddTimeTask((int tid) =>
                {
                    if (entity != null)
                    {
                        SkillAction(entity, skillData, index);
                        entity.RemoveActionCB(tid);
                    }
                }, sum);
                entity.skActCBLst.Add(actid);
            }
            else
            {
                //瞬时技能
                SkillAction(entity, skillData, index);
            }
        }
    }
コード例 #5
0
    public void SkillAction(EntityBase caster, SkillCfg skillCfg, int index)
    {
        SkillActionCfg skillActionData = resSvc.GetSkillActionCfg(skillCfg.skillActionList[index]);
        int            damage          = skillCfg.skillDamageList[index];

        if (caster.entityType == EntityType.Player)
        {
            //获取场景中所有怪物实体
            List <EntityMonster> monsterList = caster.battleMgr.GetEntityMonster();

            for (int i = 0; i < monsterList.Count; i++)
            {
                EntityMonster target = monsterList[i];
                //判断距离和角度,对满足条件的怪物进行伤害运算
                if (InRange(caster.GetPos(), target.GetPos(), skillActionData.radius) && InAngle(caster.GetTrans(), target.GetPos(), skillActionData.angle))
                {
                    CalcDamage(caster, target, skillCfg, damage);
                }
            }
        }
        else if (caster.entityType == EntityType.Monster)
        {
            EntityPlayer entityPlayer = caster.battleMgr.GetEntityPlayer();
            if (entityPlayer == null)
            {
                return;
            }
            if (InRange(caster.GetPos(), entityPlayer.GetPos(), skillActionData.radius) && InAngle(caster.GetTrans(), entityPlayer.GetPos(), skillActionData.angle))
            {
                CalcDamage(caster, entityPlayer, skillCfg, damage);
            }
        }
    }
コード例 #6
0
    /// <summary>
    /// 技能伤害
    /// </summary>
    /// <param name="entity">施放者(主角)</param>
    /// <param name="skillID">节能功能ID</param>
    public void AttackDamage(EntityBase entity, int skillID)
    {
        SkillCfg   skillData = GameEntry.Res.GetSkillCfg(skillID);
        List <int> actonLst  = skillData.skillActionLst;
        int        sum       = 0;

        for (int i = 0; i < actonLst.Count; i++)
        {
            SkillActionCfg skillAction = GameEntry.Res.GetSkillActionCfg(actonLst[i]);
            sum += skillAction.delayTime;
            int index = i;
            if (sum > 0)
            {
                int actid = GameEntry.Timer.AddTimeTask((int tid) => {
                    if (entity != null)
                    {
                        SkillAction(entity, skillData, index);
                        entity.RmvActionCB(tid);
                    }
                }, sum);
                entity.SkActionCBLst.Add(actid);
            }
            else
            {
                //瞬时技能
                SkillAction(entity, skillData, index);
            }
        }
    }
コード例 #7
0
    public void AttackDamage(EntityBase entity, int skillId)
    {
        entity._listSkillDamageCallback.Clear();
        entity._listSkillMoveCallback.Clear();

        SkillDataCfg skillData       = resSvc.GetSkillCfg(skillId);
        List <int>   listSkillAction = skillData.skillActionList;
        int          accumulate      = 0;

        for (int idx = 0; idx < listSkillAction.Count; idx++)
        {
            SkillActionCfg actionCfg = resSvc.GetSkillActionCfg(listSkillAction[idx]);
            accumulate += actionCfg.delayTime;
            int skillIdx = idx;
            if (accumulate > 0)
            {
                int actionId = -1;
                actionId = timeSvc.AddTimeTask((int tid) =>
                {
                    if (entity != null)
                    {
                        SelectDamageObj(entity, skillData, skillIdx);
                        entity.RemoveDamageCallbackID(actionId);
                    }
                }, accumulate);
                entity._listSkillDamageCallback.Add(actionId);
            }
            else
            {
                SelectDamageObj(entity, skillData, skillIdx);
            }
        }
    }
コード例 #8
0
    /// <summary>
    /// 计算技能伤害
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="skillID"></param>
    public void AttackDamage(EntityBase entity, int skillID)
    {
        SkillCfg   skillData  = resSvc.GetSkillCfg(skillID);
        List <int> actionList = skillData.skillActionList;

        int sumDelayTime = 0;

        for (int i = 0; i < actionList.Count; i++)
        {
            SkillActionCfg skillAction = resSvc.GetSkillActionCfg(actionList[i]);

            sumDelayTime += skillAction.delayTime;
            int index = i;
            if (sumDelayTime > 0)
            {
                int dmgID = timeSvc.AddTimeTask((int tid) =>
                {
                    SkillAction(entity, skillData, index);
                    entity.RemoveActionCB(tid);
                }, sumDelayTime);
                entity.skillActionCBList.Add(dmgID);
            }
            else
            {
                //瞬时技能
                SkillAction(entity, skillData, index);
            }
        }
    }
コード例 #9
0
    private void SelectDamageObj(EntityBase attacker, SkillDataCfg skillCfg, int skillIdx)
    {
        SkillActionCfg actionCfg = resSvc.GetSkillActionCfg(skillCfg.skillActionList[skillIdx]);
        int            damageVal = skillCfg.skillDamageList[skillIdx];

        if (attacker._entityType == Constants.EntityType.Monster)
        {
            EntityPlayer entityPlayer = attacker._battleMgr.GetEntityPlayer;
            if (entityPlayer == null)
            {
                return;
            }

            if (InRange(attacker.GetEntityPosition(), entityPlayer.GetEntityPosition(), actionCfg.radius) &&
                InAngle(attacker.GetEntityTransform(), entityPlayer.GetEntityPosition(), actionCfg.angle))
            {
                CalcDamage(attacker, entityPlayer, skillCfg, damageVal);
            }
        }
        else if (attacker._entityType == Constants.EntityType.Player)
        {
            //获取场景中所有的怪物
            List <EntityMonster> listMonster = attacker._battleMgr.GetAllEntityMonsters();
            for (int i = 0; i < listMonster.Count; i++)
            {
                EntityMonster monster = listMonster[i];
                //在攻击范围内
                if (InRange(attacker.GetEntityPosition(), monster.GetEntityPosition(), actionCfg.radius) &&
                    InAngle(attacker.GetEntityTransform(), monster.GetEntityPosition(), actionCfg.angle))
                {
                    CalcDamage(attacker, monster, skillCfg, damageVal);
                }
            }
        }
    }
コード例 #10
0
    /// <summary>
    /// 技能伤害计算
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="skillID"></param>
    public void AttackDamage(EntityBase entity, int skillID)
    {
        //Debug.Log(GetType()+ "/AttackDamage()/ " );

        SkillCfg   skillCfg  = resSvc.GetSkillCfg(skillID);
        List <int> actionLst = skillCfg.skillActionLst;
        int        sum       = 0;

        for (int i = 0; i < actionLst.Count; i++)
        {
            SkillActionCfg skillActionCfg = resSvc.GetSkillActionCfg(actionLst[i]);
            sum += skillActionCfg.delayTime;
            int index = i;
            if (sum > 0)
            {
                int actid = timerSvc.AddTimeTask((tid) =>
                {
                    if (entity != null)
                    {
                        SkillAction(entity, skillCfg, index);
                        entity.RmvActionCB(tid);
                    }
                }, sum);
                entity.skActionCBLst.Add(actid);
            }
            else
            {
                SkillAction(entity, skillCfg, index);
            }
        }
    }
コード例 #11
0
    private void SkillAction(EntityBase entity, SkillCfg skillCfg, SkillActionCfg act, int actIndex)
    {
        int damage = skillCfg.damageLst[actIndex];
        int type   = skillCfg.dmgType;

        if (entity.entityType == EntityType.Player) // 怪物攻击
        {
            EntityMonster[] monsters = entity.BattleMgr.GetEntityMonsters();
            for (int i = 0; i < monsters.Length; ++i)
            {
                EntityMonster monster = monsters[i];
                if (InRange(entity.GetPos(), monster.GetPos(), act.radius) &&
                    InAngle(entity.GetTransform(), monster.GetPos(), act.angle))
                {
                    CalcDamage(entity, monster, damage, type);
                }
            }
        }
        else if (entity.entityType == EntityType.Monster)
        {
            EntityBase player = entity.BattleMgr.entityPlayer;
            if (InRange(entity.GetPos(), player.GetPos(), act.radius) &&
                InAngle(entity.GetTransform(), player.GetPos(), act.angle))
            {
                CalcDamage(entity, player, damage, type);
            }
        }
    }
コード例 #12
0
    public SkillActionCfg GetSkillActionCfg(int id)
    {
        SkillActionCfg sac = null;

        skillActionDic.TryGetValue(id, out sac);

        return(sac);
    }
コード例 #13
0
ファイル: ResSvc.cs プロジェクト: wangzhenGitHup/U3D
    private void InitSkillActionCfgData(string xmlPath)
    {
        TextAsset xmlText = Resources.Load <TextAsset>(xmlPath);

        if (!xmlText)
        {
            CommonTools.Log("xml file: " + PathDefine.cPath_RandomNameCfg + "not exits!",
                            LogType.LogType_Error);
            return;
        }

        //开始解析xml文件
        XmlDocument doc = new XmlDocument();

        doc.LoadXml(xmlText.text);

        XmlNodeList nodeList = doc.SelectSingleNode("root").ChildNodes;

        for (int i = 0; i < nodeList.Count; i++)
        {
            XmlElement element = nodeList[i] as XmlElement;

            if (element.GetAttributeNode("ID") == null)
            {
                continue;
            }
            int id = Convert.ToInt32(element.GetAttributeNode("ID").InnerText);

            SkillActionCfg skillData = new SkillActionCfg
            {
                ID = id,
            };

            #region 遍历解析
            foreach (XmlElement elem in nodeList[i].ChildNodes)
            {
                switch (elem.Name)
                {
                case "delayTime":
                    skillData.delayTime = int.Parse(elem.InnerText);
                    break;

                case "radius":
                    skillData.radius = float.Parse(elem.InnerText);
                    break;

                case "angle":
                    skillData.angle = float.Parse(elem.InnerText);
                    break;
                }
            }
            #endregion

            dictSkillActionCfgData.Add(id, skillData);
        }
    }
コード例 #14
0
    public SkillActionCfg GetSkillActionCfg(int id)
    {
        SkillActionCfg skillActionCfg = null;

        if (skillActionCfgDicts.TryGetValue(id, out skillActionCfg))
        {
            return(skillActionCfg);
        }
        return(null);
    }
コード例 #15
0
ファイル: ResSev.cs プロジェクト: WhitePetal/ARPG
    public SkillActionCfg GetSkillActionCfg(int id)
    {
        SkillActionCfg cfg = null;

        if (skillActionCfgDic.TryGetValue(id, out cfg))
        {
            return(cfg);
        }
        NETCommon.Log("获取 SkillActionCfg 失败,ID:" + id);
        return(null);
    }
コード例 #16
0
ファイル: ResSvc.cs プロジェクト: wangzhenGitHup/U3D
    public SkillActionCfg GetSkillActionCfg(int id)
    {
        SkillActionCfg skillData = null;

        if (dictSkillActionCfgData.TryGetValue(id, out skillData))
        {
            return(skillData);
        }

        return(null);
    }
コード例 #17
0
    private void InitSkillActionCfg(string path)
    {
        TextAsset xml = Resources.Load <TextAsset>(path);

        if (xml == false)
        {
            Debug.LogError(GetType() + "/InitTaskRewardCfg()/xml file:" + path + " not exist");
        }
        else
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml.text);

            XmlNodeList nodLst = doc.SelectSingleNode("root").ChildNodes;

            for (int i = 0; i < nodLst.Count; i++)
            {
                XmlElement ele = nodLst[i] as XmlElement;

                if (ele.GetAttributeNode("ID") == null)
                {
                    continue;
                }

                int ID = Convert.ToInt32(ele.GetAttributeNode("ID").InnerText);

                SkillActionCfg sac = new SkillActionCfg
                {
                    ID = ID
                };

                foreach (XmlElement e in nodLst[i].ChildNodes)
                {
                    switch (e.Name)
                    {
                    case "delayTime":
                        sac.delayTime = int.Parse(e.InnerText);
                        break;

                    case "radius":
                        sac.radius = float.Parse(e.InnerText);
                        break;

                    case "angle":
                        sac.angle = float.Parse(e.InnerText);
                        break;
                    }
                }

                skillActionDic.Add(ID, sac);
            }
        }
    }
コード例 #18
0
ファイル: ResSvc.cs プロジェクト: IamnotblackCat/ArcherStory
    public SkillActionCfg GetSkillActionData(int id)
    {
        SkillActionCfg agc = null;

        //Debug.Log(id);
        if (skillActionDic.TryGetValue(id, out agc))
        {
            //Debug.Log(data);
            return(agc);
        }
        return(null);
    }
コード例 #19
0
ファイル: ResSvc.cs プロジェクト: IamnotblackCat/ArcherStory
    private void InitSkillAction(string path)
    {
        //TextAsset xml = Resources.Load<TextAsset>(path);
        string streamingXML = Application.streamingAssetsPath + path;
        //if (!xml)
        //{
        //    Debug.Log("指定文件不存在,路径:" + path);
        //}
        //else
        //{
        XmlDocument doc = new XmlDocument();

        //doc.LoadXml(xml.text);
        doc.Load(streamingXML);
        //选中子节点集合
        XmlNodeList nodList = doc.SelectSingleNode("root").ChildNodes;

        for (int i = 0; i < nodList.Count; i++)
        {
            XmlElement ele = nodList[i] as XmlElement;
            if (ele.GetAttributeNode("ID") == null)
            {    //不包含ID的节点,直接跳到下一个遍历,安全校验
                continue;
            }
            int            ID = Convert.ToInt32(ele.GetAttributeNode("ID").InnerText);
            SkillActionCfg skillActionData = new SkillActionCfg
            {
                ID = ID,
            };

            foreach (XmlElement element in nodList[i].ChildNodes)
            {
                switch (element.Name)
                {
                case "delayTime":
                    skillActionData.delayTime = int.Parse(element.InnerText);
                    break;

                case "radius":
                    skillActionData.radius = float.Parse(element.InnerText);
                    break;

                case "angle":
                    skillActionData.angle = float.Parse(element.InnerText);
                    break;
                }
            }
            skillActionDic.Add(ID, skillActionData);
            //Debug.Log("ID:"+ID+"  mapCfg:"+mapCfg.ToString());
        }
        //}
    }
コード例 #20
0
    private void InitSkillActionCfg(string assetName, object asset, float duration, object userData)
    {
        TextAsset xml = asset as TextAsset;

        if (!xml)
        {
            PECommon.Log("xml file:" + assetName + " not exist", LogType.Error);
        }
        else
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml.text);

            XmlNodeList nodLst = doc.SelectSingleNode("root").ChildNodes;

            for (int i = 0; i < nodLst.Count; i++)
            {
                XmlElement ele = nodLst[i] as XmlElement;

                if (ele.GetAttributeNode("ID") == null)
                {
                    continue;
                }
                int            ID  = Convert.ToInt32(ele.GetAttributeNode("ID").InnerText);
                SkillActionCfg sac = new SkillActionCfg {
                    ID = ID
                };

                foreach (XmlElement e in nodLst[i].ChildNodes)
                {
                    switch (e.Name)
                    {
                    case "delayTime":
                        sac.delayTime = int.Parse(e.InnerText);
                        break;

                    case "radius":
                        sac.radius = float.Parse(e.InnerText);
                        break;

                    case "angle":
                        sac.angle = int.Parse(e.InnerText);
                        break;
                    }
                }
                skillActionDic.Add(ID, sac);
            }
        }
        GameEntry.Resource.UnloadAsset(asset);
    }
コード例 #21
0
    private void SkillAction(EntityBase caster, SkillCfg skillCfg, int index)
    {
        //Debug.Log(GetType() + "/SkillAction()/ ");

        SkillActionCfg skillActionCfg = resSvc.GetSkillActionCfg(skillCfg.skillActionLst[index]);

        int damage = skillCfg.skillDamageLst[index];

        // 判断是怪物还是玩家攻击,避免怪物打怪物
        if (caster.entityType == EntityType.Monster)
        {
            EntityPlayer player = caster.battleMgr.entityPlayer;
            if (player == null)
            {
                return;
            }
            // 判断距离和角度
            if (InRange(caster.GetPos(), player.GetPos(), skillActionCfg.radius) == true &&
                InAngle(caster.GetTrans(), player.GetPos(), skillActionCfg.angle) == true
                )
            {
                // 计算伤害
                CalcDamage(caster, player, skillCfg, damage);
            }
            Debug.Log(GetType() + "/SkillAction()/ ...");
        }
        else if (caster.entityType == EntityType.Player)
        {
            // 获取场景中所有的怪物尸体,遍历运算伤害
            List <EntityMonster> monsterLst = caster.battleMgr.GetEntityMonsters();
            for (int i = 0; i < monsterLst.Count; i++)
            {
                EntityMonster monster = monsterLst[i];

                // 判断距离和角度
                if (InRange(caster.GetPos(), monster.GetPos(), skillActionCfg.radius) == true &&
                    InAngle(caster.GetTrans(), monster.GetPos(), skillActionCfg.angle) == true
                    )
                {
                    // 计算伤害
                    CalcDamage(caster, monster, skillCfg, damage);
                }
                Debug.Log(GetType() + "/SkillAction()/ ...");
            }
        }


        //Debug.Log(GetType() + "/SkillAction()/ End");
    }
コード例 #22
0
    private void InitSkillActionCfg(string path)
    {
        skillActionDic.Clear();
        XmlNodeList nodList = null;

        if (TryGetRootNodeList(path, out nodList))
        {
            for (int i = 0; i < nodList.Count; i++)
            {
                XmlElement ele = nodList[i] as XmlElement;

                if (ele.GetAttributeNode("ID") == null)
                {
                    continue;
                }
                int ID = Convert.ToInt32(ele.GetAttributeNode("ID").InnerText);

                SkillActionCfg sac = new SkillActionCfg()
                {
                    ID = ID
                };

                foreach (XmlElement e in nodList[i].ChildNodes)
                {
                    switch (e.Name)
                    {
                    case "delayTime":
                        sac.delayTime = int.Parse(e.InnerText);
                        break;

                    case "radius":
                        sac.radius = float.Parse(e.InnerText);
                        break;

                    case "angle":
                        sac.angle = int.Parse(e.InnerText);
                        break;
                    }
                }
                skillActionDic.Add(ID, sac);
            }
        }
    }
コード例 #23
0
    private void AttackDamage(EntityBase entity, int skillId)
    {
        SkillCfg   cfg      = resSev.GetSkillCfg(skillId);
        List <int> actions  = cfg.skillAction;
        int        tempTime = 0;

        for (int i = 0; i < actions.Count; ++i)
        {
            int            j      = i;
            SkillActionCfg act    = resSev.GetSkillActionCfg(actions[j]);
            IDPack         iDPack = timerSev.AddTimerTask((tid) =>
            {
                SkillAction(entity, cfg, act, j);
                entity.sklActCBSet.Remove(tid);
            }, tempTime + act.delayTime);
            entity.sklActCBSet.Add(iDPack.id);

            tempTime += act.delayTime;
        }
    }
コード例 #24
0
    public void InitSkilActionCfgs(string path)
    {
        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.Load(path);

        XmlNode     root     = xmlDoc.SelectSingleNode("root");
        XmlNodeList nodeList = root.ChildNodes;

        foreach (XmlNode node in nodeList)
        {
            int            ID             = int.Parse(node.Attributes["ID"].Value);
            SkillActionCfg skillActionCfg = new SkillActionCfg
            {
                ID = ID,
            };
            XmlNodeList fieldNodeList = node.ChildNodes;
            foreach (XmlNode fieldNode in fieldNodeList)
            {
                switch (fieldNode.Name)
                {
                case "delayTime":
                    skillActionCfg.delayTime = int.Parse(fieldNode.InnerText);
                    break;

                case "radius":
                    skillActionCfg.radius = float.Parse(fieldNode.InnerText);
                    break;

                case "angle":
                    skillActionCfg.angle = int.Parse(fieldNode.InnerText);
                    break;
                }
            }
            if (!skillActionCfgDicts.ContainsKey(ID))
            {
                skillActionCfgDicts.Add(ID, skillActionCfg);
            }
        }
    }
コード例 #25
0
ファイル: SkillMgr.cs プロジェクト: yoyo-sincerely/DarkGod
    /// <summary>
    /// 技能伤害计算
    /// </summary>
    public void SkillAction(EntityBase caster, SkillCfg skillCfg, int index)
    {
        SkillActionCfg skillActionCfg = resSvc.GetSkillActionCfg(skillCfg.skillActionLst[index]);
        int            damage         = skillCfg.skillDamageLst[index];

        // 怪物攻击,目标是玩家
        if (caster.entityType == EntityType.Monster)
        {
            EntityPlayer target = caster.battleMgr.entitySelfPlayer;
            if (target == null)
            {
                return;
            }
            //判断距离,判断角度
            if (InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius) &&
                InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
            {
                CalcDamage(caster, target, skillCfg, damage);
            }
        }
        // 玩家攻击,目标是怪物
        else if (caster.entityType == EntityType.Player)
        {
            // 获取场景里所有的怪物实体,遍历运算,怪物很多的游戏 如 MMO 就不能这样运算
            List <EntityMonster> monsterLst = caster.battleMgr.GetEntityMonsters();
            for (int i = 0; i < monsterLst.Count; i++)
            {
                EntityMonster target = monsterLst[i];
                // 判断距离,判断角度
                if (InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius) &&
                    InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
                {
                    // 计算伤害
                    CalcDamage(caster, target, skillCfg, damage);
                }
            }
        }
    }
コード例 #26
0
    public void SkillAction(EntityBase caster, SkillCfg skillCfg, int index)
    {
        SkillActionCfg skillActionCfg = resSvc.GetSkillActionCfg(skillCfg.skillActionLst[index]);

        int damage = skillCfg.skillDamageLst[index];

        if (caster.entityType == EntityType.Monster)
        {
            EntityPlayer targetEntity = caster.battleMgr.entitySelfPlayer;
            if (targetEntity == null)
            {
                return;
            }
            //判断距离,判断角度
            if (InRange(caster.GetPos(), targetEntity.GetPos(), skillActionCfg.radius) &&
                InAngle(caster.GetTrans(), targetEntity.GetPos(), skillActionCfg.angle))
            {
                //计算伤害TODO
                CalcDamage(caster, targetEntity, skillCfg, damage);
            }
        }
        else if (caster.entityType == EntityType.Player)
        {
            //获取场景里怪物实体,遍历运算
            List <EntityMonster> monsterLst = caster.battleMgr.GetEntityMonster();
            for (int i = 0; i < monsterLst.Count; i++)
            {
                EntityMonster targetEntity = monsterLst[i];
                //判断距离,判断角度
                if (InRange(caster.GetPos(), targetEntity.GetPos(), skillActionCfg.radius) &&
                    InAngle(caster.GetTrans(), targetEntity.GetPos(), skillActionCfg.angle))
                {
                    //计算伤害TODO
                    CalcDamage(caster, targetEntity, skillCfg, damage);
                }
            }
        }
    }
コード例 #27
0
ファイル: ResSev.cs プロジェクト: WhitePetal/ARPG
    private void InitSkillActionCfg()
    {
        string      xml = DeSerializeXML(PathDefine.SkillActionCfg);
        XmlDocument doc = new XmlDocument();

        doc.LoadXml(xml);
        XmlNode root = doc.SelectSingleNode("root");

        foreach (XmlElement item in root.ChildNodes)
        {
            if (item.GetAttributeNode("ID") == null)
            {
                continue;
            }
            int            id  = int.Parse(item.GetAttributeNode("ID").InnerText);
            SkillActionCfg cfg = new SkillActionCfg();
            cfg.ID = id;
            foreach (XmlElement ele in item.ChildNodes)
            {
                string value = ele.InnerText;
                switch (ele.Name)
                {
                case "delayTime":
                    cfg.delayTime = int.Parse(value);
                    break;

                case "radius":
                    cfg.radius = float.Parse(value);
                    break;

                case "angle":
                    cfg.angle = int.Parse(value);
                    break;
                }
            }
            skillActionCfgDic.Add(id, cfg);
        }
    }
コード例 #28
0
ファイル: SkillMgr.cs プロジェクト: wangzeping1998/-
    //判定
    public void AttackAction(EntityBase entity, SkillCfg skillCfg, int index)
    {
        SkillActionCfg sac = resSvc.GetSkillActionCfg(skillCfg.skillActionLst[index]);

        if (entity.enitityType == EnitityType.Player)
        {
            List <EntityMonster> monsterLst = entity.battleMgr.GetMonsters();
            int damage = skillCfg.skillDamageLst[index];
            //对列表所有怪物进行判断
            for (int i = 0; i < monsterLst.Count; i++)
            {
                //判断距离Range
                if (IsInRange(entity, monsterLst[i], sac.radius))
                {
                    //判断角度Angle
                    if (IsInAngle(entity, monsterLst[i], sac.angle))
                    {
                        CalcDamge(entity, monsterLst[i], skillCfg, damage);
                    }
                }
            }
        }
        else if (entity.enitityType == EnitityType.Monster)
        {
            EntityPlayer enitityPlayer = entity.battleMgr.GetEnitityPlayer();
            int          damage        = skillCfg.skillDamageLst[index];
            //判断距离Range
            if (IsInRange(entity, enitityPlayer, sac.radius))
            {
                //判断角度Angle
                if (IsInAngle(entity, enitityPlayer, sac.angle))
                {
                    CalcDamge(entity, enitityPlayer, skillCfg, damage);
                }
            }
        }
    }
コード例 #29
0
    /// <summary>
    /// 瞬时技能
    /// </summary>
    /// <param name="caster"></param>
    /// <param name="skillCfg"></param>
    /// <param name="index"></param>
    public void SkillAction(EntityBase caster, SkillCfg skillCfg, int index)
    {
        SkillActionCfg skillActionCfg = GameEntry.Res.GetSkillActionCfg(skillCfg.skillActionLst[index]);

        int damage = skillCfg.skillDamageLst[index];

        if (caster.entityType == EntityType.Monster)
        {
            EntityPlayer target = caster.BattleMgr.EntitySelfPlayer;
            if (target == null)
            {
                return;
            }
            //判断距离,判断角度
            if (InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius) &&
                InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
            {
                CalcDamage(caster, target, skillCfg, damage);
            }
        }
        else if (caster.entityType == EntityType.Player)
        {
            //获取场景里所有的怪物实体,遍历运算
            List <EntityMonster> monsterLst = caster.BattleMgr.GetEntityMonsters();
            for (int i = 0; i < monsterLst.Count; i++)
            {
                EntityMonster em = monsterLst[i];
                //判断距离,判断角度
                if (InRange(caster.GetPos(), em.GetPos(), skillActionCfg.radius) &&
                    InAngle(caster.GetTrans(), em.GetPos(), skillActionCfg.angle))
                {
                    CalcDamage(caster, em, skillCfg, damage);
                }
            }
        }
    }
コード例 #30
0
    public void SkillAction(EntityBase caster, SkillCfg skillCfg, int index, Vector3 blackAirPos)
    {
        SkillActionCfg skillActionCfg = resSvc.GetSkillActionData(skillCfg.skillActionList[index]);

        int damage = skillCfg.skillDamageList[index];

        if (caster.entityType == EntityType.Player)
        {
            //拿到场景中的怪物实体,遍历运算
            List <EntityMonster> monsterList = caster.battleMg.GetEntityMonsters();

            for (int i = 0; i < monsterList.Count; i++)
            {
                EntityMonster target = monsterList[i];
                if (target == null)
                {
                    return;
                }
                //判断距离,角度
                //如果是范围技能,施法者位置变更为鼠标指定区域位置,角度固定为360度
                if (skillCfg.dmgType == DamageType.AreaSkill)
                {
                    if (InRange(BattleSys.Instance.playerCtrlWnd.pos, target.GetPos(), skillActionCfg.radius))
                    {
                        CalcDamage(caster, target, skillCfg, damage);
                    }
                }
                else
                {
                    if (InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius) && InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
                    {
                        //计算伤害
                        CalcDamage(caster, target, skillCfg, damage);
                    }
                    else if (!InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius))
                    {
                        GameRoot.instance.AddTips("超出攻击范围");
                    }
                }
            }
        }
        else if (caster.entityType == EntityType.Monster)//如果是怪物只能攻击玩家
        {
            EntityPlayer target = caster.battleMg.entitySelfPlayer;

            //判断距离角度
            //范围技能(黑气)则施法者位置变更为玩家当前所处位置,提前取得
            if (skillCfg.dmgType == DamageType.AreaSkill)
            {
                if (blackAirPos == null || target == null)
                {
                    return;
                }
                if (InRange(blackAirPos, target.GetPos(), skillActionCfg.radius) && InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
                {
                    CalcDamage(caster, target, skillCfg, damage);
                }
            }
            else
            {
                if (InRange(caster.GetPos(), target.GetPos(), skillActionCfg.radius) && InAngle(caster.GetTrans(), target.GetPos(), skillActionCfg.angle))
                {
                    CalcDamage(caster, target, skillCfg, damage);
                }
            }
        }
    }