예제 #1
0
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                    bool coveredByOtherScreen)
        {
            if (Global.Back == true)
            {
                SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                ScreenManager.Game.Exit();
            }
            if (TouchPanel.IsGestureAvailable)
            {
                Gestures = TouchPanel.ReadGesture();
            }
            else
            {
                Gestures = new GestureSample();
            }



            //SoundManager.GetInstance().PlaySound(ESound.SelectButton);
            //ModeScreen modeScreen = new ModeScreen();
            //ScreenManager.AddScreen(modeScreen);
            //this.ExitScreen();
            //return;

            if (Gestures.GestureType == GestureType.Tap)
            {
                Point posTap = new Point((int)Gestures.Position.X, (int)Gestures.Position.Y);


                if (startButton.Contains(posTap))
                {
                    SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                    ModeScreen modeScreen = new ModeScreen();
                    ScreenManager.AddScreen(modeScreen);
                    this.ExitScreen();
                    return;
                }
                if (aboutButton.Contains(posTap))
                {
                    SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                    AboutScreen aboutScreen = new AboutScreen();
                    ScreenManager.AddScreen(aboutScreen);
                    this.ExitScreen();
                    return;
                }
            }
            base.Update(gameTime, otherScreenHasFocus, false);
        }
예제 #2
0
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            if (Global.Back == true)
            {
                SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                ModeScreen modeScreen = new ModeScreen();
                ScreenManager.AddScreen(modeScreen);
                this.ExitScreen();
                return;
            }

            GesturesInput.GetInstance().Update(gameTime);
            if (GesturesInput.GetInstance().GetGestureType() == GestureType.Tap)
            {
                Microsoft.Xna.Framework.Point posTap = GesturesInput.GetInstance().GetGesturePoint();


                if (pauseButton.Contains(posTap))
                {
                    if (Global.GAMESTATE == GameState.Running)
                    {
                        SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                        Global.GAMESTATE = GameState.PauseGame;
                        GesturesInput.GetInstance().Reset();
                        return;
                    }
                }

                if (resumeButton.Contains(posTap))
                {
                    if (Global.GAMESTATE == GameState.PauseGame)
                    {
                        SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                        Global.GAMESTATE = GameState.Running;
                        m_grid.DragCompleteHandle();
                        GesturesInput.GetInstance().Reset();
                        return;
                    }
                }

                if (restartButton.Contains(posTap))
                {
                    if (Global.GAMESTATE == GameState.PauseGame)
                    {
                        SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                        Reset();
                        Global.GAMESTATE = GameState.Running;
                        GesturesInput.GetInstance().Reset();
                        return;
                    }
                }

                if (menuButton.Contains(posTap))
                {
                    if (Global.GAMESTATE == GameState.PauseGame)
                    {
                        SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                        MenuScreen menuScreen = new MenuScreen();
                        ScreenManager.AddScreen(menuScreen);
                        this.ExitScreen();
                        GesturesInput.GetInstance().Reset();
                        return;
                    }
                }
                if (musicButton.Contains(posTap))
                {
                    if (Global.GAMESTATE == GameState.PauseGame)
                    {
                        SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                        if (Global.SOUND == true)
                        {
                            SoundManager.GetInstance().StopSongs();
                            //SoundManager.GetInstance().PauseSong();
                            Global.SOUND = false;
                        }
                        else
                        {
                            Global.SOUND = true;
                            SoundManager.GetInstance().PlaySong(ESong.Background);
                            //SoundManager.GetInstance().ResumeSong();
                        }


                        GesturesInput.GetInstance().Reset();
                        return;
                    }
                }

                if (Global.GAMESTATE == GameState.EndGame)
                {
                    if (Global.GAMEMODE == GameMode.EasyClassic || Global.GAMEMODE == GameMode.NormalClassic)
                    {
                        if (classic_MenuButton.Contains(posTap))
                        {
                            SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                            MenuScreen menuScreen = new MenuScreen();
                            ScreenManager.AddScreen(menuScreen);
                            this.ExitScreen();
                            GesturesInput.GetInstance().Reset();
                            return;
                        }
                        if (classic_PlayAgainButton.Contains(posTap))
                        {
                            SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                            Reset();
                            Global.GAMESTATE = GameState.Running;
                            GesturesInput.GetInstance().Reset();
                            return;
                        }
                    }
                    if (Global.GAMEMODE == GameMode.Level)
                    {
                        if (level_MenuButton.Contains(posTap))
                        {
                            SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                            MenuScreen menuScreen = new MenuScreen();
                            ScreenManager.AddScreen(menuScreen);
                            this.ExitScreen();
                            GesturesInput.GetInstance().Reset();
                            return;
                        }
                        if (level_NextLevelButton.Contains(posTap))
                        {
                            SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                            int newLevel = m_levelManager.m_currentLevel + 1;
                            m_levelManager.NewLevel();
                            SetLevel(newLevel);
                            Reset();
                            Global.GAMESTATE = GameState.Running;
                            GesturesInput.GetInstance().Reset();
                            return;
                        }
                        if (level_RetryButton.Contains(posTap))
                        {
                            SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                            Reset();
                            Global.GAMESTATE = GameState.Running;
                            GesturesInput.GetInstance().Reset();
                            return;
                        }
                    }
                }
            }
            m_grid.Update(gameTime);
            m_gameTimeManager.Update(gameTime);
            m_pointManager.Update(gameTime);
            if (Global.GAMEMODE == GameMode.Level)
            {
                if (Global.GAMESTATE == GameState.Running && m_levelManager.isWin())
                {
                    SoundManager.GetInstance().PlaySound(ESound.LevelComplete);
                    Global.GAMESTATE = GameState.BeforeEndGame;
                    return;
                }
            }

            if (Global.GAMEMODE == GameMode.EasyClassic || Global.GAMEMODE == GameMode.NormalClassic)
            {
                if (Global.GAMESTATE == GameState.Running && m_gameTimeManager.IsLose())
                {
                    Global.GAMESTATE = GameState.BeforeEndGame;
                    SoundManager.GetInstance().PlaySound(ESound.ClassicComplete);
                    return;
                }
            }

            if (Global.GAMESTATE == GameState.BeforeEndGame)
            {
                m_completeTime -= (float)gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
                m_completePos  += m_AccleComplete * (float)gameTime.ElapsedGameTime.Milliseconds;
                if (m_completeTime <= 0)
                {
                    Global.GAMESTATE = GameState.EndGame;
                    DataManager.GetInstance().LevelCount++;
                    if ((DataManager.GetInstance().LevelCount % 5) == 0)
                    {
                    }
                    m_completeTime = 0;
                    if (Global.GAMEMODE == GameMode.Level)
                    {
                        int newLevel = m_levelManager.m_currentLevel + 1;
                        if (newLevel > DataManager.GetInstance().CurrentLevel)
                        {
                            DataManager.GetInstance().CurrentLevel = newLevel;
                        }
                    }
                }
            }
            GesturesInput.GetInstance().Reset();
            base.Update(gameTime, otherScreenHasFocus, false);
        }
