コード例 #1
0
ファイル: Level2.cs プロジェクト: aenario/Squick
        public override void Update(GameTime gameTime, KinectInterface gameInput)
        {
            if (endLevel.TotalMilliseconds != 0)
            {
                double doneSince = Math.Round(gameTime.TotalGameTime.Subtract(endLevel).TotalSeconds, 1);

                if (doneSince == 3d) fadeEffect.Start(Fade.EFFECT.FADE_IN, Color.Black, 2000);
                if (doneSince == 5d)
                {
                    _sceneFinished = true;
                    _nextScene = new VictoryMenu();
                }

                moveCamera(gameTime);
                items.Clear(); // moveCamera keep spawning
                squick.Update(gameTime);
                bounceAgainstWalls(squick);
                fadeEffect.Update(gameTime);
                message.Update(gameTime);
                return;
            }
            else if (cameraOffset > goal)
            {
                endLevel = gameTime.TotalGameTime;
                ScoreHolder.Level2 = (int)score((float)gameTime.TotalGameTime.Subtract(beginLevel).TotalSeconds);
                message.SetText("Level Clear");
            }

            if(beginLevel.TotalMilliseconds == 0) beginLevel = gameTime.TotalGameTime;
            double startedSince = gameTime.TotalGameTime.Subtract(beginLevel).TotalSeconds;

            if (startedSince < 21d)
            {
                startedSince = Math.Round(startedSince, 1);
                if      (startedSince == 5d)  message.SetText("Move the branch");
                else if (startedSince == 10d) message.SetText("Small branch = ");
                else if (startedSince == 12d) message.SetText("BIG JUMP");
                else if (startedSince == 15d) message.SetText("Get Ready !");
                else if (startedSince == 18d) message.SetText("go");
                else if (startedSince == 20d) message.SetText("");

                message.Update(gameTime);
                hc.Update(gameTime, gameInput);
                activeBranch.Update(gameTime);
                return;
            }
            else hc = null;

            /* Update everything */
            squick.Update(gameTime);
            fadeEffect.Update(gameTime);
            gauge.Update(cameraOffset);
            message.Update(gameTime);
            activeBranch.Update(gameTime);
            oldBranches.RemoveAll(destroyable);
            foreach (Collectible i in items) i.Update(gameTime);
            foreach (Branch b in oldBranches) b.Update(gameTime);

            /* gravity & friction & bounce */
            squick.SpeedY += gravity * (float) gameTime.ElapsedGameTime.TotalSeconds;
            squick.SpeedX *= (float) Math.Pow(friction, gameTime.ElapsedGameTime.TotalSeconds);
            bounceAgainstWalls(squick);

            /* make squick jump on branches */
            processJump(gameInput, gameTime, activeBranch);
            foreach (Branch b in oldBranches) processJump(gameInput, gameTime, b);

            moveCamera(gameTime);

            if (squick.Speed.Y > 0 && squick.Pos.Y > 600) hitBottom();

            foreach (Collectible i in items)
                if(squick.Collide(i)){
                    int impact = i.GetBonus();
                    if (i is GoldenNut) nbOfLives++;
                    else if (i is Bomb) fadeEffect.Start(Fade.EFFECT.FADE_OUT, Color.White, 500.0f);
                    else squick.Speed = newSpeedItem(squick.Speed, impact);

                    squick.makeDizzy();
                    i.CollideWithPlayer(true);
                    i.Destroy();
                    toBeDestroy.Add(i);
                }

            if (toBeDestroy.Count > 0)
            {
                items.RemoveAll(toBeDestroy.Contains);
                toBeDestroy.Clear();
            }
        }
