Ejemplo n.º 1
0
        private void GameLoop(object sender, EventArgs e)
        {
            HighScore += ScoreForTick;
            if (Enemies.Any(enemy => CollisionDetector.AreCollided(Batwing, enemy)))
            {
                timer.Stop();
                renderer.ShowEndGameScreen(HighScore);
                return;
            }

            renderer.Clear();
            renderer.Draw(Batwing);

            if (rand.Next(100) < SpawnEnemyChange)
            {
                var enemy = enemiesFactory.Get(renderer.ScreenWidth, rand.Next(renderer.ScreenHeight));
                Enemies.Add(enemy);
                GameObjects.Add(enemy);
            }

            KillEnemiesIfColliding();

            HighScore += Enemies.Count(enemy => !enemy.IsAlive) * ScoreForKill;
            RemoveNotAliveGameObjects();
            UpdateObjectsPositions();
            DrawGameObjects();
        }
Ejemplo n.º 2
0
 public void PlayGame()
 {
     while (keepPlaying == true)
     {
         while (this.PlayerDude.IsAlive && Enemies.Count() > 0)
         {
             DisplayCombatInfo();
             this.PlayerDude.Attack(this.BadGuy);
             foreach (var baddie in Enemies)
             {
                 baddie.Attack(this.PlayerDude);
             }
         }
         if (this.PlayerDude.IsAlive)
         {
             Console.WriteLine("You Win!!");
             PlayAgain();
         }
         else if (this.BadGuy.IsAlive)
         {
             Console.WriteLine("You Lose");
             PlayAgain();
         }
     }
 }
Ejemplo n.º 3
0
        private void updateDifficulty()
        {
            switch (Enemies.Count())
            {
            case 6: Level = 8; break;

            case 3: Level = 9; break;
            }
        }
Ejemplo n.º 4
0
        public void AttackEnemy()
        {
            int attackedEnemy = random.Next(0, Enemies.Count());

            Enemy = Enemies[attackedEnemy];

            if (Enemy.Active != false)
            {
                WarProcess();
            }
        }
Ejemplo n.º 5
0
 public static int EnemiesInRange(this GameObject unit, int range)
 {
     try
     {
         return(Enemies.Count() > 1 ? Enemies.Count(u => u.Distance(unit) <= range && u.IsValid) : 0);
     }
     catch (Exception e)
     {
         Logger.KefkaLog(e.ToString());
         throw;
     }
 }
Ejemplo n.º 6
0
        private static UltTarget GetBestUltTarget()
        {
            var possibleAllies = Allies.Where(o => SpellManager.R.IsInRange(o));

            Obj_AI_Hero bestAlly   = null;
            var         allyCount  = 0;
            var         enemyCount = 0;
            var         allies     = new List <Obj_AI_Hero>();

            foreach (var ally in possibleAllies)
            {
                if (!ally.IsMe && !Menu.Item("R" + ally.ChampionName).IsActive())
                {
                    continue;
                }

                var alliesInRange =
                    Allies.Where(
                        o =>
                        !ally.Equals(o) && ally.Distance(o) <= UltimateRadius &&
                        o.HealthPercent <
                        (o.IsMe
                                ? Menu.Item("RSelf").GetValue <Slider>().Value
                                : Menu.Item("RHP" + o.ChampionName).GetValue <Slider>().Value));
                var count = alliesInRange.Count();
                if (count < MinAllies)
                {
                    continue;
                }
                Console.WriteLine("ALLIES IN RANGE: {0}/{1}", count, MinAllies);
                var enemiesInRange = Enemies.Count(o => ally.Distance(o) <= UltimateRadius);

                if (enemiesInRange > MaxEnemies)
                {
                    continue;
                }

                Console.WriteLine("ENEMIES IN RANGE: {0}/{1}", enemiesInRange, MaxEnemies);
                if (count > allyCount || (count == allyCount && enemyCount > enemiesInRange))
                {
                    bestAlly   = ally;
                    allyCount  = count;
                    allies     = alliesInRange.ToList();
                    enemyCount = enemiesInRange;
                }
            }
            return(new UltTarget(bestAlly, allies));
        }
    private void SpawnEnemies()
    {
        float time = Time.time;

        if (time - lastSpawn < SpawnCooldown)
        {
            return;
        }

        lastSpawn = time;
        int roomLeft = MaxTotalEnemies - Enemies.Count();
        int spawn    = Random.Range(0, Math.Min(MaxEnemySpawn, roomLeft) + 1);

        for (var i = 0; i < spawn; i++)
        {
            Enemy enemy = Enemies.Instantiate();
            enemy.transform.position = Helper.RandomRange(groundMin, groundMax) + Vector3.up * 0.8f;
        }
    }
