Example #1
0
        private void InitializeEnemies(bool reset)
        {
            if (reset)
            {
                for (int i = 0; i < enemyCount - 1; i++)
                {
                    if (onUpdate.Contains(enemy[i].Update))
                    {
                        onUpdate.Remove(enemy[i].Update);
                    }
                }
            }
            enemy   = new Drawable[enemyCount];
            enemyAI = new cEnemyAI[enemyCount];

            for (int i = 0; i < enemyCount; i++)
            {
                enemy[i]       = new Drawable();
                enemy[i].color = ConsoleColor.Red;
                Utils.Point enemyPos = Utils.Point.GetRandomPointInWorldAwayFromPlayer();
                enemy[i].pos.xPos = enemyPos.X;
                enemy[i].pos.yPos = enemyPos.Y;

                var r = rng.NextDouble();
                if (r < 0.25)
                {
                    r = rng.NextDouble();

                    if (r < 0.6 - Math.Max(-0.6, pcStats.level * -0.01))
                    {
                        enemy[i].texture = 'e';
                        enemy[i].tag     = "Enemy";
                        enemy[i].active  = true;
                        enemyAI[i]       = new cEnemyAI(player, pcStats, enemyPos, "Rats",
                                                        40 + (pcStats.level * 2), 10 + pcStats.level, 5, 6 + (pcStats.level / 10), 1.5, 0.10);
                        enemy[i].AddComponent(enemyAI[i]);
                        onUpdate.Add(enemy[i].Update);
                    }
                    else
                    {
                        enemy[i].texture = 'E';
                        enemy[i].tag     = "Enemy";
                        enemy[i].active  = true;
                        enemyAI[i]       = new cEnemyAI(player, pcStats, enemyPos, "Skeleton",
                                                        75 + (pcStats.level * 5), 20 + (pcStats.level * 2), 10, 4 + (pcStats.level / 10), 1.5, 0.25);
                        enemy[i].AddComponent(enemyAI[i]);
                        onUpdate.Add(enemy[i].Update);
                    }
                }
                else
                {
                    r = rng.NextDouble();

                    if (r < 0.6 - Math.Max(-0.6, pcStats.level * -0.01))
                    {
                        enemy[i].texture = 's';
                        enemy[i].tag     = "Enemy";
                        enemy[i].active  = true;
                        enemyAI[i]       = new cEnemyAI(player, pcStats, enemyPos, "Hornet",
                                                        20 + (pcStats.level * 1), 4 + pcStats.level, 1, 6 + (pcStats.level / 10), 3, 0.10);
                        enemy[i].AddComponent(enemyAI[i]);
                        onUpdate.Add(enemy[i].Update);
                    }
                    else
                    {
                        enemy[i].texture = 'S';
                        enemy[i].tag     = "Enemy";
                        enemy[i].active  = true;
                        enemyAI[i]       = new cEnemyAI(player, pcStats, enemyPos, "Archer",
                                                        40 + (pcStats.level * 5), 8 + (pcStats.level * 2), 1, 4 + (pcStats.level / 10), 4.5, 0.25);
                        enemy[i].AddComponent(enemyAI[i]);
                        onUpdate.Add(enemy[i].Update);
                    }
                }
            }
        }