Beispiel #1
0
        public override EInGameState update(ownGameTime gameTime)
        {
            //Write WinCondition Here
            int i = 0;
            foreach (Player p in playerList)
            {
                numberItemsCollected[i].updateText("Items Collected: " + p.getItemsCollected().Count + "/10");
                i++;
                //HashSet sombodey one?
                if (p.getItemsCollected().Count >= 10)
                {
                    p.hasWon = true;
                    return EInGameState.Exit;

                }

            }

            if (playerList.Count == 1)
            {
                clock.update(gameTime);
                //solo verloren?
                if (clock.getTotalMilliseconds() > 120 * 1000)
                    return EInGameState.Exit;
            }

            base.update(gameTime);
            return EInGameState.RushHour;
        }
Beispiel #2
0
        public override EGameState update(ownGameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.One);
            else if (GamePad.GetState(PlayerIndex.Two).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Two);
            else if (GamePad.GetState(PlayerIndex.Three).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Three);
            else if (GamePad.GetState(PlayerIndex.Four).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Four);

            keyboard = Keyboard.GetState();
            if (keyboard.IsKeyDown(Keys.Escape) || gamePad.IsButtonDown(Buttons.B) || gamePad.IsButtonDown(Buttons.Back))
                return EGameState.MainMenu;
            else
                return EGameState.Help;
        }
Beispiel #3
0
        public Game1()
        {
            Content.RootDirectory = "Content";
            content = Content;

            sounds = new SoundCollection();
            sounds.menuSound.Play();

            ownTime = new ownGameTime();

            currentGameState = EGameState.MainMenu; //tells GameState where so start //change back to main menu
            handleGameState();

            //graphicsDevice = GraphicsDevice;
            graphics = new GraphicsDeviceManager(this);
            //fullscreen
            graphics.IsFullScreen = Settings.isFullscreen();
            //fenstergröße
            Settings.setResolutionX(1280);// 1366, 1280, 1920
            graphics.PreferredBackBufferHeight = Settings.getResolutionY();
            graphics.PreferredBackBufferWidth = Settings.getResolutionX();
        }
        public override EInGameState update(ownGameTime gameTime)
        {
            //Write WinCondition Here
            int i = 0;
            foreach (Player p in playerList)
            {
                foreach (Item item in p.getItemsCollected())
                {
                    if (itemsToCollect[i].contains(item))
                        itemsToCollect[i].setCollected(item);
                }
                //HashSet sombodey won?
                if (itemsToCollect[i].allCollected())
                {
                    p.hasWon = true;
                    return EInGameState.Exit;
                }

                i++;
            }

            if (playerList.Count == 1)
            {
                clock.update(gameTime);
                //solo verloren?
                if (clock.getTotalMilliseconds() > 120 * 1000)
                {

                    return EInGameState.Exit;
                }

            }

            base.update(gameTime);
            return EInGameState.NeedForIngrediance;
        }
