Esempio n. 1
0
        public PlayNowState()
        {
            AssetName = "wholegame.playnow";
            MinimumConfidence = 200000;

            transitionClickOffset.X = 265;
            transitionClickOffset.Y = 365;

            transitionState = new PlayingState();
        }
Esempio n. 2
0
        public override void Update()
        {
            //!TODO!Timer on this
            if ((DateTime.Now - previousTimestamp).TotalMilliseconds < 5000)
            {
                findStates.Clear(); // need to empty this, it fills up from multiple Update() calls
                return; // Only every five seconds
            }
            game.Debug("Looking for menus from within unknown state");
            checkCount++;

            MatchingPoint match;

            findStates.Push(this);

            game.Debug("Looking for states from " + this.AssetName);
            game.Debug("Other states: " + findStates.Count);

            while (findStates.Count > 0)
            {
                BaseGameState state = findStates.Pop();
                if (state != this)
                    state.Init(game);
                //Look for different state (first time check exact only)
                match = state.FindStateFromScreen(checkCount >= DeepSearch || state.AssetName.Equals(this.AssetName));
                if (match.Confident)
                {
                    // Check for this menu
                    if (this.AssetName.Equals(state.AssetName))
                    {
                        // Click 'yes' button to confirm restart
                        SendInputClass.Click(
                            game.GameExtents.Value.X + transitionClickOffset.X,
                            game.GameExtents.Value.Y + transitionClickOffset.Y);
                        System.Threading.Thread.Sleep(400);
                        SendInputClass.Move(0, 0);
                        // Assume next state
                        game.EventStack.Push(new GameEvent(EngineEventType.CHANGE_MENU, transitionState));
                        return;
                    }

                    // Started playing
                    game.EventStack.Push(new GameEvent(EngineEventType.CHANGE_MENU, state));
                    game.Debug("MenuState found: " + state.AssetName);
                    return;
                }

            }

            PlayingState playingState = new PlayingState();
            playingState.Init(game);
            match = playingState.FindStateFromScreen(true);
            if (match.Confident)
            {
                // Started playing
                game.EventStack.Push(new GameEvent(EngineEventType.RESUME_PLAYING, playingState));
                game.Debug("Playingstate found");
                return;
            }

            //game.Debug("Nothing found, playing again");
            game.Debug("Nothing found");

            checkCount = checkCount % DeepSearch;

            previousTimestamp = DateTime.Now;

            return;
        }