Ejemplo n.º 1
0
        public void Initialize()
        {
            ReadsInput = true;

            LastFrameGestures = new List <GestureSample>();
#if USE_TOUCH
            ReadsGestures = true;
            TouchPanel.EnabledGestures =
                GestureType.Tap |
                GestureType.DoubleTap |
                GestureType.Hold |
                GestureType.Pinch |
                GestureType.PinchComplete |
                GestureType.DragComplete |
                GestureType.FreeDrag |
                GestureType.HorizontalDrag |
                GestureType.VerticalDrag |
                GestureType.Flick;

            TouchPanelCapabilities touchPanelCapabilities = TouchPanel.GetCapabilities();
            MaximumTouchCount = touchPanelCapabilities.MaximumTouchCount;
#else
            MaximumTouchCount = 2;
#endif
            NumberTouchPointsNeededForPush = 1;
        }
Ejemplo n.º 2
0
        public GameplayScreen(ScreenManager manager, int id, bool touchState, Flyinghead head, BouncingText text)
        {
            //Allgemeine Initialisierungen
            screenManager = manager;
            screenManager.endBossActive = false;
            collision = new Collision();

            m_levelId   = id;
            m_gameSpeed = 10;

            bouncingText = text;
            flyinghead   = head;

            //Spielelemente
            startWeapon = new Weapon();
            player      = new Player();
            playerInput = new Input();

            levelEins            = new Level();
            m_enemyAnimationList = new List <Animation>();

            //Level
            m_Background1 = new Background();
            m_Background2 = new Background();
            m_Background3 = new Background();
            m_Background4 = new Background();
            m_Background5 = new Background();


            //Input
            listOfRectangles     = new List <Rectangle>();
            r_backwards          = new Rectangle(0, 1080 - 160, 80, 160);
            r_forward            = new Rectangle(90, 1080 - 160, 80, 160);
            r_shoot              = new Rectangle(1600, 700, 320, 380);
            listOfTouchLocations = new List <TouchLocation>();
            tc           = TouchPanel.GetCapabilities();
            b_touchState = touchState;
            helper       = new Helper(screenManager);

            if (b_touchState == true)
            {
                m_buttons = new ButtonsDraw();
            }

            m_textures = new Texture2D[5];

            manager.audioFileSystem.menuTheme.Stop();
            audioFileSystem = screenManager.audioFileSystem;
            imageFileSystem = screenManager.imageFileSystem;


            deathApplied = false;
            screenManager.audioFileSystem.s_levelOneTheme.IsLooped = true;
            victoryApplied   = false;
            bossThemeStarted = false;

            //Zählt runter bei null = Tod
            m_countdown = 300;
        }
Ejemplo n.º 3
0
 public Dinosaur(int maxWidth, int maxHeight, ContentManager content)
 {
     touchPanelCapabilities = TouchPanel.GetCapabilities();
     touchPosition          = new Vector2();
     DinosaurTex            = content.Load <Texture2D>("Textures/dinosaur");
     this.maxWidth          = maxWidth;
     this.maxHeight         = maxHeight;
     this.Position          = new Vector2(maxWidth / 2, maxHeight / 2);
 }
Ejemplo n.º 4
0
        static Input()
        {
            TouchPanelCapabilities capabilities = TouchPanel.GetCapabilities();

            TouchPanel.EnabledGestures = GestureType.Flick | GestureType.HorizontalDrag;


            IsConnected       = capabilities.IsConnected;
            MaximumTouchCount = capabilities.MaximumTouchCount;
        }