Beispiel #5
0
        public override EGameState update(ownGameTime gameTime)
        {
            keyboard = Keyboard.GetState();
            if (GamePad.GetState(PlayerIndex.One).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.One);
            else if (GamePad.GetState(PlayerIndex.Two).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Two);
            else if (GamePad.GetState(PlayerIndex.Three).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Three);
            else if (GamePad.GetState(PlayerIndex.Four).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Four);

            if (!keyboard.IsKeyDown(Keys.Left) && !keyboard.IsKeyDown(Keys.Right) && !keyboard.IsKeyDown(Keys.Down) && !keyboard.IsKeyDown(Keys.Up) && !keyboard.IsKeyDown(Keys.Enter) && !gamePad.IsButtonDown(Buttons.A) && !gamePad.IsButtonDown(Buttons.DPadUp) && !gamePad.IsButtonDown(Buttons.DPadRight) && !gamePad.IsButtonDown(Buttons.DPadLeft) && !gamePad.IsButtonDown(Buttons.DPadDown))
                isPressed = false;

            //Input
            if ((keyboard.IsKeyDown(Keys.Down) || gamePad.IsButtonDown(Buttons.DPadDown)) && isPressed == false)
            {
                count++;
                count = count % 3;
                isPressed = true;
            }
            if ((keyboard.IsKeyDown(Keys.Up) || gamePad.IsButtonDown(Buttons.DPadUp)) && isPressed == false)
            {
                count += 2;
                count = count % 3;
                isPressed = true;
            }

            //update Buttons
            if (count == 0)
            {
                volumeButton.setNotSelected();
                volumeLR.setNotSelected();
                resolutionButton.setNotSelected();
                resolutionLR.setNotSelected();
                fullscreenButton.setSelectedKlicked();
                fullscreenLR.setSelected();
            }

            if (count == 1)
            {
                volumeButton.setNotSelected();
                volumeLR.setNotSelected();
                resolutionButton.setSelectedKlicked();
                resolutionLR.setSelected();
                fullscreenButton.setNotSelected();
                fullscreenLR.setNotSelected();
            }

            if (count == 2)
            {

                resolutionButton.setNotSelected();
                resolutionLR.setNotSelected();
                fullscreenButton.setNotSelected();
                fullscreenLR.setNotSelected();
                volumeButton.setSelectedKlicked();
                volumeLR.setSelected();
            }

            if (resolutionButton.isSelected())//resolutionLR.isSelected()
            {
                if ((keyboard.IsKeyDown(Keys.Right) || gamePad.IsButtonDown(Buttons.DPadRight)) && isPressed == false)
                {
                    resolutionLR.switchRightKlicked();
                    isPressed = true;
                }

                if ((keyboard.IsKeyDown(Keys.Left) || gamePad.IsButtonDown(Buttons.DPadLeft)) && isPressed == false)
                {
                    resolutionLR.switchLeftKlicked();
                    isPressed = true;
                }

                if (resolutionLR.getDisplayedIndex() == 2)
                {
                    resolutionX = 1920;
                }
                if (resolutionLR.getDisplayedIndex() == 1)
                {
                    resolutionX = 1366;
                }
                if (resolutionLR.getDisplayedIndex() == 0)
                {
                    resolutionX = 1280;
                }

            }

            if (fullscreenButton.isSelected())//fullscreenLR.isSelected()
            {
                if ((keyboard.IsKeyDown(Keys.Right) || gamePad.IsButtonDown(Buttons.DPadRight)) && fullscreenLR.getDisplayedIndex() == 0 && isPressed == false)
                {
                    fullscreenLR.switchRightKlicked();
                    fullScreen = true;
                    isPressed = true;
                }
                if ((keyboard.IsKeyDown(Keys.Left)|| gamePad.IsButtonDown(Buttons.DPadLeft)) && fullscreenLR.getDisplayedIndex() == 0 && isPressed == false)
                {
                    fullscreenLR.switchLeftKlicked();
                    fullScreen = true;
                    isPressed = true;
                }

                if ((keyboard.IsKeyDown(Keys.Right) || gamePad.IsButtonDown(Buttons.DPadRight)) && fullscreenLR.getDisplayedIndex() == 1 && isPressed == false)
                {
                    fullscreenLR.switchRightKlicked();
                    fullScreen = false;
                    isPressed = true;
                }
                if ((keyboard.IsKeyDown(Keys.Left) || gamePad.IsButtonDown(Buttons.DPadLeft)) && fullscreenLR.getDisplayedIndex() == 1 && isPressed == false)
                {
                    fullscreenLR.switchLeftKlicked();
                    fullScreen = false;
                    isPressed = true;
                }
            }

            if (volumeButton.isSelected())
            {
                if ((keyboard.IsKeyDown(Keys.Right) || gamePad.IsButtonDown(Buttons.DPadRight)) && isPressed == false)
                {
                    volumeLR.switchRightKlicked();
                    Volume = (10 - (float)volumeLR.getDisplayedIndex()) / 10;
                    isPressed = true;
                }
                if ((keyboard.IsKeyDown(Keys.Left) || gamePad.IsButtonDown(Buttons.DPadLeft)) && isPressed == false)
                {
                    volumeLR.switchLeftKlicked();
                    Volume = (10 - (float)volumeLR.getDisplayedIndex()) / 10;
                    isPressed = true;
                }
                //Console.WriteLine(volumeLR.getDisplayedIndex());
            }

            if ((keyboard.IsKeyDown(Keys.Enter) || gamePad.IsButtonDown(Buttons.A)) && !isPressed)
            {
                apply();
                return EGameState.MainMenu;
            }

            if (keyboard.IsKeyDown(Keys.Escape) || gamePad.IsButtonDown(Buttons.B) || gamePad.IsButtonDown(Buttons.Back))
                return EGameState.MainMenu;
            else
                return EGameState.Options;
        }
Beispiel #6
0
        /// <summary>
        /// updates the won state
        /// </summary>
        /// <param name="gameTime"></param>
        /// <returns>true if won should be closed</returns>
        public bool update(ownGameTime gameTime)
        {
            //zwei sekunden kann man nichts machen dann kann man mit enter oder a weiter
            //update the InfoText
            elapsedTime += gameTime.getElapsedGameTime();
            if (elapsedTime > 1000)
            {
                infoText.updateText("02");
                infoText.setPosition(new Vector2(Settings.getResolutionX() / 2 - infoText.getWidth() / 2, Settings.getResolutionY() - infoText.getHeight()));
            }
            if (elapsedTime > 2000)
            {
                infoText.updateText("01");
                infoText.setPosition(new Vector2(Settings.getResolutionX() / 2 - infoText.getWidth() / 2, Settings.getResolutionY() - infoText.getHeight()));
            }
            if (elapsedTime > 3000)
            {
                keyboard = Keyboard.GetState();
                gamePad1 = GamePad.GetState(PlayerIndex.One);
                gamePad2 = GamePad.GetState(PlayerIndex.Two);
                gamePad3 = GamePad.GetState(PlayerIndex.Three);
                gamePad4 = GamePad.GetState(PlayerIndex.Four);

                infoText.updateText("Press Enter or A to continue!");
                infoText.setPosition(new Vector2(Settings.getResolutionX() / 2 - infoText.getWidth() / 2, Settings.getResolutionY() - infoText.getHeight()));
                if (keyboard.IsKeyDown(Keys.Enter) || keyboard.IsKeyDown(Keys.Escape) ||gamePad1.IsButtonDown(Buttons.A) || gamePad2.IsButtonDown(Buttons.A) || gamePad3.IsButtonDown(Buttons.A) || gamePad4.IsButtonDown(Buttons.A))
                    return true;
            }
            return false;
        }
