Exemple #1
0
        public static List <string> GetHeroNameList(string directory)
        {
            List <string>            heroNameList = new List <string>();
            heroID                   h_ID         = new heroID();
            Dictionary <int, string> ID_table     = h_ID.getHeroID();                  // key is ID, value is hero_name;
            Dictionary <string, int> hero_table   = h_ID.getIDfromLowercaseHeroname(); // key is hero_name, value is ID;

            string[] infoFile = File.ReadAllLines(directory + "info.txt");
            foreach (string line in infoFile)
            {
                if (line.Contains("hero_name"))
                {
                    int key = hero_table[ConvertedHeroName.Get(line)];

                    heroNameList.Add(ID_table[key]);
                }
            }

            return(heroNameList);
        }
Exemple #2
0
        private void HandleGamePlay()
        {
            int gameStartTime = replayTick.GameStartTick - 90 * 30;

            if (CurrentTick > gameStartTime && CurrentTick < gameStartTime + 300)
            {
                Dictionary <int, string> hero_Intro_Dic = hero_Intro.getHeroIntro();
                string hero_Intro_String = hero_Intro_Dic[hero_table[GUISelection.heroName]];
                overlay.AddHeroInfoMessage(hero_Intro_String, "");
            }
            else
            {
                overlay.ClearHeroInfo();
            }

            int currentGameTime = announcer.GetCurrentGameTime();

            // if timer is after the game start and every last 8 sec of a minute
            AnalizeJungleCamps();

            int health = 0;

            if (announcer.GetCurrentGameTime() >= 780)
            {
                health = heroData.getHealth(CurrentTick, heroID);
                int gametime = announcer.GetCurrentGameTime();
                if (itemflag == 0 && health == 0)
                {
                    item_Time_Mark = 0;


                    foreach (KeyValuePair <int, int> pair in i_suggestion)
                    {
                        if (closestGaming < pair.Key && pair.Key < CurrentTick / 30)
                        {
                            closestGaming = pair.Key;
                        }
                        else if (pair.Key == CurrentTick)
                        {
                            closestGaming = pair.Key;
                        }
                        else
                        {
                            itemflag       = 1;
                            item_Time_Mark = announcer.GetCurrentGameTime();
                            break;
                        }
                    }
                }
                if (itemflag == 1 && health == 0 && announcer.GetCurrentGameTime() >= item_Time_Mark && announcer.GetCurrentGameTime() <= (item_Time_Mark + 10))
                {
                    string item_name = item_Info_Table[i_suggestion[closestGaming] + 2, 2];
                    string item_tip  = item_Info_Table[i_suggestion[closestGaming] + 2, 117];
                    string item_content;
                    if (item_tip == " 0")
                    {
                        item_content = item_name + ":\n This item will be a good choice";
                    }
                    else
                    {
                        item_content = item_name + ":\n " + item_tip;
                    }
                    item_name = item_name.TrimStart(' ');
                    string item_img = item_name.Replace(" ", "_");
                    overlay.AddItemSuggestionMessage(item_content, item_img + "_icon");
                }
                else
                {
                    itemflag = 0;
                    overlay.ClearItemSuggestion();
                }
            }


            // bar graph

            double[] hpToSend = new double[5] {
                0, 0, 0, 0, 0
            };
            double[] maxHpToSend = new double[5] {
                0, 0, 0, 0, 0
            };

            //Console.WriteLine(CurrentTick + " getting health " + heroID);
            health = heroData.getHealth(CurrentTick, heroID);
            //Console.WriteLine("Tick " + CurrentTick + " Health " + health);
            //maxHealth = (int)heroData.getMaxHealth(CurrentTick, heroID);
            //if (health <= 600)

            hpToSend[0] = health;

            //maxHpToSend[0] = heroData.getMaxHealth(CurrentTick, heroID);
            for (int i = 0; i < 5; i++)
            {
                heroID id = new heroID();
                Dictionary <int, string> id_string = id.getHeroID();
                string name     = id_string[teamIDGraph[i]];
                int    index_id = heroIDData.getHeroID(name);

                maxHpToSend[i] = heroData.getMaxHealth(CurrentTick, index_id);
                hpToSend[i]    = heroData.getHealth(CurrentTick, index_id);
            }

            int closestEnemyID = DrawOnClosestEnemy();

            int fEID = lower_hero_table[heroIDData.getHeroName(closestEnemyID)];
            int fHID = lower_hero_table[heroIDData.getHeroName(heroID)];

            bool shouldRetreat = heroData.getHealth(CurrentTick, heroID) < 400 ||
                                 retreat.CreateInput(myID: fHID,
                                                     myLvl: heroData.getLevel(CurrentTick, heroID),
                                                     myHP: health,
                                                     myMana: heroData.getMana(CurrentTick, heroID),
                                                     enemyID: fEID,
                                                     enemyLvl: heroData.getLevel(CurrentTick, closestEnemyID),
                                                     enemyHP: heroData.getHealth(CurrentTick, closestEnemyID),
                                                     enemyMana: heroData.getMana(CurrentTick, closestEnemyID));



            //overlay.ToggleGraphForHeroHP();
            //overlay.AddHPs(hpToSend);
            //overlay.AddHp(hpToSend[0]);

            //double myHp = heroData.getHealth(CurrentTick, heroID);
            //double myMaxHp = heroData.getMaxHealth(CurrentTick, heroID);
            //double myHpPercen = myHp / myMaxHp;
            //int closestHeroId = -1;

            //double min = 0;
            //Get closest hero
            //for (int i = 0; i < 4; i++)
            //{
            //    Tuple<int, int, int> pos = heroData.getHeroPosition(CurrentTick, teamHeroIds[i]);
            //    double dis = Math.Pow((Math.Pow((x - x), 2) + Math.Pow((y - y), 2)), 0.5);
            //    if (dis < min)
            //    {
            //        closestHeroId = i;
            //        min = dis;
            //    }
            //}

            //double closestHp = heroData.getHealth(CurrentTick, closestHeroId);
            //double closestMaxHp = heroData.getMaxHealth(CurrentTick, closestHeroId);
            //double closestHpPercen = closestHp / closestMaxHp;

            List <Creep> creeps = heroData.getLaneCreeps(CurrentTick);
            string       prim   = lastHitCalculator.GetPrimaryAttribute(fHID);
            double       attr   = 0;

            switch (prim)
            {
            case "Strength":
                attr = heroData.getStrength(CurrentTick, heroID);
                break;

            case "Agility":
                attr = heroData.getAgility(CurrentTick, heroID);
                break;

            case "Intelligence":
                attr = heroData.getIntellect(CurrentTick, heroID);
                break;

            default:
                break;
            }
            double        minAtk = heroData.getDamageMin(currentTick, heroID);
            List <double> creepX = new List <double>();
            List <double> creepY = new List <double>();

            foreach (var c in creeps)
            {
                double cArmor  = c.armor;
                double cHp     = c.health;
                bool   canKill = lastHitCalculator.CanLastHit(baseAtk: minAtk, primaryAtr: attr, armor: cArmor, hpLeft: cHp);

                if (canKill && cHp > 0)
                {
                    (double x, double y, double z) = heroData.getHeroPosition(CurrentTick + 6, heroID);
                    overlay.CreepLowEnough();
                    double dis  = Int32.MaxValue;
                    double temp = Math.Pow((Math.Pow(x - c.x, 2) + Math.Pow(y - c.y, 2)), 0.5);

                    if (temp < dis)
                    {
                        creepX.Add(c.x - x);
                        creepY.Add(c.y - y);
                    }
                }
            }
            overlay.ShowCreep(creepX, creepY);
            overlay.AddHeroGraphIcons(teamIDGraph);
            overlay.AddHPs(hpToSend, maxHpToSend);
            overlay.AddHp(hpToSend[0]);

            // The health at the start of the game is 0 so the retreat message will show up
            // TODO: logic
            if (shouldRetreat && health != 0)
            {
                overlay.AddRetreatMessage("Low health warning! " + "Current Health: " + health, "exclamation_mark");
            }
            else
            {
                overlay.ClearRetreat();
            }
        }
