private void UserControl_Drop(object sender, DragEventArgs e) { e.Handled = true; if (TerrainView.UpdateGamePoint(e, this)) { return; } if (_Unit.Step.Game.SelectedOrder == null || _Unit.Step.Game.SelectedOrder.WCFOrder.OrderType != "Усиление_власти_0_специальный") { return; } //только тип юнита ExtUnitType dropUnitType = (e.Data.GetData(typeof(ExtUnitType)) as ExtUnitType); if (dropUnitType == null) { return; } if (_Unit.Step.Game.SelectedOrder.ExtTerrain != _Unit.ExtTerrain) { App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_consolidate5")); return; } if (_Unit.WCFUnit.UnitType != "Пеший_воин") { App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_consolidate6")); return; } if (dropUnitType.WCFUnitType.Name == "Пеший_воин") { App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_consolidate7")); return; } if (dropUnitType.WCFUnitType.Name == "Корабль") { App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_consolidate8")); return; } _Unit.TempUnitType = dropUnitType; WCFMarchUnit WCFMarchUnit = _Unit.Step.Game.ClientStep.ExtMarch.WCFMarch.MarchUnit.SingleOrDefault(p => p.Unit == _Unit.WCFUnit.Id); if (WCFMarchUnit == null) { WCFMarchUnit = new WCFMarchUnit(); _Unit.Step.Game.ClientStep.ExtMarch.WCFMarch.MarchUnit.Add(WCFMarchUnit); } WCFMarchUnit.Unit = _Unit.WCFUnit.Id; WCFMarchUnit.Terrain = _Unit.TempTerrain.WCFTerrain.Name; WCFMarchUnit.UnitType = _Unit.TempUnitType.WCFUnitType.Name; _Unit.Step.Game.ClientStep.ExtMarch.SumCost++; }
public ExtUnit(ExtStep step, WCFUnit wcfUnit) { Step = step; WCFUnit = wcfUnit; ExtTerrain = MainWindow.ClientInfo.WorldData.Terrain.Single(p => p.WCFTerrain.Name == WCFUnit.Terrain); ExtUnitType = MainWindow.ClientInfo.WorldData.UnitType.Single(p => p.WCFUnitType.Name == WCFUnit.UnitType); }
private void Item_MouseLeave(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { ExtUnitType unitType = (ExtUnitType)((Image)sender).DataContext; DragDrop.DoDragDrop(this, unitType, DragDropEffects.All); _ExtOrder.Step.Game.OnPropertyChanged("ViewUnit"); if (_ExtOrder.Step.Game.ClientStep.ExtMarch.SumCost == _ExtOrder.ExtTerrain.WCFTerrain.Strength) { ((Popup)this.Parent).IsOpen = false; } _ExtOrder.OnPropertyChanged("UnitTypeMenu"); } }
private bool UnitTypeDrop(DragEventArgs e) { ExtUnitType dropUnitType = (e.Data.GetData(typeof(ExtUnitType)) as ExtUnitType); if (dropUnitType == null) { return(false); } if (_Terrain.ExtGarrison != null && _Terrain.ExtHolderUser != _Terrain.Game.ClientGameUser) { return(true); } if (dropUnitType.WCFUnitType.Cost > (_Terrain.Game.SelectedOrder.ExtTerrain.WCFTerrain.Strength - _Terrain.Game.ClientStep.ExtMarch.SumCost)) { App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_consolidate1")); return(true); } if (dropUnitType.WCFUnitType.Name != "Корабль" && _Terrain.Game.SelectedOrder.ExtTerrain != _Terrain) { App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_consolidate2")); return(true); } if (dropUnitType.WCFUnitType.Name == "Корабль") { if (!_Terrain.Game.SelectedOrder.ExtTerrain.JoinTerrainCol.Contains(_Terrain) || _Terrain.WCFTerrain.TerrainType == "Земля") { App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_consolidate3")); return(true); } if (_Terrain.ExtHolderUser != null && _Terrain.ExtHolderUser != _Terrain.Game.ClientGameUser) { App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_consolidate4")); return(true); } } WCFUnit unit = new WCFUnit(); unit.UnitType = dropUnitType.WCFUnitType.Name; unit.Terrain = _Terrain.WCFTerrain.Name; unit.Step = _Terrain.Game.ClientStep.WCFStep.Id; ExtUnit extUnit = new ExtUnit(_Terrain.Game.ClientStep, unit); if (!CheckMove(extUnit, _Terrain)) { return(true); } WCFMarchUnit wcfMarchUnit = new WCFMarchUnit(); wcfMarchUnit.Unit = extUnit.WCFUnit.Id; wcfMarchUnit.Terrain = extUnit.TempTerrain.WCFTerrain.Name; wcfMarchUnit.UnitType = extUnit.TempUnitType.WCFUnitType.Name; _Terrain.Game.ClientStep.ExtGameUserInfo.ExtUnit.Add(extUnit); _Terrain.Game.ClientStep.ExtMarch.WCFMarch.MarchUnit.Add(wcfMarchUnit); _Terrain.Game.ClientStep.ExtMarch.SumCost += dropUnitType.WCFUnitType.Cost; return(true); }