Пример #1
0
        public GameViewModel(ViewModelMetadata viewModelMetadata) : base(viewModelMetadata)
        {
            BackToMainMenuCommand = new RelayCommand(x => OnChangeViewModel(typeof(StartViewModel)));
            KeyDownCommand = new RelayCommand(HandleKeyDownCommand);

            FieldHeight = 20;
            FieldWidth = 20;

            var test = new IField[FieldHeight, FieldWidth];
            for (int x = 0; x < 20; x++)
            {
                for (int y = 0; y < 20; y++)
                {
                    if (x == 10)
                        test[y, x] = new Field()
                        {
                            Background = Brushes.Yellow,
                            X = x,
                            Y = y,
                        };
                    else
                        test[y, x] = new Field()
                        {
                            Background = Brushes.Brown,
                            X = x,
                            Y = y
                        };
                }
            }
            Fields = new IField[FieldHeight, FieldWidth];
            Fields = test;
            GameController = new GameController.GameController(Fields, OnPropertyChanged);
        }
Пример #2
0
        public ViewModelHandler()
        {
            ViewModelList = new List<IViewModelBase>();
            //Handle KeyDown for ViewModels
            KeyDownCommand = new RelayCommand(x => SelectedViewModel.KeyDownCommand?.Execute(x));

            var startViewModel = new StartViewModel(new ViewModelMetadata(ChangeViewModel));
            ViewModelList.Add(startViewModel);
            SelectedViewModel = startViewModel;
        }
Пример #3
0
        public StartViewModel(ViewModelMetadata viewModelMetadata): base(viewModelMetadata)
        {
            StartGameCommand = new RelayCommand(x => OnChangeViewModel(typeof(GameViewModel)));

            StartGameText = "Start Game!";
        }