Ejemplo n.º 1
0
 void spawnForestCreatures()
 {
     for (int i = 0; i < forestCampCount; i++)
     {
         if (creatures[i] == null || creatures[i].isDead)
         {
             allUnits.Add(creatures[i] = Factories.generateCreature(spawns[i], amplitude[i]));
             amplitude[i] *= 1.2;
         }
     }
 }
Ejemplo n.º 2
0
 void spawnUnits(List <Player> players)
 {
     foreach (Player player in players)
     {
         for (int i = 0; i < Const.MELEE_UNIT_COUNT; i++)
         {
             allUnits.Add(Factories.generateUnit(0, players.IndexOf(player), i, player));
         }
         for (int i = 0; i < Const.RANGED_UNIT_COUNT; i++)
         {
             allUnits.Add(Factories.generateUnit(1, players.IndexOf(player), round / Const.SPAWNRATE % 3, player));
         }
     }
 }
        public static List <Bush> generateBushes(CreatureSpawn[] spawns)
        {
            List <Bush> obstacles = new List <Bush>();
            // bushes below the lane
            int posX            = 50;
            int bottomBushCount = (int)(Const.random.NextDouble() * 4 + 1);

            for (int i = 0; i < bottomBushCount; i++)
            {
                posX = (int)(Const.random.NextDouble() * ((910 - posX) / (bottomBushCount - i)) + posX);
                if (posX > 910)
                {
                    break;
                }
                obstacles.Add(Factories.generateBush(new Point(posX, 720)));
                obstacles.Add(Factories.generateBush(new Point(1920 - posX, 720)));
                posX += 100;
            }

            // bushes above the lane
            posX            = 50;
            bottomBushCount = (int)(Const.random.NextDouble() * 2 + 2);
            for (int i = 0; i < bottomBushCount; i++)
            {
                posX = (int)(Const.random.NextDouble() * ((910 - posX) / (bottomBushCount - i)) + posX);
                if (posX > 910)
                {
                    break;
                }
                obstacles.Add(Factories.generateBush(new Point(posX, 380)));
                obstacles.Add(Factories.generateBush(new Point(1920 - posX, 380)));
                posX += 100;
            }

            int extraBushes = (spawns.Length);

            for (int i = 0; i < extraBushes; i++)
            {
                int posY = (int)spawns[i].y;
                posX = (int)spawns[i].x;
                spawnExtraBushes(posX - 150, posY - 150, posX + 150, posY + 150, obstacles);
            }

            extraBushes = (int)(Const.random.NextDouble() * 4);
            for (int i = 0; i < extraBushes; i++)
            {
                spawnExtraBushes(Const.MAPWIDTH / 2 - 300, 50, Const.MAPWIDTH / 2 + 300, 300, obstacles);
            }
            return(obstacles);
        }
        static void spawnExtraBushes(int startX, int startY, int endX, int endY, List <Bush> bushes)
        {
            for (int i = 0; i < 10; i++)
            {
                int posX = (int)(Const.random.NextDouble() * (endX - startX) + startX);
                int posY = (int)(Const.random.NextDouble() * (endY - startY) + startY);
                if (posX < Const.BUSHRADIUS ||
                    posY < Const.BUSHRADIUS ||
                    posX > Const.MAPWIDTH - Const.BUSHRADIUS ||
                    posY > Const.MAPHEIGHT - Const.BUSHRADIUS)
                {
                    continue;
                }
                Point newBush       = new Point(posX, posY);
                bool  isOverlapping = false;
                foreach (Bush bush in bushes)
                {
                    if (bush.Distance(newBush) <= bush.radius * 2)
                    {
                        isOverlapping = true;
                    }
                }

                if (!isOverlapping)
                {
                    if (Math.Abs(posX - center) < Const.BUSHRADIUS)
                    {
                        bushes.Add(Factories.generateBush(new Point(center, posY)));
                    }
                    else
                    {
                        bushes.Add(Factories.generateBush(new Point(posX, posY)));
                        bushes.Add(Factories.generateBush(new Point(1920 - posX, posY)));
                    }
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        private void pickHero(Player player)
        {
            string output = "";

            try
            {
                Point spawn = player.getIndex() == 0 ? (player.heroes.Count == 0 ? Const.HEROSPAWNTEAM0 : Const.HEROSPAWNTEAM0HERO2) : (player.heroes.Count == 0 ? Const.HEROSPAWNTEAM1 : Const.HEROSPAWNTEAM1HERO2);
                output = player.getOutputs(1)[0];
                if (player.heroes.Count > 0 && player.heroes[0].heroType == output)
                {
                    player.setScore(LostScore);
                    player.deactivate(player.getNicknameToken() + " tried to pick a hero already owned. Can't have duplicate hero.");
                    gameManager.addToGameSummary(player.getNicknameToken() + " tried to pick a hero already owned. Can't have duplicate hero.");
                    return;
                }
                else
                {
                    Hero hero = Factories.generateHero(output, player, spawn);
                    player.addHero(hero);
                    Const.game.allUnits.Add(hero);
                }
            }
            catch (Exception e)
            {
                player.setScore(LostScore);
                string msg;
                if (e is TimeoutException)
                {
                    msg = " timeout";
                }
                else
                {
                    msg = " supplied invalid input. " + e.Message;
                }
                player.deactivate(player.getNicknameToken() + msg);
            }
        }
Ejemplo n.º 6
0
 internal void initialize(List <Player> players)
 {
     setupGame(players);
     items = Factories.createItems(setupGold(players));
 }