private static void GetDepartLvUpData(DepartmentGroup depart, GameEnum.DepartMentType type, out int level, out int departId, out int SupervisorCount) { level = 0; departId = 100000; SupervisorCount = 0; switch (type) { case GameEnum.DepartMentType.Finance: level = depart.Finance.Level; departId = 100000 + 30000 + level; SupervisorCount = depart.Finance.CurDirectorCounts; break; case GameEnum.DepartMentType.Personnel: level = depart.Personnel.Level; departId = 100000 + level; SupervisorCount = depart.Finance.CurDirectorCounts; break; case GameEnum.DepartMentType.Market: level = depart.Market.Level; departId = 100000 + 20000 + level; SupervisorCount = depart.Finance.CurDirectorCounts; break; case GameEnum.DepartMentType.Investment: level = depart.Investment.Level; departId = 100000 + 10000 + level; SupervisorCount = depart.Finance.CurDirectorCounts; break; } }
private bool CheckDepartmentLvUp(Guid roleId, GameEnum.DepartMentType type, ref DepartmentGroup depart) { var company = CompanyDataHelper.Instance.GetCompanyByRoleIdAsync(roleId).Result; if (company == null) { return(false); } var bg = LogicServer.User.bag; GetDepartLvUpData(depart, type, out int level, out int departId, out int SupervisorCount); var config = DepartmentInfo.GetForId(departId + 1); bg.Items.TryGetValue(config.CostGold.Type, out Model.Data.General.Item money); if (company.Level >= config.level && money.CurCount >= config.CostGold.Count && SupervisorCount >= config.DirectorCounts) { return(true); } return(false); }
private async Task <DepartmentUpdateResult> DepartmentLvUp(Guid roleId, int departId, GameEnum.DepartMentType type) { DepartmentUpdateResult result = new DepartmentUpdateResult(); var config = DepartmentInfo.GetForId(departId); var depart = await DepartmentGroupDataHelper.Instance.GetDepartMentGroupByRoleId(roleId); var level = 0; if (config == null) { result.Result = GameEnum.WsResult.ConfigErr; return(result); } if (depart == null) { result.Result = GameEnum.WsResult.DepartmentInvalid; return(result); } switch (type) { case GameEnum.DepartMentType.Finance: level = depart.Finance.Level = depart.Finance.Level + 1; break; case GameEnum.DepartMentType.Personnel: level = depart.Personnel.Level = depart.Personnel.Level + 1; break; case GameEnum.DepartMentType.Market: level = depart.Market.Level = depart.Market.Level + 1; break; case GameEnum.DepartMentType.Investment: level = depart.Investment.Level = depart.Investment.Level + 1; break; } await DepartmentController.Instance.DepartmentLvUp(depart, departId); result.Level = level; result.Type = (int)type; return(result); }
public async Task <DepartmentUpdateResult> DepartmentLvUp(DepartmentUpdateResult result, GameEnum.DepartMentType type) { var role = LogicServer.User.role; var depart = await DepartmentGroupDataHelper.Instance.GetDepartMentGroupByRoleId(role.Id); var bg = LogicServer.User.bag; if (depart == null) { result.Result = GameEnum.WsResult.DepartmentInvalid; return(result); } if (!CheckDepartmentLvUp(role.Id, type, ref depart)) { result.Result = GameEnum.WsResult.DepartmentLvUpFailed; return(result); } int departId = 100000; switch (type) { case GameEnum.DepartMentType.Finance: departId += depart.Finance.Level + 1 + 30000; break; case GameEnum.DepartMentType.Personnel: departId += depart.Personnel.Level + 1; break; case GameEnum.DepartMentType.Market: departId += depart.Market.Level + 1 + 20000; break; case GameEnum.DepartMentType.Investment: departId += depart.Investment.Level + 1 + 10000; break; } result = await DepartmentLvUp(role.Id, departId, type); if (result == null) { result.Result = GameEnum.WsResult.DepartmentLvUpFailed; return(result); } return(result); }