Ejemplo n.º 5
0
        public Pax4Touch(String p_name, PaxState p_parent0)
            : base(p_name, p_parent0)
        {
#if !WINDOWS_MOUSE
            _touchPanelCapabilities = TouchPanel.GetCapabilities();
#endif
            Reset();

            _flickVelocityThreshold *= Pax4Camera._current._scale2.X;

            _current = this;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// constructor
        /// </summary>
        public TouchManager(ConvertToGameCoord gameCoord, GestureType supportedGestures = GestureType.Tap) : base(gameCoord)
        {
            TouchStartPosition = new TouchLocation[_numTouches];

            //Check if we even have a touchscreen available
            TouchPanelCapabilities touch = TouchPanel.GetCapabilities();

            IsEnabled = touch.IsConnected;

            //enable the tap gesture if available
            SupportedGestures = supportedGestures;
        }
Ejemplo n.º 7
0
        internal void setup()
        {
            touchInterval = Game1.config.touchInterval;

#if WINDOWS_PHONE
            touchPanelCapabilities = TouchPanel.GetCapabilities();
            if (touchPanelCapabilities.IsConnected)
            {
                maximumTouchCount = touchPanelCapabilities.MaximumTouchCount;
            }
#endif
        }
Ejemplo n.º 8
0
        public int getTouchPoints()
        {
            TouchPanelCapabilities tc = TouchPanel.GetCapabilities();

            if (tc.IsConnected)
            {
                return(tc.MaximumTouchCount);
            }
            else
            {
                return(-1);
            }
        }
Ejemplo n.º 9
0
        internal TouchPanel(ScreenView screen)
        {
            this.screen = screen;

            try
            {
                this.caps = XnaTouchPanel.GetCapabilities();
            }
            catch (TypeLoadException)
            {
                this.caps = new TouchPanelCapabilities();
            }

            this.touches    = new List <Touch>(caps.MaximumTouchCount);
            this.newTouches = new List <Touch>(caps.MaximumTouchCount);
        }
Ejemplo n.º 10
0
        private bool TouchInRectangle(Rectangle rectangle)
        {
            TouchPanelCapabilities touchCap = TouchPanel.GetCapabilities();

            if (touchCap.IsConnected)
            {
                TouchCollection touches  = TouchPanel.GetState();
                Vector2         position = Vector2.Zero;

                if (touches.Count > 0)
                {
                    position = touches[0].Position;
                }

                return(position.X >= rectangle.X && position.X <= rectangle.X + rectangle.Width && position.Y >= rectangle.Y && position.Y <= rectangle.Y + rectangle.Height);
            }
            return(false);
        }
Ejemplo n.º 11
0
        private bool GetTouchState()
        {
            TouchPanelCapabilities touchCap = TouchPanel.GetCapabilities();

            if (touchCap.IsConnected)
            {
                TouchCollection touches = TouchPanel.GetState();

                if (touches.Count > 0)
                {
                    return(touches [0].State == TouchLocationState.Pressed);
                }

                return(false);
            }

            return(false);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) &&
                oldstate.IsKeyUp(Keys.Escape))
            {
                if (gameState == PAUSED || gameState == GAMEOVER)
                {
                    gameState = TITLE;
                    waveManager.StopSong();
                }
            }

            //Touch input
            TouchPanelCapabilities tc = TouchPanel.GetCapabilities();//Determine if there is a touch panel connected or not.
            GestureSample          gesture;

            if (tc.IsConnected && TouchPanel.IsGestureAvailable)
            {
                gesture = TouchPanel.ReadGesture();
            }
            else
            {
                gesture = new GestureSample();//Reset it so it's not stuck on one touch method.
            }
            //Get the number of fingers on the screen.
            int             numTaps         = 0;
            TouchCollection touchCollection = TouchPanel.GetState();

            foreach (TouchLocation tl in touchCollection)
            {
                if ((tl.State == TouchLocationState.Pressed) ||
                    (tl.State == TouchLocationState.Moved))
                {
                    numTaps++;//All of this to get the number of fingers on the screen and each one's position.
                }
            }



            //Pausing
            if ((Keyboard.GetState().IsKeyDown(Keys.P) || Keyboard.GetState().IsKeyDown(Keys.Enter)) &&
                (oldstate.IsKeyUp(Keys.P) && oldstate.IsKeyUp(Keys.Enter)))
            {
                if (gameState == GAME)
                {
                    gameState = PAUSED;
                }
                else if (gameState == PAUSED)
                {
                    gameState = GAME;
                }
            }
            else if (numTaps >= 3 || gesture.GestureType == GestureType.Flick)
            {
                if (gameState == GAME && numTaps >= 3)
                {
                    gameState = PAUSED;
                }
                else if (gameState == PAUSED && gesture.GestureType == GestureType.Flick)
                {
                    gameState = GAME;
                }
            }

            //Delete Scores
            if (Keyboard.GetState().IsKeyUp(Keys.X) && oldstate.IsKeyDown(Keys.X))
            {
                clear_scores(10);
                //save_data();
            }

            //Title
            if (gameState == TITLE)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Enter) || gesture.GestureType == GestureType.Tap)
                {
                    gameState = GAME;

                    //Reset the game
                    Initialize();
                    waveManager.PlayWave("bgm");
                }
            }
            //Game
            else if (gameState == GAME)
            {
                //Do all of the player stuff.
                player.Update(stages, gameTime, level, gesture);

                //Update the camera.
                camera(player);

                //Add new stage if necessary
                add_new_stage(stages);

                //Play sound on beat
                beat_timer(gameTime);

                //Fireworks
                for (int i = 0; i < fireworks.Count(); i++)
                {
                    fireworks.ElementAt(i).Update();
                }

                //Fragments
                for (int i = 0; i < fragments.Count(); i++)
                {
                    fragments.ElementAt(i).Update();
                    paint_sky(fragments.ElementAt(i));

                    bool hit_ground = fragments.ElementAt(i).hit_ground(fragments.ElementAt(i).position, stages);
                    bool hit_player = player.rectangle.Intersects(fragments.ElementAt(i).rectangle);

                    //Hit the player
                    if (hit_player)
                    {
                        if (!player.spinning)
                        {
                            if (playerHurtTimer <= 0)//Don't let the player get hurt too much.
                            {
                                lives -= 1;
                                hit.Play();
                                playerHurtTimer = playerHurtTimerMax;
                                paint_splat(fragments.ElementAt(i).color);
                            }
                            fragments.Remove(fragments.ElementAt(i));
                        }
                        //If the player is spinning
                        else
                        {
                            fragments.ElementAt(i).speedY = -5;
                            score += 30;
                        }
                    }
                    //Remove frags that hit the ground or go offscreen.
                    else if (hit_ground || fragments.ElementAt(i).position.Y > screenHeight)
                    {
                        fragments.Remove(fragments.ElementAt(i));
                        ground_instance.Play();//Use instance so only one can play at a time.
                    }
                }

                //Check if the player is in the safehouse
                for (int i = 0; i < stages.Count(); i++)
                {
                    //Reach the safehouse
                    if (player.rectangle.Intersects(stages.ElementAt(i).rectangle) && stages.ElementAt(i).safehouse)
                    {
                        inSafehouse = true;
                    }
                    else if (player.rectangle.Intersects(stages.ElementAt(i).rectangle) && !stages.ElementAt(i).safehouse)
                    {
                        inSafehouse = false;
                    }
                }

                //Paint the ground
                paint_the_ground();

                //Manage Lives
                if (lives <= 0)
                {
                    gameState = GAMEOVER;
                    //Show them their score
                    add_score(displayedScore);
                }
                //Subtract lives if the player falls off the stage.
                if (player.position.Y >= screenHeight)
                {
                    lives -= 1;
                    hit.Play();
                    player.position.Y = screenHeight / 3;
                    player.speedY     = 0;//They don't have momentum built up.
                    player.spinning   = false;
                    player.burstMode  = false;
                }

                //Pause the game if the screen is snapped.
                if (Windows8._windowState == WindowState.Snap1Quarter)
                {
                    gameState = PAUSED;
                }

                //Update the camera
                //cameraView.Update(new Vector2(player.position.X - (screenWidth / 2), player.position.Y - (screenHeight / 2)));

                //Decrement timers
                if (playerHurtTimer > 0)
                {
                    playerHurtTimer--;
                }
            }
            else if (gameState == GAMEOVER)
            {
                if ((Keyboard.GetState().IsKeyUp(Keys.Enter) && oldstate.IsKeyDown(Keys.Enter)) || gesture.GestureType == GestureType.Tap)
                {
                    //Reset the game
                    SaveGameData temp = highscores;
                    Initialize();
                    highscores = temp;
                    gameState  = GAME;
                    waveManager.RestartSong();
                }
            }
            else if (gameState == PAUSED)
            {
            }
            //Update the old keyboard state each frame.
            oldstate = Keyboard.GetState();

            base.Update(gameTime);
        }
 public TouchPanelCapabilitiesEx(TouchPanelCapabilities copy)
 {
     IsConnected       = copy.IsConnected;
     MaximumTouchCount = copy.MaximumTouchCount;
     HasPressure       = copy.HasPressure;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Alternative way to get contacts.  Instead of using TouchHook
        /// this uses the XNA touch support.
        /// </summary>
        public static Touch[] AltGetTouchContacts()
        {
#if DEBUG
            TouchPanelCapabilities caps = TouchPanel.GetCapabilities();
            Debug.Assert(caps.IsConnected, "Should be a touch panel?!?");
#endif

            // Get the contacts.
            TouchCollection collection = TouchPanel.GetState();

            // Translate the contacts into an array of Touch.
            List <Touch> touchList = new List <Touch>();
            foreach (TouchLocation tl in collection)
            {
                // Filter out Invalid ones.  No clue what to do with them anyway...
                if (tl.State != TouchLocationState.Invalid)
                {
                    Touch touch = new Touch();
                    touch.position = tl.Position;

                    // Set position with offset for Tutorial mode.
                    touch.position = touch.position - BokuGame.ScreenPosition;

                    touch.fingerId = tl.Id;
                    touch.phase    = TouchPhase.Stationary;
                    switch (tl.State)
                    {
                    case TouchLocationState.Moved:
                        touch.phase = TouchPhase.Moved;
                        break;

                    case TouchLocationState.Pressed:
                        touch.phase = TouchPhase.Began;
                        break;

                    case TouchLocationState.Released:
                        touch.phase = TouchPhase.Ended;
                        break;
                    }
                    touch.deltaTime = Time.WallClockFrameSeconds;

                    // Look for matching Id to calc deltaPosition.
                    touch.deltaPosition = Vector2.Zero;
                    if (prevTouchList != null)
                    {
                        foreach (Touch t in prevTouchList)
                        {
                            if (t.fingerId == touch.fingerId)
                            {
                                touch.deltaPosition = touch.position - t.position;
                            }
                        }
                    }

                    touchList.Add(touch);
                }
            }   // end of loop over collection

            // Save a reference to this list for next frame.
            prevTouchList = touchList;

            return(touchList.ToArray());
        }   // end of AltGetTouchContacts()
Ejemplo n.º 15
0
        public void Update(LinkedList <Stage> stages, GameTime gameTime, int level, GestureSample gesture)
        {
            TouchPanelCapabilities tc = TouchPanel.GetCapabilities(); //Determine if there is a touch panel connected or not.

            numTaps = 0;                                              //The number of fingers on the screen.
            TouchCollection touchCollection = TouchPanel.GetState();

            foreach (TouchLocation tl in touchCollection)
            {
                if ((tl.State == TouchLocationState.Pressed) ||
                    (tl.State == TouchLocationState.Moved))
                {
                    numTaps++;//All of this to get the number of fingers on the screen and each one's position.
                    tapPositionX = tl.Position.X;
                }
            }

            //Ground Collision
            if (hit_ground(new Vector2(position.X + spriteWidth / 2, position.Y + spriteHeight), stages))
            {
                inAir = false;
            }
            else
            {
                inAir = true;
                //If you are not already in burst mode, falling removes burst mode.
                if (!burstMode)
                {
                    burstMode  = false;
                    burstTimer = 0;
                }

                //Short hop
                if (!Keyboard.GetState().IsKeyDown(Keys.Up) && !Keyboard.GetState().IsKeyDown(Keys.Space) && numTaps == 0)
                {
                    if (speedY > shortHopHeight)
                    {
                        speedY = shortHopHeight;//If you are not holding the jump button, you jump less.
                    }
                }
            }

            //Set the burst speed.
            if (level <= maxBurstSpeedLevel)
            {
                burstSpeed = maxSpeed + level;
            }

            //Spin timer
            if (spinTimer > 0 && spinning)
            {
                spinTimer--;
            }
            else
            {
                spinning = false;
            }


            //Move the player
            horizontal_movement(level, gesture, numTaps, tapPositionX);
            vertical_movement(stages, gesture, numTaps);

            //Animate
            //Which animation do you play?
            choose_animation(level);

            animation.Update(gameTime, new Vector2(position.X + spriteWidth, position.Y + spriteHeight));

            //Actually do the movement
            if (!hit_ground(new Vector2((float)(position.X + spriteWidth / 2 + Math.Sign(speedX) * spriteWidth / 2), position.Y + spriteHeight / 2), stages))
            {
                position.X += (float)speedX;//Only move in the X if there is not a wall in your path.
            }
            else
            {
                speedX     = 0;     //If you hit a wall, you are no longer moving.
                burstMode  = false; //And burst mode is killed
                burstTimer = 0;
            }
            position.Y -= (float)speedY;

            //Update the rectangle based on the new position.
            rectangle = new Rectangle((int)position.X, (int)position.Y, spriteWidth, spriteHeight);

            //Update the keyboard with the new state
            oldstate = Keyboard.GetState();
        }