Ejemplo n.º 1
0
        public bool isReplayStarted()
        {
#if DEBUG
            if (SteamAppsLocation.Get() == "./../../debug")
            {
                return(false);
            }
#endif
            if (!listenerStarted)
            {
                gameStateIntegration.StartListener();
                listenerStarted = true;
            }
            return(
                gameStateIntegration.GameState != "Undefined" &&
                gameStateIntegration.GameState != null &&
                gameStateIntegration.GameState != "");
        }
Ejemplo n.º 2
0
        public override void Start()
        {
            Console.WriteLine("Started live...");

            overlay = OverlaySingleton.Instance;
            gsi     = GameStateIntegrationSingleton.Instance;

            gsi.StartListener();

            while (gsi.GameState == "Undefined" || gsi.GameState == null || gsi.GameState == "")
            {
                if (!IsDotaRunning())
                {
                    overlay.Clear();
                    Console.WriteLine("Dota ended");
                    return;
                }

                bool isInitialInstructionsBoxVisible = true;
                System.Windows.Application.Current.Dispatcher.Invoke(
                    () =>
                {
                    isInitialInstructionsBoxVisible = initialInstructionsBox.IsOverlayVisible;
                });

                if (isInitialInstructionsBoxVisible)
                {
                    double positionX = 0;
                    double positionY = 0;
                    GetBoxPosition(initialInstructionsBox, out positionX, out positionY);

                    overlay.UpdateWindowHandler();
                    overlay.Intructions_setup("Start a game");
                    overlay.ShowInstructionMessage(positionX, positionY, visualCustomizeHandle);
                }
                else
                {
                    overlay.Clear();
                }
            }

            overlay.Clear();

            bool keepLooping = true;

            Console.WriteLine("Currently analyzing...");
            string lastGameState = "";

            while (keepLooping)
            {
                if (!IsDotaRunning())
                {
                    overlay.Clear();
                    Console.WriteLine("Dota ended");
                    return;
                }

                switch (gsi.GameState)
                {
                case null:
                case "":
                case "Undefined":
                    if (lastGameState != "Undefined")
                    {
                        lastGameState = "Undefined";
                        System.Windows.Application.Current.Dispatcher.Invoke(
                            () =>
                        {
                            initialInstructionsBox.Visibility = Visibility.Hidden;
                            heroSelectionBox.Visibility       = Visibility.Hidden;
                            highlightBarBox.Visibility        = Visibility.Hidden;
                            healthGraphsBox.Visibility        = Visibility.Hidden;
                            itemBox.Visibility     = Visibility.Hidden;
                            junglingBox.Visibility = Visibility.Hidden;
                            retreatBox.Visibility  = Visibility.Hidden;
                        });
                    }
                    break;

                case "DOTA_GAMERULES_STATE_HERO_SELECTION":
                    if (lastGameState != "DOTA_GAMERULES_STATE_HERO_SELECTION")
                    {
                        lastGameState = "DOTA_GAMERULES_STATE_HERO_SELECTION";
                        consoleData.StartHeroSelectionParsing();

                        System.Windows.Application.Current.Dispatcher.Invoke(
                            () =>
                        {
                            initialInstructionsBox.Visibility = Visibility.Hidden;
                            heroSelectionBox.Visibility       = Visibility.Visible;
                            highlightBarBox.Visibility        = Visibility.Hidden;
                            healthGraphsBox.Visibility        = Visibility.Hidden;
                            itemBox.Visibility     = Visibility.Hidden;
                            junglingBox.Visibility = Visibility.Hidden;
                            retreatBox.Visibility  = Visibility.Hidden;
                        });
                    }

                    bool isHeroSelectionBoxVisible = true;
                    System.Windows.Application.Current.Dispatcher.Invoke(
                        () =>
                    {
                        isHeroSelectionBoxVisible = heroSelectionBox.IsOverlayVisible;
                    });


                    HandleHeroSelection();

                    if (isHeroSelectionBoxVisible)
                    {
                        ShowHeroSelectionSuggestions();
                    }
                    else
                    {
                        overlay.Clear();
                    }
                    break;

                case "DOTA_GAMERULES_STATE_STRATEGY_TIME":
                    if (lastGameState != "DOTA_GAMERULES_STATE_STRATEGY_TIME")
                    {
                        if (playerName == null)
                        {
                            playerName = GetPlayerName();
                        }

                        lastGameState = "DOTA_GAMERULES_STATE_STRATEGY_TIME";

                        consoleData.StopHeroSelectionParsing();
                    }

                    overlay.ClearHeroSuggestion();
                    overlay.Clear();
                    break;

                case "DOTA_GAMERULES_STATE_WAIT_FOR_MAP_TO_LOAD":
                    break;

                case "DOTA_GAMERULES_STATE_PRE_GAME":
                case "DOTA_GAMERULES_STATE_GAME_IN_PROGRESS":
                    if (lastGameState != "DOTA_GAMERULES_STATE_GAME_IN_PROGRESS")
                    {
                        lastGameState = "DOTA_GAMERULES_STATE_GAME_IN_PROGRESS";

                        consoleData.StartHeroDataParsing();

                        System.Windows.Application.Current.Dispatcher.Invoke(
                            () =>
                        {
                            initialInstructionsBox.Visibility = Visibility.Hidden;
                            heroSelectionBox.Visibility       = Visibility.Hidden;
                            highlightBarBox.Visibility        = Visibility.Hidden;
                            healthGraphsBox.Visibility        = Visibility.Hidden;
                            itemBox.Visibility     = Visibility.Visible;
                            junglingBox.Visibility = Visibility.Hidden;
                            retreatBox.Visibility  = Visibility.Visible;
                        });
                    }

                    SendCommandsToDota();

                    bool isHealthGraphsBoxVisible    = true;
                    bool isItemSuggestionsBoxVisible = true;
                    bool isRetreatBoxVisible         = true;
                    System.Windows.Application.Current.Dispatcher.Invoke(
                        () =>
                    {
                        isHealthGraphsBoxVisible    = healthGraphsBox.IsOverlayVisible;
                        isItemSuggestionsBoxVisible = itemBox.IsOverlayVisible;
                        isRetreatBoxVisible         = retreatBox.IsOverlayVisible;
                    });

                    //if (isHealthGraphsBoxVisible)
                    //overlay.ShowHealthGraphs();
                    //else
                    overlay.HideHealthGraphs();
                    overlay.ToggleHighlight(false);

                    if (isItemSuggestionsBoxVisible)
                    {
                        overlay.ShowItemSuggestions();
                    }
                    else
                    {
                        overlay.HideItemSuggestions();
                    }

                    if (isRetreatBoxVisible)
                    {
                        overlay.ShowRetreat();
                    }
                    else
                    {
                        overlay.HideRetreat();
                    }

                    HandleGamePlay();
                    HandleHeroGraph();

                    UpdateInGameOverlay();
                    break;

                default:
                    lastGameState = "Other";
                    break;
                }

                if (!keepLooping)
                {
                    break;
                }

                Thread.Sleep(10);
            }

            overlay.Clear();
            System.Windows.Application.Current.Dispatcher.Invoke(() => { visualCustomize.CloseWindow(); });
            Console.WriteLine("Game stopped!");
        }