public override void Execute(INotification notification) { var parameter = notification.Body as TwoMsgParams <PlayerVO, MainBaseVO>; if (parameter != null) { PlayerVO playerVO = parameter.first; MainBaseVO mainBaseVO = parameter.second; if (parameter.first != null && parameter.second != null) { PlayerVOProxy playerProxy = Facade.RetrieveProxy(PlayerVOProxy.NAME) as PlayerVOProxy; BuildingVOProxy buildingProxy = Facade.RetrieveProxy(BuildingVOProxy.NAME) as BuildingVOProxy; if (mainBaseVO.ower != playerVO) {//占领 if (mainBaseVO.ower.IsUser) { bool isWin = mainBaseVO.ower.mainBases.Count == buildingProxy.mainBaseTotalCount; playerProxy.VisitAllPlayers((p) => { if (!p.Equals(mainBaseVO.ower)) { _OthersDonotHaveSoldier = _OthersDonotHaveSoldier && p.soldierAmount <= 0; } }); isWin = isWin && _OthersDonotHaveSoldier; if (isWin) { BattleManager.Instance.SetBattleResult(true); } } else { } } else {//收复 } } TwoMsgParamsPool <PlayerVO, MainBaseVO> .Instance.Push(parameter); parameter = null; } }
public override void Execute(INotification notification) { var msgParam = notification.Body as TwoMsgParams <PlayerVO, IBuildingVO>; if (msgParam != null && msgParam.first != null && msgParam.second != null) { PlayerVO playerVo = msgParam.first; IBuildingVO building = msgParam.second; PlayerVOProxy playerVOProxy = Facade.RetrieveProxy(PlayerVOProxy.NAME) as PlayerVOProxy; MapVOProxy mapVOProxy = Facade.RetrieveProxy(MapVOProxy.NAME) as MapVOProxy; BuildingVOProxy buildingProxy = Facade.RetrieveProxy(BuildingVOProxy.NAME) as BuildingVOProxy; //判断资源是否满足创建需求 if (playerVo.gold < building.createCostGold || playerVo.grain < building.createCostGrain) { return; } playerVo.gold -= building.createCostGold; playerVo.grain -= building.createCostGrain; switch (building.buildingType) { case E_Building.None: break; case E_Building.MainBase: //判断是否可以被添加.... MainBaseVO mainBaseVO = building as MainBaseVO; if (mainBaseVO != null) { if (mapVOProxy.IsCanOccupedArea(mainBaseVO.tilePositon, mainBaseVO.radius)) { mainBaseVO.SetOwer(playerVo); buildingProxy.CreateBuilding(mainBaseVO, mainBaseVO, playerVo); //更新地图建筑信息 mapVOProxy.SetBuildingInfo(true, building.tilePositon, building.rect); //更新占领信息 mapVOProxy.SetOccupiedInfo(true, building.tilePositon, mainBaseVO.radius); } } break; case E_Building.FarmLand: case E_Building.GoldMine: case E_Building.MilitaryCamp: MainBaseVO mainBase = playerVOProxy.GetMainBasePlayerBuildingBelongTo(building, playerVo); if (mainBase != null) { //添加建筑 mainBase.AddBuilding(building); //更新地图建筑信息 mapVOProxy.SetBuildingInfo(true, building.tilePositon, building.rect); buildingProxy.CreateBuilding(building, mainBase, playerVo); } break; default: break; } TwoMsgParamsPool <PlayerVO, IBuildingVO> .Instance.Push(msgParam); } BattleManager.Instance.CancelConstraction(); }