Ejemplo n.º 1
0
        private void UpdateProcessTouchInput()
        {
            SpriteObject touchSprite;
            TouchCollection tc = TouchPanel.GetState();
            // Is the player tapping the screen?
            if (tc.Count == 1)
            {
                TouchLocation touch = tc[0];
                if (touch.State == TouchLocationState.Pressed)
                {
                    touchSprite = GetSpriteAtPoint(touch.Position);
                    if (touchSprite is ControlObject)
                    {
                        //   Debug.WriteLine("tap");
                        _controlButton = (ControlObject)touchSprite;
                        _controlButton.TapUpdateCount = 10;
                        switch (_controlButton.InputType)
                        {
                            case ControlObject.ControlType.Right:
                                ProcessRightColumn(ControlObject.ControlType.Right);
                                break;
                            case ControlObject.ControlType.Left:
                                ProcessRightColumn(ControlObject.ControlType.Left);
                                break;
                            case ControlObject.ControlType.Up:
                                ProcessLeftColumn(ControlObject.ControlType.Up);
                                break;
                            case ControlObject.ControlType.Down:
                                ProcessLeftColumn(ControlObject.ControlType.Down);
                                break;
                        }
                    }

                }
            }
        }
Ejemplo n.º 2
0
 //// Process left hand and left foot (a.k.a up and down icon)
 private void ProcessRightColumn(ControlObject.ControlType type)
 {
     GameObjectBase gameObj;
     BalloonObject spriteObj;
     int objectCount = GameObjects.Count;
     for (int i = 0; i < objectCount; i++)
     {
         gameObj = GameObjects[i];
         if (gameObj is BalloonObject)
         {
             spriteObj = (BalloonObject)gameObj;
             if (spriteObj.PositionX == RightColumPos)
             {
                 if (!(spriteObj.BoundingBox.Bottom < ScoreRowBeginPos || spriteObj.BoundingBox.Top > ScoreRowEndPos)
                     && spriteObj.BalloonType == type)
                 {
                     GameScore++;
                     _score.Text = GameScore.ToString();
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void ResetGame()
        {
            GameObjects.Clear();

            // Play back ground music
            var bgSong = Songs["BackgroundMusic"];
            MediaPlayer.Play(bgSong);

            // Create some balloon object
            BalloonObject balloonObject;
            for (int i = 0; i < 30; i++)
            {
                balloonObject = new BalloonObject(this, Textures["Balloon"],
                                                            new Vector2(LeftColumnPos, 100));
                GameObjects.Add(balloonObject);
            }

            // Add controller
            ControlObject controlObject;
            int controlPosY = GraphicsDevice.Viewport.Height - 200;
            controlObject = new ControlObject(this, new Vector2(0, controlPosY),
                            Textures["UpArrow"], ControlObject.ControlType.Up);
            GameObjects.Add(controlObject);
            controlObject = new ControlObject(this, new Vector2(200, controlPosY),
                            Textures["DownArrow"], ControlObject.ControlType.Down);
            GameObjects.Add(controlObject);
            controlObject = new ControlObject(this, new Vector2(400, controlPosY),
                            Textures["LeftArrow"], ControlObject.ControlType.Left);
            GameObjects.Add(controlObject);
            controlObject = new ControlObject(this, new Vector2(600, controlPosY),
                            Textures["RightArrow"], ControlObject.ControlType.Right);
            GameObjects.Add(controlObject);

            // Add mark line
            LineObject line;
            line = new LineObject(this, new Vector2(0, ScoreRowBeginPos), Textures["RedLine"]);
            line.ScaleX = 5;
            GameObjects.Add(line);
            line = new LineObject(this, new Vector2(0, ScoreRowEndPos), Textures["RedLine"]);
            line.ScaleX = 5;
            GameObjects.Add(line);

            // Add score
            _score = new TextObject(this, Fonts["Kootenay"], new Vector2(GraphicsDevice.Viewport.Width / 2, 100), "0") { ScaleX = 5, ScaleY = 5 };
            GameObjects.Add(_score);

            // Load beat
            LoadBeat("Beat.txt");

            GetRightBeat();
            GetLeftBeat();
        }
Ejemplo n.º 4
0
 // Reset properties for another use
 internal void ResetProperties(Texture2D texture, Vector2 position, ControlObject.ControlType type)
 {
     Position = position;
     SpriteTexture = texture;
     BalloonType = type;
 }