Esempio n. 1
0
        public override void Initialise()
        {
            if (!initialised)
            {
                roomTrapType = (TrapType)(Utility.Instance.cRand.NextDouble() * (int)TrapType.MAX_TRAPS);
                Console.WriteLine("Trap type: " + roomTrapType.ToString());

                if (!defeated)
                {
                    double enemyBuffChance = Utility.Instance.cRand.NextDouble();
                    int numMonsters = (int)(Utility.Instance.cRand.NextDouble() * maxMonsters);
                    if (roomTrapType == TrapType.INCR_NUM_ENEMIES)
                    {
                        numMonsters *= 2;
                    }
                    else if (roomTrapType == TrapType.DECR_NUM_ENEMIES)
                    {
                        numMonsters = numMonsters == 0 ? 1 : numMonsters / 2;
                    }

                    if (numMonsters == 0)
                    {
                        numMonsters = 1;
                    }

                    for (int i = 0; i < numMonsters; ++i)
                    {
                        //increased values
                        Enemy t = null;
                        double typeChance = Utility.Instance.cRand.NextDouble();

                        //pursuer
                        if (typeChance >= 0 && typeChance < 0.2)
                        {
                            t = new Pursuer(new Vector2((float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenWidth - 500)), (float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenHeight - 500))), new Vector2(32), Color.Yellow);
                        }
                        else if (typeChance >= 0.2 && typeChance < 0.4)
                        {
                            t = new PursuingShooter(new Vector2((float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenWidth - 500)), (float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenHeight - 500))), new Vector2(32), Color.Yellow);
                        }
                        else if (typeChance >= 0.4 && typeChance < 0.6)
                        {
                            t = new Avoider(new Vector2((float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenWidth - 500)), (float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenHeight - 500))), new Vector2(32), Color.Yellow);
                        }
                        else if (typeChance >= 0.6 && typeChance < 0.8)
                        {
                            t = new EvadingShooter(new Vector2((float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenWidth - 500)), (float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenHeight - 500))), new Vector2(32), Color.Yellow);
                        }
                        else if (typeChance >= 0.8 && typeChance < 1)
                        {
                            t = new Shooter(new Vector2((float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenWidth - 500)), (float)(250 + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenHeight - 500))), new Vector2(32), Color.Yellow);
                        }

                        if (enemyBuffChance > 0.5)
                        {
            #if DEBUG
                            enemyBuffed = true;
            #endif
                            Console.WriteLine("ENEMY GETS BUFFED");
                            switch (roomTrapType)
                            {
                                case TrapType.INCR_ATTACK_DAMAGE:
                                    t.IncreaseAttackDamage();
                                    t.IncreaseAttackDamage();
                                    t.IncreaseAttackDamage();
                                    break;
                                case TrapType.INCR_ATTACK_SPEED:
                                    t.IncreaseAttackSpeed();
                                    t.IncreaseAttackSpeed();
                                    t.IncreaseAttackSpeed();
                                    break;
                                case TrapType.INCR_BULLET_SIZE:
                                    t.IncreaseBulletSize();
                                    t.IncreaseBulletSize();
                                    t.IncreaseBulletSize();
                                    break;
                                case TrapType.INCR_MOVEMENT_SPEED:
                                    t.IncreaseMovementSpeed();
                                    t.IncreaseMovementSpeed();
                                    t.IncreaseMovementSpeed();
                                    break;
                                case TrapType.INCR_HEALTH:
                                    t.IncreaseMaxHealth();
                                    t.IncreaseMaxHealth();
                                    break;
                                default: break;
                            }
                        }

                        Console.WriteLine("Adding: " + t.GetType().ToString());
                        enemies.Add(t);
                    }

                    //player gets buffed instead
                    if (enemyBuffChance <= 0.5)
                    {
            #if DEBUG
                        enemyBuffed = false;
            #endif
                        Console.WriteLine("PLAYER GETS BUFFED");
                        Dungeon.GetPlayer.SaveStats();
                        switch (roomTrapType)
                        {
                            case TrapType.INCR_ATTACK_DAMAGE:
                                Dungeon.GetPlayer.IncreaseAttackDamage();
                                Dungeon.GetPlayer.IncreaseAttackDamage();
                                Dungeon.GetPlayer.IncreaseAttackDamage();
                                break;
                            case TrapType.INCR_ATTACK_SPEED:
                                Dungeon.GetPlayer.IncreaseAttackSpeed();
                                Dungeon.GetPlayer.IncreaseAttackSpeed();
                                Dungeon.GetPlayer.IncreaseAttackSpeed();
                                break;
                            case TrapType.INCR_BULLET_SIZE:
                                Dungeon.GetPlayer.IncreaseBulletSize();
                                Dungeon.GetPlayer.IncreaseBulletSize();
                                Dungeon.GetPlayer.IncreaseBulletSize();
                                break;
                            case TrapType.INCR_MOVEMENT_SPEED:
                                Dungeon.GetPlayer.IncreaseMovementSpeed();
                                Dungeon.GetPlayer.IncreaseMovementSpeed();
                                Dungeon.GetPlayer.IncreaseMovementSpeed();
                                break;
                            case TrapType.INCR_HEALTH:
                                Dungeon.GetPlayer.IncreaseMaxHealth();
                                Dungeon.GetPlayer.IncreaseMaxHealth();
                                break;
                            default: break;
                        }
                    }
                }
            }

            base.Initialise();
        }
