示例#1
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            gsm = new GamestateManager();
            //graphics.IsFullScreen = true;
            graphics.PreferredBackBufferHeight = 500;
            graphics.PreferredBackBufferWidth = 900;
            Content.RootDirectory = "Content";
            ExitGame = this;
            ch = new ControlHandler();
            r = new Random();
            p = new Player(ch);
            scores = new Highscores();

            intro = new AsteroidsIntro();
            credit = new Credit();

            screenHeight = graphics.PreferredBackBufferHeight;
            screenWidth = graphics.PreferredBackBufferWidth;
            drawShield = false;
            intersected = false;
            randomized = false;
            shield = new Classes.Perks.ShieldPerk(Content, p);
            speedUp = new Classes.Perks.SpeedUpPerk(Content, p);
            extraLife = new Classes.Perks.ExtraLifePerk(Content, p);
            machineGun = new Classes.Perks.MachineGunPerk(Content, p);
            hud = new HUD(screenWidth, screenHeight, shield);
            pickUp = new Pickup();

            numOfAsteroids = 3;
            currentGameState = 1;
        }
示例#2
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            gsm = new GamestateManager();
            graphics.IsFullScreen = true;
            graphics.PreferredBackBufferHeight = 500;
            graphics.PreferredBackBufferWidth = 900;
            Content.RootDirectory = "Content";
            ExitGame = this;
            ch = new ControlHandler();
            r = new Random();
            p = new Player(ch);
            scores = new Highscores();

            oMenu = new OptionsMenu(graphics, Content);
            intro = new AsteroidsIntro();

            screenHeight = graphics.PreferredBackBufferHeight;
            screenWidth = graphics.PreferredBackBufferWidth;

            numOfAsteroids = 3;
            currentGameState = 1;
        }
示例#3
0
        public void Load(GraphicsDevice graphicsDevice, Highscores scores)
        {
            spriteBatch = new SpriteBatch(graphicsDevice);

            //FontType
            txSelectArrow = Content.Load<Texture2D>("SelectArrow");
            fontType = Content.Load<SpriteFont>("Courier New");
            fontTypeTitle = Content.Load<SpriteFont>("Courier New");

            fontHighscores = Content.Load<SpriteFont>("HighScores");
            velocityHighscores = new Vector2(2f, 2f);
            scoreList = scores.highscores;
            highscores = new string[10];
            highscoreCounter = new int[10];
            for (int i = 0; i < highscores.Length; i++)
            {
                if (scoreList[i].Name != null)
                {
                    highscores[i] = scoreList[i].Name;
                    highscoreCounter[i] = scoreList[i].Score;
                }
                else
                {
                    highscores[i] = "Empty";
                    highscoreCounter[i] = 0;
                }
            }
        }
示例#4
0
        public void Update(GameTime gameTime, HUD hud, Highscores scores, ControlHandler contHand)
        {
            MouseState mouse = Mouse.GetState();
            Point mousePoint = new Point(mouse.X, mouse.Y);
            textScore = hud.GetScore().ToString();
            SelectName(mouse, mousePoint, gameTime, contHand, scores);
            //Rectangle mouseRec = new Rectangle((int)mouse.X, (int)mouse.Y, 1,1);
            //if (recRetry.Contains(mousePoint))
            //{
            //    if (mouse.LeftButton == ButtonState.Pressed && mouseReleased == true)
            //    {
            //        gameStateNumber = 2;
            //        mouseReleased = false;
            //    }
            //}
            //if (recMainMenu.Contains(mousePoint))
            //{
            //    if (mouse.LeftButton == ButtonState.Pressed && mouseReleased == true)
            //    {
            //        gameStateNumber = 1;
            //        mouseReleased = false;
            //    }
            //}
            //if (recSubmit.Contains(mousePoint))
            //{
            //    if (mouse.LeftButton == ButtonState.Pressed && mouseReleased == true)
            //    {
            //        scores.AddHighscore(hud.GetScore(), Name);
            //        scores.SaveHighScores();
            //        scores.LoadHighScores();
            //        scores.SortHighScores();

            //        mouseReleased = false;
            //    }
            //}
            //if (mouse.LeftButton == ButtonState.Released)
            //{
            //    mouseReleased = true;
            //}
        }
示例#5
0
        public void SelectName(MouseState mouse, Point mousePoint, GameTime gameTime, ControlHandler contHand, Highscores scores)
        {
            if (selectedRect >= 8)
            {
                selectedRect = 8;
            }
            if (selectedRect <= 0)
            {
                selectedRect = 0;
            }

            if (frames > 60)
            {
                if (contHand.GetInput().Contains("Right"))
                {
                    selectedRect++;
                }
                if (contHand.GetInput().Contains("Left"))
                {
                    selectedRect--;
                }

                if (contHand.GetInput().Contains("Select"))
                {
                    System.Threading.Thread.Sleep(100);
                    switch (selectedRect)
                    {
                        case 0:
                            if (letter[0] < 25)
                                letter[0]++;
                            else if (letter[0] == 25)
                                letter[0] = 0;
                            break;
                        case 1:
                            if (letter[0] > 0)
                                letter[0]--;
                            else if (letter[0] == 0)
                                letter[0] = 25;
                            break;
                        case 2:
                            if (letter[1] < 25)
                                letter[1]++;
                            else if (letter[1] == 25)
                                letter[1] = 0;
                            break;
                        case 3:
                            if (letter[1] > 0)
                                letter[1]--;
                            else if (letter[1] == 0)
                                letter[1] = 25;
                            break;
                        case 4:
                            if (letter[2] < 25)
                                letter[2]++;
                            else if (letter[1] == 25)
                                letter[2] = 0;
                            break;
                        case 5:
                            if (letter[2] > 0)
                                letter[2]--;
                            else if (letter[2] == 0)
                                letter[2] = 25;
                            break;
                        case 6:
                            scores.AddHighscore(Convert.ToInt32(textScore), Name);
                            scores.SaveHighScores();
                            scores.LoadHighScores();
                            scores.SortHighScores();
                            Saved = true;
                            break;
                        case 7:
                            gameStateNumber = 3;
                            break;
                        case 8:
                            gameStateNumber = 2;
                            break;
                        default:
                            break;
                    }
                }
                frames = 0;
            }
            frames++;

            //if (mouse.LeftButton == ButtonState.Pressed && mouseReleased == true && Saved != true)
            //{
            //    framesPassed++;
            //    if (framesPassed % 7 == 0)
            //    {
            //        for (int i = 0; i < 3; i++)
            //        {
            //            if (recArrowDown[i].Contains(mousePoint))
            //            {
            //                if (letter[i] < 25)
            //                    letter[i]++;
            //                else if (letter[i] == 25)
            //                    letter[i] = 0;
            //            }
            //            else if (recArrowUp[i].Contains(mousePoint))
            //            {
            //                if (letter[i] > 0)
            //                    letter[i]--;
            //                else if (letter[i] == 0)
            //                    letter[i] = 25;
            //            }
            //        }
            //    }
            //    if (recSubmit.Contains(mousePoint))
            //    {
            //        if (Name == "AAA")
            //        {
            //            textSucces = "Very creative...Saved Succesful!";
            //        }
            //        Saved = true;
            //    }
            //}
            //if (mouse.LeftButton == ButtonState.Released)
            //{
            //    mouseReleased = true;
            //}
            OrderName();
            framesPassed++;
        }
示例#6
0
 public void AddHighscore(int score, string name)
 {
     var highscore = new Highscores() { Score = score, Name = name };
     highscores.Add(highscore);
 }