public MenuViewModel() { gameInfo = Cell.Create <GameInformation>(new GameInformation()); PlayerOne = new PlayerInformationViewModel(gameInfo, 1); PlayerTwo = new PlayerInformationViewModel(gameInfo, 2); List <ColorPickerViewModel> colors = new List <ColorPickerViewModel>(); for (int i = 0; i != gameInfo.Value.Colors.Count; ++i) { colors.Add(new ColorPickerViewModel(gameInfo, i, 1, this)); } ColorsP1 = colors; List <ColorPickerViewModel> colors2 = new List <ColorPickerViewModel>(); for (int i = 0; i != gameInfo.Value.Colors.Count; ++i) { colors2.Add(new ColorPickerViewModel(gameInfo, i, 2, this)); } ColorsP2 = colors2; this.GetHeight = this.gameInfo.Derive(h => h.Height); this.GetWidth = this.gameInfo.Derive(w => w.Width); this.GetPlayerOne = this.gameInfo.Derive(p1 => p1.Player_One); this.GetPlayerTwo = this.gameInfo.Derive(p2 => p2.Player_Two); List <int> options = new List <int>(); for (int i = 2; i <= 20; i += 2) { options.Add(i); } DimentionOptions = options; }
public PlayerInfoViewModel(string defaultName, string initialColor) { DefaultName = defaultName; Name = Cell.Create(""); AllColors = new ColorSelectionViewModel(initialColor); Color = AllColors.ChosenColor; }
public BoardViewModel(MainWindowViewModel parentViewModel, ReversiGame game, string playername1, string playername2) { mainWindowViewModel = parentViewModel; gameCell = Cell.Create <ReversiGame>(game); reversiGame = game; rows = new List <BoardRowViewModel>(); foreach (var i in Enumerable.Range(0, game.Board.Height)) { rows.Add(new BoardRowViewModel(gameCell, i)); } // Setup first player data, always Player.BLACK for the model scorePlayer1 = gameCell.Derive(g => g.Board.CountStones(Player.BLACK)); FirstPlayersTurn = gameCell.Derive(g => g.CurrentPlayer == Player.BLACK); PlayerName1 = playername1; // Setup second player data, always Player.WHITE for the model scorePlayer2 = gameCell.Derive(g => g.Board.CountStones(Player.WHITE)); SecondPlayersTurn = gameCell.Derive(g => g.CurrentPlayer == Player.WHITE); PlayerName2 = playername2; // Setup gameOver listener _gameOver = gameCell.Derive(g => g.IsGameOver); _gameOver.ValueChanged += () => GameOver(); }
public StartViewModel() { Player1 = new PlayerInfoViewModel("Player 1", "Black"); Player2 = new PlayerInfoViewModel("Player 2", "White"); Dimension = Cell.Create(8); DimensionString = Cell.Derive(Dimension, dim => dim.ToString() + " x " + dim.ToString()); }
public SimulationViewModel() { this.Simulation = new Simulation(); this.World = new WorldViewModel(Simulation.World); this.Species = new List <SpeciesViewModel>(); Vector = Cell.Create(new Vector2D(50, 50)); foreach (BoidSpecies item in Simulation.Species) { Species.Add(new SpeciesViewModel(item, this)); } int i = 10; foreach (var item in this.Simulation.Species) { item.CreateBoid(new Vector2D(i, i)); i += 100; } this.SelectedSpecies = Cell.Create(Species[0]); this.ControllerSpecies = Species.First(s => s.Name.Equals("controller")); StartStopTime = new StartStopTimerCommand(this); }
public ColorSelectionViewModel(string initialColor) { InitializeColors(new List <string> { "Yellow", "Orange", "Red", "DarkRed", "GreenYellow", "Turquoise", "CornflowerBlue", "DarkOrchid", "Peru", "White", "Gray", "Black" }); ChosenColor = Cell.Create(initialColor); Rows = Enumerable.Range(0, Colors.Count).Select(i => new ColorSelectionRowViewModel(ChosenColor, i, Colors[i])).ToList().AsReadOnly(); }
public PuzzleEntryViewModel(IPuzzleLibraryEntry puzzle, SelectPuzzleViewModel parent) { Parent = parent; Puzzle = puzzle; Grid = Puzzle.Puzzle.Grid; Author = "Author: " + puzzle.Author; Select = new PuzzleLeft(this); Selected = Cell.Create <bool>(false); }
//Constructor public GameVM(MainWindowVM mainWindowVM, Puzzle puzzle) { MainWindowVM = mainWindowVM; Puzzle = puzzle; grid = Cell.Create <IGrid <SquareVM> >(null); back = new ReturnToStartCommand(MainWindowVM); quit = new CloseCommand(MainWindowVM); IsSolved = Cell.Create(false); Start(); }
public BoardViewModel(int dimension, PlayerInfoViewModel player1, PlayerInfoViewModel player2) { ReversiGame = Cell.Create(new ReversiGame(dimension, dimension)); InitializePlayers(dimension, player1, player2); IsGameOver = Cell.Derive(ReversiGame, g => g.IsGameOver); Winner = Cell.Derive(ReversiGame, g => GetWinner(g)); GameOverMessage = Cell.Derive(ReversiGame, g => CreateGameOverMessage(g)); Rows = Enumerable.Range(0, ReversiGame.Value.Board.Height).Select(i => new BoardRowViewModel(ReversiGame, i)).ToList().AsReadOnly(); }
public PuzzleViewModel(Puzzle puzzle) { var facade = new PiCrossFacade(); this.playablePuzzle = facade.CreatePlayablePuzzle(puzzle); this.Grid = playablePuzzle.Grid.Map((IPlayablePuzzleSquare s) => new SquareViewModel(s)); this.ColumnConstraints = playablePuzzle.ColumnConstraints.Map((IPlayablePuzzleConstraints c) => new ConstraintsViewModel(c)); this.RowConstraints = playablePuzzle.RowConstraints.Map((IPlayablePuzzleConstraints c) => new ConstraintsViewModel(c)); this.ElapsedTime = Cell.Create(TimeSpan.Zero); InitiateTimer(); }
public WorldViewModel() { this.Simulation = new Simulation(); this.Simulation.Species[0].CreateBoid(new Vector2D(50, 50)); this.Simulation.Species[1].CreateBoid(new Vector2D(150, 150)); this.Population = Cell.Create <IEnumerable <BoidViewModel> >(null); RefreshPopulation(); //this.Species = Cell.Create<IEnumerable<SpeciesViewModel>>(null); this.Simulation.World.Population.CollectionChanged += Population_CollectionChanged; }
//Initialisatie & dooverwijzing naar het maken van een puzzel public GameScreenViewModel(MainViewModel m, Puzzle p) { this.mvm = m; this.puzzle = p; this.Quit = new QuitCommand(this.mvm); this.Home = new HomeCommand(this.mvm); this.Reset = new ResetCommand(this); //this.f = new PiCrossFacade(); this.grid = Cell.Create <IGrid <SquareViewModel> >(null); this.IsSolved = Cell.Create(false); //this.GoedePuzzel = f.CreatePlayablePuzzle(p); //this.PuzzelMaken(m, GoedePuzzel); PuzzelMaken(); }
public SelectionScreen(Navigator navigator) : base(navigator) { var facade = new PiCrossFacade(); cell = Cell.Create <IList <PuzzleViewModel> >(facade.LoadGameData("../../../../python/picross.zip").PuzzleLibrary.Entries.Select(entry => new PuzzleViewModel(entry)).ToList()); backup = this.Puzzles.Select(puzzle => puzzle).ToList(); PuzzleSizes = this.Puzzles.Select(puzzle => puzzle.Entry.Puzzle.Size).Distinct().ToList(); GoToPuzzle = new GoToPuzzleCommand(navigator, this); GoToMenu = new EasyCommand(() => SwitchTo(new MenuScreen(navigator))); FilterUnsolved = new FilterUnsolvedCommand(); FilterSize = new FilterSizeCommand(); ClearFilters = new ClearFiltersCommand(); OrderBySolved = new OrderBySolvedCommand(); OrderByUnsolved = new OrderByUnsolvedCommand(); OrderBySize = new OrderBySizeCommand(); }
public SelectPuzzleViewModel(MainWindowViewModel main) { this.Main = main; Library = new PiCrossFacade().LoadGameData(path); Puzzles = new List <PuzzleEntryViewModel>(); Chosen = Cell.Create <PuzzleEntryViewModel>(new PuzzleEntryViewModel("empty")); ClosePuzzleSelect = new ClosePuzzleSelectCommand(Main); SelectPuzzleSelect = new SelectPuzzleSelectCommand(this); foreach (IPuzzleLibraryEntry i in Library.PuzzleLibrary.Entries) { Puzzles.Add(new PuzzleEntryViewModel(i, this)); } }
public PicrossViewModel(Puzzle puzzle) { IsSolved = Cell.Create <bool>(false); var facade = new PiCrossFacade(); playablePuzzle = facade.CreatePlayablePuzzle(puzzle); this.Grid = this.playablePuzzle.Grid.Map(square => new SquareViewModel(square)); this.Chronometer = new Chronometer(); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(250); timer.Tick += (o, s) => Chronometer.Tick(); timer.Start(); RowConstraints = new PlayablePuzzleConstraintsViewModel(this.playablePuzzle.RowConstraints); ColumnConstraints = new PlayablePuzzleConstraintsViewModel(this.playablePuzzle.ColumnConstraints); }
public BoardViewModel(Cell <GameInformation> info) { Game = Cell.Create <ReversiGame>(new ReversiGame(info.Value.Width, info.Value.Height)); Debug.WriteLine(info.ToString()); ReversiBoard board = Game.Value.Board; List <BoardRowViewModel> rows = new List <BoardRowViewModel>(); P1Name = info.Value.Player_One.Name; P2Name = info.Value.Player_Two.Name; for (int i = 0; i != board.Height; ++i) { List <BoardSquareViewModel> squares = new List <BoardSquareViewModel>(); for (int j = 0; j != board.Width; ++j) { squares.Add(new BoardSquareViewModel(i, j, Game, info.Value.Player_One.Color, info.Value.Player_Two.Color)); } rows.Add(new BoardRowViewModel(squares)); } this.Rows = rows; this.BlackCount = this.game.Derive(g => g.Board.CountStones(Player.BLACK)); this.WhiteCount = this.game.Derive(g => g.Board.CountStones(Player.WHITE)); this.CurrentPlayer = this.game.Derive(g => g.CurrentPlayer); }
public ColorSelectionSquareViewModel(Cell <string> chosenColor, int rowNumber, int columnNumber, string color) { position = new Vector2D(rowNumber, columnNumber); Color = Cell.Create(color); SelectColorCommand = new SelectColorCommand(chosenColor, color); }
public PuzzleEntryViewModel(string v) { Selected = Cell.Create <bool>(false); }