Beispiel #7
0
        /// <summary>
        /// Keyboard Movement
        /// </summary>
        /// <param name="gameTime">GameTime for correct movement dependent on Time not FPS</param>
        private void moveK(ownGameTime gameTime, Keys moveUp, Keys moveDown, Keys moveLeft, Keys moveRight, Keys lookLeft, Keys lookRight)
        {
            Vector3 newPosition = position;
            timeSinceLastMove = gameTime.getElapsedGameTime();
            keyboard = Keyboard.GetState();
            direction = lookAt - position;
            ortoDirection = Vector3.Cross(direction, upDirection);
            bool up = keyboard.IsKeyDown(moveUp) && !keyboard.IsKeyDown(moveDown);
            bool down = keyboard.IsKeyDown(moveDown) && !keyboard.IsKeyDown(moveUp);
            bool left = keyboard.IsKeyDown(moveLeft) && !keyboard.IsKeyDown(moveRight);
            bool right = keyboard.IsKeyDown(moveRight) && !keyboard.IsKeyDown(moveLeft);
            if (isBouncing)
            {
                newPosition += bounceDirection * (timeSinceLastMove / timescale) * bouncingTimeLeft;

                if (/*mapCollision(newPosition) ||*/ bouncingTimeLeft < 0){
                    isBouncing = false;
                    bouncingTimeLeft = bouncingTime;
                }
                else
                {
                    movementRotationX -= (position - newPosition).X;
                    movementRotationZ += (position - newPosition).Z;

                    if (!this.mapCollision(new Vector3(newPosition.X, position.Y, position.Z)))
                    {
                        position.X = newPosition.X;
                    }

                    if (!this.mapCollision(new Vector3(position.X, position.Y, newPosition.Z)))
                    {
                        position.Z = newPosition.Z;
                    }
                    bouncingTimeLeft -= (timeSinceLastMove / timescale);

                    //movementRotationX -= (position - newPosition).X;

                    //movementRotationZ += (position - newPosition).Z;
                    //position = newPosition;
                    //bouncingTimeLeft -= (timeSinceLastMove / timescale);
                    //Console.WriteLine(bouncingTimeLeft);

                }
            }
            else
            {
                //compute the "new position" for the player after keyboard inputs
                if (up)
                {//forward
                    newPosition = newPosition + direction;// * (timeSinceLastMove / timescale);
                }
                if (down)
                {//backward
                    newPosition = newPosition - direction;// * (timeSinceLastMove / timescale);
                }
                if (right)
                {//right
                    newPosition = newPosition + ortoDirection;// * (timeSinceLastMove / timescale);
                }
                if (left)
                {//left
                    newPosition = newPosition - ortoDirection;// *(timeSinceLastMove / timescale);
                }
            }

            //compute the move Vector and ormalize it
            Vector2 moveVector = new Vector2(newPosition.X - position.X, newPosition.Z - position.Z);//darf nur vector 2 sein, sonst führt die y coordinate beim normalisieren zu problemen

            //normalize the move Vector if needet and add the timeScaling bevore collision
            if (moveVector.Length() > 1)
                moveVector.Normalize();
            moveVector *= (timeSinceLastMove / timescale);

            //Hier nen dicken Player drehen
            //Roll, Roll, Roll A Witch, Twist It At The End. Light It Up And Take A Puff, And Pass It To Your Friends
            //The Witch in the Maze goes round and round, round and round, round and round, the Witch in the Maze goes round and round all throung Game
            if (left)
                movementRotationX -= moveVector.Length();
            if (right)
                movementRotationX += moveVector.Length();
            if (up)
                movementRotationZ -= moveVector.Length();
            if (down)
                movementRotationZ += moveVector.Length();

            //move at the x coordinates and roll the Player
            if (!this.mapCollision(new Vector3(position.X + moveVector.X, position.Y, position.Z)))
            {
                //movementRotationX += moveVector.X;
                position.X += moveVector.X;
                lookAt = position + direction;
            }
            //move at the z coordinates
            if (!this.mapCollision(new Vector3(position.X, position.Y, position.Z + moveVector.Y)))
            {
                //movementRotationZ += moveVector.Y;
                position.Z += moveVector.Y;
                lookAt = position + direction;
            }

            //rotate the player
            if (keyboard.IsKeyDown(lookLeft) && !keyboard.IsKeyDown(lookRight))
            {//rotate left / look left
                Vector3 newLookAt = position + (Vector3.Transform((lookAt - position), Matrix.CreateRotationY(turningScale * timeSinceLastMove / timescale)));

                //inner schön vom player mittelpunkt aus rechnen du pfeife...
                Vector3 playerToLookAt = lookAt - position;
                Vector3 playerToNewLookAt = newLookAt - position;

                //lookatRotation += (float)Math.Acos(Math.Abs(Vector3.Dot(playerToNewLookAt, playerToLookAt)) / (playerToNewLookAt.Length() * playerToLookAt.Length()));
                lookatRotation += (float)Math.Asin(Math.Abs(Vector3.Cross(playerToNewLookAt, playerToLookAt).Length()) / (playerToNewLookAt.Length() * playerToLookAt.Length()));
                lookAt = newLookAt;
            }
            if (keyboard.IsKeyDown(lookRight) && !keyboard.IsKeyDown(lookLeft))
            {//rotate rigth / look right
                Vector3 newLookAt = position + (Vector3.Transform((lookAt - position), Matrix.CreateRotationY(turningScale * (-timeSinceLastMove) / timescale)));

                //inner schön vom player mittelpunkt aus rechnen du pfeife...
                Vector3 playerToLookAt = lookAt - position;
                Vector3 playerToNewLookAt = newLookAt - position;

                //lookatRotation -= (float)Math.Acos(Math.Abs(Vector3.Dot(playerToNewLookAt, playerToLookAt)) / (playerToNewLookAt.Length() * playerToLookAt.Length()));
                lookatRotation -= (float)Math.Asin(Math.Abs(Vector3.Cross(playerToNewLookAt, playerToLookAt).Length()) / (playerToNewLookAt.Length() * playerToLookAt.Length()));
                lookAt = newLookAt;
            }
            //reset if bigger than 2OI or smaller then 0
            while (lookatRotation > 2 * Math.PI)
                lookatRotation %= 2 * Math.PI;
            while (lookatRotation < 0)
                lookatRotation += 2 * Math.PI;

            ////fliegen
            //if (!keyboard.IsKeyDown(Keys.LeftControl) && keyboard.IsKeyDown(Keys.LeftShift))
            //{
            //    position += new Vector3(0,timeSinceLastMove / timescale,0);
            //    lookAt += new Vector3(0, timeSinceLastMove / timescale, 0);
            //}
            //if (keyboard.IsKeyDown(Keys.LeftControl) && !keyboard.IsKeyDown(Keys.LeftShift))
            //{
            //    position -= new Vector3(0, timeSinceLastMove / timescale, 0);
            //    lookAt -= new Vector3(0, timeSinceLastMove / timescale, 0);
            //}
        }
