Beispiel #1
0
        void touch_GestureOccured(object sender, ZeroLibrary.Xna.Args.GestureArgs e)
        {
            if (ScreenManager.MainScreen == Name)
            {
                GestureSample gesture = e.Gesture;

                if (gesture.GestureType == GestureType.Tap)
                {
                    if (SpriteCollection["tap"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                        Global.Control = Mechanics.ControlTypes.Tap;
                        _setting.Set("control", Global.Control.ToInt(), typeof(int));
                    }
                    else if (SpriteCollection["swipe"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                        Global.Control = Mechanics.ControlTypes.Swipe;
                        _setting.Set("control", Global.Control.ToInt(), typeof(int));
                    }

                    if (Global.Control != Mechanics.ControlTypes.NoControl)
                    {
                        ScreenManager.MainScreen = "Game";
                    }
                }
            }
        }
        //void storeButton_MouseClick(object sender, ZeroXNALibrary.Args.MouseArgs e)
        //{
        //    if (Global.SFXEnabled)
        //    {
        //        clickSound.Play();
        //    }
        //    Global.GotHighScore = false;
        //    Global.ElapsedGameTime = TimeSpan.Zero;
        //    ScreenManager.MainScreen = "Store";
        //}
#else
        void touch_GestureOccured(object sender, ZeroLibrary.Xna.Args.GestureArgs e)
        {
            if (ScreenManager.MainScreen == Name)
            {
                GestureSample gesture = e.Gesture;
                if (gesture.GestureType == GestureType.Tap)
                {
                    if (SpriteCollection["House"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        Global.ShowAds(true);
                        transtitionToTitle();
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                    }

                    if (SpriteCollection["statButton"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        Global.ShowAds(true);
                        transitionToHighScore();
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                    }
                    if (SpriteCollection["settingsButton"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                        trasitionToOption();
                        Global.ShowAds(true);
                    }

                    if (SpriteCollection["Play"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                        transitionToGame();
                        Global.ShowAds(false);
                    }

                    for (int i = 0; i < Global.HighScores.Length; i++)
                    {
                        _setting.Set(String.Format("HighScore{0}", i), Global.HighScores[i].Ticks, typeof(long));

                        _setting.Set(String.Format("HighScoreControl{0}", i), Global.HighScoresType[i].ToInt(), typeof(int));
                        _setting.Set(String.Format("HighScoresDate{0}", i), Global.HighScoreDates[i].Ticks, typeof(long));
                    }
                }
            }
        }
Beispiel #3
0
        void touchManger_GestureOccured(object sender, ZeroLibrary.Xna.Args.GestureArgs e)
        {
            if (ScreenManager.MainScreen == Name)
            {
                GestureSample gesture = e.Gesture;

                if (gesture.GestureType == GestureType.Tap)
                {
                    if (SpriteCollection["playButton"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                        if (Global.Control == Mechanics.ControlTypes.NoControl)
                        {
                            ScreenManager.MainScreen = "ControlSelect";
                            MediaPlayer.Stop();

                            Global.PlayTutorial = true;

                            Global.CurrentBackgroundIndex = random.Next(0, Global.Backgrounds.Count);
                            Global.currentSongIndex       = random.Next(0, Global.GameplaySongs.Count);
                        }
                        else
                        {
                            transitionToGame();
                        }
                        Global.ShowAds(false);
                    }
                    else if (SpriteCollection["options"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                        Global.ShowAds(true);
                        ScreenManager.MainScreen = "Option";
                    }
                    else if (SpriteCollection["highScore"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                        Global.ShowAds(true);
                        ScreenManager.MainScreen = "HighScore";
                    }
                }
            }
        }
        void touchManger_GestureOccured(object sender, ZeroLibrary.Xna.Args.GestureArgs e)
        {
            if (ScreenManager.MainScreen == Name)
            {
                GestureSample gesture = e.Gesture;

                if (gesture.GestureType == GestureType.Tap)
                {
                    if (SpriteCollection["homeButton"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }

                        Global.ShowAds(true);
                        ScreenManager.MainScreen = "Title";
                    }
                }
            }
        }
        void touch_GestureOccured(object sender, ZeroLibrary.Xna.Args.GestureArgs e)
        {
            if (player.CurrentState != CharacterState.Death)
            {
                if (ScreenManager.MainScreen == Name)
                {
                    GestureSample gesture = e.Gesture;

                    if (gesture.GestureType == GestureType.DragComplete || gesture.GestureType == GestureType.Flick)
                    {
                        //direction = directionToGo;
                        swipeRegister = false;
                        deltaSwipe    = 0;
                    }

                    if (player.CurrentState == CharacterState.Idle)
                    {
                        if (Global.Control == ControlTypes.Swipe)
                        {
                            if (gesture.GestureType == GestureType.HorizontalDrag || gesture.GestureType == GestureType.FreeDrag)
                            {
                                int distance = 5;
                                deltaSwipe += gesture.Delta.X;


                                if (Math.Abs(deltaSwipe) > distance && swipeRegister == false)
                                {
                                    swipeRegister = true;
                                    direction     = deltaSwipe > distance ? Direction.Right : Direction.Left;
                                }
                            }
                        }


                        switch (direction)
                        {
                        case Direction.Right:

                            playerIndex++;

                            if (playerIndex < 0 || playerIndex > fallingLocation.Length - 1)
                            {
                                player.CurrentState = CharacterState.Idle;
                            }
                            else
                            {
                                player.CurrentState = CharacterState.Moving;
                                player.Effect       = SpriteEffects.FlipHorizontally;

                                if (Global.SFXEnabled)
                                {
                                    rightSwipe.Play();
                                    //XnaAudio.MediaPlayer.Play(rightSwipe);
                                }
                            }

                            break;

                        case Direction.Left:

                            playerIndex--;
                            if (playerIndex < 0 || playerIndex > fallingLocation.Length - 1)
                            {
                                player.CurrentState = CharacterState.Idle;
                            }
                            else
                            {
                                player.CurrentState = CharacterState.Moving;
                                player.Effect       = SpriteEffects.None;

                                if (Global.SFXEnabled)
                                {
                                    leftSwipe.Play();
                                    //XnaAudio.MediaPlayer.Play(leftSwipe);
                                }
                            }
                            break;

                        default:
                            //do nothing
                            break;
                        }

                        CheckLocation();

                        if (direction == Direction.Right)
                        {
                            player.X = fallingLocation[playerIndex].X;
                        }
                    }
                }
            }
        }
Beispiel #6
0
        void touch_GestureOccured(object sender, ZeroLibrary.Xna.Args.GestureArgs e)
        {
            if (ScreenManager.MainScreen == Name)
            {
                GestureSample gesture = e.Gesture;

                if (gesture.GestureType == GestureType.Tap)
                {
                    if (SpriteCollection["homeButton"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }

                        ScreenManager.MainScreen = "Title";
                        Global.ShowAds(true);
                        _setting.Set("music", Global.MusicEnabled, typeof(bool));
                        _setting.Set("sfx", Global.SFXEnabled, typeof(bool));
                        _setting.Set("control", Global.Control.ToInt(), typeof(int));
                    }
                    else if (SpriteCollection["soundButton"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        Global.SFXEnabled = !Global.SFXEnabled;

                        if (Global.SFXEnabled)
                        {
                            soundButton.Image = selectedSound;
                        }
                        else
                        {
                            soundButton.Image = unSelectedSound;
                        }
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                    }

                    else if (SpriteCollection["musicButton"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }

                        Global.MusicEnabled = !Global.MusicEnabled;

                        if (Global.MusicEnabled)
                        {
                            musicButton.Image = selectedMusic;
                            MediaPlayer.Resume();
                        }
                        else
                        {
                            musicButton.Image = unSelectedMusic;
                            MediaPlayer.Pause();
                        }
                    }
                    else if (SpriteCollection["tapButton"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                        Global.Control    = Mechanics.ControlTypes.Tap;
                        tapButton.Image   = selectedTap;
                        swipeButton.Image = unselectedSwipe;
                    }
                    else if (SpriteCollection["swipeButton"].BoundingBox.Contains(gesture.Position / Scale))
                    {
                        if (Global.SFXEnabled)
                        {
                            clickSound.Play();
                        }
                        Global.Control    = Mechanics.ControlTypes.Swipe;
                        swipeButton.Image = selectedSwipe;
                        tapButton.Image   = unselectedTap;
                    }
                }
            }
        }