Exemple #1
0
        void damage(NetFrame.UserToken token, DamageDTO value)
        {
            int           userID = getUserID(token);
            AbsFightModel atkModel;
            int           skillLevel = 0;

            //判断攻击者
            if (value.userId >= 0)
            {
                if (value.userId != userID)
                {
                    return;
                }
                atkModel = getPlayer(userID);
                if (value.skill > 0)
                {
                    skillLevel = (atkModel as FightPlayerModel).SkillLevel(value.skill);
                    if (skillLevel == -1)
                    {
                        return;
                    }
                }
            }
            else
            {
                atkModel = getPlayer(userID);
            }
            //TODO
            //获取技能算法
            //循环获取目标数据 和攻击者数据 进行伤害计算 得出伤害数值
            if (!SkillProcessMap.has(value.skill))
            {
                return;
            }
            ISkill       skill   = SkillProcessMap.get(value.skill);
            List <int[]> damages = new List <int[]>();

            foreach (int[] item in value.target)
            {
                AbsFightModel target = getPlayer(item[0]);
                skill.damage(skillLevel, ref atkModel, ref target, ref damages);
                //Console.WriteLine("计算伤害值");
                if (target.hp == 0)
                {
                    switch (target.type)
                    {
                    case ModelType.HUMAN:
                        if (target.id > 0)
                        {
                            //击杀英雄
                            //启动定时任务 指定时间之后发送英雄复活信息 并且将英雄数据设置为满状态
                        }
                        else
                        {
                            //击杀小兵
                            //移除小兵数据
                        }
                        break;

                    case ModelType.BUILD:
                        //打破了建筑 给钱
                        break;
                    }
                }
            }
            value.target = damages.ToArray();
            brocast(FightProtocol.DAMAGE_BRO, value);
        }
Exemple #2
0
        private void damage(UserToken token, DamageDTO value)
        {
            AbsFightModel  atkPlayer  = null;
            int            userId     = getUserId(token);
            int            skillLevel = 0;
            int            atkTeam    = 0;
            FightModelType atkType;

            if (value.id > 0)
            {
                if (value.id != userId)
                {
                    return;
                }
                atkPlayer = getPlayer(userId);
                if (value.skill > 0)
                {
                    skillLevel = (atkPlayer as FightPlayerModel).skillLevel(value.skill);
                    if (skillLevel == -1)
                    {
                        return;
                    }
                }
                atkTeam = getPlayerTeam(userId);
                atkType = FightModelType.HUMAN;
            }
            else
            {
                //TODO 如果ID小于0的话 则为炮塔或者小兵 需要判断目标是否为用户
                if (value.id >= -20)
                {
                    atkType = FightModelType.BUILD;
                }
                else
                {
                    atkType = FightModelType.HUMAN;
                }
            }

            if (!SkillProcessMap.has(value.skill))
            {
                return;
            }



            ISkill       skill   = SkillProcessMap.get(value.skill);
            List <int[]> damages = new List <int[]>();

            foreach (int[] item in value.targetDamage)
            {
                AbsFightModel  beatk  = null;
                int            beTeam = 0;
                FightModelType beatkType;
                if (item[0] > 0)
                {
                    beatk     = getPlayer(item[0]);
                    beTeam    = getPlayerTeam(item[0]);
                    beatkType = FightModelType.HUMAN;
                }
                else
                {
                    if (item[0] >= -20)
                    {
                        if (item[0] >= -10)
                        {
                            beatk  = teamOneBuildMap[item[0]];
                            beTeam = 1;
                        }
                        else
                        {
                            beatk  = teamTwoBuildMap[item[0]];
                            beTeam = 2;
                        }
                        beatkType = FightModelType.BUILD;
                    }
                    else
                    {
                        //TODO这里是小兵了

                        beatkType = FightModelType.HUMAN;
                    }
                }
                skill.damage(skillLevel, ref atkPlayer, ref beatk, atkType, beatkType, atkTeam == beTeam, ref damages);
                if (beatk.hp == 0)
                {
                    if (beatk.id > 0)
                    {
                        //说明是英雄 给予击杀者奖金
                    }
                    else if (beatk.id < -20)
                    {
                        //说明是小兵 给予周围辅助 辅助金
                    }
                    else
                    {
                        //说明是炮台 判断是否拥有复活能力 给予全体奖金
                    }
                }
            }
            DamageDTO dto = new DamageDTO();

            dto.id           = value.id;
            dto.skill        = value.skill;
            dto.targetDamage = damages.ToArray();
            brocast(FightProtocol.DAMAGE_BRO, dto);
        }