Beispiel #8
0
        //GamePad
        private void moveG(ownGameTime gameTime, PlayerIndex playerIndex)
        {
            // Get the current gamepad state.
                GamePadState currentState = GamePad.GetState(playerIndex);

                Vector3 newPosition = position;
                timeSinceLastMove = gameTime.getElapsedGameTime();
                keyboard = Keyboard.GetState();
                direction = lookAt - position;
                ortoDirection = Vector3.Cross(direction, upDirection);
                bool up = currentState.ThumbSticks.Left.Y > 0.1f;
                bool down = currentState.ThumbSticks.Left.Y < -0.1f;
                bool left = currentState.ThumbSticks.Left.X < -0.1f;
                bool right = currentState.ThumbSticks.Left.X > 0.0f;
                bool lookLeft = currentState.ThumbSticks.Right.X < -0.1f;
                bool lookRight = currentState.ThumbSticks.Right.X > 0.1f;
                float leftMoveScale = 1;
                float rightMoveScale = 1;
                if (isBouncing)
                {
                    newPosition += bounceDirection * (timeSinceLastMove / timescale) * bouncingTimeLeft;

                    if (/*mapCollision(newPosition) ||*/ bouncingTimeLeft < 0)
                    {
                        isBouncing = false;
                        bouncingTimeLeft = bouncingTime;
                    }
                    else
                    {
                        movementRotationX -= (position - newPosition).X;
                        movementRotationZ += (position - newPosition).Z;

                        if (!this.mapCollision(new Vector3(newPosition.X, position.Y, position.Z)))
                        {
                            position.X = newPosition.X;
                        }

                        if (!this.mapCollision(new Vector3(position.X, position.Y, newPosition.Z)))
                        {
                            position.Z = newPosition.Z;
                        }
                        bouncingTimeLeft -= (timeSinceLastMove / timescale);

                    }
                }
                else
                {
                    //compute the "new position" for the player after keyboard inputs
                    if (up)
                    {//forward
                        newPosition = newPosition + direction;
                        leftMoveScale = Math.Abs(currentState.ThumbSticks.Left.Y);
                    }
                    if (down)
                    {//backward
                        newPosition = newPosition - direction;
                        leftMoveScale = Math.Abs(currentState.ThumbSticks.Left.Y);
                    }
                    if (right)
                    {//right
                        newPosition = newPosition + ortoDirection;
                        rightMoveScale = Math.Abs(currentState.ThumbSticks.Left.X);
                    }
                    if (left)
                    {//left
                        newPosition = newPosition - ortoDirection;
                        rightMoveScale = Math.Abs(currentState.ThumbSticks.Left.X);
                    }
                }

                //compute the move Vector and ormalize it
                Vector2 moveVector = new Vector2(newPosition.X - position.X, newPosition.Z - position.Z);//darf nur vector 2 sein, sonst führt die y coordinate beim normalisieren zu problemen

                //normalize the move Vector if needet and add the timeScaling bevore collision
                Console.WriteLine(moveVector);
                if (moveVector.Length() > 1)
                    moveVector.Normalize();
                float h = (leftMoveScale + rightMoveScale);//h scales the movescale back if its too high
                if(h > 1)
                    h = 1;
                moveVector *= (timeSinceLastMove / timescale) * h;
                    //moveVector.Y  *= Math.Abs(currentState.ThumbSticks.Left.Y);
                    //moveVector.X *= Math.Abs(currentState.ThumbSticks.Left.X);

                //Hier nen dicken Player drehen
                //Roll, Roll, Roll A Witch, Twist It At The End. Light It Up And Take A Puff, And Pass It To Your Friends
                //The Witch in the Maze goes round and round, round and round, round and round, the Witch in the Maze goes round and round all throung Game
                if (left)
                    movementRotationX -= moveVector.Length();
                if (right)
                    movementRotationX += moveVector.Length();
                if (up)
                    movementRotationZ -= moveVector.Length();
                if (down)
                    movementRotationZ += moveVector.Length();

                //move at the x coordinates and roll the Player
                if (!this.mapCollision(new Vector3(position.X + moveVector.X, position.Y, position.Z)))
                {
                    //movementRotationX += moveVector.X;
                    position.X += moveVector.X;
                    lookAt = position + direction;
                }
                //move at the z coordinates
                if (!this.mapCollision(new Vector3(position.X, position.Y, position.Z + moveVector.Y)))
                {
                    //movementRotationZ += moveVector.Y;
                    position.Z += moveVector.Y;
                    lookAt = position + direction;
                }

                //rotate the player
                if (lookLeft)
                {//rotate left / look left
                    Vector3 newLookAt = position + (Vector3.Transform((lookAt - position), Matrix.CreateRotationY(turningScale * timeSinceLastMove / timescale)));
                    Vector3 moveLookAt = newLookAt - lookAt;//to scale toth the controller
                    moveLookAt *= Math.Abs(currentState.ThumbSticks.Right.X);
                    newLookAt = lookAt + moveLookAt;
                    //inner schön vom player mittelpunkt aus rechnen du pfeife...
                    Vector3 playerToLookAt = lookAt - position;
                    Vector3 playerToNewLookAt = newLookAt - position;

                    //lookatRotation += (float)Math.Acos(Math.Abs(Vector3.Dot(playerToNewLookAt, playerToLookAt)) / (playerToNewLookAt.Length() * playerToLookAt.Length()));
                    lookatRotation += (float)Math.Asin(Math.Abs(Vector3.Cross(playerToNewLookAt, playerToLookAt).Length()) / (playerToNewLookAt.Length() * playerToLookAt.Length()));
                    lookAt = newLookAt;
                }
                if (lookRight)
                {//rotate rigth / look right
                    Vector3 newLookAt = position + (Vector3.Transform((lookAt - position), Matrix.CreateRotationY(turningScale * (-timeSinceLastMove) / timescale)));
                    Vector3 moveLookAt = newLookAt - lookAt;//to scale toth the controller
                    moveLookAt *= Math.Abs(currentState.ThumbSticks.Right.X);
                    newLookAt = lookAt + moveLookAt;
                    //inner schön vom player mittelpunkt aus rechnen du pfeife...
                    Vector3 playerToLookAt = lookAt - position;
                    Vector3 playerToNewLookAt = newLookAt - position;

                    //lookatRotation -= (float)Math.Acos(Math.Abs(Vector3.Dot(playerToNewLookAt, playerToLookAt)) / (playerToNewLookAt.Length() * playerToLookAt.Length()));
                    lookatRotation -= (float)Math.Asin(Math.Abs(Vector3.Cross(playerToNewLookAt, playerToLookAt).Length()) / (playerToNewLookAt.Length() * playerToLookAt.Length()));
                    lookAt = newLookAt;
                }
                //reset if bigger than 2OI or smaller then 0
                while (lookatRotation > 2 * Math.PI)
                    lookatRotation %= 2 * Math.PI;
                while (lookatRotation < 0)
                    lookatRotation += 2 * Math.PI;
        }
