예제 #1
0
        //public Player player;
        //public Ai ai;
        #endregion

        public GameWindow() {
            instance = this;
            InitializeFileWatcher();
            InitializeComponent(); // initialize Board and custom UserControls
            InitializeGUIPins();
            
            // If we have a saved game state then load from that instead of starting from scratch
            if ( DoesFileExist(filesavelocation) ) {
                GameData gameData = JsonConvert.DeserializeObject<GameData>(File.ReadAllText(filesavelocation));
                engine = new GameEngine(gameData.WhosCodeMaker);
                engine.CurrentLevel = gameData.CurrentLevel;
                engine.createdCode = gameData.createdCode;
                engine.GuessesLeft = gameData.GuessesLeft;
                engine.IsGameOver = gameData.IsGameOver;
                LoadGameAtStartup(gameData);
            } else {
                engine = new GameEngine("Ai");
            }

            rules = new RulesEngine();
            #region context setting for properties
                GuessesLeft.DataContext = engine;
                WhosCodeMaker.DataContext = engine;
                WhosCodeBreaker.DataContext = engine;
                GuessButton.DataContext = engine;
            #endregion
            DetermineStartGUILayout();
        }
예제 #2
0
 public RulesEngine() {
     instance = this;
 }