Ejemplo n.º 8
0
    private IEnumerable <Vertex> GetOutline(IEnumerable <Vertex> outline1, IEnumerable <Vertex> outline2)
    {
        testCollider.points = outline1.Select(x => x.Coordinates).ToArray();

        int count1 = Enemies.Count(x => testCollider.OverlapPoint(x.CurrentCell.Coordinates));

        testCollider.points = outline2.Select(x => x.Coordinates).ToArray();

        int count2 = Enemies.Count(x => testCollider.OverlapPoint(x.CurrentCell.Coordinates));

        if (count1 > count2)
        {
            return(outline1);
        }

        if (count2 > count1)
        {
            return(outline2);
        }

        testCollider.points = outline1.Select(x => x.Coordinates).ToArray();

        count1 = _cells.Cast <Cell>().Count(x => testCollider.OverlapPoint(x.Coordinates));

        testCollider.points = outline2.Select(x => x.Coordinates).ToArray();

        count2 = _cells.Cast <Cell>().Count(x => testCollider.OverlapPoint(x.Coordinates));

        if (count1 > count2)
        {
            return(outline1);
        }

        if (count2 > count1)
        {
            return(outline2);
        }

        return(outline1);
    }
Ejemplo n.º 9
0
    public void Step()
    {
        if (_finished)
        {
            return;
        }

        var containsPlayer = Bounds.Contains(Player.transform.position);

        if (!_activated && containsPlayer)
        {
            _enemyCounter.SetVisible(true);
            Activate();
        }
        else if (_activated && !containsPlayer)
        {
            _enemyCounter.SetVisible(false);
            DeActivateAI();
        }
        else if (_activated && containsPlayer)
        {
            foreach (var enemy in Enemies)
            {
                enemy.CanMove   = true;
                enemy.CanSearch = true;
            }
            _roomEvents.ActiveRoom = this;
            _enemyCounter.SetVisible(true);
            _enemyCounter.SetTally(Enemies.Count(e => e.gameObject.activeSelf), Enemies.Count);
        }

        if (_activated && (!Enemies.Any(i => i.gameObject.activeSelf)))
        {
            _enemyCounter.SetVisible(false);
            OpenDoors();
        }
    }
Ejemplo n.º 10
0
        protected override void LoadContent()
        {
            base.LoadContent();
            ContentManager Content = Game.Content;


            textSprite = Game.Content.Load <Texture2D>(@"Images/textBox");
            font       = Game.Content.Load <SpriteFont>(@"Fonts/ControlFont");


            Background = new PictureBox(
                Content.Load <Texture2D>(@"Backgrounds\CombatBackground"),
                GameRef.ScreenRectangle);
            ControlManager.Add(Background);

            Texture2D arrow = Content.Load <Texture2D>(@"GUI\leftarrowUp");

            ArrowTexture = new PictureBox(
                arrow,
                new Rectangle(0, 0, arrow.Width, arrow.Height));
            ControlManager.Add(ArrowTexture);

            enemyBackground = new PictureBox(
                Enemies[0].image,
                new Rectangle(250, 250,
                              Enemies[0].image.Width * 3, Enemies[0].image.Height * 3));
            ControlManager.Add(enemyBackground);

            EnemyName          = new Label();
            EnemyName.Text     = Enemies[0].name;
            EnemyName.Position = new Vector2(250, 220);
            ControlManager.Add(EnemyName);

            EnemyHealthLabel          = new Label();
            EnemyHealthLabel.Text     = "Health:";
            EnemyHealthLabel.Position = new Vector2(250, 440);
            EnemyHealthLabel.Size     = EnemyHealthLabel.SpriteFont.MeasureString(EnemyHealthLabel.Text);
            ControlManager.Add(EnemyHealthLabel);

            EnemyHealth          = new Label();
            EnemyHealth.Position = new Vector2(250 + EnemyHealthLabel.Size.X, 440);
            EnemyHealth.Text     = Enemies[0].CurrentHP.ToString();
            ControlManager.Add(EnemyHealth);

            EnemyLevelLabel          = new Label();
            EnemyLevelLabel.Text     = "Level: ";
            EnemyLevelLabel.Size     = EnemyLevelLabel.SpriteFont.MeasureString(EnemyLevelLabel.Text);
            EnemyLevelLabel.Position = new Vector2(250, 465);
            ControlManager.Add(EnemyLevelLabel);

            EnemyLevel          = new Label();
            EnemyLevel.Text     = Enemies[0].Level.ToString();
            EnemyLevel.Position = new Vector2(250 + EnemyLevelLabel.Size.X, 465);
            ControlManager.Add(EnemyLevel);

            if (Enemies.Count() > 1)
            {
                SecondEnemyBackground = new PictureBox(
                    Enemies[1].image,
                    new Rectangle(600, 250,
                                  Enemies[1].image.Width * 3, Enemies[1].image.Height * 3));
                ControlManager.Add(SecondEnemyBackground);

                SecondEnemyName          = new Label();
                SecondEnemyName.Text     = Enemies[1].name;
                SecondEnemyName.Position = new Vector2(600, 220);
                ControlManager.Add(SecondEnemyName);

                SecondEnemyHealthLabel          = new Label();
                SecondEnemyHealthLabel.Text     = "Health:";
                SecondEnemyHealthLabel.Position = new Vector2(600, 440);
                SecondEnemyHealthLabel.Size     = EnemyHealthLabel.SpriteFont.MeasureString(EnemyHealthLabel.Text);
                ControlManager.Add(SecondEnemyHealthLabel);

                SecondEnemyHealth          = new Label();
                SecondEnemyHealth.Position = new Vector2(600 + EnemyHealthLabel.Size.X, 440);
                SecondEnemyHealth.Text     = Enemies[1].CurrentHP.ToString();
                ControlManager.Add(SecondEnemyHealth);

                SecondEnemyLevelLabel          = new Label();
                SecondEnemyLevelLabel.Text     = "Level: ";
                SecondEnemyLevelLabel.Size     = EnemyLevelLabel.SpriteFont.MeasureString(EnemyLevelLabel.Text);
                SecondEnemyLevelLabel.Position = new Vector2(600, 465);
                ControlManager.Add(SecondEnemyLevelLabel);

                SecondEnemyLevel          = new Label();
                SecondEnemyLevel.Text     = Enemies[1].Level.ToString();
                SecondEnemyLevel.Position = new Vector2(600 + EnemyLevelLabel.Size.X, 465);
                ControlManager.Add(SecondEnemyLevel);
            }


            PlayerName          = new Label();
            PlayerName.Position = new Vector2(300, 800);
            PlayerName.Text     = Player.name;
            ControlManager.Add(PlayerName);

            Label LevelLabel = new Label();

            LevelLabel.Text     = "Level:";
            LevelLabel.Size     = LevelLabel.SpriteFont.MeasureString(LevelLabel.Text);
            LevelLabel.Position = new Vector2(300, 855);
            ControlManager.Add(LevelLabel);

            Label PlayerHealthLabel = new Label();

            PlayerHealthLabel.Text     = "Health:";
            PlayerHealthLabel.Position = new Vector2(300, 830);
            PlayerHealthLabel.Size     = PlayerHealthLabel.SpriteFont.MeasureString(PlayerHealthLabel.Text);
            ControlManager.Add(PlayerHealthLabel);

            PlayerHealth          = new Label();
            PlayerHealth.Position = new Vector2(300 + PlayerHealthLabel.Size.X, 830);
            PlayerHealth.Text     = Player.CurrentHP.ToString();
            ControlManager.Add(PlayerHealth);

            PlayerLevel          = new Label();
            PlayerLevel.Position = new Vector2(300 + LevelLabel.Size.X, 855);
            PlayerLevel.Text     = Player.Level.ToString();
            ControlManager.Add(PlayerLevel);

            Label ManaLabel = new Label();

            ManaLabel.Text     = "Mana: ";
            ManaLabel.Size     = ManaLabel.SpriteFont.MeasureString(ManaLabel.Text);
            ManaLabel.Position = new Vector2(300, 880);
            ControlManager.Add(ManaLabel);

            PlayerMana          = new Label();
            PlayerMana.Position = new Vector2(300 + ManaLabel.Size.X, 880);
            PlayerMana.Text     = Player.CurrentMana.ToString();
            ControlManager.Add(PlayerMana);

            PlayerTurn();
        }
