Пример #1
0
        //EditorConsumer
        public EditorViewModel(EditorProducer editorProducer, EditorConsumer editorConsumer, EditorModel editorModel)
        {
            this.editorProducer = editorProducer;
            this.editorConsumer = editorConsumer;

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

            editorConsumer.ClientsInEditorEvent += HandleClientsInEditorEvent;
            editorConsumer.FieldSavedEvent      += HandleFieldSaved;
            editorConsumer.NameChangedEvent     += HandleNameChanged;
        }
Пример #2
0
        public EditorMenuViewModel(MainConsumer mainConsumer, MainProducer mainProducer, EditorConsumer editorConsumer, EditorProducer editorProducer)
        {
            this.mainConsumer   = mainConsumer;
            this.mainProducer   = mainProducer;
            this.editorConsumer = editorConsumer;
            this.editorProducer = editorProducer;

            mainConsumer.ClientLoginEvent   += HandleClientLoginEvent;
            mainConsumer.ClientLogoutEvent  += HandleClientLogoutEvent;
            mainConsumer.ClientsOnlineEvent += HandleClientsOnlineEvent;

            mainConsumer.EditorEntryEvent   += InitEditorCommunication;
            mainConsumer.OpenEditorsEvent   += HandleOpenEditorsEvent;
            mainConsumer.ClosingEditorEvent += HandleClosingEditorEvent;  //ClosingGameEvent
        }
Пример #3
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;
        }