Example #1
0
        //开启种植功能
        public static void GetUserLand(string userID)
        {
            UserPlant plant = new GameDataCacheSet<UserPlant>().FindKey(userID);
            if (plant == null)
            {
                UserPlant userPlant = new UserPlant()
                {
                    UserID = userID,
                    LandNum = 1,
                    DewNum = ConfigEnvSet.GetInt("UserQueue.ShengShuiMaxNum"),
                    PayDewTime = 0,
                };
                new GameDataCacheSet<UserPlant>().Add(userPlant);
            }
            int postion = 1;
            UserLand land = new GameDataCacheSet<UserLand>().FindKey(userID, postion);
            if (land == null)
            {
                UserLand userLand = new UserLand()
                                      {
                                          UserID = userID,
                                          LandPositon = postion,
                                          IsRedLand = 2,
                                          IsBlackLand = 2,
                                          IsGain = 2,
                                          PlantType = PlantType.Experience,
                                          PlantQuality = PlantQualityType.PuTong,
                                          GeneralID = 0,
                                      };
                new GameDataCacheSet<UserLand>().Add(userLand);

            }
        }
Example #2
0
        public override bool TakeAction()
        {
            var cacheSet = new GameDataCacheSet<UserPlant>();
            UserPlant plant = cacheSet.FindKey(ContextUser.UserID);
            var landCacheSet = new GameDataCacheSet<UserLand>();
            List<UserLand> landArray = landCacheSet.FindAll(ContextUser.UserID);
            if (plant == null)
            {
                UserPlant uPlant = new UserPlant()
                {
                    UserID = ContextUser.UserID,
                    LandNum = 1,
                    DewNum = ConfigEnvSet.GetInt("UserQueue.ShengShuiMaxNum"),
                    PayDewTime = 0,
                };
                cacheSet.Add(uPlant);
            }
            if (landArray.Count == 0)
            {
                UserLand userLand = new UserLand()
                {
                    UserID = ContextUser.UserID,
                    PlantType = PlantType.Experience,
                    LandPositon = 1,
                    IsRedLand = 2,
                    IsBlackLand = 2,
                    IsGain = 2
                };
                landCacheSet.Add(userLand);
            }

            if (new GameDataCacheSet<UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.Zhongzhijingqianshu) == null)
            {
                isShow = 2;
            }
            else
            {
                isShow = 1;
            }
            userPlant = new GameDataCacheSet<UserPlant>().FindKey(ContextUser.UserID);
            userLandArray = new GameDataCacheSet<UserLand>().FindAll(ContextUser.UserID);

            //圣水恢复
            var queueCacheSet = new GameDataCacheSet<UserQueue>();
            List<UserQueue> ShengShuiQueueArray = queueCacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.ShengShuiHuiFu);

            if (ShengShuiQueueArray.Count > 0)
            {
                UserQueue shengShuiQueue = ShengShuiQueueArray[0];
                if (userPlant != null)
                {
                    int shengshuiMaxNum = ConfigEnvSet.GetInt("UserQueue.ShengShuiMaxNum");
                    int restorationDate = ConfigEnvSet.GetInt("UserQueue.ShengShuiRestorationDate"); //三小时
                    int restorationNum = ConfigEnvSet.GetInt("UserQueue.ShengShuiRestorationNum"); //恢复1点
                    int timeCount = (int)(DateTime.Now - shengShuiQueue.Timing).TotalSeconds / restorationDate;

                    if (userPlant.DewNum < shengshuiMaxNum && timeCount > 0)
                    {
                        userPlant.DewNum = MathUtils.Addition(userPlant.DewNum, (timeCount * restorationNum), shengshuiMaxNum);
                        //userPlant.Update();

                        shengShuiQueue.Timing = DateTime.Now;
                        //shengShuiQueue.Update();
                    }
                }
            }
            else
            {
                UserQueue queue = new UserQueue()
                {
                    QueueID = Guid.NewGuid().ToString(),
                    UserID = ContextUser.UserID,
                    QueueType = QueueType.ShengShuiHuiFu,
                    QueueName = QueueType.ShengShuiHuiFu.ToString(),
                    Timing = DateTime.Now,
                    ColdTime = 0,
                    TotalColdTime = 0,
                    IsSuspend = false,
                    StrengNum = 0
                };
                queueCacheSet.Add(queue);
            }

            return true;
        }