Пример #1
0
        public void FindStateFromScreenTest()
        {
            GameEngine game = new GameEngine(new Rectangle(1920,0,1440,900));

            game.GameExtents = new Rectangle(2326, 333 ,525 ,435);
            //game.GameExtents = new Rectangle(1920 + 203, 333, 523, 432);

            PlayNowState target = new PlayNowState(); // TODO: Initialize to an appropriate value
            bool quickCheck = true; // TODO: Initialize to an appropriate value
            MatchingPoint expected = new MatchingPoint(); // TODO: Initialize to an appropriate value
            expected.Certainty = 151380;
            expected.X = 203;
            expected.Y = 333;
            expected.MaxCertaintyDelta = 92.580321039088346;
            expected.MinimumCertainty = 200000;
            expected.Resolution = 1;
            expected.Confident = true;

            MatchingPoint actual;
            target.Init(game);
            actual = target.FindStateFromScreen(quickCheck);
            Assert.AreEqual(expected.Certainty, actual.Certainty);
        }
Пример #2
0
        private void KillGameEngine()
        {
            tUpdateDisplay.Stop();

            //if (startGameThread != null)
            //{
            //    if (states.Count > 0)
            //        states.Peek().StopRequested = true;

            //    startGameThread.Join();
            //    startGameThread = null;
            //}

            if (gameEngine != null)
            {
                gameEngine.Cleanup();

                gameEngine.DebugEvent -= DebugMessage;
                gameEngine.findBitmapWorker.ImageSearchEvent -= ImageSearch;
            }

            gameEngine = null;

            playButton.Enabled = true;
            playButton.Text = "Start";
        }
Пример #3
0
        private void InitGameEngine(Rectangle screenBounds)
        {
            DebugMessage("Initializing game engine");
            //gameEngine = new GameEngine(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
            gameEngine = new GameEngine(screenBounds);

            bool debugMode = Convert.ToBoolean(ConfigurationManager.AppSettings["DebugMode"]);

            #if DEBUG
            debugMode = true;
            #endif

            if (gameEngine != null)
                gameEngine.DebugMode = debugMode;

            //System.IO.Directory.CreateDirectory(workingPath);

            gameEngine.DebugEvent += DebugMessage;
            gameEngine.findBitmapWorker.ImageSearchEvent += ImageSearch;

            playButton.Enabled = true;
            playButton.Text = "Start";

            tUpdateDisplay.Start();
        }
Пример #4
0
 public GameStateManager(GameEngine gameRef)
 {
     game = gameRef;
     states = new Stack<BaseGameState>();
 }