コード例 #1
0
ファイル: ModeScreen.cs プロジェクト: MaxKomisar/Zombie-Set
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                    bool coveredByOtherScreen)
        {
            if (Global.Back == true)
            {
                SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                MenuScreen menuScreen = new MenuScreen();
                ScreenManager.AddScreen(menuScreen);
                this.ExitScreen();
                return;
            }
            if (TouchPanel.IsGestureAvailable)
            {
                Gestures = TouchPanel.ReadGesture();
            }
            else
            {
                Gestures = new GestureSample();
            }

            if (Gestures.GestureType == GestureType.Tap)
            {
                Point posTap = new Point((int)Gestures.Position.X, (int)Gestures.Position.Y);
                if (m_state == ModeScreenState.Select)
                {
                    if (EasyButton.Contains(posTap))
                    {
                        SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                        MainGameScreen mainGameScreen = new MainGameScreen();
                        mainGameScreen.SetModeGame(GameMode.EasyClassic);
                        ScreenManager.AddScreen(mainGameScreen);
                        this.ExitScreen();
                        return;
                    }
                    if (NormalButton.Contains(posTap))
                    {
                        SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                        MainGameScreen mainGameScreen = new MainGameScreen();
                        mainGameScreen.SetModeGame(GameMode.NormalClassic);
                        ScreenManager.AddScreen(mainGameScreen);
                        this.ExitScreen();
                        return;
                    }
                    if (levelsButton.Contains(posTap))
                    {
                        SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                        LevelScreen levelScreen = new LevelScreen();
                        ScreenManager.AddScreen(levelScreen);
                        this.ExitScreen();
                        return;
                    }
                    if (howToPlayButton.Contains(posTap))
                    {
                        SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                        m_state = ModeScreenState.Tutorial;

                        return;
                    }
                }
                if (m_state == ModeScreenState.Tutorial)
                {
                    SoundManager.GetInstance().PlaySound(ESound.SelectButton);
                    m_pHowToPlay.CurentFrame++;
                    m_pHowToPlay.setFrame(m_pHowToPlay.CurentFrame);
                    if (m_pHowToPlay.CurentFrame > m_pHowToPlay.TotalFrame - 1)
                    {
                        m_pHowToPlay.CurentFrame = 0;
                        m_pHowToPlay.setFrame(m_pHowToPlay.CurentFrame);
                        m_state = ModeScreenState.Select;
                    }
                }
            }
            base.Update(gameTime, otherScreenHasFocus, false);
        }
コード例 #2
0
ファイル: LevelScreen.cs プロジェクト: MaxKomisar/Zombie-Set
        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);
        }