Beispiel #1
0
        ///////// Cal if need defend

        public List <Location> AttPath(LavaGiant ene)
        {
            List <Location> AttackPath = new List <Location>();
            Location        start      = ene.GetLocation();

            AttackPath.Add(start);
            while (!start.InRange(game.GetMyCastle(), game.LavaGiantAttackRange + game.GetMyCastle().Size))
            {
                start = start.Towards(game.GetMyCastle(), game.LavaGiantMaxSpeed);
                AttackPath.Add(start);
            }
            return(AttackPath);
        }
Beispiel #2
0
        public IceTroll Closest_IceTroll_to_Lava(IceTroll[] f, LavaGiant w, Game game)
        {
            IceTroll closest = null;

            if (f.Length != 0)
            {
                closest = f[0];
                foreach (var p in f)
                {
                    if (w.Distance(p) < closest.Distance(p))
                    {
                        closest = p;
                    }
                }
            }
            return(closest);
        }
Beispiel #3
0
        public bool DefTurn(LavaGiant giant, Portal defn)
        {
            Location        ice    = defn.Location;
            List <Location> Attp   = AttPath(giant);
            int             hplava = giant.CurrentHealth;


            if (game.GetMyIceTrolls().Length == 0)
            {
                for (int i = 0; i < Attp.Count; i++)
                {
                    if (i <= game.IceTrollSummoningDuration - 1)
                    {
                    }
                    else if (!ice.InRange(Attp[i], game.IceTrollAttackRange))
                    {
                        ice = ice.Towards(Attp[i], game.IceTrollMaxSpeed);
                    }
                    else
                    {
                        hplava = hplava - game.IceTrollAttackMultiplier;
                    }

                    hplava = hplava - giant.SuffocationPerTurn;
                }
                if (hplava != 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                //////////// Backup

                /// Trolls Info
                Dictionary <int, Location> troll_loc = new Dictionary <int, Location>();
                Dictionary <int, int>      troll_hp  = new Dictionary <int, int>();
                Dictionary <int, bool>     troll_act = new Dictionary <int, bool>();
                foreach (IceTroll againt in game.GetMyIceTrolls())
                {
                    troll_hp.Add(againt.Id, againt.CurrentHealth);
                    troll_loc.Add(againt.Id, againt.GetLocation());
                    troll_act.Add(againt.Id, false);
                }

                /// Lava Info
                Dictionary <int, Location> lava_loc = new Dictionary <int, Location>();
                Dictionary <int, int>      lava_hp  = new Dictionary <int, int>();
                foreach (LavaGiant againt in game.GetMyLavaGiants())
                {
                    lava_hp.Add(againt.Id, againt.CurrentHealth);
                    lava_loc.Add(againt.Id, againt.GetLocation());
                }

                /// Tornado Info
                Dictionary <int, Location> tornado_loc = new Dictionary <int, Location>();
                Dictionary <int, int>      tornado_hp  = new Dictionary <int, int>();
                foreach (Tornado againt in game.GetMyTornadoes())
                {
                    tornado_hp.Add(againt.Id, againt.CurrentHealth);
                    tornado_loc.Add(againt.Id, againt.GetLocation());
                }

                int counter = 1;
                /// Buildings Info
                Dictionary <int, Location> buildings_loc = new Dictionary <int, Location>();
                Dictionary <int, int>      buildings_hp  = new Dictionary <int, int>();
                foreach (Building againt in game.GetMyManaFountains())
                {
                    buildings_hp.Add(counter, againt.CurrentHealth);
                    buildings_loc.Add(counter, againt.GetLocation());
                    counter++;
                }
                counter = -1;
                foreach (Building againt in game.GetMyPortals())
                {
                    buildings_hp.Add(counter, againt.CurrentHealth);
                    buildings_loc.Add(counter, againt.GetLocation());
                    counter--;
                }

                /// Enemy Lava Info
                Dictionary <int, Location> lava_enemy_loc = new Dictionary <int, Location>();
                Dictionary <int, int>      lava_enemy_hp  = new Dictionary <int, int>();
                foreach (LavaGiant againt in game.GetEnemyLavaGiants())
                {
                    lava_enemy_hp.Add(againt.Id, againt.CurrentHealth);
                    lava_enemy_loc.Add(againt.Id, againt.GetLocation());
                }

                /// Enemy Troll Info
                Dictionary <int, Location> troll_enemy_loc = new Dictionary <int, Location>();
                Dictionary <int, int>      troll_enemy_hp  = new Dictionary <int, int>();
                Dictionary <int, bool>     troll_enemy_act = new Dictionary <int, bool>();
                foreach (IceTroll againt in game.GetEnemyIceTrolls())
                {
                    troll_enemy_hp.Add(againt.Id, againt.CurrentHealth);
                    troll_enemy_loc.Add(againt.Id, againt.GetLocation());
                    troll_enemy_act.Add(againt.Id, false);
                }

                /// Enemy Tornado Info
                Dictionary <int, Location> tornado_enemy_loc = new Dictionary <int, Location>();
                Dictionary <int, int>      tornado_enemy_hp  = new Dictionary <int, int>();
                foreach (Tornado againt in game.GetEnemyTornadoes())
                {
                    tornado_enemy_hp.Add(againt.Id, againt.CurrentHealth);
                    tornado_enemy_loc.Add(againt.Id, againt.GetLocation());
                }

                counter = 1;

                /// Enemy Buildings Info
                Dictionary <int, Location> buildings_enemy_loc = new Dictionary <int, Location>();
                Dictionary <int, int>      buildings_enemy_hp  = new Dictionary <int, int>();
                foreach (Building againt in game.GetEnemyManaFountains())
                {
                    buildings_enemy_hp.Add(counter, againt.CurrentHealth);
                    buildings_enemy_loc.Add(counter, againt.GetLocation());
                    counter++;
                }
                counter = -1;
                foreach (Building againt in game.GetEnemyPortals())
                {
                    buildings_enemy_hp.Add(counter, againt.CurrentHealth);
                    buildings_enemy_loc.Add(counter, againt.GetLocation());
                    counter--;
                }

                // No BackUp Check
                for (int j = 0; j < Attp.Count; j++)
                {
                    ///// HitCheck
                    HitCheck(troll_loc, troll_hp, troll_enemy_loc, troll_enemy_hp, lava_enemy_loc, lava_enemy_hp, lava_loc, lava_hp, troll_act, troll_enemy_act, tornado_enemy_loc, tornado_enemy_hp, tornado_loc, tornado_hp);

                    Dictionary <int, int>      troll_enemy_hp_old    = new Dictionary <int, int>(troll_enemy_hp);
                    Dictionary <int, Location> troll_enemy_loc_old   = new Dictionary <int, Location>(troll_enemy_loc);
                    Dictionary <int, Location> lava_enemy_loc_old    = new Dictionary <int, Location>(lava_enemy_loc);
                    Dictionary <int, int>      lava_enemy_hp_old     = new Dictionary <int, int>(lava_enemy_hp);
                    Dictionary <int, Location> tornado_enemy_loc_old = new Dictionary <int, Location>(tornado_enemy_loc);
                    Dictionary <int, int>      tornado_enemy_hp_old  = new Dictionary <int, int>(tornado_enemy_hp);

                    ///// MoveEnemy
                    MoveCheck(troll_enemy_loc, troll_enemy_hp, troll_loc, troll_hp, lava_loc, lava_hp, lava_enemy_loc, lava_enemy_hp, troll_enemy_act, game.GetMyCastle(), tornado_enemy_loc, tornado_enemy_hp, buildings_loc, buildings_hp, tornado_loc, tornado_hp);

                    ///// MoveMy
                    MoveCheck(troll_loc, troll_hp, troll_enemy_loc_old, troll_enemy_hp_old, lava_enemy_loc_old, lava_enemy_hp_old, lava_loc, lava_hp, troll_act, game.GetEnemyCastle(), tornado_loc, tornado_hp, buildings_enemy_loc, buildings_enemy_hp, tornado_enemy_loc_old, tornado_enemy_hp_old);

                    ResetTurn(troll_enemy_act); // Prep For Next Turn
                    ResetTurn(troll_act);       // Prep For Next Turn
                }

                bool nobackup = false;

                foreach (var item in lava_enemy_loc)
                {
                    if (item.Value.InRange(game.GetMyCastle(), game.LavaGiantAttackRange + game.GetMyCastle().Size) && lava_enemy_hp[item.Key] > 3)
                    {
                        nobackup = true;
                    }
                }

                if (nobackup)
                {
                    lava_enemy_hp.Clear();
                    lava_enemy_loc.Clear();
                    foreach (LavaGiant againt in game.GetEnemyLavaGiants())
                    {
                        lava_enemy_hp.Add(againt.Id, againt.CurrentHealth);
                        lava_enemy_loc.Add(againt.Id, againt.GetLocation());
                    }

                    troll_hp.Clear();
                    troll_loc.Clear();
                    foreach (IceTroll againt in game.GetMyIceTrolls())
                    {
                        troll_hp.Add(againt.Id, againt.CurrentHealth);
                        troll_loc.Add(againt.Id, againt.GetLocation());
                    }

                    troll_enemy_hp.Clear();
                    troll_enemy_loc.Clear();
                    foreach (IceTroll againt in game.GetEnemyIceTrolls())
                    {
                        troll_enemy_hp.Add(againt.Id, againt.CurrentHealth);
                        troll_enemy_loc.Add(againt.Id, againt.GetLocation());
                    }

                    lava_hp.Clear();
                    lava_loc.Clear();
                    foreach (LavaGiant againt in game.GetMyLavaGiants())
                    {
                        lava_hp.Add(againt.Id, againt.CurrentHealth);
                        lava_loc.Add(againt.Id, againt.GetLocation());
                    }

                    tornado_enemy_hp.Clear();
                    tornado_enemy_loc.Clear();
                    foreach (Tornado againt in game.GetEnemyTornadoes())
                    {
                        tornado_enemy_hp.Add(againt.Id, againt.CurrentHealth);
                        tornado_enemy_loc.Add(againt.Id, againt.GetLocation());
                    }

                    tornado_hp.Clear();
                    tornado_loc.Clear();
                    foreach (Tornado againt in game.GetMyTornadoes())
                    {
                        tornado_hp.Add(againt.Id, againt.CurrentHealth);
                        tornado_loc.Add(againt.Id, againt.GetLocation());
                    }

                    buildings_enemy_hp.Clear();
                    buildings_enemy_loc.Clear();
                    counter = 1;
                    foreach (Building againt in game.GetEnemyManaFountains())
                    {
                        buildings_enemy_hp.Add(counter, againt.CurrentHealth);
                        buildings_enemy_loc.Add(counter, againt.GetLocation());
                        counter++;
                    }
                    counter = -1;
                    foreach (Building againt in game.GetEnemyPortals())
                    {
                        buildings_enemy_hp.Add(counter, againt.CurrentHealth);
                        buildings_enemy_loc.Add(counter, againt.GetLocation());
                        counter--;
                    }

                    buildings_hp.Clear();
                    buildings_loc.Clear();
                    counter = 1;
                    foreach (Building againt in game.GetMyManaFountains())
                    {
                        buildings_hp.Add(counter, againt.CurrentHealth);
                        buildings_loc.Add(counter, againt.GetLocation());
                        counter++;
                    }
                    counter = -1;
                    foreach (Building againt in game.GetMyPortals())
                    {
                        buildings_hp.Add(counter, againt.CurrentHealth);
                        buildings_loc.Add(counter, againt.GetLocation());
                        counter--;
                    }



                    ResetTurn(troll_enemy_act);
                    ResetTurn(troll_act);


                    for (int j = 0; j < Attp.Count; j++)
                    {
                        if (j == game.IceTrollSummoningDuration - 1)
                        {
                            troll_hp.Add(555, game.IceTrollMaxHealth);
                            troll_loc.Add(555, DefPortal.GetLocation());
                            troll_act.Add(555, false);
                        }

                        ///// HitCheck
                        HitCheck(troll_loc, troll_hp, troll_enemy_loc, troll_enemy_hp, lava_enemy_loc, lava_enemy_hp, lava_loc, lava_hp, troll_act, troll_enemy_act, tornado_enemy_loc, tornado_enemy_hp, tornado_loc, tornado_hp);

                        Dictionary <int, int>      troll_enemy_hp_old    = new Dictionary <int, int>(troll_enemy_hp);
                        Dictionary <int, Location> troll_enemy_loc_old   = new Dictionary <int, Location>(troll_enemy_loc);
                        Dictionary <int, Location> lava_enemy_loc_old    = new Dictionary <int, Location>(lava_enemy_loc);
                        Dictionary <int, int>      lava_enemy_hp_old     = new Dictionary <int, int>(lava_enemy_hp);
                        Dictionary <int, Location> tornado_enemy_loc_old = new Dictionary <int, Location>(tornado_enemy_loc);
                        Dictionary <int, int>      tornado_enemy_hp_old  = new Dictionary <int, int>(tornado_enemy_hp);

                        ///// MoveEnemy
                        MoveCheck(troll_enemy_loc, troll_enemy_hp, troll_loc, troll_hp, lava_loc, lava_hp, lava_enemy_loc, lava_enemy_hp, troll_enemy_act, game.GetMyCastle(), tornado_enemy_loc, tornado_enemy_hp, buildings_loc, buildings_hp, tornado_loc, tornado_hp);

                        ///// MoveMy
                        MoveCheck(troll_loc, troll_hp, troll_enemy_loc_old, troll_enemy_hp_old, lava_enemy_loc_old, lava_enemy_hp_old, lava_loc, lava_hp, troll_act, game.GetEnemyCastle(), tornado_loc, tornado_hp, buildings_enemy_loc, buildings_enemy_hp, tornado_enemy_loc_old, tornado_enemy_hp_old);

                        ResetTurn(troll_enemy_act); // Prep For Next Turn
                        ResetTurn(troll_act);       // Prep For Next Turn
                    }

                    foreach (var item in lava_enemy_loc)
                    {
                        if (item.Value.InRange(game.GetMyCastle(), game.LavaGiantAttackRange + game.GetMyCastle().Size) && (lava_enemy_hp[item.Key] < 3 || lava_enemy_hp[item.Key] > 5))
                        {
                            return(true);
                        }
                    }
                }


                /////////////////////////////////////////////////////////////////////////

                IceTroll defend = Closest_IceTroll_to_Lava(game.GetMyIceTrolls(), giant, game);
                Location icetr  = defend.GetLocation();
                int      i      = 0;
                int      hpice  = defend.CurrentHealth;

                while (!ice.InRange(icetr, 100))
                {
                    if (i <= 2)
                    {
                    }
                    else
                    {
                        ice = ice.Towards(icetr, 100);
                    }
                    i++;
                    hpice = hpice - defend.SuffocationPerTurn;
                    if (hpice < 0 && game.GetMyIceTrolls().Length < 4)
                    {
                        return(true);
                    }
                }
                return(false);
            }
        }