Exemplo n.º 1
0
        /// <summary>
        /// Intializes the game creating everything that is needed
        /// </summary>
        /// <param name="Display">The form being drawn on</param>
        public void IntializeGame(Form1 Display)
        {
            Threads.initializeTasks();
            level                  = 1;
            score                  = 0;
            lives                  = 3;
            extraLivesCounter      = 0;
            Utilities.screenBounds = Screen.PrimaryScreen.Bounds;//Display.ClientRectangle;
            Utilities.screenCenter = new Coordinates(Utilities.screenBounds.Width / 2, Utilities.screenBounds.Height / 2);
            isRunning              = true;
            PlayerShip             = new PlayerShip(Utilities.screenBounds.Width / 2, Utilities.screenBounds.Height / 2);
            InGameMeteors          = new List <Meteor>();
            inGameAlienShips       = new List <AlienBase>();
            alienSpawnTimer        = Settings.SpawnTimer;
            ACollision             = new Collisions();
            stateDescription       = "fine";
            needsToExit            = false;

            int x;
            int y;
            int i = 0;

            while (i < Settings.meteorInitAmount)
            {
                //create asteriod away from middle
                x = (Utilities.getRand10() * (Utilities.screenBounds.Width / 10));
                while (x > Utilities.screenBounds.Width / 2 - 300 && x < Utilities.screenBounds.Width / 2 + 300)
                {
                    x = (Utilities.getRand10() * (Utilities.screenBounds.Width / 10));
                }

                y = (Utilities.getRand10() * (Utilities.screenBounds.Height / 10));
                while (y > Utilities.screenBounds.Height / 2 - 300 && y < Utilities.screenBounds.Height / 2 + 300)
                {
                    y = (Utilities.getRand10() * (Utilities.screenBounds.Height / 10));
                }

                InGameMeteors.Add(new Meteor(new Coordinates(x, y),
                                             Settings.meteorStartSize, new Coordinates((Utilities.getRandBase(Settings.meteorSpawnSpeed) - Settings.meteorSpawnSpeed / 2) / (float)10.0,
                                                                                       (Utilities.getRandBase(Settings.meteorSpawnSpeed) - Settings.meteorSpawnSpeed / 2) / (float)10.0)));
                i++;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// initialized the next level
        /// </summary>
        /// <param name="Display">the form on which to operate</param>
        public void InitializeNextLevel(Form Display)
        {
            //GameSounds.CloseSFX();
            //GameSounds.InitializeSFX();
            //Task.WaitAll()

            Threads.initializeTasks();
            InGameMeteors       = new List <Meteor>();
            inGameAlienShips    = new List <AlienBase>();
            alienSpawnTimer     = Settings.SpawnTimer;
            ACollision          = new Collisions();
            PlayerShip          = new PlayerShip(Display.ClientRectangle.Width / 2, Display.ClientRectangle.Height / 2);
            PlayerShip.Position = new Coordinates(Display.ClientRectangle.Width / 2, Display.ClientRectangle.Height / 2);
            Utilities.populateRandPool();

            Settings.chancePool = 160 - level * 10;                         // at level 15 an alien should spawn every time the alien spawner loops
            if (Settings.chancePool <= 10)
            {
                Settings.chancePool = 10;
            }
            Settings.WussRemover = level / 5;                               // at level 35 only the tough aliens will spawn
            if (Settings.WussRemover >= 7)
            {
                Settings.WussRemover = 7;
            }
            int totalMeteorMaterial = 200 + level * 75;

            if (totalMeteorMaterial >= 2100)
            {
                totalMeteorMaterial = 2100;                                 // 10 large asteroids will be the max ever spawned
            }
            Settings.meteorInitAmount = totalMeteorMaterial / 200;
            Settings.meteorStartSize  = totalMeteorMaterial / Settings.meteorInitAmount;
            Settings.meteorSpawnSpeed = 6 + level / 12;                     // every 12 levels meteor speed will increase (can't go over 10)
            if (Settings.meteorSpawnSpeed <= 10)
            {
                Settings.meteorSpawnSpeed = 10;
            }

            int x;
            int y;
            int i = 0;

            while (i < Settings.meteorInitAmount)
            {
                //create asteriod away from middle
                x = (Utilities.getRand10() * (Utilities.screenBounds.Width / 10));
                while (x > Utilities.screenBounds.Width / 2 - 300 && x < Utilities.screenBounds.Width / 2 + 300)
                {
                    x = (Utilities.getRand10() * (Utilities.screenBounds.Width / 10));
                }

                y = (Utilities.getRand10() * (Utilities.screenBounds.Height / 10));
                while (y > Utilities.screenBounds.Height / 2 - 300 && y < Utilities.screenBounds.Height / 2 + 300)
                {
                    y = (Utilities.getRand10() * (Utilities.screenBounds.Height / 10));
                }

                InGameMeteors.Add(new Meteor(new Coordinates(x, y),
                                             Settings.meteorStartSize, new Coordinates((Utilities.getRandBase(Settings.meteorSpawnSpeed) - Settings.meteorSpawnSpeed / 2) / (float)10.0,
                                                                                       (Utilities.getRandBase(Settings.meteorSpawnSpeed) - Settings.meteorSpawnSpeed / 2) / (float)10.0)));
                i++;
            }
        }