コード例 #2
0
ファイル: Level1.cs プロジェクト: aenario/Squick
        public override void Update(GameTime gameTime, KinectInterface gameInput)
        {
            _backToMenu.Update(gameTime, gameInput);
            if (_backToMenu.IsPressed())
            {
                _nextScene = new MainMenu();
                _sceneFinished = true;
            }

            /* TODO : Clean up all below (_step ?) */
            if (justStarted)
            {
                Level1CollectibleFactory.startNow(gameTime);
                justStarted = false;
                _eventTimer = gameTime.TotalGameTime.TotalSeconds;
            }
            if (Level1CollectibleFactory.doneSince(gameTime) > 10 & Level1CollectibleFactory.doneSince(gameTime) < 10.1)
            {
                _gameEventMessage.SetText("LEVEL CLEAR");
                squick.isDizzy = false;
                if(_modeAdventure) squick.SpeedY = -600;
                _bombEffect.Start(Fade.EFFECT.FADE_IN, Color.Black, 4000.0f);
            }
            if (Level1CollectibleFactory.doneSince(gameTime) > 15)
            {
                ScoreHolder.Level1 = _score;
                if (_modeAdventure) _nextScene = new Level2(gameInput);
                else _nextScene = new VictoryMenu();
                _sceneFinished = true;
            }

            // spawn items
            foreach (EntityFactory se in Level1CollectibleFactory.getSpawnAt(gameTime))
            {
                Entity item = se.asEntity();
                //item.Speed = new Vector2(0, GravitySpeed);
                items.Add(item);
            }

            // destroy items below screen
            List<Collectible> toBeDestroy = new List<Collectible>();
            foreach (Collectible item in items) // quick & dirty
            {
                item.Update(gameTime);

                if (item.Pos.Y > 600)
                {
                    toBeDestroy.Add(item);
                    continue;
                }

                // Collisions
                if (item.GetBoundingBox().Intersects(squick.GetBoundingBox()))
                {
                    // Update internal state
                    item.CollideWithPlayer(true);

                    // BONUS
                    if (item.GetBonus() > 0)
                    {
                        _bonusChain++;
                        _score += this.ComputeBonus(_bonusChain) * item.GetBonus();

                        // Display bonus text
                        if (this._bonusChain % BONUS_CHAIN_VALUE == 0)
                            _gameScoreMessage.SetText(_bonusChain.ToString() + " in a row!");

                    }
                    else
                    {
                        _bonusChain = 0;
                        _gameScoreMessage.SetText("");
                        _score += item.GetBonus();
                    }

                    // ADDITIONAL EFFECTS
                    // . Bomb effect
                    if (item is Bomb)
                    {
                        _bombEffect.Start(Fade.EFFECT.FADE_OUT, Color.White, 300.0f);
                    }

                    // Destroy item
                    toBeDestroy.Add(item);
                }

                // Remove if under the ground

            }

            foreach (Collectible i in toBeDestroy) { i.Destroy(); items.Remove(i); }

            /* Make squick bump */
            if ((squick.Pos.X < 36 && squick.Speed.X < leftBound)
                 || (squick.Pos.X + squick.Width > rightBound && squick.Speed.X > 0))
            {
                // Bounce
                squick.SpeedX *= -1;
                // Sound
                AudioManager.PlaySound(AudioManager.sound_bounce);
            }
            /* INGAME EVENTS */
            double time = Math.Round(gameTime.TotalGameTime.TotalSeconds - _eventTimer, 2);
            // Wave 1
            if (time == (double)Level1CollectibleFactory.WAVE_1)
            {
                _gameEventMessage.SetText("");
                _gameEventMessage.SetMode(Message.DISPLAY_BLINK, 250);
            }
            // Wave 2
            if (time == (double)Level1CollectibleFactory.WAVE_2 - 1)
                _gameEventMessage.SetText("     Warning!!");
            if (time == (double)Level1CollectibleFactory.WAVE_2 + 2)
                _gameEventMessage.SetText("");
            // Wave 3
            if (time == (double)Level1CollectibleFactory.WAVE_3 - 3)
                _gameEventMessage.SetText("     Speed-up!");
            if (time == (double)Level1CollectibleFactory.WAVE_3)
                _gameEventMessage.SetText("");
            // Wave 4
            if (time == (double)Level1CollectibleFactory.WAVE_4 - 2)
                _gameEventMessage.SetText("     Warning!");
            if (time == (double)Level1CollectibleFactory.WAVE_4 + 3)
                _gameEventMessage.SetText("");
            // Wave 5
            if (time == (double)Level1CollectibleFactory.WAVE_5 - 3)
                _gameEventMessage.SetText("     Stay focused!");
            if (time == (double)Level1CollectibleFactory.WAVE_5)
                _gameEventMessage.SetText("");
            // Wave 6
            if (time == (double)Level1CollectibleFactory.WAVE_6 - 1)
                _gameEventMessage.SetText("     Warning!");
            if (time == (double)Level1CollectibleFactory.WAVE_6 + 2)
                _gameEventMessage.SetText("");
            // Wave 7
            if (time == (double)Level1CollectibleFactory.WAVE_7 - 3)
                _gameEventMessage.SetText("     Speed-up!");
            if (time == (double)Level1CollectibleFactory.WAVE_7)
                _gameEventMessage.SetText("");

            // HUD update
            _HUD_score.Update(_score,this.ComputeBonus(_bonusChain));
            _gameEventMessage.Update(gameTime);
            _gameScoreMessage.Update(gameTime);

            // Special effects
            _bombEffect.Update(gameTime);

            squick.Update(gameTime);
        }