Beispiel #9
0
 private void move(ownGameTime gameTime)
 {
     //ToDo kollieion dierekt hier einbauen...
     switch (playerControlls)
     {
         case EPlayerControlls.Keyboard1:
             this.moveK(gameTime, Keys.W, Keys.S, Keys.A, Keys.D, Keys.Q, Keys.E);
             break;
         //case EPlayerControlls.Keyboard2:
         //    this.moveK(gameTime, Keys.T, Keys.F, Keys.G, Keys.H, Keys.R, Keys.Z);
         //    break;
         //case EPlayerControlls.Keyboard3:
         //    this.moveK(gameTime, Keys.I, Keys.J, Keys.K, Keys.L, Keys.U, Keys.O);
             break;
         case EPlayerControlls.KeyboardNumPad:
             //this.moveK(gameTime, Keys.NumPad5, Keys.NumPad2, Keys.NumPad1, Keys.NumPad3, Keys.NumPad4, Keys.NumPad6);
             this.moveK(gameTime, Keys.I, Keys.J, Keys.K, Keys.L, Keys.U, Keys.O);
             break;
         case EPlayerControlls.Gamepad1:
             moveG(gameTime, PlayerIndex.One);
             break;
         case EPlayerControlls.Gamepad2:
             moveG(gameTime, PlayerIndex.Two);
             break;
         case EPlayerControlls.Gamepad3:
             moveG(gameTime, PlayerIndex.Three);
             break;
         case EPlayerControlls.Gamepad4:
             moveG(gameTime, PlayerIndex.Four);
             break;
         default:
             throw new NotImplementedException();
     }
 }
