Пример #1
0
 public HighscoreViewModel(GameConsumer gameConsumer, GameProducer gameProducer)
 {
     this.gameConsumer             = gameConsumer;
     this.gameProducer             = gameProducer;
     gameConsumer.GameOverEvent   += HandleShowHighscoreView;
     gameConsumer.NoRevancheEvent += HandleNoRevancheEvent;
 }
Пример #2
0
        public GameLobbyViewModel(MainConsumer mainConsumer, MainProducer mainProducer, GameConsumer gameConsumer, GameProducer gameProducer)
        {
            this.mainConsumer = mainConsumer;
            this.mainProducer = mainProducer;
            this.gameConsumer = gameConsumer;
            this.gameProducer = gameProducer;

            mainConsumer.GameLobbyEntryEvent    += InitGameCommunication;
            gameConsumer.ClientsIngameEvent     += HandleClientsInGame;
            gameConsumer.PlayerReadyToPlayEvent += HandlePlayerReadyToPlay;
            gameConsumer.NoRevancheEvent        += HandleNoRevancheEvent;
        }
Пример #3
0
        public GameViewModel(GameProducer gameProducer, GameConsumer gameConsumer, GameModel gameModel)
        {
            this.gameProducer = gameProducer;
            this.gameConsumer = gameConsumer;

            dispatcherTimer.Tick    += new EventHandler(DispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);


            gameConsumer.GameStartEvent        += HandleStartTimer;
            gameConsumer.PlayerNumberListEvent += HandlePlayerNumberList;
            gameConsumer.NewScoreEvent         += HandleScore;
            gameConsumer.GameOverEvent         += ClearPlayerList;
        }
Пример #4
0
        public MainWindowViewModel()
        {
            mainProducer   = new MainProducer();
            mainConsumer   = new MainConsumer();
            gameProducer   = new GameProducer();
            gameConsumer   = new GameConsumer();
            editorProducer = new EditorProducer();
            editorConsumer = new EditorConsumer();

            GameModel.Instance.GameProducer     = gameProducer;
            GameModel.Instance.GameConsumer     = gameConsumer;
            EditorModel.Instance.EditorProducer = editorProducer;

            loginViewModel              = new LoginViewModel(mainConsumer, mainProducer);
            menuViewModel               = new MenuViewModel(mainConsumer, mainProducer);
            gameMenuViewModel           = new GameMenuViewModel(mainConsumer, mainProducer);
            editorMenuViewModel         = new EditorMenuViewModel(mainConsumer, mainProducer, editorConsumer, editorProducer);
            gameViewModel               = new GameViewModel(gameProducer, gameConsumer, GameModel.Instance);
            editorViewModel             = new EditorViewModel(editorProducer, editorConsumer, EditorModel.Instance);
            gameLobbyViewModel          = new GameLobbyViewModel(mainConsumer, mainProducer, gameConsumer, gameProducer);
            highscoreViewModel          = new HighscoreViewModel(gameConsumer, gameProducer);
            gameFieldSelectionViewModel = new GameFieldSelectionViewModel(mainConsumer, mainProducer);
            aboutViewModel              = new AboutViewModel();


            //Consumer-Events
            mainConsumer.LoginOkEvent += HandleLoginOk;

            gameConsumer.SetPosXEvent       += GameModel.Instance.SetPosX;
            gameConsumer.SetPosYEvent       += GameModel.Instance.SetPosY;
            gameConsumer.SetTypeEvent       += GameModel.Instance.SetType;
            gameConsumer.SetChangeableEvent += GameModel.Instance.SetChangeableInfo;
            gameConsumer.GameLoadMessageProcessCompleteEvent += HandleShowGameView;

            gameConsumer.UpdatePosXEvent     += GameModel.Instance.UpdatePosX;
            gameConsumer.UpdatePosYEvent     += GameModel.Instance.UpdatePosY;
            gameConsumer.UpdateRotationEvent += GameModel.Instance.UpdateRotation;

            editorConsumer.SetTypeEvent        += EditorModel.Instance.SetType;
            editorConsumer.SetPosXEvent        += EditorModel.Instance.SetPosX;
            editorConsumer.SetPosYEvent        += EditorModel.Instance.SetPosY;
            editorConsumer.ElementSetEvent     += EditorModel.Instance.SetElement;
            editorConsumer.ElementDeletedEvent += EditorModel.Instance.DeleteElement;
            editorConsumer.ElementMovedEvent   += EditorModel.Instance.MoveElement;
            editorConsumer.EditorLoadMessageProcessCompleteEvent += HandleShowEditorView;
            editorConsumer.EditorLoadMessageProcessCompleteEvent += EditorModel.Instance.SetLoadingCompleteEvent;;

            //Start bei LoginView
            CurrentUserControl = loginViewModel;

            //aus Hauptmenü
            menuViewModel.ShowGameMenuView   += HandleShowGameMenuView;
            menuViewModel.ShowEditorMenuView += HandleShowEditorMenuView;

            //Zurück zum Menü
            editorMenuViewModel.BackToMenuEvent += HandleShowMenuView;
            gameMenuViewModel.BackToMenuEvent   += HandleShowMenuView;
            editorViewModel.BackToMenuEvent     += HandleShowEditorMenuView;

            //einen Schritt zurück
            gameLobbyViewModel.StepBackEvent += HandleShowGameMenuView;

            //von GameMenuView zu GamelobbyView wechseln
            mainConsumer.GameLobbyEntryEvent       += HandleShowGameLobbyView;
            mainConsumer.GameLobbyEntryDeniedEvent += HandleShowGameLobbyEntryDenied;

            //von EditorMenuView zu EditorView wechseln
            mainConsumer.EditorEntryEvent += HandleSetEditorGUIVariables;

            //GameFieldSelectionView anzeigen
            gameMenuViewModel.ShowGameFieldSelectionViewEvent   += HandleShowGameFieldSelectionView_Game;   //von GameMenu aus
            editorMenuViewModel.ShowGameFieldSelectionViewEvent += HandleShowGameFieldSelectionView_Editor; // von EditorMenu aus

            //aus GameFieldSelectionView zurueck in GameMenuView
            gameFieldSelectionViewModel.ShowGameMenuEvent   += HandleShowGameMenuView;
            gameFieldSelectionViewModel.ShowEditorMenuEvent += HandleShowEditorMenuView;

            //Spiel ist beendet und Highscore soll angezeigt werden
            gameConsumer.GameOverEvent += HandleShowHighscoreView;

            //Navigation aus Highscoreliste zum Hauptbildschirm oder zur GameLobbyView
            highscoreViewModel.BackToMenu      += HandleShowMenuView;
            highscoreViewModel.BackToGameLobby += HandleShowGameLobbyViewAgain;

            //Credits
            loginViewModel.ShowCredits += HandleShowCreditsView;
            aboutViewModel.ShowLogin   += HandleShowLoginView;

            //bei Verbindungsabbruch
            mainProducer.ConnectionLostEvent   += HandleConnectionLost;
            gameProducer.ConnectionLostEvent   += HandleConnectionLost;
            editorProducer.ConnectionLostEvent += HandleConnectionLost;
        }