示例#1
0
        /// <summary>
        /// Debug Constructor
        /// </summary>
        /// <param name="game"></param>
        public GameViewModel(Game.Middleware.Logic.Model.Model.Game game, string playerName)
        {
            try
            {
                StartStopwatch(true);

                this.PlayerName = playerName;

                this.GUIGameInstance = new GuiGameArea(game.GameArea)
                {
                    AreaWidth = 800,
                    AreaHeight = 600
                };

            }
            catch (Exception ex)
            {
                this.ShowInformationOverlay(ex.Message);
                ViewHelper.Wait(4);
                this.CloseTrigger = true;
            }
        }
示例#2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="client"></param>
        /// <param name="game"></param>
        /// <param name="playerName"></param>
        public GameViewModel(GameTcpClient client, Game.Middleware.Logic.Model.Model.Game game, string playerName)
        {
            try
            {
                this.PlayerName = playerName;

                Controller = new ViewController(client, game.GameArea);
                Controller.AreaUpdateEvent += OnAreaUpdateEvent;
                Controller.PlayerLeftEvent += OnPlayerLeftEvent;
                Controller.GameReadyEvent += OnGameReadyEvent;
                Controller.GameStartEvent += OnGameStartEvent;
                Controller.GameResetEvent += ControllerOnGameResetEvent;
                Controller.GameFinishEvent += OnGameFinishEvent;
                Controller.PlayerFinishEvent += OnPlayerFinishEvent;
                Controller.PlayerKickedEvent += ControllerOnPlayerKickedEvent;
                Controller.PlayerLostEvent += ControllerOnPlayerLostEvent;
                Controller.ErrorEvent += ControllerOnErrorEvent;
                Controller.PlayerJoinedEvent += ControllerOnPlayerJoinedEvent;

                this.GUIGameInstance = new GuiGameArea(game.GameArea)
                {
                    AreaWidth = 800,
                    AreaHeight = 600
                };

                ReinitGameStateWorker = new BackgroundWorker { WorkerSupportsCancellation = true };
                ReinitGameStateWorker.DoWork += ReinitGameStateWorkerOnDoWork;
                ReinitGameStateWorker.RunWorkerAsync(game);
            }
            catch (Exception ex)
            {
                this.ShowInformationOverlay(ex.Message);
                ViewHelper.Wait(4);
                this.CloseTrigger = true;
            }
        }