示例#1
0
        public void Update(GameTime gameTime, KinectInterface gameInput)
        {
            // Cursors positions
            Rectangle[] cursors = gameInput.GetHandCursorsBoundingBoxes();

            // Look if user "cursor" is currently hover
            if (_boundingBox.Intersects(cursors[KinectInterface.LEFT_HAND]) || _boundingBox.Intersects(cursors[KinectInterface.RIGHT_HAND]))
            {
                _hover = true;
                _textCurrentColor = _textSelectedColor;
            }
            else
            {
                // Reset current status
                _hover = false;
                _hoverTime = 0.0f;
                _pressed = false;
                _textCurrentColor = _textNormalColor;
            }
            // If currently hover, we measure the total time spent hover, and set the button as selected if the minimal "selection time" was reached
            if(_hover && !_pressed)
            {
                // Coompute total time
                float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
                _hoverTime += dt;

                // Selection time is reached !
                if (_hoverTime >= TextButton.BUTTON_SELECTION_TIME)
                {
                    _pressed = true;
                    Console.WriteLine("BUTTON " + _buttonText + " IS PRESSED");
                }
            }
        }
示例#2
0
        public override void Update(GameTime gameTime, KinectInterface gameInput)
        {
            // Update buttons state

            _victoryMsg.Update(gameTime, gameInput);
            _backToMenuBtn.Update(gameTime, gameInput);
            _quitBtn.Update(gameTime, gameInput);

            if (ScoreHolder.hasLevel1) _level1Box.Update(gameTime, gameInput);
            if (ScoreHolder.hasLevel2) _level2Box.Update(gameTime, gameInput);
            if (ScoreHolder.hasLevel1 && ScoreHolder.hasLevel2) _levelTotal.Update(gameTime, gameInput);

            _hc.Update(gameTime, gameInput);

            // Action
            if (_backToMenuBtn.IsPressed())
            {
                _nextScene = new MainMenu();
                _sceneFinished = true;
            }
            else if (_quitBtn.IsPressed())
            {
                _nextScene = null; // Game will quit
                _sceneFinished = true;
            }
        }
示例#3
0
文件: Branch.cs 项目: aenario/Squick
 public Branch(KinectInterface gameInput)
     : base()
 {
     _gameInput = gameInput;
     _texture = ResourceManager.tex_branch;
     branchExtremity = new Rectangle(64, 0, 0, _texture.Height);
 }
示例#4
0
        public SceneManager(Squick game, KinectInterface gameInput)
        {
            _game = game;
            _gameInput = gameInput;

            ScoreHolder.Level1 = 10000;
            ScoreHolder.Level2 = 12000;

            //_currentScene = new Level1(gameInput); // Change with your level
            //_currentScene = new DebugMenu(); // For testing purpose
            //_currentScene = new VictoryMenu(); // For testing purpose
            _currentScene = new MainMenu();
        }
示例#5
0
文件: Level2.cs 项目: aenario/Squick
        public Level2(KinectInterface gameInput)
        {
            _levelBackground = ResourceManager.tex_background_level2;
            squick = new JumpingSquick(gameInput);
            squick.Pos = new Vector2(400, 800);
            squick.Speed = new Vector2(0,-600);
            toBeDestroy = new List<Entity>();

            activeBranch = new Branch(gameInput);
            oldBranches = new List<Branch>();
            cameraOffset = 0;

            fadeEffect = new Fade();

            gauge = new Gauge(new Rectangle(30, 50, 10, 500), goal, Color.BurlyWood, Color.Gold);
            message = new Message("Training time !", new Vector2(20, 220), 2.0f, Message.DISPLAY_LBL, 50);
            hc = new HandCursors();
        }
示例#6
0
文件: Level1.cs 项目: aenario/Squick
        //private Player _squick;
        public Level1(KinectInterface gameInput, bool modeAdventure = false)
        {
            _levelBackground = ResourceManager.tex_background_level1;
            _modeAdventure = modeAdventure;

            _bombEffect = new Fade();

            _HUD_score = new Score(new Vector2(10,0));
            _backToMenu = new TextButton("Menu", new Vector2(690, 10));

            squick = new DizzySquick(gameInput);
            squick.Pos = new Vector2(400, 400);

            _gameEventMessage = new Message("Ready?  Set...  Go!", new Vector2(20, 220),2.0f,Message.DISPLAY_LBL,250);
            _gameScoreMessage = new Message("",new Vector2(10,160),1.0f,Message.DISPLAY_LBL,1000);

            // Level score
            _score = 0;
            _bonusChain = 0;
        }
示例#7
0
        public override void Update(GameTime gameTime, KinectInterface gameInput)
        {
            // Update buttons state

            _hc = new HandCursors();

            _gameOverMsg.Update(gameTime, gameInput);
            _backToMenuBtn.Update(gameTime, gameInput);
            _continueBtn.Update(gameTime, gameInput);
            _quitBtn.Update(gameTime, gameInput);

            _hc.Update(gameTime, gameInput);

            // Action
            if (_backToMenuBtn.IsPressed())
            {
                _nextScene = new MainMenu();
                _sceneFinished = true;
            }
            else if (_continueBtn.IsPressed())
            {
                switch (_fromLevel)
                {
                    case 1: _nextScene = new Level1(gameInput);
                        break;
                    case 2: _nextScene = new Level2(gameInput);
                        break;
                    default: _nextScene = null;
                        break;
                }

                _sceneFinished = true;
            }
            else if (_quitBtn.IsPressed())
            {
                _nextScene = null; // Game will quit
                _sceneFinished = true;
            }
        }
