A class representing various information retaining to Game State Integration of Dota 2
Esempio n. 1
0
        static void OnNewGameState(GameState gs)
        {
            Console.Clear();
            Console.WriteLine("Press ESC to quit");
            Console.WriteLine("Current Dota version: " + gs.Provider.Version);
            Console.WriteLine("Current time as displayed by the clock (in seconds): " + gs.Map.ClockTime);
            Console.WriteLine("Your steam name: " + gs.Player.Name);
            Console.WriteLine("hero ID: " + gs.Hero.ID);
            Console.WriteLine("Health: " + gs.Hero.Health);
            for (int i = 0; i < gs.Abilities.Count; i++)
            {
                Console.WriteLine("Ability {0} = {1}", i, gs.Abilities[i].Name);
            }
            Console.WriteLine("First slot inventory: " + gs.Items.GetInventoryAt(0).Name);
            Console.WriteLine("Second slot inventory: " + gs.Items.GetInventoryAt(1).Name);
            Console.WriteLine("Third slot inventory: " + gs.Items.GetInventoryAt(2).Name);
            Console.WriteLine("Fourth slot inventory: " + gs.Items.GetInventoryAt(3).Name);
            Console.WriteLine("Fifth slot inventory: " + gs.Items.GetInventoryAt(4).Name);
            Console.WriteLine("Sixth slot inventory: " + gs.Items.GetInventoryAt(5).Name);

            if (gs.Items.InventoryContains("item_blink"))
                Console.WriteLine("You have a blink dagger");
            else
                Console.WriteLine("You DO NOT have a blink dagger");
        }
        private async void Run(CancellationToken token)
        {
            _listener.Start();

            while (!token.IsCancellationRequested)
            {
                HttpListenerContext context = await _listener.GetContextAsync();

                var json = GetJsonFromGameContext(context);

                CurrentGameState = new GameState(json);
            }

            _listener.Stop();
        }
Esempio n. 3
0
        private void ReceiveGameState(IAsyncResult result)
        {
            try
            {
                HttpListenerContext context = net_Listener.EndGetContext(result);
                HttpListenerRequest request = context.Request;
                string JSON;

                waitForConnection.Set();

                using (Stream inputStream = request.InputStream)
                {
                    using (StreamReader sr = new StreamReader(inputStream))
                        JSON = sr.ReadToEnd();
                }
                using (HttpListenerResponse response = context.Response)
                {
                    response.StatusCode = (int)HttpStatusCode.OK;
                    response.StatusDescription = "OK";
                    response.Close();
                }
                CurrentGameState = new GameState(JSON);
            }
            catch (ObjectDisposedException)
            {
                // Intentionally left blank, when the Listener is closed.
            }
        }
 private void UpdateKeyboard(GameState gamestate)
 {
     if (HpBars) UpdateHpBars(gamestate.Hero.HealthPercent);
     if (ManaBars) updateManaBars(gamestate.Hero.ManaPercent);
     UpdateAbilityKeys(gamestate);
 }
        private void UpdateAbilityKeys(GameState gs)
        {
            Abilities abilities = gs.Abilities;
            Color currentcolor;
            for (int i = 0; i < abilities.Count; i++)
            {
                currentcolor = _abilityColor;
                if (abilities[i].Cooldown > 0)
                {
                    currentcolor = _abilityCooldownColor;
                }
                if (gs.Hero.IsHexed || gs.Hero.IsSilenced || gs.Hero.IsStunned)
                {
                    currentcolor = _abilitySilencedColor;
                }

                _keyboard.SetKey(AbilityKeys[i], currentcolor);

            }
        }
        private void OnNewGameState(GameState gamestate)
        {
            if (gamestate.Map.GameState == DOTA_GameState.DOTA_GAMERULES_STATE_GAME_IN_PROGRESS || gamestate.Map.GameState == DOTA_GameState.DOTA_GAMERULES_STATE_PRE_GAME)
            {
                UpdateKeyboard(gamestate);

            }
        }