예제 #3
0
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                    bool coveredByOtherScreen)
        {
            if (Global.Back == true)
            {
                SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                ModeScreen modeScreen = new ModeScreen();
                ScreenManager.AddScreen(modeScreen);
                this.ExitScreen();
                return;
            }

            GesturesInput.GetInstance().Update(gameTime);

            if (GesturesInput.GetInstance().GetGestureType() == GestureType.Tap)
            {
                Point posTap = GesturesInput.GetInstance().GetGesturePoint();

                if (backToMenuButton.Contains(posTap))
                {
                    SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                    MenuScreen menuScreen = new MenuScreen();
                    ScreenManager.AddScreen(menuScreen);
                    this.ExitScreen();
                    GesturesInput.GetInstance().Reset();
                    return;
                }

                for (int i = 0; i < m_level; i++)
                {
                    if (m_buttonLevelList[i].Contains(posTap))
                    {
                        SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                        MainGameScreen mainGameScreen = new MainGameScreen();
                        mainGameScreen.SetModeGame(GameMode.Level);
                        int level = i + 1;
                        mainGameScreen.SetLevel(level);
                        ScreenManager.AddScreen(mainGameScreen);
                        GesturesInput.GetInstance().Reset();
                        this.ExitScreen();
                        GesturesInput.GetInstance().Reset();
                        return;
                    }
                }
            }
            if (GesturesInput.GetInstance().GetDirDrag() == DirDrag.Left_Right)
            {
                if (m_state != LevelScreenState.Moving)
                {
                    m_state   = LevelScreenState.Moving;
                    m_VelocX  = -VELOC_X;
                    m_MovingX = 0;
                    GesturesInput.GetInstance().Reset();
                }
            }

            if (GesturesInput.GetInstance().GetDirDrag() == DirDrag.Right_Left)
            {
                if (m_state != LevelScreenState.Moving)
                {
                    m_state   = LevelScreenState.Moving;
                    m_VelocX  = VELOC_X;
                    m_MovingX = 0;
                    GesturesInput.GetInstance().Reset();
                }
            }

            if (m_state == LevelScreenState.Moving)
            {
                MovingScreen(-(int)m_MovingX);
                m_MovingX += m_VelocX * (float)gameTime.ElapsedGameTime.Milliseconds;

                if (m_VelocX > 0)
                {
                    if (m_MovingX >= VIEWPORT_WIDTH)
                    {
                        m_state = LevelScreenState.Wait;
                        MovingScreen(VIEWPORT_WIDTH);
                        m_MovingX = 0;
                        m_VelocX  = 0;
                    }
                    else
                    {
                        MovingScreen((int)m_MovingX);
                    }
                }
                if (m_VelocX < 0)
                {
                    if (m_MovingX <= -VIEWPORT_WIDTH)
                    {
                        m_state = LevelScreenState.Wait;
                        MovingScreen(-VIEWPORT_WIDTH);
                        m_MovingX = 0;
                        m_VelocX  = 0;
                    }
                    else
                    {
                        MovingScreen((int)m_MovingX);
                    }
                }
                if (_srcRect.X < 0)
                {
                    int BonusDeltaX = _srcRect.X - 0;
                    MovingScreen(-BonusDeltaX);
                }
                if (_srcRect.X > MAXPOS_X)
                {
                    int BonusDeltaX = _srcRect.X - MAXPOS_X;
                    MovingScreen(-BonusDeltaX);
                }
            }
            UpdateCurrentLevelGrid();
            base.Update(gameTime, otherScreenHasFocus, false);
        }