Ejemplo n.º 11
0
        public void HeadsUpDisplay()
        {
            //keeps track of """"""
            string bulletHud = "";
            string moneyHud  = "";
            string badGuy    = null;
            string badGuyHP  = null;
            //indentation count
            int hudReset = 0;

            //cities count and implants status
            //displays current level
            Console.WriteLine("                             Level: {0}\n", levelCounter);



            Console.WriteLine("                    Cities Cleared: {0}", citiesCleared);
            Console.WriteLine("                       Cities Lost: {0}\n", citiesLost);
            Console.ForegroundColor = ConsoleColor.DarkRed;
            for (int i = 0; i < Enemies.Count(); i++)
            {
                badGuy = badGuy + string.Format("{0}.(⌐■_■)  ", i + 1);
                if (Enemies[i].HP <= 0)
                {
                    Enemies[i].HP = 0;
                }
                badGuyHP = badGuyHP + string.Format(" HP: {0}  ", Enemies[i].HP);
                hudReset++;
                if (hudReset == 7)
                {
                    badGuyHP = badGuyHP + "\n";
                    hudReset = 0;
                }
            }
            Console.ForegroundColor = ConsoleColor.DarkCyan;


            //scroll through and ad """"" to bullets hud
            for (int i = 0; i < Players[0].HP; i += 2)
            {
                //add " to string
                bulletHud = bulletHud + "\"";
                //onlhy print 25 per line
                hudReset++;
                if (hudReset == 25)
                {
                    bulletHud = bulletHud + "\n";
                    hudReset  = 0;
                }
            }
            //build money hud
            hudReset = 0;
            for (int i = 0; i < Players[0].Money; i += 2)
            {
                moneyHud = moneyHud + "\"";
                hudReset++;
                if (hudReset == 25)
                {
                    moneyHud = moneyHud + "\n";
                    hudReset = 0;
                }
            }
            hudReset = 0;

            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("Replicants Remaining: " + badGuy);
            Console.WriteLine("Replicant Health    : {0}  ", badGuyHP);

            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("Bullets Left: {0}\n{1}", Players[0].HP, bulletHud);
            Console.WriteLine("Money Left: ${1}\n{0}", moneyHud, Players[0].Money);
        }