Exemple #3
0
        /*
         * This function is to logic of what to draw in selection mode.
         */
        private void HandleHeroSelection()
        {
            for (int i = 0; i < 30; i++)
            {
                if (table[i, 2] == team_side)
                {
                    teamIDGraph.Add(table[i, 0]);
                    heroID id = new heroID();
                    Dictionary <int, string> id_string = id.getHeroID();
                    string name     = id_string[table[i, 0]];
                    int    index_id = heroIDData.getHeroID(name);
                    if (!teamHeroIds.Contains(index_id))
                    {
                        teamHeroIds.Add(index_id);
                    }
                }
            }
            int ticLast    = 0;
            int ticNext    = Int32.MaxValue;
            int mark_index = 0;
            int index      = 0;

            while (mark_index < 25 && suggestiontable[mark_index, 0] < CurrentTick)
            {
                if (suggestiontable[mark_index, 0] == 0 && suggestiontable[mark_index, 1] == 0)
                {
                    break;
                }
                mark_index++;
            }

            if (mark_index > 0 && mark_index < 25)
            {
                ticNext = suggestiontable[mark_index, 0];
                ticLast = suggestiontable[mark_index - 1, 0];
                index   = mark_index - 1;
            }
            else if (mark_index == 0)
            {
                ticNext = suggestiontable[mark_index, 0];
                ticLast = ticNext;
                index   = mark_index;
            }
            else
            {
                ticNext = suggestiontable[mark_index - 1, 0];
                ticLast = ticNext;
                index   = mark_index - 1;
            }

            string[] heroes    = new string[5];
            string[] heroesimg = new string[5];

            int counter = 0;

            if (CurrentTick > table_checkmark[counter, 0] && CurrentTick < table_checkmark[counter, 1])
            {
                overlay.XorCheck(table_checkmark[counter, 2]);
                index = index - 1;
                counter++;
            }
            else
            {
                overlay.XorCheck(0);
            }

            for (int j = 1; j < 6; j++)
            {
                heroesimg[j - 1] = suggestiontable[index, j].ToString();
                heroes[j - 1]    = ID_table[suggestiontable[index, j]];
            }

            overlay.AddHeroesSuggestionMessage(heroes, heroesimg);
        }