コード例 #1
0
        public async Task <CreateBuildResult> CreateBuild(Guid roleId, CreateBuildReq data)
        {
            CreateBuildResult result = new CreateBuildResult();
            BuildData         build  = new BuildData(roleId, data.Name, data.ShopType, data.Pos);
            var config = AutoData.Building.GetForId(data.ShopType);

            build.CostGold += config.BuildingCost.Count;                                                         //记录创建时消耗的金砖
            await CreateBuild(roleId, data.Pos, build, config.BuildingCost.Count, config.BuildingCost.GoldType); //建造商铺

            result.LandBuildInfo.Employee          = build.Employee;
            result.LandBuildInfo.GetMoney          = build.GetMoney;
            result.LandBuildInfo.BuildId           = build.Id;
            result.LandBuildInfo.Level             = build.Level;
            result.LandBuildInfo.Name              = build.Name;
            result.LandBuildInfo.Popularity        = build.Popularity;
            result.LandBuildInfo.BuildType         = build.BuildType;
            result.LandBuildInfo.Star              = build.Star;
            result.LandBuildInfo.TodayCanAdvartise = build.TodayCanAdvartise;
            result.LandBuildInfo.Pos = build.Pos;
            return(result);
        }
コード例 #2
0
ファイル: LogicServer.cs プロジェクト: chenhongyi/Server
        private static async Task <BaseResponseData> CreateBuild()
        {
            CreateBuildResult result = new CreateBuildResult();

            if (User.bytes == null)
            {
                result.Result = GameEnum.WsResult.ParamsError;
                return(result);
            }
            var data = await InitHelpers.GetPse().DeserializeAsync <CreateBuildReq>(User.bytes);

            if (data == null)
            {
                result.Result = GameEnum.WsResult.ParamsError;
                return(result);
            }



            //检查钱够不够
            var  config    = AutoData.Building.GetForId(data.ShopType);
            long needMoney = config.BuildingCost.Count;
            var  moneyType = config.BuildingCost.GoldType;

            if (needMoney <= 0)
            {
                result.Result = GameEnum.WsResult.ParamsError;
                return(result);
            }
            if (!(BagController.Instance.CheckMoney(needMoney, moneyType)))
            {
                result.Result = GameEnum.WsResult.NotEnoughMoney;
                return(result);
            }

            return(await BuildController.Instance.CreateBuild(data, result));
        }
コード例 #3
0
        internal async Task <BaseResponseData> CreateBuild(CreateBuildReq data, CreateBuildResult result)
        {
            if (string.IsNullOrEmpty(data.Name) || data.Pos < 0 || data.Pos > MaxPosValue || data.ShopType < 0)
            {
                result.Result = GameEnum.WsResult.ParamsError;
                return(result);
            }
            var role = LogicServer.User.role;
            //检查土地状态 是否可以购买
            var mapInfo = await LandController.Instance.GetLandCell(data.Pos);

            if (mapInfo.State == (int)GameEnum.MapStatus.Saled && mapInfo.RoleId.Equals(LogicServer.User.role.Id.ToString()))
            {
                result = await CreateBuild(role.Id, data);
            }
            else if (mapInfo.State == (int)GameEnum.MapStatus.Building)
            {
                result.Result = GameEnum.WsResult.UnNullLand;
            }
            else if (mapInfo.State == (int)GameEnum.MapStatus.Empty)
            {
                result.Result = GameEnum.WsResult.UnOwnLand;
            }
            else if (mapInfo.State == (int)GameEnum.MapStatus.BanningLand)
            {
                result.Result = GameEnum.WsResult.BanningLand;
            }
            else if (mapInfo.State == (int)GameEnum.MapStatus.BanningBuild)
            {
                result.Result = GameEnum.WsResult.BanningBuild;
            }
            else if (mapInfo.State == (int)GameEnum.MapStatus.Saled && !mapInfo.RoleId.Equals(LogicServer.User.role.Id.ToString()))
            {
                result.Result = GameEnum.WsResult.NotYourLand;
            }
            return(result);
        }