Пример #1
0
        internal AbstractGame(IGameContext gameContext)
        {
            myGameViewModel = new GameViewModel(gameContext.DisplayConfiguration);

            myDisplayAdapter = new DisplayAdapter(myGameViewModel);

            myInputAdapter = new InputAdapter(gameContext.InputConfiguration);
        }
 public GamesController(IPlayerRepository playerRepository, IGamesRepository gamesRepository, IGameViewModel gameViewModel, IGame game, IGameListViewModel gameListViewModel)
 {
     _playerRepository  = playerRepository;
     _gameRepository    = gamesRepository;
     _gameViewModel     = gameViewModel;
     _game              = game;
     _gameListViewModel = gameListViewModel;
 }
Пример #3
0
        private void SetBackgroundImage(object view)
        {
            IGameViewModel game = view as IGameViewModel;

            if (game != null)
            {
                BackgroundImage = game.BackgroundImage;
            }
        }
        private static void ComboBoxOnSelectionChanged(object sender, SelectionChangedEventArgs selectionChangedEventArgs)
        {
            IGameViewModel gameViewModel = (sender as ComboBox).DataContext as IGameViewModel;

            var gameData = (KeyValuePair <string, IGame>)(selectionChangedEventArgs.AddedItems[0]);

            gameViewModel.GameControllerCommand.Execute(gameData.Value);

            gameViewModel.StartGameCommand.Execute(null);
        }
Пример #5
0
        private void BattleGround_Loaded(object sender, RoutedEventArgs e)
        {
            IGameViewModel game = this.DataContext as IGameViewModel;

            if (game.User1.Id != ServiceTypeProvider.Instance.LoggedInUserId)
            {
                this.Angle.CenterX = this.ActualHeight / 2;
                this.Angle.CenterY = this.ActualHeight / 2;
                this.Angle.Angle   = 180;
            }
        }
Пример #6
0
 public ChessboardField(int row, int column)
 {
     Row                             = row;
     Column                          = column;
     _tipService                     = UnityService.Instance.Get().Resolve <ITipService>();
     _gameViewModel                  = UnityService.Instance.Get().Resolve <IGameViewModel>();
     _validatorStrategy              = UnityService.Instance.Get().Resolve <IChessboardValidatorManager>().GetChessboardValidatorStrategy(_gameViewModel.SelectedPawn.GetType());
     _thisLock                       = new object();
     ChangeRectangleColorCommand     = new RelayCommand(ChangeColor);
     SetDefaultRectangleColorCommand = new RelayCommand(SetDefaultFieldColor);
     ClickRectangleCommand           = new RelayCommand(ManagePawn);
     CurrentFieldColor               = DefaultFieldColor;
 }
        private static void ComboBoxOnSelectionChanged(object sender, SelectionChangedEventArgs selectionChangedEventArgs)
        {
            IGameViewModel gameViewModel = (sender as ComboBox).DataContext as IGameViewModel;

            var selectedGame = (KeyValuePair <string, IGame>)(selectionChangedEventArgs.AddedItems[0]);

            IGameControllerContext gameControllerContext = new GameControllerContext {
                Game = selectedGame.Value, GameMode = gameViewModel.GameMode
            };

            gameViewModel.GameControllerCommand.Execute(gameControllerContext);

            gameViewModel.StartGameCommand.Execute(gameViewModel.GameMode);
        }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the ClockViewModel class and sets the
 /// GameViewModel property to the specified view model.
 /// </summary>
 public ClockViewModel(IGameViewModel gameViewModel)
 {
     GameViewModel = gameViewModel;
     PlayerOneMoveTimeStopwatch  = new Stopwatch();
     PlayerOneTotalTimeStopwatch = new Stopwatch();
     PlayerTwoMoveTimeStopwatch  = new Stopwatch();
     PlayerTwoTotalTimeStopwatch = new Stopwatch();
     Timer = new DispatcherTimer {
         Interval = new TimeSpan(0, 0, 0, 1)
     };
     Timer.Tick += (sender, e) => UpdateClockView();
     if (gameViewModel != null)
     {
         Start();
     }
 }