示例#8
0
        public override void Update(GameTime gameTime, KinectInterface gameInput)
        {
            // Update buttons state
            _startButton.Update(gameTime, gameInput);
            _start2Button.Update(gameTime, gameInput);
            _quitButton.Update(gameTime, gameInput);

            // Action
            if (_startButton.IsPressed())
            {
                _nextScene = new Level1(gameInput); // Game will quit
                _sceneFinished = true;
            }
            else if (_start2Button.IsPressed())
            {
                _nextScene = new Level2(gameInput); // Game will quit
                _sceneFinished = true;
            }
            else if (_quitButton.IsPressed())
            {
                _nextScene = null; // Game will quit
                _sceneFinished = true;
            }
        }
示例#9
0
        public override void Update(GameTime gameTime, KinectInterface gameInput)
        {
            // Update buttons state

            _hc.Update(gameTime, gameInput);
            _aventureBtn.Update(gameTime, gameInput);
            _level1Btn.Update(gameTime, gameInput);
            _level2Btn.Update(gameTime, gameInput);
            _quitBtn.Update(gameTime, gameInput);

            // Action
            if (_level1Btn.IsPressed()){
                ScoreHolder.clearLevel1();
                ScoreHolder.clearLevel2();
                _nextScene = new Level1(gameInput);
                _sceneFinished = true;

            }else if(_aventureBtn.IsPressed()){
                ScoreHolder.clearLevel1();
                ScoreHolder.clearLevel2();
                _nextScene = new Level1(gameInput, true);
                _sceneFinished = true;
            }
            else if (_level2Btn.IsPressed())
            {
                ScoreHolder.clearLevel1();
                ScoreHolder.clearLevel2();
                _nextScene = new Level2(gameInput);
                _sceneFinished = true;
            }
            else if (_quitBtn.IsPressed())
            {
                _nextScene = null; // Game will quit
                _sceneFinished = true;
            }
        }
示例#10
0
文件: TextBox.cs 项目: aenario/Squick
 public void Update(GameTime gameTime, KinectInterface gameInput)
 {
     // Cursors positions
 }
示例#11
0
文件: Scene.cs 项目: aenario/Squick
 public abstract void Update(GameTime gameTime, KinectInterface gameInput);
示例#12
0
 public DizzySquick(KinectInterface gameInput)
     : base()
 {
     _gameInput = gameInput;
     _bodyTexBox = new Rectangle(0, 0, ResourceManager.tex_squick_body.Width, ResourceManager.tex_squick_body.Height);
 }
示例#13
0
 public JumpingSquick(KinectInterface gameInput)
     : base()
 {
     _gameInput = gameInput;
     _boundingBox = ResourceManager.tex_squick_body.Bounds;
 }
示例#14
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);
        }
示例#15
0
文件: Level2.cs 项目: aenario/Squick
        private void processJump(KinectInterface gameInput, GameTime gameTime, Branch b)
        {
            var later = Vector2.Add(squick.Bottom, Vector2.Multiply(squick.Speed, impactTrigger));
            bool aboutToCross = b.isBelow(squick.Bottom) && b.isAbove(later);

            if (!aboutToCross) return;

            AudioManager.PlaySound(AudioManager.sound_jump);

            float oldSpeed = squick.Speed.Length();
            Vector2 direction = Vector2.Reflect(squick.Speed, b.Normal);

            squick.Speed = Vector2.Multiply(Vector2.Normalize(direction),
                newSpeed(oldSpeed, b.BounceLength));

            b.HitAndBreak(gameTime);
            if (b.Equals(activeBranch))
            {
                oldBranches.Add(activeBranch);
                activeBranch = new Branch(gameInput);
                activeBranch.Update(gameTime);
            }
        }
示例#16
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();
            }
        }
示例#17
0
文件: Squick.cs 项目: aenario/Squick
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Set graphic options
            _graphicsDevice.PreferredBackBufferWidth = SCREEN_WIDTH;
            _graphicsDevice.PreferredBackBufferHeight = SCREEN_HEIGHT;
            _graphicsDevice.IsFullScreen = FULLSCREEN_ENABLED;
            _graphicsDevice.ApplyChanges();

            // Managers (singleton static classes)
            RenderManager.Initialize(GraphicsDevice);
            ResourceManager.Initialize(Content,GraphicsDevice);
            AudioManager.Initialize(Content);

            // Initialize Kinect and its interface
            _kinectsManager = new KinectManager();
            _gameInput = new KinectInterface(_kinectsManager, KinectInterface.MODE_HANDS);

            _sceneManager = new SceneManager(this,_gameInput);
            base.Initialize();
        }
示例#18
0
 public void Update(GameTime gameTime, KinectInterface gameInput)
 {
     Vector2[] pos = gameInput.GetLatestCoordinates();
     _left = pos[KinectInterface.LEFT_HAND];
     _right = pos[KinectInterface.RIGHT_HAND];
 }