public override ReqWrapper Execute() { //占用工人数量 DataCenter.Instance.FreeWorker += 1; EntityModel replaceModel = null; if (entity.buildingVO.buildingStatus == BuildingVO.BuildingStatus.Construct) { replaceModel = entity.model; //判断是否是军营 if (EntityTypeUtil.IsBarracks(entity.model)) { DataCenter.Instance.TotalSpace += entity.model.spaceProvide; } } else if (entity.buildingVO.buildingStatus == BuildingVO.BuildingStatus.Upgrade)//升级 { replaceModel = DataCenter.Instance.FindEntityModelById(entity.model.upgradeId); //判断是否是军营 if (EntityTypeUtil.IsBarracks(entity.model)) { DataCenter.Instance.TotalSpace += (replaceModel.spaceProvide - entity.model.spaceProvide);//军营空间升级 } else if (EntityTypeUtil.IsCenterBuilding(entity.model)) { DataCenter.Instance.Defender.player.baseId = replaceModel.baseId; } } else { Assert.Fail("building status error!"); } DataCenter.Instance.AddExp(replaceModel.buildExp); //替换成建造或者升级完成后的建筑 entity.buildingVO.buildingStatus = BuildingVO.BuildingStatus.On; entity.buildingVO.cid = replaceModel.baseId; var newEntity = entity.ReplaceWith(replaceModel, entity.buildingVO); ((IsoWorldModeBuilder)GameWorld.Instance.CurrentWorldMode).SelectBuilding(newEntity); EventDispather.DispatherEvent(GameEvents.BUILDING_COMPLETE, entity.buildingVO); var buildingCompleteReq = new BuildingCompleteReq(); buildingCompleteReq.sid = sid; if (immediately) { buildingCompleteReq.completeType = BuildingCompleteReq.CompleteType.CompleteImmediately; var now = ServerTime.Instance.Now(); buildingCompleteReq.timestamp = DateTimeUtil.DateTimeToUnixTimestampMS(now); int deltaTime = (int)(DateTimeUtil.UnixTimestampMSToDateTime(entity.buildingVO.endTime) - now).TotalSeconds; DataCenter.Instance.RemoveResource(ResourceType.Diamond, GameDataAlgorithm.TimeToGem(deltaTime)); } else { buildingCompleteReq.completeType = BuildingCompleteReq.CompleteType.Normal; } return new ReqWrapper() { requestType = ReqWrapper.RequestType.BuildingComplete, buildingCompleteReq = buildingCompleteReq }; }
public override void OnCompleteProductionImmediately() { foreach (var productionItem in ProductionItems) { DataCenter.Instance.AddSkill(new SkillVO() { cid = productionItem.cid, amount = productionItem.count }); } ProductionItems.Clear(); int diamond = GameDataAlgorithm.TimeToGem(TotalTimeLeft); EndTime = System.DateTime.MinValue; new ProductionRequestCommand(ProductionReq.ProductionRequestType.CompleteImmediately, Entity.buildingVO, null, diamond).ExecuteAndSend(); }
public override void OnCompleteProductionImmediately() { DataCenter.Instance.SpaceUsed += CurrentQueueSize; var newViewActors = new List <ArmyVO>(); foreach (var productionItem in ProductionItems) { var army = new ArmyVO() { amount = productionItem.count, cid = productionItem.cid }; DataCenter.Instance.AddArmy(army); newViewActors.Add(army); } ProductionItems.Clear(); int diamond = GameDataAlgorithm.TimeToGem(TotalTimeLeft); EndTime = System.DateTime.MinValue; CoroutineHelper.Run(CreateViewActors(newViewActors)); new ProductionRequestCommand(ProductionReq.ProductionRequestType.CompleteImmediately, Entity.buildingVO, null, diamond).ExecuteAndSend(); }
private void OnComplete(bool immediately) { if (immediately) { new ResearchRequestCommand(Entity.buildingVO.researchBuildingVO, ResearchReq.ResearchRequestType.CompleteImmediately, CurrentResearchId, GameDataAlgorithm.TimeToGem(TimeLeft)).ExecuteAndSend(); } else { new ResearchRequestCommand(Entity.buildingVO.researchBuildingVO, ResearchReq.ResearchRequestType.Complete, CurrentResearchId, 0).ExecuteAndSend(); } Init();//init from vo }