static public void AddTask(ExtGame game) { if (IsBusy) { return; } IsBusy = true; Application.Current.Dispatcher.BeginInvoke(new Action(() => { App.TaskFactory.StartNew(() => { try { game.ClientStep.WCFStep.IsFull = true; game.GameService.SendStep(game.ClientStep.WCFStep); game.ClientStep = null; } catch (Exception exp) { MainWindow.ClientInfo.OnLineStatus = false; App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_error"), App.GetResources("error_sendStep") + exp.Message); } IsBusy = false; }); }), DispatcherPriority.ApplicationIdle); }
static public void CompleteStep(ExtGame game) { if (game == null || game.ClientStep == null) { return; } if (game.ClientStep.WCFStep.StepType == "Замысел") { if (game.ClientStep.WCFStep.GameUserInfo.Order.Any(p => p.OrderType == null)) { App.Agot2.questionView.Show(MessageBoxButton.YesNo, App.GetResources("text_orderFree"), () => SendStepTask.AddTask(game)); return; } } if (game.ClientStep.CheckStep()) { if (game.ClientStep.AttackTerrain?.SingleOrDefault(p => p.ExtHolderUser != null)? .JoinTerrainCol.Any(p => p.Order?.ExtOrderType.WCFOrderType.DoType == "Подмога") ?? false) { App.Agot2.questionView.Show(MessageBoxButton.YesNo, App.GetResources("text_RequestSupport"), () => { game.ClientStep.WCFStep.IsNeedSupport = true; SendStepTask.AddTask(game); }, () => { game.ClientStep.WCFStep.IsNeedSupport = false; SendStepTask.AddTask(game); }); return; } SendStepTask.AddTask(game); } }
public HomeDetail() { InitializeComponent(); DataContextChanged += HomeDetail_DataContextChanged; Game = MainWindow.ClientInfo.ClientGame;//TODO из-за tabcontrol который блокирует конструктор до первого обращения к вкладке ClientInfo.ClientGameChanging += ClientInfo_ClientGameChanging; }
private void ClientInfo_ClientGameChanging(ExtGame game) { if (Game != null) { Game.CurrentViewKeyCganged -= ExtGame_CurrentViewKeyCgange; } if (game != null) { Game = game; Game.CurrentViewKeyCganged += ExtGame_CurrentViewKeyCgange; } }
private void ClientInfo_ClientGameChanging(ExtGame game) { if (Game != null) { Game.ClientStepCganged -= ExtGame_ClientStepCganged; } if (game != null) { Game = game; Game.ClientStepCganged += ExtGame_ClientStepCganged; } }
void ClientInfo_ClientGameChanging(ExtGame game) { if (Game != null) { Game.CurrentViewKeyCganged -= ExtGame_CurrentViewKeyCgange; } if (game != null) { Game = game; Game.CurrentViewKeyCganged += ExtGame_CurrentViewKeyCgange; } this.ExtHolderUser = null; }
private void ClientInfo_ClientGameChanging(ExtGame game) { if (Game != null) { Game.GameUserEvent -= ExtGame_GameUserEvent; } if (game != null) { Game = game; Items.Clear(); game.ExtGameUser.Where(p => p.WCFGameUser.Login != null && p.WCFGameUser.Login != "Вестерос").ToList().ForEach(p => ExtGame_GameUserEvent(p, true)); Game.GameUserEvent += ExtGame_GameUserEvent; } }
private void ClientInfo_ClientGameChanging(ExtGame game) { if (Game != null) { Game.ClientStepCganged -= ExtGame_ClientStepCgange; Game.CurrentViewKeyCganged -= ExtGame_CurrentViewKeyCgange; } if (game != null) { Game = game; Game.ClientStepCganged += ExtGame_ClientStepCgange; Game.CurrentViewKeyCganged += ExtGame_CurrentViewKeyCgange; } this.SupportVisibility = Visibility.Collapsed; }
public ChatItemViewModel(Chat model, ExtGame game) { Model = model; GamePersonModel = new GamePersonItemViewModel(); try { GamePersonModel.User = model.Creator == "Вестерос" ? MainWindow.GamePortal.Vesteros : MainWindow.GamePortal.GetUser(model.Creator); } catch { //если пользователь не найден (написали с сайта) GamePersonModel.User = new GPUser(new WCFUser() { Login = "******" }) { Title = $"{App.GetResources("titleType_Ghost")}, {model.Creator}" }; } if (game != null) { //ищем игру в истории профиля GamePersonModel.HomeType = game.ExtGameUser.SingleOrDefault(p => p.WCFGameUser.Login == Model.Creator)?.ExtHomeType; if (GamePersonModel.HomeType == null) { string hometype = GamePersonModel.User.UserGames.SingleOrDefault(p => p.GameId == game.WCFGame.Id && model.Time > p.StartTime && (!p.EndTime.HasValue || model.Time < p.EndTime))?.HomeType; if (hometype != null) { GamePersonModel.HomeType = MainWindow.ClientInfo.WorldData.HomeType.Single(p => p.WCFHomeType.Name == hometype); } } //string hometype = GamePersonModel.User.UserGames.SingleOrDefault(p => p.GameId == game.WCFGame.Id && model.Time > p.StartTime && (!p.EndTime.HasValue || model.Time < p.EndTime))?.HomeType; //GamePersonModel.HomeType = hometype != null? MainWindow.ClientInfo.WorldData.HomeType.SingleOrDefault(p => p.WCFHomeType.Name == hometype) // : game.ExtGameUser.SingleOrDefault(p => p.WCFGameUser.Login == Model.Creator)?.ExtHomeType; //viewModel.ImageName = hometype != null // ? $"/image/{ExtHomeType.Keys[hometype]}/{ExtHomeType.Keys[hometype]}.png" // : Game?.ExtGameUser.SingleOrDefault(p => p.WCFGameUser.Login == viewModel.Model.Creator)?.ExtHomeType?.ImageName; } Model.IsVisible = GamePersonModel.User.ChatVisibility == Visibility.Visible ? true : false; }
private static string SaveScreen() { DateTime time = DateTime.Now; ExtGame game = MainWindow.ClientInfo.ClientGame; if (game != null) { time = game.WCFGame.CreateTime.LocalDateTime; } string dirName = string.Format("{0}{1}\\{2}", AppDomain.CurrentDomain.BaseDirectory, "Screenshot", time.ToString("yyyy.MM.dd_HH.mm")); Directory.CreateDirectory(dirName); string fileName = string.Format("{0}\\{1}.png", dirName, Guid.NewGuid()); ImageExt.SaveToPNG(App.Agot2.gameView.worldLayer.mapLayer, new Size(1920, 1920 * 0.668), fileName); return(fileName); }
public ExtGameUser(ExtGame game, WCFGameUser wcfGameUser) { Game = game; WCFGameUser = wcfGameUser; if (wcfGameUser.Login == "Вестерос") { GPUser = MainWindow.GamePortal.Vesteros; } else if (!string.IsNullOrEmpty(wcfGameUser.Login)) { GPUser = MainWindow.GamePortal.GetUser(wcfGameUser.Login); } if (!string.IsNullOrEmpty(WCFGameUser.HomeType)) { ExtHomeType = MainWindow.ClientInfo.WorldData.HomeType.Single(p => p.WCFHomeType.Name == WCFGameUser.HomeType); } Sync(wcfGameUser); }
private void ClientInfo_ClientGameChanging(ExtGame game) { if (Game != null) { Game.ClientStepCganged -= ExtGame_ClientStepCganged; Game.NewWesterosPhase -= _OpenEventTab; Game.NewPlanningPhase -= _CloseEventsTab; Game.ToHomeCardEvent -= _OpenHomesTab; Game.BattleDataChanged -= _OpenBattleTab; Game.HomeCardSelected -= _OpenBattleTab; } if (game != null) { Game = game; Game.ClientStepCganged += ExtGame_ClientStepCganged; Game.NewWesterosPhase += _OpenEventTab; Game.NewPlanningPhase += _CloseEventsTab; Game.ToHomeCardEvent += _OpenHomesTab; Game.BattleDataChanged += _OpenBattleTab; Game.HomeCardSelected += _OpenBattleTab; } }
public ExtStep(WCFStep wcfStep, ExtGame game) { WCFStep = wcfStep; Game = game; ExtGameUser = game.ExtGameUser.Single(p => p.WCFGameUser.Id == WCFStep.GameUser); if (wcfStep.GameUserInfo != null) { ExtGameUserInfo = new ExtGameUserInfo(this, wcfStep.GameUserInfo); } if (wcfStep.GameInfo != null) { ExtGameInfo = new ExtGameInfo(this, wcfStep.GameInfo); } if (wcfStep.Support != null) { ExtSupport = new ExtSupport(this, wcfStep.Support); } if (wcfStep.BattleUser != null) { ExtBattleUser = new ExtBattleUser(this, wcfStep.BattleUser); } if (wcfStep.March != null) { ExtMarch = new ExtMarch(this, wcfStep.March); } if (wcfStep.StepType == "Замысел") { Game.OnNewPlanningPhase(); } }
private void ClientInfo_ClientGameChanging(ExtGame game) { Game = game; }
public GetStepTask(ExtGame game) { _Game = game; }
public DisConnectTask(ExtGame game) { _Game = game; }
public GetUserInfoTask(ExtGame game) { _Game = game; _Timer.Interval = TimeSpan.FromSeconds(2); _Timer.Tick += _DispatcherTimer_Tick; }
private void ClientInfo_ClientGameChanging(ExtGame game) { Dispose(); }
public static void AddTask(Guid gameId) { if (IsBusy) { return; } IsBusy = true; MainWindow.ClientInfo.OnLineStatus = false; Application.Current.Dispatcher.BeginInvoke(new Action(() => { App.TaskFactory.StartNew(() => { try { ChannelFactory <IGameService> cf = new ChannelFactory <IGameService>("AGOT2Game"); cf.Endpoint.Address = new EndpointAddress($"http://{App.Config.Settings.ServerAddress}:{App.Config.Settings.ServerPort}/GameHost/{gameId}"); IGameService service = cf.CreateChannel(); WCFGame result = service.Connect( MainWindow.GamePortal.User.Login, string.IsNullOrEmpty(MainWindow.ClientInfo.GamePassword) ? null : MainWindow.ClientInfo.GamePassword, MainWindow.ClientInfo.HomeSelected); if (result == null) { MainWindow.ClientInfo.OnLineStatus = false; MainWindow.ClientInfo.ClientGameId = null; App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("notify_connectionGame")); } else { result.GameUser.Where(p => !string.IsNullOrEmpty(p.Login) && p.Login != "Вестерос").ToList().ForEach(p => MainWindow.GamePortal.GetUser(p.Login)); ExtGame game = null; Application.Current.Dispatcher.BeginInvoke(new Action(() => { ArrowViewModel.GlobalDuration = new Duration(TimeSpan.FromSeconds(5)); game = new ExtGame(result, service); //скрываем профиль игрока if (game.WCFGame.CloseTime == null) { game.ExtGameUser.Where(p => p.WCFGameUser.HomeType != null && p.WCFGameUser.Login != null && p.WCFGameUser.Login != "Вестерос") .ToList().ForEach(p => { p.GPUser.LeaderBoardVisibility = Visibility.Collapsed; p.GPUser.OnPropertyChanged("LeaderBoardVisibility"); }); } }), DispatcherPriority.ApplicationIdle).Wait(); MainWindow.ClientInfo.ClientGame = game; MainWindow.ClientInfo.OnLineStatus = true; App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("notify_mapRender")); } } catch (Exception exp) { MainWindow.ClientInfo.OnLineStatus = false; MainWindow.ClientInfo.ClientGameId = null; App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_error"), App.GetResources("error_connection") + exp.Message); } IsBusy = false; }); }), DispatcherPriority.ApplicationIdle); }