Exemplo n.º 1
0
 /// <summary>
 /// 添加Buffer(不同的发送者可叠加)
 /// </summary>
 /// <param name="buffer"></param>
 /// <param name="sender"></param>
 /// <returns></returns>
 public bool AddBuffer(SkillBuffer buffer, string sender)
 {
     int index = FindIndexBuffer(buffer.ID, sender);
     if (index < 0)
     {
         m_buffers.Add(buffer);
         return true;
     }
     else
     {
         if (buffer > m_buffers[index])
         {
             m_buffers[index] = buffer;
             return true;
         }
         else
         {
             return false;
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 免死的技能(修身)
        /// </summary>
        /// <param name="fighter"></param>
        /// <param name="level"></param>
        /// <param name="gc"></param>
        private bool SkillNoDeath(FightObject fighter, int level, GameConfig gc)
        {
            TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType");
            AttackParameter par = new AttackParameter(gc, level);
            var targets = FriendTargets(fighter, targetType, par);

            if (targets.Count == 0) return false;
            var config = par.LevelConfig;
            if (config == null) return false;
            double a = config.GetDoubleOrDefault("A");
            int r = config.GetIntOrDefault("Round");
            if (r <= 0) return false;
            List<ActionResult> results = new List<ActionResult>();
            foreach (var target in targets)
            {
                ActionResult result = new ActionResult(target.ID);
                SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, r, gc.Value, a);
                target.AddBuffer(buf);
                result.ActionFlag |= ActionFlag.AddBuff;
                result.Value["AddBuffer"] = buf;
                results.Add(result);
            }
            fighter.Action.Result = results;
            fighter.Action.FightCount = FightAction.HasAction;
            m_actions.Add(fighter.Action);
            return true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加攻击次数(蓄力)
        /// </summary>
        /// <param name="fighter"></param>
        /// <param name="level"></param>
        /// <param name="gc"></param>
        private bool SkillXuli(FightObject fighter, int level, GameConfig gc)
        {
            var config = gc.Value.GetVariantOrDefault(level.ToString());
            if (config == null) return false;
            int r = config.GetIntOrDefault("Round");

            SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, r + 1, gc.Value);
            fighter.AddBuffer(buf);
            fighter.Action.Value = new Variant();

            ActionResult result = new ActionResult(fighter.ID);
            result.ActionFlag |= ActionFlag.AddBuff;
            result.Value["AddBuffer"] = buf;

            fighter.Action.Result = new List<ActionResult>() { result };
            fighter.Action.FightCount = FightAction.HasAction;
            m_actions.Add(fighter.Action);
            return true;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 增强防御的技能
        /// 石壁/神龙(主动)
        /// </summary>
        /// <param name="fighter"></param>
        /// <param name="level"></param>
        /// <param name="gc"></param>
        private bool SkillIncreaseDefense(FightObject fighter, int level, GameConfig gc)
        {
            TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType");
            AttackParameter par = new AttackParameter(gc, level);
            var targets = FriendTargets(fighter, targetType, par);

            if (targets.Count == 0) return false;
            var config = par.LevelConfig;
            if (config == null) return false;
            double a = config.GetDoubleOrDefault("A");
            double b = config.GetDoubleOrDefault("B");
            if (a == 0 && b == 0) return false;
            int r = config.GetIntOrDefault("Round");
            if (r <= 0) return false;

            double c;
            if (gc.Name == BufferType.ShiBi)
            {
                c = a + ((fighter.Life.TiZhi / 50) * b);
            }
            else
            {
                c = a + ((fighter.Life.JingShen / 50) * b);
            }
            if (c <= 0) return false;

            List<ActionResult> results = new List<ActionResult>();
            foreach (var target in targets)
            {
                //添加Buffer
                ActionResult result = new ActionResult(target.ID);
                SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, r, gc.Value, c);
                target.AddBuffer(buf);
                result.ActionFlag |= ActionFlag.AddBuff;
                result.Value["AddBuffer"] = buf;
                results.Add(result);
            }
            fighter.Action.Result = results;
            fighter.Action.FightCount = FightAction.HasAction;
            m_actions.Add(fighter.Action);
            return true;
        }
Exemplo n.º 5
0
        ///// <summary>
        ///// 自身产生Buffer(开刃/沼气/焚烧)
        ///// </summary>
        ///// <param name="fighter"></param>
        ///// <param name="level"></param>
        ///// <param name="gc"></param>
        //private bool SkillAddBuffer(FightObject fighter, int level, GameConfig gc)
        //{
        //    SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, Byte.MaxValue, gc.Value);
        //    fighter.AddBuffer(buf);
        //    fighter.Action.Value = new Variant();
        //    ActionResult result = new ActionResult(fighter.ID);
        //    result.ActionFlag |= ActionFlag.AddBuff;
        //    result.Value["AddBuffer"] = buf;
        //    fighter.Action.Result = new List<ActionResult>() { result };
        //    fighter.Action.FightCount = FightAction.HasAction;
        //    m_actions.Add(fighter.Action);
        //    return true;
        //}
        /// <summary>
        /// 治疗的技能
        /// 回春/母育/祭祀/神谕
        /// </summary>
        /// <param name="fighter"></param>
        /// <param name="level"></param>
        /// <param name="gc"></param>
        private bool SkillCure(FightObject fighter, int level, GameConfig gc)
        {
            TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType");
            AttackParameter par = new AttackParameter(gc, level);
            var targets = FriendTargets(fighter, targetType, par);

            if (targets.Count == 0) return false;
            var config = par.LevelConfig;
            if (config == null) return false;
            double a = config.GetDoubleOrDefault("A");
            double b = config.GetDoubleOrDefault("B");
            double c = config.GetDoubleOrDefault("C");
            //double d = config.GetDoubleOrDefault("D");
            int r = config.GetIntOrDefault("Round");
            List<ActionResult> results = new List<ActionResult>();
            foreach (var target in targets)
            {
                ActionResult result = new ActionResult(target.ID);
                result.ActionFlag |= ActionFlag.Supply;
                int hp = target.TryHP(a) + (int)(fighter.Life.JingShen * b);
                target.AddHPAndMP(hp, 0);
                result.Value["HP"] = hp;
                //result.Value["ShengMing"] = target.HP;
                result.Value["ShengMing"] = new MVPair(target.Life.ShengMing, target.HP);
                //添加Buffer
                if (r > 0)
                {
                    SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, r, gc.Value, c);
                    target.AddBuffer(buf);
                    result.ActionFlag |= ActionFlag.AddBuff;
                    result.Value["AddBuffer"] = buf;
                }
                results.Add(result);
            }
            fighter.Action.Result = results;
            fighter.Action.FightCount = FightAction.HasAction;
            m_actions.Add(fighter.Action);
            return true;
        }
Exemplo n.º 6
0
        /// <summary>
        /// 在攻击敌方时(冲锋/封尘/冻结)
        /// 直接产生Buffer的技能
        /// </summary>
        /// <param name="fighter"></param>
        private bool SkillCreateBuffer(FightObject fighter, int level, GameConfig gc)
        {
            if (fighter == null || gc == null || gc.Value == null)
            {
                return false;
            }
            string newbuffer = gc.Value.GetStringOrDefault("BufferID");
            GameConfig g = GameConfigAccess.Instance.FindOneById(newbuffer);
            if (g == null)
            {
                return false;
            }
            List<FightObject> targets;
            TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType", 1);
            if (targetType == TargetType.Single)
            {
                targets = FilterTargets(fighter);
            }
            else
            {
                targets = EnemyTargets(fighter, targetType, new AttackParameter(gc, level));
            }

            //产生石化/混乱/冰冻
            fighter.Action.Value = new Variant();
            if (targets.Count == 0)
            {
                return false;
            }

            SkillBuffer buf = new SkillBuffer(g.Name, fighter.ID, level, 1, gc.Value);
            //修正次数.
            int round = buf.LevelConfig.GetIntOrDefault("Round", 1);
            buf.RemainingNumber = round;

            targets[0].AddBuffer(buf);
            ActionResult result = new ActionResult(targets[0].ID);
            result.ActionFlag |= ActionFlag.AddBuff;
            result.Value["AddBuffer"] = buf;
            fighter.Action.Result = new List<ActionResult> { result };

            if (targetType != TargetType.Single)
            {
                for (int i = 1; i < targets.Count; i++)
                {
                    SkillBuffer bufi = new SkillBuffer(g.Name, fighter.ID, level, 1, gc.Value);
                    bufi.RemainingNumber = round;

                    targets[i].AddBuffer(bufi);
                    ActionResult resulti = new ActionResult(targets[i].ID);
                    resulti.ActionFlag |= ActionFlag.AddBuff;
                    resulti.Value["AddBuffer"] = bufi;
                    fighter.Action.Result.Add(resulti);
                }
            }

            fighter.Action.FightCount = FightAction.HasAction;
            m_actions.Add(fighter.Action);
            return true;
        }
Exemplo n.º 7
0
 /// <summary>
 // 森严/凝固/凝霜/附骨(被动)
 // 添加(混乱/石化/冰冻/附骨)
 /// </summary>
 /// <param name="r"></param>
 /// <param name="target"></param>
 /// <param name="level"></param>
 /// <param name="gc"></param>
 /// <returns></returns>
 private bool TryAddBuffer(ActionResult r, FightObject target, int level, GameConfig gc)
 {
     Variant levelConfig = gc.Value.GetVariantOrDefault(level.ToString());
     if (levelConfig == null) return false;
     //根据概率计算出是否产生附加Buffer
     if (RandomHit(levelConfig.GetDoubleOrDefault("C")))
     {
         int senderSkillType = gc.Value.GetIntOrDefault("SkillType");
         bool pass = CheckSkillType(senderSkillType);
         if (pass)
         {
             string newbuffer = gc.Value.GetStringOrDefault("BufferID");
             GameConfig buffConfig = GameConfigAccess.Instance.FindOneById(newbuffer);
             //Round:int  Buffer可持续回合数
             int round = levelConfig.GetIntOrDefault("Round");
             //A:double  生成的Buffer的值
             double v = levelConfig.GetDoubleOrDefault("A");
             //每1点精神会增加的伤害(附骨)
             double b = levelConfig.GetDoubleOrDefault("B");
             if (b > 0)
             {
                 v += (b * m_a.Life.JingShen);
             }
             SkillBuffer bf = new SkillBuffer(buffConfig.Name, m_a.ID, level, round, gc.Value, v);
             if (target.AddBuffer(bf))
             {
                 r.Value["AddBuffer"] = bf;
             }
             return true;
         }
     }
     return false;
 }
Exemplo n.º 8
0
        /// <summary>
        /// 开刃/沼气/焚烧 (主动)
        /// 添加(流血/中毒/灼烧)
        /// </summary>
        /// <param name="r"></param>
        /// <param name="target"></param>
        /// <param name="level"></param>
        /// <param name="buffer"></param>
        /// <returns></returns>
        private bool TryAddBuffer(ActionResult r, FightObject target, int level, SkillBuffer buffer)
        {
            Variant levelConfig = buffer.LevelConfig;
            if (levelConfig == null) return false;
            //根据概率计算出是否产生附加Buffer
            if (RandomHit(levelConfig.GetDoubleOrDefault("C")))
            {
                int senderSkillType = buffer.Config.GetIntOrDefault("SkillType");
                bool pass = CheckSkillType(senderSkillType);
                if (pass)
                {
                    //Round:int  Buffer可持续回合数
                    int round = levelConfig.GetIntOrDefault("Round");
                    //A:double  生成的Buffer的值
                    double v = levelConfig.GetDoubleOrDefault("A");
                    if (buffer.ID == BufferType.KaiRen)
                    {
                        IncreaseBuffer(BufferType.DaMo, ref round, ref v);
                    }
                    else if (buffer.ID == BufferType.ZhaoQi)
                    {
                        IncreaseBuffer(BufferType.DiMai, ref round, ref v);
                    }
                    else if (buffer.ID == BufferType.FenShao)
                    {
                        IncreaseBuffer(BufferType.XuanJi, ref round, ref v);
                    }

                    string newID = buffer.Config.GetStringOrDefault("BufferID");
                    GameConfig buffConfig = GameConfigAccess.Instance.FindOneById(newID);
                    SkillBuffer newBuff = new SkillBuffer(buffConfig.Name, m_a.ID, m_Par.Level, round, buffer.Config, v);
                    if (target.AddBuffer(newBuff))
                    {
                        r.Value["AddBuffer"] = newBuff;
                    }
                    return true;
                }
            }
            return false;
        }