private void LoadGame(ActiveGameData data) { gameData = data; MainWindow.Main.LoadGame(ref data); isClosing = true; Close(); }
private void Awake() { ActiveSocket = this; ActiveGameData = Instantiate <GameData>(gameData); ActiveGameData.Init(); DontDestroyOnLoad(this); }
public void Init() { isClosing = false; MainDockPanel.Children.Clear(); var gameNames = (GameName[])Enum.GetValues(typeof(GameName)); var games = new List <ActiveGameData>(); foreach (var gameName in gameNames) { var activeGameData = new ActiveGameData { EnumValue = gameName, GameName = gameName.ToString(), GameDescription = GameList.GetGameDescription(gameName), GameIcon = GameList.GetGameIcon(gameName), GameCustomControl = GameList.GetGameControls(gameName) }; games.Add(activeGameData); } foreach (var game in games) { #region Generate Elements var sp = new StackPanel { Name = $"{game.GameName}_StackPanel", Width = 80, Height = 90 }; var lb = new Label { Content = game.GameName, HorizontalAlignment = HorizontalAlignment.Center }; var imgBrush = new ImageBrush { ImageSource = ImageExtensions.BitmapToImageSource(game.GameIcon) }; var btn = new Button { Height = 64, Width = 64, Background = imgBrush }; #endregion btn.Click += (sender, args) => LoadGame(game); sp.Children.Add(lb); sp.Children.Add(btn); MainDockPanel.Children.Add(sp); } }
public void LoadGame(ref ActiveGameData newGameData) { gameData = newGameData; newGameData = null; this.Title = gameData.GameName; DescriptionTextBlock.Text = gameData.GameDescription; this.Icon = ImageExtensions.BitmapToImageSource(gameData.GameIcon); CustomControlArea.Content = gameData.GameCustomControl; SetStartButton(gameData.EnumValue); Game.Get.SetRunningGameBehavior(GameList.GetGameBehavior(gameData.EnumValue)); }
// Update is called once per frame void Update() { if (Reset) { ResetSocket(); Reset = false; } // always process the inbound queue, as the game can inject protocols, // as a means of notifcation, ie when the connection is lost. while (inboundQueue.Count > 0) { BaseProtocol protocol = inboundQueue.Dequeue() as BaseProtocol; HandleProtocol.Inst.InvokeProtocol(protocol); } if (!Running) { return; } if (ReconnectCooldown > 0) { ReconnectCooldown -= Time.deltaTime; } // check that the required threads are running if (ReconnectCooldown <= 0 && !Connecting && !Connected) // connect { ActiveGameData.SetConnectionStatus(ConnectionStatus.Connecting); Connecting = true; connectThread = new Thread(Connect); connectThread.Start(); } else if (Connected) { ActiveGameData.SetConnectionStatus(ConnectionStatus.Connected); if (!ReciveThread_isRunning) { ReciveThread_isRunning = true; receiveThread = new Thread(ReciveMessage); receiveThread.Start(); } if (outboundQueue.Count > 0 && !SendThread_isRunning) { SendThread_isRunning = true; sendThread = new Thread(SendMessage); sendThread.Start(); } } }
public GameSelectWindow(ActiveGameData existingGameData) { gameData = existingGameData; InitializeComponent(); Init(); }