Пример #9
0
        public IGameViewModel Play(IGameViewModel gameModel, Random random)
        {
            using (var db = new JUGContext())
            {
                var gameDAO = GameDataService.GetById(gameModel.Id, db);

                var game = Mapper.DAOToDomain(gameDAO);

                game.Play(new Random());

                MapGameResults(gameDAO, game);

                GameDataService.Save(gameDAO, db);
                GameDataService.SaveChanges(db);

                var resultModel = Mapper.DomainToViewModel(game);

                return(resultModel);
            }
        }
        public GameHostWindow()
        {
            InitializeComponent();

            myGameProvider.LoadGames();

            IDictionary <string, IGame> myGames = myGameProvider.GetGames();

            if (myGames.Any())
            {
                myGameHost = GameControllerFactory.CreateGameController(GameMode.SinglePlayer);
            }

            IGameViewModel viewModel = myGameHost.GetGameViewModel();

            viewModel.Games = myGames;

            viewModel.GameControllerCommand = new GameControllerCommand(myGameHost);

            viewModel.StartGameCommand = new StartGameCommand(myGameHost);

            this.DataContext = viewModel;
        }
Пример #11
0
        public IGameViewModel Update(IGameViewModel gameModel)
        {
            using (var db = new JUGContext())
            {
                var gameDAO = GameDataService.GetById(gameModel.Id, db);

                if (gameDAO.Home.Id != gameModel.HomeId)
                {
                    var newHomeTeam = TeamDataService.GetById(gameModel.HomeId, db);
                    //check if null
                    gameDAO.Home = newHomeTeam;
                }

                if (gameDAO.Away.Id != gameModel.AwayId)
                {
                    var newAwayTeam = TeamDataService.GetById(gameModel.AwayId, db);
                    //check if null
                    gameDAO.Away = newAwayTeam;
                }
            }

            return(null);
        }
Пример #12
0
        public ViewModelLocator(Identity identity, IPresentationServices presentationServices, MainNavigationModel mainNavigationModel, NameNavigationModel nameNavigationModel)
        {
            _identity = identity;
            _presentationServices = presentationServices;
            _mainNavigationModel = mainNavigationModel;
            _nameNavigationModel = nameNavigationModel;

            _main = new MainViewModel(_presentationServices, _identity, _mainNavigationModel);
            _newGame = new NewGameViewModel(_identity, _mainNavigationModel, _nameNavigationModel);
            _depGame = new Dependent(delegate
            {
                if (_mainNavigationModel.SelectedPlayer != null)
                {
                    _game = new RemoteGameViewModel(_mainNavigationModel.SelectedPlayer, _mainNavigationModel);
                }
                else if (_mainNavigationModel.SelectedGameRequest != null)
                {
                    _game = new GameRequestViewModel(_mainNavigationModel.SelectedGameRequest, _mainNavigationModel);
                }
                else
                {
                    LocalGame localGame = _identity.ActiveLocalGames.FirstOrDefault();
                    if (localGame != null)
                        _game = new LocalGameViewModel(localGame, _mainNavigationModel);
                    else
                        _game = null;
                }
            });
            _depChat = new Dependent(delegate
            {
                _chat = _mainNavigationModel.SelectedPlayer == null
                    ? null
                    : new ChatViewModel(_mainNavigationModel.SelectedPlayer, _mainNavigationModel);
            });
            _settings = new SettingsViewModel(_identity);
        }
 public void Navigate(IGameViewModel viewModel)
 {
     CurrentPageViewModel = viewModel;
 }
