예제 #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 Player(ControlHandler contHand)
 {
     playerPos = new Vector2(250, 250);
     lives = 3;
     weapList = new List<Weapon>();
     maxDelay = 25;
     delay = maxDelay;
     r = new Random();
     GetHit = false;
     IsInAnimation = false;
     this.contHand = contHand;
 }
예제 #3
0
        public MainMenu(ContentManager Content, GraphicsDevice graphicsDevice, ControlHandler ch)
        {
            this.Content = Content;
            this.ch = ch;
            background = new Background(graphicsDevice, Content);
            sizeSelectArrow = new Vector2(graphicsDevice.Viewport.Width / 900 * 30, graphicsDevice.Viewport.Height / 500 * 30);
            posSelectArrow = new Vector2(4.5f, 2.6f);
            recSelectArrow = new Rectangle(graphicsDevice.Viewport.Width / (int)posSelectArrow.X, graphicsDevice.Viewport.Height / (int)posSelectArrow.Y, (int)sizeSelectArrow.X, (int)sizeSelectArrow.Y);

            framesPassed = 0;
            selectedNumber = 0;
            currentGameState = 2;
        }
예제 #4
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();
     hud = new HUD();
     oMenu = new OptionsMenu(graphics, Content);
     intro = new AsteroidsIntro();
     screenHeight = graphics.PreferredBackBufferHeight;
     screenWidth = graphics.PreferredBackBufferWidth;
     numOfAsteroids = 3;
     currentGameState = 1;
 }
        private void LoadControls()
        {
            controlHandler = new ControlHandler();
            keyBindings = controlHandler.GetKeyBindings();
            originalKeybindings = controlHandler.GetKeyBindings();

            controlsEnabled = true;
            int posX = 0;
            int posY = 0;
            pointerPos = new Vector2(xPositions[posX], yPositions[posY]);

            if (controlHandler.GetNumberOfWiimotes() > 0)
                wm = controlHandler.GetWiimote(0);
        }
 private void DiscardChanges()
 {
     controlHandler = new ControlHandler();
     keyBindings = controlHandler.GetKeyBindings();
     reset = true;
 }
예제 #7
0
        public void Update(GameTime gameTime, ControlHandler contHand)
        {
            //Player movement
            if (contHand.GetInput().Contains("Up"))
            {
                Move();
                playerTextureIdle = playerTextureMoving;
            }
            if (!contHand.GetInput().Contains("Up"))
            {
                SlowDown();
                playerTextureIdle = defaultTexture;
            }
            if (contHand.GetInput().Contains("Right"))
            {
                rotationAngle = rotationAngle + 0.1f;
                bulletDirection = new Vector2((float)Math.Cos(rotationAngle), (float)Math.Sin(rotationAngle));
            }
            if (contHand.GetInput().Contains("Left"))
            {
                rotationAngle = rotationAngle - 0.1f;
                bulletDirection = new Vector2((float)Math.Cos(rotationAngle), (float)Math.Sin(rotationAngle));
            }

            if (delay > 0)
            {
                delay--;
            }

            if (delay <= 0)
            {
                if (contHand.GetInput().Contains("Shoot"))
                {
                    weapList.Add(Shoot(1));
                }
            }

            hitBox = new Rectangle((int)(playerPos.X - (playerTextureIdle.Width / 2)), (int)(playerPos.Y - (playerTextureIdle.Height / 2)), playerTextureIdle.Width, playerTextureIdle.Height);
            contHand.SetWiimoteLeds(0, lives);
        }
