public void Parse(Building building, bool isLogin = false) { id = building.id; isUnlockedNextLevel = (building.unlockedNextLevel == 0) ? false : true; isUpgrading = (building.upgrading == 0) ? false : true; endToUpgrade = building.endToUpgrade; if (!isUnlocked) { isUnlocked = true; } level = building.level; if (isUpgrading) { // 登录时正在升级建筑 增加建筑队列数 if (isLogin) { InstancePlayer.instance.model_User.model_Queue.AddBuildingQueue(); } _nextLevelUpTime = TimeHelper.GetCurrentRealTimestamp() + this.endToUpgrade * 1000; } else { _nextLevelUpTime = 0; } if (building.production != null) { if (model_Production == null) { model_Production = new Model_Production(); } model_Production.Parse(building.production, level); } else { if (model_Production != null) { model_Production.StopTimer(); model_Production = null; } } UpdateUnlockedBuildings(); }
void DrawProduction() { if (InstancePlayer.instance.model_User.buildings.Count > 0) { DrawProductionRequest request = new DrawProductionRequest(); Model_Building building = InstancePlayer.instance.model_User.buildings[Model_Building.Building_Type.OilFactory]; if (building != null) { Model_Production production = building.model_Production; if (production != null) { request.resourceType = production.resourceType; //要收取的资源类型 request.api = new Model_ApiRequest().api; (new PBConnect_drawProduction()).Send(request, OnDrawProduction); return; } } } _WARNING("no production DrawProduction"); }
// ================================================================ // 向服务器请求数据 void DrawProduction() { UIHelper.LoadingPanelIsOpen(true); if (InstancePlayer.instance.model_User.buildings.Count > 0) { DrawProductionRequest request = new DrawProductionRequest(); Model_Building building = InstancePlayer.instance.model_User.buildings[_model_Building.buildingType]; if (building != null) { Model_Production production = building.model_Production; if (production != null) { request.resourceType = production.resourceType; //要收取的资源类型 request.api = new Model_ApiRequest().api; (new PBConnect_drawProduction()).Send(request, OnDrawProduction); return; } } } }