Exemplo n.º 1
0
        public Main()
        {
            InitializeComponent();

            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.New, newGame));
            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, openGame));
            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, saveGame));

            using (Stream s = new FileStream("Master Detective.clueVariety", FileMode.Open)) {
                game = GameVariety.LoadFrom(s).Initialize();
            }
            game.Players.Add(new Player("Andrew"));
            game.Players.Add(new Player("Cheryl"));
            game.Players.Add(new Player("Jeff"));
            game.Players.Add(new Player("Julia"));
            game.Players.Add(new Player("Anthony"));
            game.Players.Add(new Player("Brandee"));
            game.AssignApproximatePlayerHandSizes();
            game.AutoConstraintRegeneration = false;
            game.Start();
            this.clueMatrix.DataContext = game;
            this.clueMatrix.Game = game;
            this.clueMatrix.PlayerClicked += new EventHandler<ClueGrid.PlayerClickedEventArgs>((sender, e) => {
                this.sidePanel.CurrentClue.Player = e.Player;
            });
            this.clueMatrix.CardClicked += new EventHandler<ClueGrid.CardClickedEventArgs>((sender, e) => {
                CompositeClue cc = this.sidePanel.CurrentClue as CompositeClue;
                if (cc != null) {
                    if (e.Card is Weapon) {
                        cc.Suspicion.Weapon = e.Card as Weapon;
                    } else if (e.Card is Suspect) {
                        cc.Suspicion.Suspect = e.Card as Suspect;
                    } else if (e.Card is Place) {
                        cc.Suspicion.Place = e.Card as Place;
                    }
                }
            });
            this.sidePanel.DataContext = game;

            game.Clues.Add(new CompositeClue());
        }