Esempio n. 1
0
        public override bool TakeAction()
        {
            PlantType pType = plantType.ToEnum<PlantType>();
            UserPlantQuality userPlantQuality = new GameDataCacheSet<UserPlantQuality>().FindKey(ContextUser.UserID, generalID, pType);
            UserGeneral userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(ContextUser.UserID, generalID);
            if (userPlantQuality == null)
            {
                return false;
            }
            UserPlant userPlant = new GameDataCacheSet<UserPlant>().FindKey(ContextUser.UserID);
            if (userPlant == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().LoadDataError;
                return false;
            }

            if (pType == PlantType.GameGoin && userPlant.DewNum == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St10004_DewNotEnough;
                return false;
            }

            if (userGeneral != null && pType == PlantType.Experience)
            {
                if (UserHelper.GeneralIsUpLv(ContextUser.UserID, generalID, ContextUser.UserLv, landPsition))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St10004_GeneralNotUserLv;
                    return false;
                }
            }

            var cacheSet = new GameDataCacheSet<UserLand>();
            UserLand land = cacheSet.FindKey(ContextUser.UserID, landPsition);
            if (land == null)
            {
                land = new UserLand();
                land.UserID = ContextUser.UserID;
                land.LandPositon = landPsition;
                land.GeneralID = generalID;
                land.IsBlackLand = 2;
                land.IsRedLand = 2;
                land.IsGain = 1;
                land.PlantQuality = userPlantQuality.PlantQuality;
                land.GainDate = MathUtils.SqlMinDate;
                cacheSet.Add(land);
            }

            if (land.IsGain > 1 && ((DateTime.Now - land.GainDate).TotalSeconds > 28800))
            {
                land.GeneralID = generalID;
                land.PlantType = pType;
                land.IsGain = 1;
                land.PlantQuality = userPlantQuality.PlantQuality;
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            if (pType == PlantType.GameGoin)
            {
                userPlant.DewNum = MathUtils.Subtraction(userPlant.DewNum, 1, 0);
            }
            userPlantQuality.PlantQuality = PlantQualityType.PuTong;

            //日常任务-庄园
            TaskHelper.TriggerDailyTask(Uid, 4008);
            return true;
        }
Esempio n. 2
0
        public override bool TakeAction()
        {
            int sumGold = GetPostionUseGold(landPostion);
            UserPlant plant = new GameDataCacheSet<UserPlant>().FindKey(ContextUser.UserID);
            UserLand uLands = new GameDataCacheSet<UserLand>().FindKey(ContextUser.UserID, landPostion);
            if (uLands != null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St10008_LandPostionIsOpen;
                return false;
            }

            if (Ops == 1)
            {
                ErrorCode = 1;
                ErrorInfo = string.Format(LanguageManager.GetLang().St10008_OpenLandPostion, sumGold);
                return false;
            }
            else if (Ops == 2)
            {
                if (ContextUser.GoldNum < sumGold)
                {
                    ErrorCode = 2;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return false;
                }
                if (ContextUser.GoldNum >= sumGold)
                {
                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, sumGold, int.MaxValue);
                    //ContextUser.Update();

                    plant.LandNum = landPostion;
                    //plant.Update();

                    UserLand land = new UserLand()
                                        {
                                            UserID = ContextUser.UserID,
                                            GeneralID = 0,
                                            LandPositon = landPostion,
                                            PlantType = PlantType.Experience,
                                            IsRedLand = 2,
                                            IsBlackLand = 2,
                                            IsGain = 2,
                                            PlantQuality = PlantQualityType.PuTong
                                        };
                    var cacheSet = new GameDataCacheSet<UserLand>();
                    cacheSet.Add(land, GameEnvironment.CacheUserPeriod);
                    UserLogHelper.AppenLandLog(ContextUser.UserID, 1, 0, landPostion, sumGold, 0, 0, 0);
                }
            }
            return true;
        }
Esempio n. 3
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);

            }
        }
Esempio n. 4
0
 /// <summary>
 /// 种植获得经验
 /// </summary>
 /// <param name="land"></param>
 /// <param name="userLv"></param>
 /// <param name="pType"></param>
 /// <returns></returns>
 private static int GetLandExperience(UserLand land, short userLv)
 {
     int experience = 0;
     if (land != null)
     {
         PlantInfo plantInfo = new ConfigCacheSet<PlantInfo>().FindKey(userLv, (short)PlantType.Experience, land.PlantQuality);
         if (plantInfo != null)
         {
             experience = plantInfo.GainNum;
             if (land.IsRedLand == 1)
             {
                 experience = MathUtils.Addition(experience, (int)(experience * 0.2), int.MaxValue);
             }
             if (land.IsBlackLand == 1)
             {
                 experience = MathUtils.Addition(experience, (int)(experience * 0.4), int.MaxValue);
             }
         }
     }
     return experience;
 }
Esempio n. 5
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;
        }