Пример #14
0
 public DisplayAdapter(IGameViewModel viewModel)
 {
     myViewModel = viewModel;
 }
        public MainWindow()
        {
            InitializeComponent();

            MapEntity mapEntityGhost = new MapEntity
            {
                Description        = "Ghost",
                Icon               = null,
                DisplayText        = "G",
                ScoringWeight      = -100,
                DistributionWeight = 1
            };
            MapEntity mapEntityZombie = new MapEntity
            {
                Description        = "Zombie",
                Icon               = null,
                DisplayText        = "Z",
                ScoringWeight      = -10,
                DistributionWeight = 3
            };
            MapEntity mapEntityWall = new MapEntity
            {
                Description        = "Wall",
                Icon               = null,
                DisplayText        = "W",
                ScoringWeight      = 10,
                DistributionWeight = 2
            };
            MapEntity mapEntityExit = new MapEntity
            {
                Description   = "Exit",
                Icon          = null,
                DisplayText   = "Ex",
                ScoringWeight = 0,
                Multiplicity  = MapEntityMultiplicity.Single
            };


            DisplayConfiguration displayConfiguration = new DisplayConfiguration
            {
                Columns     = 5,
                GameTitle   = "Haunted House",
                MapEntities = new System.Collections.Generic.List <IMapEntity> {
                    mapEntityGhost, mapEntityExit, mapEntityWall, mapEntityZombie
                },
                Rows          = 5,
                MaxScore      = 100,
                MoveScore     = -5,
                ParentControl = myCanvas
            };

            IGameContext gameContext = new GameContext
            {
                DisplayConfiguration = displayConfiguration,
                InputConfiguration   = new InputConfiguration {
                    InputElement = this
                },
                IsTwoPlayer   = false,
                ParentControl = this.myCanvas,
            };

            myGameHost = GameFactory.CreateGameController(gameContext);

            IGameViewModel viewModel = myGameHost.GetGameViewModel();

            this.DataContext = viewModel;
        }
Пример #16
0
 /// <summary>
 /// Konstruktor
 /// </summary>
 /// <param name="model">ViewModel okna</param>
 internal MainWindow(IGameViewModel model)
 {
     InitializeComponent();
     DataContext = model ?? throw new ArgumentNullException(nameof(model));
 }
Пример #17
0
 public SinglePlayerGameController(IGameViewModel gameViewModel) : base(gameViewModel)
 {
 }
Пример #18
0
 internal AbstractGameController()
 {
     myGameViewModel = new GameViewModel();
 }
Пример #19
0
 public DisplayAdapter(IGameViewModel viewModel)
 {
     myViewModel = viewModel;
     myCanvas    = viewModel.Canvas;
 }
Пример #20
0
 public DefaultRoomViewModel(KifuTree kifu)
 {
     this.GameViewModel = new GameViewModel(kifu);
 }
 internal static void SetViewModel(IGameViewModel gameViewModel)
 {
     myGameViewModel = gameViewModel;
 }
Пример #22
0
        public MainWindow()
        {
            InitializeComponent();

            MapEntity mapEntityMine = new MapEntity
            {
                Description        = "Mine",
                Icon               = null,
                DisplayText        = "X",
                ScoringWeight      = -100,
                DistributionWeight = 1
            };
            MapEntity mapEntityTrench = new MapEntity
            {
                Description        = "Trench",
                Icon               = null,
                DisplayText        = "T",
                ScoringWeight      = -10,
                DistributionWeight = 3
            };
            MapEntity mapEntityEnemy = new MapEntity
            {
                Description        = "Enemy Soldier",
                Icon               = null,
                DisplayText        = "ES",
                ScoringWeight      = 10,
                DistributionWeight = 2
            };
            MapEntity mapEntityExit = new MapEntity
            {
                Description   = "Exit",
                Icon          = null,
                DisplayText   = "Ex",
                ScoringWeight = 0,
                Multiplicity  = MapEntityMultiplicity.Single
            };
            MapEntity mapEntityHill = new MapEntity
            {
                Description         = "Hill",
                Icon                = null,
                DisplayText         = "H",
                ScoringWeight       = -5,
                DistributionWeight  = 1,
                IsMoveAllowedOnThis = false
            };

            DisplayConfiguration displayConfiguration = new DisplayConfiguration
            {
                Columns     = 5,
                GameTitle   = "Tank Buster",
                MapEntities = new System.Collections.Generic.List <IMapEntity> {
                    mapEntityMine, mapEntityHill, mapEntityExit, mapEntityEnemy, mapEntityTrench
                },
                Rows          = 5,
                MaxScore      = 100,
                MoveScore     = -5,
                ParentControl = myCanvas
            };

            IGameContext gameContext = new GameContext
            {
                DisplayConfiguration = displayConfiguration,
                InputConfiguration   = new InputConfiguration {
                    InputElement = this
                },
                IsTwoPlayer   = false,
                ParentControl = this.myCanvas,
            };

            myGameHost = GameFactory.CreateGameController(gameContext);

            IGameViewModel viewModel = myGameHost.GetGameViewModel();

            this.DataContext = viewModel;
        }
 internal AbstractGameController(IGameViewModel gameViewModel)
 {
     myGameViewModel = gameViewModel;
 }