Exemple #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);
            }
        }
Exemple #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);
        }
    private void OnReciveLand(OperationResponse response)
    {
        byte[] landData = (byte[])response.Parameters[(byte)ParameterCode.UserLand];
        byte[] userData = (byte[])response[(byte)ParameterCode.UserBase];

        UserLand userLand = Serialization.Load <UserLand>(landData);

        GameManager.GameUser.Land = userLand;
        _manager.curLand          = userLand;

        if (userData != null)
        {
            GameUser.UserBase miniUser = Serialization.LoadStruct <GameUser.UserBase>(userData);
            GameManager.GameUser.Base = miniUser;
        }
    }
Exemple #4
0
    private void InitLand()
    {
        if (isFriend)
        {
            curLand = friendLand;
            slidePoint.gameObject.SetActive(false);
            buildingPanel.gameObject.SetActive(false);
            togCustomBuilding.gameObject.SetActive(false);
            btnExpand.gameObject.SetActive(false);
            uiContaint.silverOfBank.SetActive(false);
            uiContaint.panelInfo.SetActive(false);
        }
        else
        {
            curLand = GameManager.GameUser.Land;

            if (curLand.Houses.Count(p => p.HouseId == 1) > 0)
            {
                uiContaint.silverOfBank.SetActive(true);
                uiContaint.txtSilverOfBank.text = curLand.BankSilver.ToString();
            }

            AnimationSilverBank(uiContaint.silverOfBank);

            slidePoint.gameObject.SetActive(true);
            buildingPanel.Init(this);
            _controller.SendCheckBank(false);

            LoadUserInfo();
        }

        slidePoint.value = Mathf.Lerp(0, 1, ((float)(30 - curLand.ClosePoint)) / 30.0f);
        Color c = Color.green;

        if (slidePoint.value < 0.3)
        {
            c = Color.red;
        }
        else if (slidePoint.value < 0.6)
        {
            c = Color.yellow;
        }
        imageSlidePoint.color = c;
        empireMap.sizeMap     = new Vector2(curLand.LandSizeX, curLand.LandSizeY);
    }
    private void OnHandleCheckBank(OperationResponse response)
    {
        byte[] landData = (byte[])response.Parameters[(byte)ParameterCode.UserLand];
        byte[] userData = (byte[])response[(byte)ParameterCode.UserBase];

        float oldSilver = GameManager.GameUser.Base.Silver;
        float newSilver = GameManager.GameUser.Base.Silver;

        if (userData != null)
        {
            GameUser.UserBase miniUser = Serialization.LoadStruct <GameUser.UserBase>(userData);
            GameManager.GameUser.Base = miniUser;
            newSilver = GameManager.GameUser.Base.Silver;
        }

        UserLand userLand = Serialization.Load <UserLand>(landData);

        GameManager.GameUser.Land = userLand;


        _manager.OnResponseCheckBank(newSilver - oldSilver);
    }
Exemple #6
0
        public override bool TakeAction()
        {
            var             cacheSet     = new PersonalCacheStruct <UserPlant>();
            UserPlant       plant        = cacheSet.FindKey(ContextUser.UserID);
            var             landCacheSet = new PersonalCacheStruct <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 PersonalCacheStruct <UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.Zhongzhijingqianshu) == null)
            {
                isShow = 2;
            }
            else
            {
                isShow = 1;
            }
            userPlant     = new PersonalCacheStruct <UserPlant>().FindKey(ContextUser.UserID);
            userLandArray = new PersonalCacheStruct <UserLand>().FindAll(ContextUser.UserID);

            //圣水恢复
            var queueCacheSet = new PersonalCacheStruct <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);
        }
Exemple #7
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);
        }