/// <summary> /// 获取战争奖励金牌数 /// </summary> /// <param name="star"></param> /// <returns></returns> public int GetBattleRewardMedal(int star) { var attackerLevel = DataCenter.Instance.GetCenterBuildingModel(OwnerType.Attacker).level; var defenderLevel = DataCenter.Instance.GetCenterBuildingModel(OwnerType.Defender).level; return(GameDataAlgorithm.GetBattleRewardMetal(attackerLevel, defenderLevel, star)); }
/// <summary> /// 战争奖励系数 /// </summary> /// <returns></returns> public float GetBattleRewardRatio() { var attackerLevel = DataCenter.Instance.GetCenterBuildingModel(OwnerType.Attacker).level; var defenderLevel = DataCenter.Instance.GetCenterBuildingModel(OwnerType.Defender).level; return(GameDataAlgorithm.GetBattleRewardRatio(attackerLevel, defenderLevel)); }
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(); }
/// <summary> /// 获取战斗积分奖励 /// </summary> /// <param name="win">是否胜利</param> /// <param name="star"></param> /// <returns></returns> public int GetBattleRewardCrown(bool win, int star) { int attackerLevel = 0; int defenderLevel = 0; attackerLevel = DataCenter.Instance.GetCenterBuildingModel(OwnerType.Attacker).level; defenderLevel = DataCenter.Instance.GetCenterBuildingModel(OwnerType.Defender).level; if (win) { return(GameDataAlgorithm.GetBattleRewardScore(attackerLevel, defenderLevel, star)); } else { return(GameDataAlgorithm.GetBattleRewardScore(defenderLevel, attackerLevel, 3));//进攻失败 == 被对方3星干掉 } }
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 }