예제 #8
0
        public void Update(ControlHandler ch)
        {
            if (framesPassed >= 3)
            {
                framesPassed = 0;
                if (ch.GetInput().Contains("Up"))
                {
                    switch (selectedNumber)
                    {
                        case 0:
                            {
                                boolSound = true;
                                boolResolution = false;
                                boolAlias = false;
                                boolText = false;
                                oText.UpdateSelect(0);
                                Thread.Sleep(sleepTimeUpDown);
                                break;
                            }
                        case 1:
                            {
                                selectedNumber--;
                                boolSound = false;
                                boolResolution = true;
                                boolAlias = false;
                                boolText = false;
                                oText.UpdateSelect(1);
                                Thread.Sleep(sleepTimeUpDown);
                                break;
                            }
                        case 2:
                            {
                                selectedNumber--;
                                boolSound = false;
                                boolResolution = false;
                                boolAlias = true;
                                boolText = false;
                                oText.UpdateSelect(2);
                                Thread.Sleep(sleepTimeUpDown);
                                break;
                            }
                        case 3:
                            {
                                selectedNumber--;
                                boolSound = false;
                                boolResolution = false;
                                boolAlias = false;
                                boolText = true;
                                oText.UpdateSelect(3);
                                Thread.Sleep(sleepTimeUpDown);
                                break;
                            }
                    }
                }

                else if (ch.GetInput().Contains("Down"))
                {
                    switch (selectedNumber)
                    {
                        case 0:
                            {
                                selectedNumber++;
                                boolSound = true;
                                boolResolution = false;
                                boolAlias = false;
                                boolText = false;
                                oText.UpdateSelect(0);
                                Thread.Sleep(sleepTimeUpDown);
                                break;
                            }
                        case 1:
                            {
                                selectedNumber++;
                                boolSound = false;
                                boolResolution = true;
                                boolAlias = false;
                                boolText = false;
                                oText.UpdateSelect(1);
                                Thread.Sleep(sleepTimeUpDown);
                                break;
                            }
                        case 2:
                            {
                                selectedNumber++;
                                boolSound = false;
                                boolResolution = false;
                                boolAlias = true;
                                boolText = false;
                                oText.UpdateSelect(2);
                                Thread.Sleep(sleepTimeUpDown);
                                break;
                            }
                        case 3:
                            {
                                boolSound = false;
                                boolResolution = false;
                                boolAlias = false;
                                boolText = true;
                                oText.UpdateSelect(3);
                                Thread.Sleep(sleepTimeUpDown);
                                break;
                            }

                    }
                }
                else if (ch.GetInput().Contains("Left"))
                {
                    if (boolSound)
                    {
                        tSound.SelectLeft();
                        Thread.Sleep(sleepTimeLeftRight);
                    }
                    if (boolResolution)
                    {
                        tResolution.SelectLeft();
                        Thread.Sleep(sleepTimeResolution);
                    }
                    if (boolAlias)
                    {
                        cbAlias.SelectLeftRight();
                        Thread.Sleep(sleepTimeCheckBox);
                    }
                }

                else if (ch.GetInput().Contains("Right"))
                {
                    if (boolSound)
                    {
                        tSound.SelectRight();
                        Thread.Sleep(sleepTimeLeftRight);
                    }

                    if (boolResolution)
                    {
                        tResolution.SelectRight();
                        Thread.Sleep(sleepTimeResolution);
                    }

                    if (boolAlias)
                    {
                        cbAlias.SelectLeftRight();
                        Thread.Sleep(sleepTimeCheckBox);
                    }
                }
                else if (ch.GetInput().Contains("Select"))
                {
                    if (boolText)
                    {
                        currentGameState = 2;
                    }
                }
                else if (ch.GetInput().Contains("Back"))
                {
                    currentGameState = 2;
                }

            }
            framesPassed++;

            if (tResolution.GetResolutionChanged())
            {
                tResolution.Init();
                tSound.Init();
                cbAlias.Init();
                oText.Init();
            }
            MouseState mouse = Mouse.GetState();
            cbAlias.Update(mouse);
            tResolution.Update(mouse);
            tSound.Update(mouse);
            if (oText.Update(mouse))
            {
                currentGameState = 2;
            }
        }
예제 #9
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;
            //}
        }
예제 #10
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++;
        }
예제 #11
0
 public OptionsMenu(Game1.StructOptionsMain structOptionsMain)
 {
     this.structOptionsMain = structOptionsMain;
     this.graphics = structOptionsMain.Graphics;
     this.Content = structOptionsMain.Content;
     this.ch = structOptionsMain.Ch;
 }
예제 #12
0
 public override void Initialize()
 {
     cHandler = new ControlHandler();
     keyBindingsContent = new KeyBindingsContent(graphics, Content);
 }