Beispiel #10
0
        //update
        public void update(ownGameTime gameTime)
        {
            //this.reportStatus();
            this.move(gameTime);

            this.itemCollision(position);
        }
Beispiel #11
0
        public override EGameState update(ownGameTime gameTime)
        {
            keyboard = Keyboard.GetState();
            if(GamePad.GetState(PlayerIndex.One).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.One);
            else if (GamePad.GetState(PlayerIndex.Two).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Two);
            else if (GamePad.GetState(PlayerIndex.Three).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Three);
            else if (GamePad.GetState(PlayerIndex.Four).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Four);

            if (!keyboard.IsKeyDown(Keys.W)
                && !keyboard.IsKeyDown(Keys.S)
                && !keyboard.IsKeyDown(Keys.Up)
                && !keyboard.IsKeyDown(Keys.Down)
                && !keyboard.IsKeyDown(Keys.Enter)
                && !gamePad.IsButtonDown(Buttons.DPadUp)
                && !gamePad.IsButtonDown(Buttons.DPadDown)
                && !gamePad.IsButtonDown(Buttons.A))
                isPressed = false;
            //Input
            if ((keyboard.IsKeyDown(Keys.S) || keyboard.IsKeyDown(Keys.Down) || gamePad.IsButtonDown(Buttons.DPadDown)) && isPressed == false)
            {
                count++;
                count = count % 5;
                isPressed = true;
            }
            if ((keyboard.IsKeyDown(Keys.W) || keyboard.IsKeyDown(Keys.Up) || gamePad.IsButtonDown(Buttons.DPadUp)) && isPressed == false)
            {
                    count += 4;
                    count = count % 5;
                    isPressed = true;
            }
            //update Buttons
            if (count == 0)
            {
                start.setSelectedKlicked();
                help.setNotSelected();
                option.setNotSelected();
                credits.setNotSelected();
                exit.setNotSelected();
            }

            if (count == 1)
            {
                start.setNotSelected();
                help.setSelectedKlicked();
                option.setNotSelected();
                credits.setNotSelected();
                exit.setNotSelected();
            }

            if (count == 2)
            {
                start.setNotSelected();
                help.setNotSelected();
                option.setSelectedKlicked();
                credits.setNotSelected();
                exit.setNotSelected();
            }

            if (count == 3)
            {
                start.setNotSelected();
                help.setNotSelected();
                option.setNotSelected();
                credits.setSelectedKlicked();
                exit.setNotSelected();
            }

            if (count == 4)
            {
                start.setNotSelected();
                help.setNotSelected();
                option.setNotSelected();
                credits.setNotSelected();
                exit.setSelectedKlicked();
            }

            //switch the GameState
            if ((keyboard.IsKeyDown(Keys.Enter) || gamePad.IsButtonDown(Buttons.A)) && count == 0 && !isPressed)
                return EGameState.CharacterSelection;
            if ((keyboard.IsKeyDown(Keys.Enter) || gamePad.IsButtonDown(Buttons.A)) && count == 1 && !isPressed)
                return EGameState.Help;
            if ((keyboard.IsKeyDown(Keys.Enter) || gamePad.IsButtonDown(Buttons.A)) && count == 2 && !isPressed)
                return EGameState.Options;
            if ((keyboard.IsKeyDown(Keys.Enter) || gamePad.IsButtonDown(Buttons.A)) && count == 3 && !isPressed)
                return EGameState.Credits;
            if ((keyboard.IsKeyDown(Keys.Enter) || gamePad.IsButtonDown(Buttons.A)) && count == 4 && !isPressed)
                return EGameState.Exit;
            else
                return EGameState.MainMenu;
        }
