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 GameDataCacheSet <UserMagic>(); cacheUserMagic.Add(userMagic); cacheUserMagic.Update(); //初始阵法 string[] gridRange = new ConfigCacheSet <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 GameDataCacheSet <UserEmbattle>(); cacheEmbattle.Add(userEmbattle); cacheEmbattle.Update(); } }
/// <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 }
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); }
public override bool TakeAction() { //List<UserQueue> queueList = new PersonalCacheStruct<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 ShareCacheStruct <MagicInfo>().FindKey(magicID); if (magicInfo == null) { return(false); } int maxMagicLv = ConfigEnvSet.GetInt("Queue.MaxLength"); UserMagic userMagic = new PersonalCacheStruct <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 ShareCacheStruct <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 PersonalCacheStruct<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 PersonalCacheStruct<UserQueue>().Add(userQueue); //} } if (userMagic != null) { if (userMagic.MagicType == MagicType.MoFaZhen) { MagicLvInfo mLvInfo = new ShareCacheStruct <MagicLvInfo>().FindKey(userMagic.MagicID, userMagic.MagicLv); string[] mGridRange = mLvInfo.GridRange.Split(','); foreach (string gridRange in mGridRange) { UserEmbattle userEmbattle = new PersonalCacheStruct <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 PersonalCacheStruct <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 PersonalCacheStruct <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); }