示例#1
0
        public override void Init(GraphicsDeviceManager graphics, ContentManager contentManager)
        {
            score               = 0;
            playedMs            = 0;
            timeElapsedSinceQTE = 0;
            startTimerMs        = 0;
            screenWidth         = graphics.PreferredBackBufferWidth;
            screenHeight        = graphics.PreferredBackBufferHeight;

            character      = new GameCharacter(screenHeight, contentManager);
            defaultFont    = contentManager.Load <SpriteFont>("DefaultFont");
            background     = contentManager.Load <Texture2D>("background");
            elementTexture = contentManager.Load <Texture2D>("elements");
            elementSheet   = new SpriteSheet(elementTexture, Constants.ELEMENT_IMAGE_SIZE);

            pointLightManager = new PointLightManager(contentManager);

            int levelSize = Constants.CurrentLevel * 5;

            topWall    = new Wall(contentManager, screenWidth, screenHeight, false, levelSize);
            bottomWall = new Wall(contentManager, screenWidth, screenHeight, true, levelSize);

            camera = new Camera(graphics.GraphicsDevice);

            currentElement = Constants.ChoseElement(false, currentElement);
            currentColor   = Constants.ELEMENT_COLORS[currentElement];

            RestartQTE();
        }
示例#2
0
        public void HandleInput(GameTime time)
        {
            if (elapsedMs < 100 || Passed)
            {
                return;
            }

            KeyboardState keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.Space) && oldState.IsKeyUp(Keys.Space))
            {
                AudioCache.Instance.PlaySoundEffect("pick");

                int currentIndex = (int)selectedElement;
                ++currentIndex;
                if (currentIndex >= Constants.ELEMENT_COUNT)
                {
                    currentIndex = 0;
                }

                selectedElement = (Constants.ELEMENT)currentIndex;
            }

            oldState = keyboardState;
        }
示例#3
0
 public QTE(Constants.ELEMENT selectedElement, int currentScore, SpriteSheet elementSheet)
 {
     elapsedMs         = 0;
     Failed            = false;
     elementLabelY     = 25.0f;
     this.elementSheet = elementSheet;
     ChoseElement();
     ChoseTimeout(currentScore);
     this.selectedElement = selectedElement;
     AudioCache.Instance.PlaySong("battle-theme");
 }
示例#4
0
        public override void Update(GameTime time)
        {
            camera.Update(time);
            camera.Position = character.Position;

            startTimerMs += time.ElapsedGameTime.Milliseconds;
            if (!StartTimerPassed)
            {
                return;
            }

            if (isInQTE)
            {
                if (qte.Failed)
                {
                    GameOver();
                }
                else if (qte.Passed)
                {
                    currentElement = qte.SelectedElement;
                    currentColor   = Constants.ELEMENT_COLORS[currentElement];
                    RestartQTE();
                }
                else
                {
                    qte.Update(time);
                }

                return;
            }

            playedMs += time.TotalGameTime.Milliseconds;
            if (playedMs > 0)
            {
                score = playedMs / 10000;

                // update qte timer
                timeElapsedSinceQTE += time.ElapsedGameTime.Milliseconds;
                CheckQTE();
            }

            character.Update(time, score);
            CheckGameState();
        }