Beispiel #12
0
        /// <summary>
        /// Updates Player, ItemMap and Minimap
        /// </summary>
        /// <param name="gameTime">GameTime</param>
        /// <returns>State of the Game</returns>
        public virtual EInGameState update(ownGameTime gameTime)
        {
            keyboard = Keyboard.GetState();
            foreach (Player player in playerList)
            {
                player.update(gameTime);
                //are player colliding?
                foreach (Player p in playerList)
                {
                    if(p != player){
                        if (ownFunctions.Collision.circleCirlceCollision(new Vector2(p.getPosition().X, p.getPosition().Z), p.getRadius(), new Vector2(player.getPosition().X, player.getPosition().Z), player.getRadius()))
                        {
                            player.bounce(player.getPosition() - p.getPosition());
                            Game1.sounds.bounce.Play(Settings.getSoundVolume(), -1f, p.pan);
                        }
                    }
                }

                //delete all blocks but black holes
                List<MapStuff.Blocks.BlackHole> blackHoles = new List<MapStuff.Blocks.BlackHole>();
                List<MapStuff.Blocks.Block> blocksStandingOn = player.mapBlocksStandingOn(player.getPosition());
                foreach (MapStuff.Blocks.Block block in blocksStandingOn)
                {
                    if (block.name == MapStuff.MapCreator.tiles.blackhole)
                        blackHoles.Add((MapStuff.Blocks.BlackHole)block);
                }
                //reset player position for black holes
                foreach (MapStuff.Blocks.BlackHole blackHole in blackHoles)
                {
                    if (blackHole.transportable)
                    {
                        Vector3 transportPosition = blackHole.transportPosition;
                        player.setPosition(new Vector3(transportPosition.X, player.getPosition().Y, transportPosition.Z));
                        bool canPort = true;
                        Game1.sounds.teleport.Play(Settings.getSoundVolume(), 0, player.pan);
                        //festbuggen ist grad möglich...

                    }

                }

            }
            itemSpawner.update(itemMap, gameTime, playerList);
            minimap.update(itemMap, playerList);

            if (currentInGameState == null)
                throw new IndexOutOfRangeException();
            return currentInGameState;
        }
        public override EGameState update(ownGameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.One);
            else if (GamePad.GetState(PlayerIndex.Two).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Two);
            else if (GamePad.GetState(PlayerIndex.Three).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Three);
            else if (GamePad.GetState(PlayerIndex.Four).IsConnected)
                gamePad = GamePad.GetState(PlayerIndex.Four);

            updatePlayer();
            if (!keyboard.IsKeyDown(Keys.Left) && !keyboard.IsKeyDown(Keys.Right) && !gamePad.IsButtonDown(Buttons.DPadLeft) && !gamePad.IsButtonDown(Buttons.DPadRight) && !gamePad.IsButtonDown(Buttons.A) && !gamePad.IsButtonDown(Buttons.B))
                isPressed = false;

            if ((keyboard.IsKeyDown(Keys.Left) || gamePad.IsButtonDown(Buttons.DPadLeft)) && !isPressed)
            {
                GameModeSelected.switchLeftKlicked();
                isPressed = true;
            }

            if ((keyboard.IsKeyDown(Keys.Right) || gamePad.IsButtonDown(Buttons.DPadRight)) && !isPressed)
            {
                GameModeSelected.switchRightKlicked();
                isPressed = true;
            }

            //start?
            if ((player1Controlls == Player.EPlayerControlls.none || player1Icon.isSelected())
                && (player2Controlls == Player.EPlayerControlls.none || player2Icon.isSelected())
                && (player3Controlls == Player.EPlayerControlls.none || player3Icon.isSelected())
                && (player4Controlls == Player.EPlayerControlls.none || player4Icon.isSelected())
                && !(player1Controlls == Player.EPlayerControlls.none && player2Controlls == Player.EPlayerControlls.none && player3Controlls == Player.EPlayerControlls.none && player4Controlls == Player.EPlayerControlls.none))
                startGame = true;
            else
                startGame = false;

            if (startGame)
            {
                elapsedTime += gameTime.getElapsedGameTime();
                if (elapsedTime > 1000)
                {
                    infoText.updateText("Game starts in 02!");
                    infoText.setPosition(new Vector2(Settings.getResolutionX() / 2 - infoText.getWidth() / 2, Settings.getResolutionY()/2 - infoText.getHeight()/2));
                }
                if (elapsedTime > 2000)
                {
                    infoText.updateText("Game starts in 01!");
                    infoText.setPosition(new Vector2(Settings.getResolutionX() / 2 - infoText.getWidth() / 2, Settings.getResolutionY() / 2 - infoText.getHeight() / 2));
                }
                if (elapsedTime > 3000)
                {
                    infoText.updateText("Start!");
                    infoText.setPosition(new Vector2(Settings.getResolutionX() / 2 - infoText.getWidth() / 2, Settings.getResolutionY() / 2 - infoText.getHeight() / 2));
                }
                if (elapsedTime > 3200)
                {
                    return EGameState.InGame; // GameState InGame braucht übergabeparameter!
                }
            }
            else
            {
                elapsedTime = 0;
                infoText.updateText("Game starts in 03!");
                infoText.setPosition(new Vector2(Settings.getResolutionX() / 2 - infoText.getWidth() / 2, Settings.getResolutionY() / 2 - infoText.getHeight() / 2));
            }
            //set selected GameMode
            switch (GameModeSelected.getDisplayedIndex())
            {
                case 0:
                    this.eInGameState = EInGameState.NeedForIngrediance;
                    break;
                case 1:
                    this.eInGameState = EInGameState.RushHour;
                    break;
                default:
                    throw new NotImplementedException();
            }

            //if(keyboard.IsKeyDown(Keys.Space))
            //    return EGameState.InGame; // GameState InGame braucht übergabeparameter!
            if (keyboard.IsKeyDown(Keys.Escape) /*|| gamePad.IsButtonDown(Buttons.B)*/ || gamePad.IsButtonDown(Buttons.Back))
                return EGameState.MainMenu;
            else
                return EGameState.CharacterSelection;
        }
