Example #1
0
        public void LaunchShowGame(OthelloLogic logic = null)
        {
            gameUi = new GameUI(logic);

            grid_main.Children.Remove(menuUi);
            grid_main.Children.Add(gameUi);
        }
Example #2
0
        public void SaveGame(OthelloLogic logic)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter = "othello save files (*.oth)|*.oth";

            if (dialog.ShowDialog() == true)
            {
                Tools.SerializeToFile(dialog.FileName, logic);
            }
        }
Example #3
0
        public void LoadSaveGame()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "othello save files (*.oth)|*.oth";
            OthelloLogic dataSave = null;

            if (dialog.ShowDialog() == true)
            {
                dataSave = (OthelloLogic)Tools.DeserializeFromFile(dialog.FileName);
                dataSave.InitTimer();
                this.LaunchShowGame(dataSave);
            }
        }
Example #4
0
        public GameUI(OthelloLogic logic = null)
        {
            InitializeComponent();

            // Prepare data
            if (logic == null)
            {
                this.logic = new OthelloLogic();
            }
            else
            {
                this.logic = logic;
            }

            // Define data context for each panel of the players
            this.player_ui_top.DataContext = this.logic.GetBlackPlayerData();
            this.player_ui_bot.DataContext = this.logic.GetWhitePlayerData();

            // Prepare the grid
            grid = new OthelloGrid(new IntPosition(this.logic.Columns, this.logic.Rows));
            Viewbox box = new Viewbox();

            box.Child   = grid;
            box.Stretch = System.Windows.Media.Stretch.Uniform;
            main_dock_panel.Children.Add(box);

            // Events
            grid.EventSlotClicked += OnSlotClicked;

            // Init the game
            InitGame();

            // Execute
            ExecuteBefore();
            ShowCurrentPlayerTurn();
        }