Esempio n. 1
0
        public void Update(MouseState msNow, MouseState msPrev, ref screenState activeScr, ref int currentLevel, ref DateTime levelStart)
        {
            unlockedLevel = getUnlocked();

            foreach (levelButton f in levelGrid)
            {
                if (f.isClicked(msNow, msPrev) && (f.levelNum <= unlockedLevel))
                {
                    if (f.levelNum == 1)
                    {
                        activeScr    = screenState.howtoScr;
                        currentLevel = f.levelNum;
                    }
                    else
                    {
                        levelStart   = new DateTime();
                        activeScr    = screenState.gameScr;
                        currentLevel = f.levelNum;
                    }
                }
            }



            if (backButton.isClicked(msNow, msPrev))
            {
                activeScr = screenState.menuScr;
            }
        }
Esempio n. 2
0
        public void Update(MouseState msNow, MouseState msPrev, ref screenState activeScr)
        {
            if (levelsButton.isClicked(msNow, msPrev))
            {
                activeScr = screenState.levelScr;
            }

            if (rndButton.isClicked(msNow, msPrev))
            {
                activeScr = screenState.randScr;
            }

            if (new Rectangle(547, 36, 19, 39).Contains(msNow.X, msNow.Y))
            {
                if (msNow.LeftButton == ButtonState.Released && msPrev.LeftButton == ButtonState.Pressed)
                {
                    //WRITE TO SAVE FILE
                    string _path = Environment.CurrentDirectory;
                    for (int i = 0; i < 6; i++)
                    {
                        _path = Convert.ToString(Directory.GetParent(_path));
                    }
                    _path += @"\save.txt";
                    if (File.Exists(_path))
                    {
                        using (var writer = new StreamWriter(_path))
                        {
                            writer.WriteLine("36");
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 public void Update(MouseState msNow, MouseState msPrev, ref screenState activeScr, ref DateTime levelStart)
 {
     if (playButton.isClicked(msNow, msPrev))
     {
         levelStart = new DateTime();
         activeScr  = screenState.gameScr;
     }
 }
Esempio n. 4
0
        public void Update(MouseState msNow, MouseState msPrev, ref screenState activeScr)
        {
            if (playButton.isClicked(msNow, msPrev))
            {
                activeScr = screenState.menuScr;
            }

            animation.Update();
        }
Esempio n. 5
0
        public void Update(MouseState msNow, MouseState msPrev, ref screenState activeScr, ref DateTime levelStart, ref DateTime levelEnd)
        {
            if (levelStart.Second == 0)
            {
                levelStart = DateTime.Now;
            }

            foreach (Pipe p in pipeGrid)
            {
                p.Update(msNow, msPrev);
            }

            waterList.Clear();
            waterList = waterTree(4, 0, 0, pipeGrid, waterList);

            //FILLER
            int s = 0;
            int t = 0;

            for (s = 0; s < pipeGrid.GetLength(0); s++)
            {
                for (t = 0; t < pipeGrid.GetLength(1); t++)
                {
                    if (waterList.Contains(pipeGrid[s, t]))
                    {
                        pipeGrid[s, t].filled = true;
                    }
                    else
                    {
                        if (!pipeGrid[s, t].isSource)
                        {
                            pipeGrid[s, t].filled = false;
                        }
                    }
                }
            }

            if (pipeGrid[pipeGrid.GetLength(0) - 1, pipeGrid.GetLength(1) - 1].filled)
            {
                levelEnd  = DateTime.Now;
                activeScr = screenState.compScr;
            }
            if (backButton.isClicked(msNow, msPrev))
            {
                levelEnd  = DateTime.Now;
                activeScr = screenState.menuScr;
            }
        }
Esempio n. 6
0
        public void Update(MouseState msNow, MouseState msPrev, ref screenState activeScr, ref int currentLevel, ref int width, ref int length, ref DateTime levelStart)
        {
            gridWidth  = widthSlider.Update(msNow, msPrev);
            gridHeight = heightSlider.Update(msNow, msPrev);
            if (backButton.isClicked(msNow, msPrev))
            {
                activeScr = screenState.menuScr;
            }

            if (playButton.isClicked(msNow, msPrev))
            {
                width        = gridWidth;
                length       = gridHeight;
                levelStart   = new DateTime();
                currentLevel = 99;
                activeScr    = screenState.gameScr;
            }
        }
Esempio n. 7
0
        protected override void Initialize()
        {
            state = screenState.Game;

            switch (state)
            {
            case screenState.Splash: break;

            case screenState.Menu: break;

            case screenState.Game:
                Gameplay         = new Gameplay();
                Gameplay.Content = Content;
                Gameplay.Initialize();
                break;
            }

            base.Initialize();
        }
Esempio n. 8
0
        public virtual void Update(GameTime gameTime, bool otherScreenFocus, bool coveredOtherScreen)
        {
            this.otherScreenHasFocus = otherScreenFocus;

            if (exit)
            {
                currentState = screenState.Off;

                if (!theTransition(gameTime, offT, 1))
                {
                    SManager.RemoveScreen(this);
                }
            }
            else if (coveredOtherScreen)
            {
                if (theTransition(gameTime, offT, 1))
                {
                    currentState = screenState.Off;
                }
                else
                {
                    currentState = screenState.Hidden;
                }
            }
            else
            {
                if (theTransition(gameTime, oT, -1))
                {
                    currentState = screenState.On;
                }
                else
                {
                    currentState = screenState.Active;
                }
            }
        }
Esempio n. 9
0
        public void Update(MouseState msNow, MouseState msPrev, ref screenState activeScr)
        {
            if (backButton.isClicked(msNow, msPrev))
            {
                //WRITE TO SAVE FILE
                string _path = Environment.CurrentDirectory;
                for (int i = 0; i < 6; i++)
                {
                    _path = Convert.ToString(Directory.GetParent(_path));
                }
                _path += @"\save.txt";
                if (File.Exists(_path) && (currentLevel + 1 > getUnlocked()))
                {
                    using (var writer = new StreamWriter(_path))
                    {
                        writer.WriteLine(currentLevel + 1);
                    }
                }

                activeScr = screenState.menuScr;
            }

            inpBox.Update(msNow, msPrev);
        }
Esempio n. 10
0
        /// <summary>
        /// Lógica del programa.
        /// </summary>
        /// <returns>Si se sale del programa o no</returns>
        public Boolean update()
        {
            this.currentScreenState = this.nextScreenState;
            this.currentPlayState   = this.nextPlayState;

            switch (this.currentScreenState)
            {
            case screenState.INIT:
                // algo en inicio?
                this.nextScreenState = screenState.MENU;
                break;

            case screenState.MENU:
                updateButtonsState(this.menuButtons);
                if (this.menuButtons[(int)GameButtonList.menuButton.PLAY].justPushed())
                {
                    this.nextScreenState = screenState.PLAY;
                    this.nextPlayState   = playState.INIT;
                }
                else if (this.menuButtons[(int)GameButtonList.menuButton.EXIT].justPushed())
                {
                    // termina el juego
                    return(false);
                }
                break;

            case screenState.PLAY:
                switch (this.currentPlayState)
                {
                case playState.INIT:
                    // algo en inicio?
                    this.gamePostures = null;
                    this.gameScores.Clear();
                    this.nextPlayState = playState.SELECT_POSTURE;
                    break;

                case playState.SELECT_POSTURE:
                    // actualiza la postura objetivo
                    if (updateCurrentGamePosture())
                    {
                        /// @FIX001:
                        this.drawPostureTimeOut = Stopwatch.StartNew();
                        this.nextPlayState      = playState.DRAW_POSTURE;
                    }
                    // si no quedan mas posturas va a la puntuacion final
                    else
                    {
                        this.nextPlayState = playState.FINAL_SCORE;
                    }
                    break;

                case playState.DRAW_POSTURE:
                    // Esta fase es para presentarle al usuario la postura objetivo
                    // TIMEOUT de 10 segundos o pulsar CONTINUE

                    /// @FIX001: Estaba a null el this.drawPostureTimeOut, asique le he puesto valor en SELECT_POSTURE (Margen de error: 1frame).
                    updateButtonsState(this.pauseButtons);
                    if (this.pauseButtons[(int)GameButtonList.pauseButton.CONTINUE].justPushed() ||
                        isTimedOut(this.drawPostureTimeOut, DRAW_POSTURE_TIME))
                    {
                        this.drawPostureTimeOut.Reset();
                        this.nextPlayState = playState.DETECT_POSTURE;
                    }
                    break;

                case playState.DETECT_POSTURE:
                    updateButtonsState(this.gameButtons);
                    if (this.gameButtons[(int)GameButtonList.gameButton.PAUSE].justPushed())
                    {
                        this.nextPlayState = playState.PAUSE;
                    }
                    else
                    {
                        if (playerSkeleton != null)
                        {
                            Posture.Posture p = new Posture.Posture(playerSkeleton);
                            score = p.compareTo(gamePostures[gamePosturesIndex], ref jointScore, averageTolerance, puntualTolerance);
                            if (score < 1.0)
                            {
                                this.holdPostureTimeOut = Stopwatch.StartNew();
                                this.nextPlayState      = playState.HOLD_POSTURE;
                            }
                        }
                    }
                    break;

                case playState.HOLD_POSTURE:
                    updateButtonsState(this.gameButtons);
                    if (this.gameButtons[(int)GameButtonList.gameButton.PAUSE].justPushed())
                    {
                        this.nextPlayState = playState.PAUSE;
                    }
                    else
                    {
                        if (playerSkeleton != null)
                        {
                            Posture.Posture p = new Posture.Posture(playerSkeleton);
                            score = p.compareTo(gamePostures[gamePosturesIndex], ref jointScore, averageTolerance, puntualTolerance);
                            if (score < 1.0)
                            {
                                // La postura hay que mantenerla 2 segundos (HOLD_POSTURE_TIME)
                                if (isTimedOut(this.holdPostureTimeOut, HOLD_POSTURE_TIME))
                                {
                                    gameScores.Add(gamePostures[gamePosturesIndex], score);
                                    this.holdPostureTimeOut.Reset();
                                    this.scoreTimeOut  = Stopwatch.StartNew();
                                    this.nextPlayState = playState.SCORE;
                                }
                            }
                            else
                            {
                                this.holdPostureTimeOut.Reset();
                                this.nextPlayState = playState.DETECT_POSTURE;
                            }
                        }
                    }
                    break;

                case playState.PAUSE:
                    updateButtonsState(this.pauseButtons);
                    if (this.pauseButtons[(int)GameButtonList.pauseButton.CONTINUE].justPushed())
                    {
                        this.nextPlayState = playState.DETECT_POSTURE;
                    }
                    else if (this.pauseButtons[(int)GameButtonList.pauseButton.REPLAY].justPushed())
                    {
                        this.nextPlayState = playState.INIT;
                    }
                    else if (this.pauseButtons[(int)GameButtonList.pauseButton.EXIT].justPushed())
                    {
                        this.nextPlayState = playState.END;
                    }
                    break;

                case playState.SCORE:
                    updateButtonsState(this.scoreButtons);
                    // TIMEOUT de 10 segundos a la siguiente postura o se pulsa alguna opcion
                    if (this.scoreButtons[(int)GameButtonList.scoreButton.NEXT].justPushed() ||
                        isTimedOut(this.scoreTimeOut, SCORE_TIME))
                    {
                        this.scoreTimeOut.Reset();
                        this.nextPlayState = playState.SELECT_POSTURE;
                    }
                    else if (this.scoreButtons[(int)GameButtonList.scoreButton.MENU].justPushed())
                    {
                        this.scoreTimeOut.Reset();
                        this.nextPlayState = playState.END;
                    }
                    else if (this.scoreButtons[(int)GameButtonList.scoreButton.REPLAY].justPushed())
                    {
                        this.scoreTimeOut.Reset();
                        this.nextPlayState = playState.INIT;
                    }
                    break;

                case playState.FINAL_SCORE:
                    updateButtonsState(this.scoreButtons);
                    if (this.scoreButtons[(int)GameButtonList.scoreButton.MENU].justPushed())
                    {
                        this.nextPlayState = playState.END;
                    }
                    else if (this.scoreButtons[(int)GameButtonList.scoreButton.REPLAY].justPushed())
                    {
                        this.nextPlayState = playState.INIT;
                    }
                    break;

                default:
                case playState.END:
                    this.nextScreenState = screenState.MENU;
                    break;
                }
                break;

            default:
            case screenState.END:
                return(false);    // Se avisa de que el programa dejara de actualizarse
            }

            return(true); // Si no esta en estado de END se continua con la ejecucion
        }
        /// <summary>
        /// Lógica del programa.
        /// </summary>
        /// <returns>Si se sale del programa o no</returns>
        public Boolean update()
        {
            this.currentScreenState = this.nextScreenState;
            this.currentPlayState   = this.nextPlayState;

            switch (this.currentScreenState)
            {
                case screenState.INIT:
                    // algo en inicio?
                    this.nextScreenState = screenState.MENU;
                    break;

                case screenState.MENU:
                    updateButtonsState(this.menuButtons);
                    if (this.menuButtons[(int)GameButtonList.menuButton.PLAY].justPushed())
                    {
                        this.nextScreenState = screenState.PLAY;
                        this.nextPlayState = playState.INIT;
                    }
                    else if (this.menuButtons[(int)GameButtonList.menuButton.EXIT].justPushed())
                    {
                        // termina el juego
                        return false;
                    }
                    break;

                case screenState.PLAY:
                    switch (this.currentPlayState)
                    {
                        case playState.INIT:
                            // algo en inicio?
                            this.gamePostures = null;
                            this.gameScores.Clear();
                            this.nextPlayState = playState.SELECT_POSTURE;
                            break;

                        case playState.SELECT_POSTURE:
                            // actualiza la postura objetivo
                            if (updateCurrentGamePosture())
                            {
                                /// @FIX001:
                                this.drawPostureTimeOut = Stopwatch.StartNew();
                                this.nextPlayState = playState.DRAW_POSTURE;
                            }
                            // si no quedan mas posturas va a la puntuacion final
                            else
                            {
                                this.nextPlayState = playState.FINAL_SCORE;
                            }
                            break;

                        case playState.DRAW_POSTURE:
                            // Esta fase es para presentarle al usuario la postura objetivo
                            // TIMEOUT de 10 segundos o pulsar CONTINUE

                            /// @FIX001: Estaba a null el this.drawPostureTimeOut, asique le he puesto valor en SELECT_POSTURE (Margen de error: 1frame).
                            updateButtonsState(this.pauseButtons);
                            if (this.pauseButtons[(int)GameButtonList.pauseButton.CONTINUE].justPushed() ||
                                isTimedOut(this.drawPostureTimeOut, DRAW_POSTURE_TIME))
                            {
                                this.drawPostureTimeOut.Reset();
                                this.nextPlayState = playState.DETECT_POSTURE;
                            }
                            break;

                        case playState.DETECT_POSTURE:
                            updateButtonsState(this.gameButtons);
                            if (this.gameButtons[(int)GameButtonList.gameButton.PAUSE].justPushed())
                                this.nextPlayState = playState.PAUSE;
                            else
                            {
                                if (playerSkeleton != null)
                                {
                                    Posture.Posture p = new Posture.Posture(playerSkeleton);
                                    score = p.compareTo(gamePostures[gamePosturesIndex], ref jointScore, averageTolerance, puntualTolerance);
                                    if (score < 1.0)
                                    {
                                        this.holdPostureTimeOut = Stopwatch.StartNew();
                                        this.nextPlayState = playState.HOLD_POSTURE;
                                    }
                                }
                            }
                            break;

                        case playState.HOLD_POSTURE:
                            updateButtonsState(this.gameButtons);
                            if (this.gameButtons[(int)GameButtonList.gameButton.PAUSE].justPushed())
                                this.nextPlayState = playState.PAUSE;
                            else
                            {
                                if (playerSkeleton != null)
                                {
                                    Posture.Posture p = new Posture.Posture(playerSkeleton);
                                    score = p.compareTo(gamePostures[gamePosturesIndex], ref jointScore, averageTolerance, puntualTolerance);
                                    if (score < 1.0)
                                    {
                                        // La postura hay que mantenerla 2 segundos (HOLD_POSTURE_TIME)
                                        if (isTimedOut(this.holdPostureTimeOut, HOLD_POSTURE_TIME))
                                        {
                                            gameScores.Add(gamePostures[gamePosturesIndex], score);
                                            this.holdPostureTimeOut.Reset();
                                            this.scoreTimeOut = Stopwatch.StartNew();
                                            this.nextPlayState = playState.SCORE;
                                        }
                                    }
                                    else
                                    {
                                        this.holdPostureTimeOut.Reset();
                                        this.nextPlayState = playState.DETECT_POSTURE;
                                    }
                                }
                            }
                            break;

                        case playState.PAUSE:
                            updateButtonsState(this.pauseButtons);
                            if (this.pauseButtons[(int)GameButtonList.pauseButton.CONTINUE].justPushed())
                                this.nextPlayState = playState.DETECT_POSTURE;
                            else if (this.pauseButtons[(int)GameButtonList.pauseButton.REPLAY].justPushed())
                                this.nextPlayState = playState.INIT;
                            else if (this.pauseButtons[(int)GameButtonList.pauseButton.EXIT].justPushed())
                                this.nextPlayState = playState.END;
                            break;

                        case playState.SCORE:
                            updateButtonsState(this.scoreButtons);
                            // TIMEOUT de 10 segundos a la siguiente postura o se pulsa alguna opcion
                            if (this.scoreButtons[(int)GameButtonList.scoreButton.NEXT].justPushed() ||
                                isTimedOut(this.scoreTimeOut, SCORE_TIME))
                            {
                                this.scoreTimeOut.Reset();
                                this.nextPlayState = playState.SELECT_POSTURE;
                            }
                            else if (this.scoreButtons[(int)GameButtonList.scoreButton.MENU].justPushed())
                            {
                                this.scoreTimeOut.Reset();
                                this.nextPlayState = playState.END;
                            }
                            else if (this.scoreButtons[(int)GameButtonList.scoreButton.REPLAY].justPushed())
                            {
                                this.scoreTimeOut.Reset();
                                this.nextPlayState = playState.INIT;
                            }
                            break;

                        case playState.FINAL_SCORE:
                            updateButtonsState(this.scoreButtons);
                            if (this.scoreButtons[(int)GameButtonList.scoreButton.MENU].justPushed())
                                this.nextPlayState = playState.END;
                            else if (this.scoreButtons[(int)GameButtonList.scoreButton.REPLAY].justPushed())
                                this.nextPlayState = playState.INIT;
                            break;

                        default:
                        case playState.END:
                            this.nextScreenState = screenState.MENU;
                            break;
                    }
                    break;

                default:
                case screenState.END:
                    return false; // Se avisa de que el programa dejara de actualizarse
            }

            return true; // Si no esta en estado de END se continua con la ejecucion
        }
Esempio n. 12
0
 // Use this for initialization
 void Start()
 {
     currentState = play;  //for testing current shooter mechanics
 }
Esempio n. 13
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch  = new SpriteBatch(GraphicsDevice);
            activeScr    = screenState.openScr;
            prevScr      = screenState.openScr;
            currentLevel = 1;
            rndWidth     = 0;
            rndLength    = 0;

            buttonFont = Content.Load <SpriteFont>("butFont");

            //ANIMATION LOADING
            for (int i = 0; i < 80; i++)
            {
                animationLibrary.Add(Content.Load <Texture2D>("Textures/OpenAnimation/ani" + (i + 1)));
            }

            //SAVE FILE LOADING
            string _path = Environment.CurrentDirectory;

            for (int i = 0; i < 6; i++)
            {
                _path = Convert.ToString(Directory.GetParent(_path));
            }
            _path += @"\save.txt";
            if (!File.Exists(_path))
            {
                using (var writer = new StreamWriter(_path))
                {
                    writer.WriteLine(0);
                }
            }

            //TEXTURE LOADING
            textureLibrary.Add(Content.Load <Texture2D>("Textures/OpenScr/bcg"));               //0
            textureLibrary.Add(Content.Load <Texture2D>("Textures/OpenScr/playButton1"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/OpenScr/playButton2"));       //2
            textureLibrary.Add(Content.Load <Texture2D>("Textures/OpenScr/playButton3"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/MenuScr/bcg"));               //4
            textureLibrary.Add(Content.Load <Texture2D>("Textures/MenuScr/levelsButton1"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/MenuScr/levelsButton2"));     //6
            textureLibrary.Add(Content.Load <Texture2D>("Textures/MenuScr/levelsButton3"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Corner/corPipe1"));   //8
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Corner/corPipe2"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Corner/corPipe3"));   //10
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Corner/corPipe4"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Corner/corPipe5"));   //12
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Corner/corPipe6"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Corner/corPipe7"));   //14
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Corner/corPipe8"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Cutoff/cutPipe1"));   //16
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Cutoff/cutPipe2"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Cutoff/cutPipe3"));   //18
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Cutoff/cutPipe4"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Cutoff/cutPipe5"));   //20
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Cutoff/cutPipe6"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Cutoff/cutPipe7"));   //22
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Cutoff/cutPipe8"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Straight/strPipe1")); //24
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Straight/strPipe2"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Straight/strPipe3")); //26
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/Straight/strPipe4"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/levelScr/lvlButton1"));       //28
            textureLibrary.Add(Content.Load <Texture2D>("Textures/levelScr/lvlButton2"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/levelScr/lvlButton3"));       //30
            textureLibrary.Add(Content.Load <Texture2D>("Textures/CompScr/bcg"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/CompScr/backButton1"));       //32
            textureLibrary.Add(Content.Load <Texture2D>("Textures/CompScr/backButton2"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/CompScr/backButton3"));       //34
            textureLibrary.Add(Content.Load <Texture2D>("Textures/RandomScr/horBar"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/RandomScr/horSlider"));       //36
            textureLibrary.Add(Content.Load <Texture2D>("Textures/RandomScr/verBar"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/RandomScr/verSlider"));       //38
            textureLibrary.Add(Content.Load <Texture2D>("Textures/RandomScr/blob"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/RandomScr/canvas"));          //40
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/howto"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/MenuScr/rndButton1"));        //42
            textureLibrary.Add(Content.Load <Texture2D>("Textures/MenuScr/rndButton2"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/MenuScr/rndButton3"));        //44
            textureLibrary.Add(Content.Load <Texture2D>("Textures/CompScr/input1"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/CompScr/input2"));            //46
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/crossButton1"));
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/crossButton2"));      //48
            textureLibrary.Add(Content.Load <Texture2D>("Textures/GameScr/crossButton3"));

            //SOUND LOADING
            soundLibrary.Add(Content.Load <SoundEffect>("Sounds/pipeShift1"));//0
            soundLibrary.Add(Content.Load <SoundEffect>("Sounds/pipeShift2"));

            OpeningScreen  = new openScr(textureLibrary, soundLibrary, animationLibrary, buttonFont);
            MenuScreen     = new menuScr(textureLibrary, soundLibrary);
            GameScreen     = new gameScr(textureLibrary, soundLibrary, currentLevel, rndWidth, rndLength);
            LevelScreen    = new levelScr(textureLibrary, soundLibrary, buttonFont);
            CompleteScreen = new compScr(textureLibrary, soundLibrary, buttonFont, levelTime.Seconds, currentLevel);
            RandomScreen   = new randomScr(textureLibrary, soundLibrary, buttonFont);
            HowToScreen    = new howtoScr(textureLibrary, soundLibrary);
        }
Esempio n. 14
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)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            msNow = Mouse.GetState();

            if (gameTime.TotalGameTime != TimeSpan.FromTicks(0))
            {
                prevScr = activeScr;
                switch (activeScr)
                {
                case screenState.openScr:
                {
                    OpeningScreen.Update(msNow, msPrev, ref activeScr);
                    break;
                }

                case screenState.menuScr:
                {
                    MenuScreen.Update(msNow, msPrev, ref activeScr);
                    break;
                }

                case screenState.levelScr:
                {
                    LevelScreen.Update(msNow, msPrev, ref activeScr, ref currentLevel, ref levelStart);
                    break;
                }

                case screenState.gameScr:
                {
                    GameScreen.Update(msNow, msPrev, ref activeScr, ref levelStart, ref levelEnd);
                    break;
                }

                case screenState.compScr:
                {
                    CompleteScreen.Update(msNow, msPrev, ref activeScr);
                    break;
                }

                case screenState.randScr:
                {
                    RandomScreen.Update(msNow, msPrev, ref activeScr, ref currentLevel, ref rndWidth, ref rndLength, ref levelStart);
                    break;
                }

                case screenState.howtoScr:
                {
                    HowToScreen.Update(msNow, msPrev, ref activeScr, ref levelStart);
                    break;
                }
                }

                levelTime = levelEnd - levelStart;
                if (activeScr != prevScr)
                {
                    if (activeScr == screenState.gameScr)
                    {
                        GameScreen = new gameScr(textureLibrary, soundLibrary, currentLevel, rndWidth, rndLength);
                    }
                    else if (activeScr == screenState.compScr)
                    {
                        CompleteScreen = new compScr(textureLibrary, soundLibrary, buttonFont, levelTime.Seconds, currentLevel);
                    }
                }
            }

            msPrev = msNow;

            base.Update(gameTime);
        }