Beispiel #14
0
        public void update(ownGameTime gameTime)
        {
            //check if clock is started jet
            if (!running)
                return;
            else
            {
                elapsedTime += gameTime.getElapsedGameTime();
                int hseconds = (int)(elapsedTime / 1000) % 60;
                int hminutes = ((int)(elapsedTime / 1000) - hseconds) / 60;

                if (hseconds < 10)
                    seconds.updateText("0" + hseconds.ToString());
                else
                    seconds.updateText(hseconds.ToString());
                if (hminutes < 10)
                    minutes.updateText("0" + hminutes.ToString());
                else
                    minutes.updateText(hminutes.ToString());
            }
        }
Beispiel #15
0
 public abstract EGameState update(ownGameTime gameTime);
Beispiel #16
0
        public override EGameState update(ownGameTime gameTime)
        {
            if (isWon)
            {
                bool w = won.update(gameTime);
                if (w)
                    return EGameState.MainMenu;
            }
            else
            {
                gamePad1 = GamePad.GetState(PlayerIndex.One);
                gamePad2 = GamePad.GetState(PlayerIndex.Two);
                gamePad3 = GamePad.GetState(PlayerIndex.Three);
                gamePad4 = GamePad.GetState(PlayerIndex.Four);

                keyboard = Keyboard.GetState();
                prevInGameState = currentInGameState;
                currentInGameState = inGameState.update(gameTime);
                if (currentInGameState != prevInGameState)
                    handleInGameState();

                if (isPaused)
                {
                    Pause.EPausState pauseState = Pause.update();
                    if (pauseState == Pause.EPausState.pause)
                        isPaused = true;
                    if (pauseState == Pause.EPausState.game)
                    {
                        isPaused = false;
                        gameTime.resume();
                    }

                    if (pauseState == Pause.EPausState.mainMenu)
                    {
                        gameTime.resume();
                        //wird sonst nicht vorher aufgerufen
                        Game1.sounds.inGameSound.Stop();
                        Game1.sounds.menuSound.Play();
                        //currentInGameState = EInGameState.Exit;
                        return EGameState.MainMenu;
                    }
                }

                //if (currentInGameState == EInGameState.Exit)
                //    return EGameState.CharacterSelection;

                //activate pause Keyboard
                if (keyboard.IsKeyDown(Keys.Escape) && !isPaused)
                {
                    isPaused = true;
                    gameTime.pause();
                    pause = new Pause(PlayerStuff.Player.EPlayerControlls.Keyboard1);
                }
                if (gamePad1.IsButtonDown(Buttons.Back) && !isPaused)
                {
                    isPaused = true;
                    gameTime.pause();
                    pause = new Pause(PlayerStuff.Player.EPlayerControlls.Gamepad1);
                }
                if (gamePad2.IsButtonDown(Buttons.Back) && !isPaused)
                {
                    isPaused = true;
                    gameTime.pause();
                    pause = new Pause(PlayerStuff.Player.EPlayerControlls.Gamepad2);
                }
                if (gamePad3.IsButtonDown(Buttons.Back) && !isPaused)
                {
                    isPaused = true;
                    gameTime.pause();
                    pause = new Pause(PlayerStuff.Player.EPlayerControlls.Gamepad3);
                }
                if (gamePad4.IsButtonDown(Buttons.Back) && !isPaused)
                {
                    isPaused = true;
                    gameTime.pause();
                    pause = new Pause(PlayerStuff.Player.EPlayerControlls.Gamepad4);
                }
            }

            return EGameState.InGame;
        }