Esempio n. 2
0
        public MonsterRoom(int a_X, int a_Y, int[] a_Connections)
            : base(a_X, a_Y)
        {
            enemiesLeft = new OnScreenText("Enemies left: ", Vector2.Zero, Color.Black, Color.White, Utility.Instance.LabelsFont);
            defeated = false;
            roomType = PreRoomType.MONSTER;
            int counter = 0;
            foreach (int n in a_Connections)
            {
                connections[counter] = n;
                counter++;
            }

            name = "Monster";
            colour = Color.Red;

            int numEnemies = 1 + (int)(Utility.Instance.cRand.NextDouble() * (maxEnemies - 1));
            for (int i = 0; i < numEnemies; ++i)
            {
                Vector2 randPos = new Vector2((float)(Utility.Instance.ScreenWidth * 0.25f + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenWidth * 0.75f - Utility.Instance.ScreenWidth * 0.25f)),
                                              (float)(Utility.Instance.ScreenHeight * 0.25f + Utility.Instance.cRand.NextDouble() * (Utility.Instance.ScreenHeight * 0.75f - Utility.Instance.ScreenHeight * 0.25f)));
                float dimensions = 20;
                Enemy t = null;

                double typeChance = Utility.Instance.cRand.NextDouble();

                if (typeChance >= 0 && typeChance < 0.2)
                {
                    t = new Pursuer(randPos, new Vector2(dimensions), Color.DarkGreen);
                }
                else if (typeChance >= 0.2 && typeChance < 0.4)
                {
                    t = new PursuingShooter(randPos, new Vector2(dimensions), Color.DeepSkyBlue);
                }
                else if (typeChance >= 0.4 && typeChance < 0.6)
                {
                    t = new Avoider(randPos, new Vector2(dimensions), Color.HotPink);
                }
                else if (typeChance >= 0.6 && typeChance < 0.8)
                {
                    t = new EvadingShooter(randPos, new Vector2(dimensions), Color.LightYellow);
                }
                else
                {
                    t = new Shooter(randPos, new Vector2(dimensions), Color.SpringGreen);
                }

                if (t != null)
                {
                    Console.WriteLine(t.GetType().ToString());
                    enemies.Add(t);
                }
            }

            textToDisplay.ChangeDisplayedText("Kill everything first, then you can leave.");
        }