Exemplo n.º 1
0
 /// <summary>
 /// 圣吉塔加成
 /// </summary>
 /// <param name="embattle"></param>
 /// <param name="combatGeneral"></param>
 private void SJTAddition(UserEmbattle embattle, CombatGeneral combatGeneral)
 {
     if(_combatType==CombatType.ShengJiTa)
     {
         var cacheSetUserSJT = new GameDataCacheSet<UserShengJiTa>();
         var userSJT = cacheSetUserSJT.FindKey(embattle.UserID);
         if (userSJT != null)
         {
             combatGeneral.LifeNum = MathUtils.Addition(combatGeneral.LifeNum, (combatGeneral.LifeNum * userSJT.LifeNum).ToInt());
             combatGeneral.LifeMaxNum = MathUtils.Addition(combatGeneral.LifeMaxNum, (combatGeneral.LifeNum * userSJT.LifeNum).ToInt());
             combatGeneral.ExtraAttack.AdditionWuliNum = MathUtils.Addition(combatGeneral.ExtraAttack.AdditionWuliNum, (combatGeneral.ExtraAttack.AdditionWuliNum * userSJT.WuLiNum));
             combatGeneral.ExtraAttack.AdditionHunjiNum = MathUtils.Addition(combatGeneral.ExtraAttack.AdditionHunjiNum, (combatGeneral.ExtraAttack.AdditionHunjiNum * userSJT.FunJiNum));
             combatGeneral.ExtraAttack.AdditionMofaNum = MathUtils.Addition(combatGeneral.ExtraAttack.AdditionMofaNum, (combatGeneral.ExtraAttack.AdditionMofaNum * userSJT.MofaNum));
             combatGeneral.ExtraDefense.AdditionWuliNum = MathUtils.Addition(combatGeneral.ExtraDefense.AdditionWuliNum, (combatGeneral.ExtraDefense.AdditionWuliNum * userSJT.WuLiNum));
             combatGeneral.ExtraDefense.AdditionHunjiNum = MathUtils.Addition(combatGeneral.ExtraDefense.AdditionHunjiNum, (combatGeneral.ExtraDefense.AdditionHunjiNum * userSJT.FunJiNum));
             combatGeneral.ExtraDefense.AdditionMofaNum = MathUtils.Addition(combatGeneral.ExtraDefense.AdditionMofaNum, (combatGeneral.ExtraDefense.AdditionMofaNum * userSJT.MofaNum));
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 获取命力
 /// </summary>
 /// <param name="embattle"></param>
 /// <returns></returns>
 public double GetMingliNum(UserEmbattle embattle)
 {
     double num = 0;
     var packageCrystal = UserCrystalPackage.Get(embattle.UserID);
     if (packageCrystal != null)
     {
         UserCrystalInfo[] userCrystalList = packageCrystal.CrystalPackage.FindAll(m => m.GeneralID.Equals(embattle.GeneralID)).ToArray();
         foreach (UserCrystalInfo userCrystal in userCrystalList)
         {
             num += (userCrystal.CurrExprience / 10);
         }
     }
     return num;
 }
Exemplo n.º 3
0
        private CombatGeneral Create(UserEmbattle embattle, double inspirePercent, short replacePotion)
        {
            GameUser userInfo = UserCacheGlobal.CheckLoadUser(embattle.UserID);
            UserGeneral userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(embattle.UserID, embattle.GeneralID);
            if (userGeneral == null || userInfo == null)
            {
                return null;
            }

            AbilityInfo ability = new ConfigCacheSet<AbilityInfo>().FindKey(userGeneral.AbilityID);
            CareerInfo careerInfo = new ConfigCacheSet<CareerInfo>().FindKey(userGeneral.CareerID);

            if (ability == null || careerInfo == null)
            {
                throw new Exception("职业或技能为空");
            }
            //职业加成
            decimal baojiNum = GetCareerAddition(careerInfo, AbilityType.BaoJi);
            decimal bishaNum = GetCareerAddition(careerInfo, AbilityType.BiSha);
            decimal renxingNum = GetCareerAddition(careerInfo, AbilityType.RenXing);
            decimal hitNum = GetCareerAddition(careerInfo, AbilityType.MingZhong);
            decimal shanbiNum = GetCareerAddition(careerInfo, AbilityType.ShanBi);
            decimal gedangNum = GetCareerAddition(careerInfo, AbilityType.GeDang);
            decimal pojiNum = GetCareerAddition(careerInfo, AbilityType.PoJi);
            //公会技能加成

            short powerNum = MathUtils.Addition(userGeneral.PowerNum, userGeneral.TrainingPower, short.MaxValue);
            short soulNum = MathUtils.Addition(userGeneral.SoulNum, userGeneral.TrainingSoul, short.MaxValue);
            short intellectNum = MathUtils.Addition(userGeneral.IntellectNum, userGeneral.TrainingIntellect, short.MaxValue);
            GameUser user = new GameDataCacheSet<GameUser>().FindKey(embattle.UserID);
            if (user != null && !string.IsNullOrEmpty(user.MercenariesID) && userGeneral.GeneralID == LanguageManager.GetLang().GameUserGeneralID)
            {
                powerNum = MathUtils.RoundCustom(powerNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.PowerNum)).ToShort();
                soulNum = MathUtils.RoundCustom(soulNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.SoulNum)).ToShort();
                intellectNum = MathUtils.RoundCustom(intellectNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.IntellectNum)).ToShort();
            }

            if (embattle.GeneralID == LanguageManager.GetLang().GameUserGeneralID)
            {
                //法宝基础属性加成
                powerNum = MathUtils.Addition(powerNum, TrumpAbilityAttack.TrumpPropertyNum(embattle.UserID, embattle.GeneralID, AbilityType.PowerNum));
                soulNum = MathUtils.Addition(soulNum, TrumpAbilityAttack.TrumpPropertyNum(embattle.UserID, embattle.GeneralID, AbilityType.SoulNum));
                intellectNum = MathUtils.Addition(intellectNum, TrumpAbilityAttack.TrumpPropertyNum(embattle.UserID, embattle.GeneralID, AbilityType.IntelligenceNum));

                //法宝--技能属性转换获得的值
                //法宝--技能属性转换获得的值
                decimal trumpPower = TrumpAbilityAttack.ConversionPropertyNum(embattle.UserID, powerNum, soulNum, intellectNum, AbilityType.PowerNum);
                decimal trumpsoul = TrumpAbilityAttack.ConversionPropertyNum(embattle.UserID, powerNum, soulNum, intellectNum, AbilityType.SoulNum);
                decimal trumpintellect = TrumpAbilityAttack.ConversionPropertyNum(embattle.UserID, powerNum, soulNum, intellectNum, AbilityType.IntelligenceNum);
                powerNum = MathUtils.Addition(trumpPower.ToShort(), powerNum);
                soulNum = MathUtils.Addition(trumpsoul.ToShort(), soulNum);
                intellectNum = MathUtils.Addition(trumpintellect.ToShort(), intellectNum);
            }

            if (userGeneral.LifeMaxNum == 0 || userGeneral.LifeNum > userGeneral.LifeMaxNum)
            {
                userGeneral.RefreshMaxLife();
                userGeneral.LifeNum = userGeneral.LifeMaxNum;
            }
            //
            decimal effectValue = 0;// AbilityDispose.GetAbilityEffect(embattle.UserID, embattle.GeneralID, ability.AbilityID);
            decimal selfEffectValue = 0;
            List<AbilityInfo> selfAbilityList = AbilityDispose.GetSelfAbilityList(embattle.UserID, embattle.GeneralID,
                                                                                  ability.AbilityID, out selfEffectValue);
            CombatGeneral general = new CombatGeneral()
            {
                UserID = embattle.UserID,
                Position = embattle.Position,
                GeneralID = embattle.GeneralID,
                CombatType = _combatType,
                GeneralName = userGeneral.GeneralName,
                HeadID = userGeneral.HeadID,
                CareerID = userGeneral.CareerID,
                CareerType = careerInfo.CareerType,
                IsMove = careerInfo.IsMove,
                LifeNum = userGeneral.LifeNum,
                LifeMaxNum = userGeneral.LifeMaxNum,
                Lv = userGeneral.GeneralLv,
                Momentum = (short)CombatMomentum,
                Ability = ability,
                IsAttrMove = ability.IsMove,
                BaojiNum = MathUtils.Addition(CombatBaojiNum, baojiNum, decimal.MaxValue),
                BishaNum = bishaNum,
                RenxingNum = renxingNum,
                HitNum = MathUtils.Addition(userGeneral.HitProbability, hitNum, decimal.MaxValue),
                ShanbiNum = shanbiNum,
                GedangNum = gedangNum,
                PojiNum = pojiNum,
                BattleStatus = BattleStatus.Normal,
                PowerNum = powerNum,
                SoulNum = soulNum,
                IntellectNum = intellectNum,
                ExtraAttack = new CombatProperty(),
                ExtraDefense = new CombatProperty(),
                InspirePercent = inspirePercent,
                Fatigue = userInfo.Fatigue,
                UserStatus = userInfo.UserStatus,
                IsMonster = false,
                IsWait = false,
                EffectValue = effectValue,
                AbilityInfoList = AbilityDispose.GetTriggerAbilityList(embattle.UserID, embattle.GeneralID, ability.AbilityID),
                SelfAbilityInfoList = selfAbilityList,
                SelfEffectValue = selfEffectValue
            };

            if (_combatType == CombatType.User)
            {
                //玩家竞技都是满血
                general.LifeNum = general.LifeMaxNum;
                userGeneral.ResetEmbatleReplace();
            }

            //判断是否替补佣兵
            if (replacePotion == general.Position)
            {
                if (_combatType == CombatType.Country && general.LifeNum > 0)
                {
                    general.ReplacePosition = userGeneral.ReplacePosition;
                }
                if (general.ReplacePosition > 0)
                {
                    general.Position = general.ReplacePosition;
                }
                else
                {
                    general.IsWait = true;
                }
            }
            SetExtraProperty(general);
            AbilityAddition(selfAbilityList, general);
            KarmaAddition(embattle.UserID, general);
            SJTAddition(embattle, general);
            
            return general;
        }
