Beispiel #1
0
        protected override void ProcessCmd(string[] args)
        {
            int magicID = args.Length > 0 ? args[0].Trim().ToInt() : 0;
            short magicLv = args.Length > 1 ? args[1].Trim().ToShort() : (short)1;

            var cacheSet = new GameDataCacheSet<UserMagic>();
            var userMagic = cacheSet.FindKey(UserID, magicID);
            MagicInfo magic = new ConfigCacheSet<MagicInfo>().FindKey(magicID);
            if (magic == null)
            {
                return;
            }
            if (userMagic == null)
            {
                userMagic = new UserMagic()
                {
                    UserID = UserID,
                    MagicID = magicID,
                    MagicLv = magicLv,
                    IsEnabled = false,
                    MagicType = magic.MagicType,
                };
                cacheSet.Add(userMagic);
            }
            else
            {
                userMagic.MagicLv = magicLv;
            }
        }
Beispiel #2
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);
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public override bool TakeAction()
        {
            if (magicType == 0)
            {
                userMagicArray = new GameDataCacheSet<UserMagic>().FindAll(ContextUser.UserID).GetPaging(pageIndex, pageSize, out pageCount);
            }
            else
            {
                userMagicArray = new GameDataCacheSet<UserMagic>().FindAll(ContextUser.UserID, m => m.MagicType == magicType).GetPaging(pageIndex, pageSize, out pageCount);
                //List<UserMagic> tempList = new List<UserMagic>(userMagicArray);
                //userMagicArray = tempList.FindAll(m => m.MagicID != new GameUser().UserMagicID);
            }
            userMagicArray.ForEach(obj =>
            {
                obj.IsOpen = true;
            });
            if (magicType == MagicType.MoFaZhen)
            {
                var cacheSetMagic = new ConfigCacheSet<MagicInfo>();
                var magicList = cacheSetMagic.FindAll(s => s.MagicType == MagicType.MoFaZhen && s.DemandLv > ContextUser.UserLv);

                magicList.ForEach(mgic =>
                {
                    if (userMagicArray.Find(s => s.MagicID == mgic.MagicID) == null)
                    {
                        UserMagic userMagic = new UserMagic();
                        userMagic.IsOpen = mgic.DemandLv <= ContextUser.UserLv ? true : false;
                        userMagic.MagicID = mgic.MagicID;
                        userMagic.UserID = string.Empty;
                        userMagic.MagicLv = 0;
                        userMagic.MagicType = MagicType.MoFaZhen;
                        userMagic.IsLv = mgic.DemandLv;
                        userMagicArray.Add(userMagic);
                    }
                });
            }
            pageCount = MathUtils.Subtraction(pageCount, 1, 0);

            //List<UserQueue> userQueueArray = new GameDataCacheSet<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.MagicStrong);
            //if (userQueueArray.Count > 0 && userQueueArray[0].StrengNum >= 2)
            //{
            //    queueID = userQueueArray[0].QueueID;
            //    coldTime = userQueueArray[0].DoRefresh();
            //}
            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);
            });
            ////记录操作日志
            //UserOperationLog userOperationLog = new UserOperationLog();
            //userOperationLog.UserID = ContextUser.UserID;
            //userOperationLog.ActionID = ActionIDDefine.Cst_Action1501;
            //userOperationLog.FunctionID = "魔术列表";
            //userOperationLog.CreateDate = DateTime.Now;
            //userOperationLog.Num = 1;
            //userOperationLog.Append();
            return true;
        }
Beispiel #4
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();
            }
        }
Beispiel #5
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
        }