Exemplo n.º 4
0
        public override bool TakeAction()
        {
            //List<UserQueue> queueList = new GameDataCacheSet<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.MagicStrong);
            //if (queueList.Count > 0)
            //{
            //    if (queueList[0].StrengNum >= 2 && queueList[0].DoRefresh() > 0)
            //    {
            //        ErrorCode = LanguageManager.GetLang().ErrorCode;
            //        ErrorInfo = LanguageManager.GetLang().St1503_MagicColding;
            //        return false;
            //    }
            //}
            magicInfo = new ConfigCacheSet<MagicInfo>().FindKey(magicID);
            if (magicInfo == null)
            {
                return false;
            }
            int maxMagicLv = ConfigEnvSet.GetInt("Queue.MaxLength");

            UserMagic userMagic = new GameDataCacheSet<UserMagic>().FindKey(ContextUser.UserID, magicID);
            if (userMagic == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1503_MagicIDNotEnough;
                return false;
            }
            sumMagicLv = MathUtils.Addition(userMagic.MagicLv, (short)1, (short)100);
            MagicLvInfo magicLvInfo = new ConfigCacheSet<MagicLvInfo>().FindKey(magicID, sumMagicLv);
            if (magicLvInfo == null || userMagic.MagicLv == maxMagicLv)
            {
                guideID = 1;
                //等级已达到最高
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1503_MaxMagicLv;
                return false;
            }
            if (ContextUser.UserLv < magicLvInfo.EscalateMinLv)
            {
                //超出用户等级
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1503_MagicLevel;
                return false;
            }

            experience = magicLvInfo.ExpNum;
            //codeTime = magicLvInfo.ColdTime;
            if (experience > ContextUser.ExpNum)
            {
                guideID = 3;
                //阅历不足
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = string.Format(LanguageManager.GetLang().St1503_UpgradeExpNum);
                return false;
            }
            int useGold = 0;
            if (ops == 1)
            {
                if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.EquXiaoChuLengQueShiJian))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                    return false;
                }
                useGold = (codeTime / 60);
                if (ContextUser.GoldNum < useGold)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return false;
                }

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue);
            }
            else
            {
                //放入队列中
                // List<UserQueue> queueList = new GameDataCacheSet<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType ==QueueType.MagicStrong);
                //todo
                //if (queueList.Count > 0)
                //{
                //    UserQueue queue = queueList[0];
                //    if (queue.DoRefresh() > 0 && queue.StrengNum < 2)
                //    {
                //        queue.TotalColdTime = MathUtils.Addition(queue.TotalColdTime, codeTime, int.MaxValue);
                //        queue.ColdTime = MathUtils.Addition(queue.ColdTime, codeTime, int.MaxValue);
                //        queue.IsSuspend = false;
                //        queue.StrengNum = MathUtils.Addition(queue.StrengNum, 1, int.MaxValue);
                //        //queue.Update();
                //    }
                //    else
                //    {
                //        queue.TotalColdTime = codeTime;
                //        queue.Timing = DateTime.Now;
                //        queue.ColdTime = codeTime;
                //        queue.IsSuspend = false;
                //        queue.StrengNum = 1;
                //        //queue.Update();
                //    }
                //}
                //else
                //{
                //    UserQueue userQueue = new UserQueue()
                //    {
                //        QueueID = Guid.NewGuid().ToString(),
                //        UserID = ContextUser.UserID,
                //        QueueType = QueueType.MagicStrong,
                //        QueueName = QueueType.MagicStrong.ToString(),
                //        TotalColdTime = codeTime,
                //        Timing = DateTime.Now,
                //        ColdTime = codeTime,
                //        StrengNum = 1,
                //        IsSuspend = false
                //    };
                //    new GameDataCacheSet<UserQueue>().Add(userQueue);
                //}
            }

            if (userMagic != null)
            {
                if (userMagic.MagicType == MagicType.MoFaZhen)
                {
                    MagicLvInfo mLvInfo = new ConfigCacheSet<MagicLvInfo>().FindKey(userMagic.MagicID, userMagic.MagicLv);
                    string[] mGridRange = mLvInfo.GridRange.Split(',');
                    foreach (string gridRange in mGridRange)
                    {
                        UserEmbattle userEmbattle = new GameDataCacheSet<UserEmbattle>().FindKey(ContextUser.UserID, userMagic.MagicID, gridRange.ToShort());
                        if (userEmbattle == null)
                        {
                            UserEmbattle embattle = new UserEmbattle()
                            {
                                UserID = ContextUser.UserID,
                                MagicID = userMagic.MagicID,
                                Position = gridRange.ToShort(),
                                GeneralID = 0
                            };
                            new GameDataCacheSet<UserEmbattle>().Add(embattle);
                        }
                    }
                }

                if (experience < ContextUser.ExpNum)
                {
                    ContextUser.ExpNum = MathUtils.Subtraction(ContextUser.ExpNum, experience, 0);
                    userMagic.MagicLv = MathUtils.Addition(userMagic.MagicLv, (short)1, (short)maxMagicLv);
                }
                UserLogHelper.AppenStrongLog(ContextUser.UserID, 1, null, magicID, 2, (short)userMagic.MagicLv, useGold, 0);
            }

            List<UserGeneral> userGeneralsArray = new GameDataCacheSet<UserGeneral>().FindAll(ContextUser.UserID, s => s.GeneralStatus == GeneralStatus.DuiWuZhong && s.GeneralType != GeneralType.Soul);
            foreach (UserGeneral general in userGeneralsArray)
            {
                general.RefreshMaxLife();
            }
            //日常任务-魔术升级
            TaskHelper.TriggerDailyTask(Uid, 4004);
            return true;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 玩家升级开启魔术、阵法
        /// </summary>
        public static void OpenMagic(string userID, int userLv)
        {
            var magicCacheSet = new GameDataCacheSet<UserMagic>();
            var embattleCacheSet = new GameDataCacheSet<UserEmbattle>();
            var magicArray = new ConfigCacheSet<MagicInfo>().FindAll(u => u.DemandLv <= userLv);
            foreach (MagicInfo magicInfo in magicArray)
            {
                UserMagic userMagic = magicCacheSet.FindKey(userID, magicInfo.MagicID);
                if (userMagic == null)
                {
                    UserMagic magic = new UserMagic()
                                         {
                                             UserID = userID,
                                             MagicID = magicInfo.MagicID,
                                             MagicLv = magicInfo.MagicLv,
                                             MagicType = magicInfo.MagicType,
                                             IsEnabled = false
                                         };
                    magicCacheSet.Add(magic, GameEnvironment.CacheUserPeriod);

                    if (magicInfo.MagicType == MagicType.MoFaZhen)
                    {
                        MagicLvInfo lvInfo = new ConfigCacheSet<MagicLvInfo>().FindKey(magicInfo.MagicID, magicInfo.MagicLv);
                        if (lvInfo != null)
                        {
                            string[] magicRang = lvInfo.GridRange.Split(',');
                            if (magicRang.Length > 0)
                            {
                                UserEmbattle embattle = new UserEmbattle()
                                                            {
                                                                UserID = userID,
                                                                MagicID = magicInfo.MagicID,
                                                                Position = Convert.ToInt16(magicRang[0]),
                                                                GeneralID = 0 // LanguageManager.GetLang().GameUserGeneralID
                                                            };
                                embattleCacheSet.Add(embattle, GameEnvironment.CacheUserPeriod);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void CreateMagic(GameUser userEntity)
        {
            UserMagic userMagic = new UserMagic
            {
                UserID = userEntity.UserID,
                IsEnabled = true,
                MagicID = new GameUser().UserMagicID,
                MagicLv = 1,
                MagicType = MagicType.MoFaZhen
            };
            var cacheUserMagic = new PersonalCacheStruct<UserMagic>();
            cacheUserMagic.Add(userMagic);
            cacheUserMagic.Update();

            //初始阵法
            string[] gridRange = new ShareCacheStruct<MagicLvInfo>().FindKey(userMagic.MagicID, userMagic.MagicLv).GridRange.Split(new char[] { ',' });
            if (gridRange.Length > 0)
            {
                string grid = gridRange[0];
                UserEmbattle userEmbattle = new UserEmbattle
                {
                    UserID = userEntity.UserID,
                    GeneralID = generalID,
                    MagicID = userMagic.MagicID,
                    Position = grid.ToShort()

                };
                var cacheEmbattle = new PersonalCacheStruct<UserEmbattle>();
                cacheEmbattle.Add(userEmbattle);
                cacheEmbattle.Update();
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 初始化魔法阵
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="userLv"></param>
        private static void InitMagicEmbattle(string userId, short userLv)
        {
            List<UserMagic> userMagicList = new GameDataCacheSet<UserMagic>().FindAll(userId, m => m.MagicType == MagicType.MoFaZhen && m.MagicID != new GameUser().UserMagicID);
            if (userMagicList.Count == 0)
            {
                List<MagicInfo> magicInfoList = new ConfigCacheSet<MagicInfo>().FindAll(m => m.MagicType == MagicType.MoFaZhen && m.DemandLv <= userLv);
                foreach (var magicInfo in magicInfoList)
                {
                    var userMagic = new GameDataCacheSet<UserMagic>().FindKey(userId, magicInfo.MagicID);
                    if (userMagic != null) continue;

                    userMagic = new UserMagic
                    {
                        UserID = userId,
                        MagicID = magicInfo.MagicID,
                        MagicLv = magicInfo.MagicLv,
                        MagicType = magicInfo.MagicType,
                        IsEnabled = false
                    };
                    new GameDataCacheSet<UserMagic>().Add(userMagic);
                    MagicLvInfo magicLvInfo = new ConfigCacheSet<MagicLvInfo>().FindKey(magicInfo.MagicID, magicInfo.MagicLv);
                    short position = magicLvInfo.GetFirstGrid();
                    var userEmbattle = new UserEmbattle
                    {
                        UserID = userId,
                        GeneralID = 0, // LanguageManager.GetLang().GameUserGeneralID,
                        MagicID = magicInfo.MagicID,
                        Position = position
                    };
                    new GameDataCacheSet<UserEmbattle>().Add(userEmbattle);
                }
            }
            //UserEmbattle
        }
Exemplo n.º 8
0
        public override bool TakeAction()
        {

            GeneralHelper.StotyTaskFunction(ContextUser); //已完成替换佣兵功能开启
            _userMagicArray = new GameDataCacheSet<UserMagic>().FindAll(ContextUser.UserID, u => u.MagicID != 1 && u.MagicType == MagicType.MoFaZhen);
            _userMagicArray.QuickSort((x, y) =>
            {
                if (x == null && y == null) return 0;
                if (x != null && y == null) return 1;
                if (x == null) return -1;
                return x.MagicID.CompareTo(y.MagicID);
            });

            var userFunction = new GameDataCacheSet<UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.ReplaceGeneral);
            foreach (UserMagic magic in _userMagicArray)
            {
                if (magic == null) continue;
                MagicLvInfo magicLv = new ConfigCacheSet<MagicLvInfo>().FindKey(magic.MagicID, magic.MagicLv);
                if (magicLv != null)
                {
                    string gridPostion = magicLv.GridRange;
                    if (magicLv.ReplacePostion > 0 && userFunction != null)
                    {
                        gridPostion = gridPostion.TrimEnd(',') + "," + magicLv.ReplacePostion;
                    }
                    string[] gridRangeArray = gridPostion.Split(',');
                    foreach (string gridRange in gridRangeArray)
                    {
                        UserEmbattle userEmbattle = new GameDataCacheSet<UserEmbattle>().FindKey(ContextUser.UserID, magic.MagicID, gridRange.ToShort());
                        if (userEmbattle == null)
                        {
                            UserEmbattle embattle = new UserEmbattle()
                            {
                                UserID = ContextUser.UserID,
                                MagicID = magic.MagicID,
                                Position = gridRange.ToShort(),
                                GeneralID = 0
                            };
                            var cacheSet = new GameDataCacheSet<UserEmbattle>();
                            cacheSet.Add(embattle);
                        }
                    }
                }
            }
            _userGeneralArray = new GameDataCacheSet<UserGeneral>().FindAll(ContextUser.UserID, u => u.GeneralStatus == GeneralStatus.DuiWuZhong && u.GeneralType != GeneralType.Soul);
            
            // 佣兵排序
            GeneralSortHelper.GeneralSort(ContextUser.UserID, _userGeneralArray);

            return true;
        }