public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }

                pointerPosition.X = ein.RightHand.Pos.X * 640;
                pointerPosition.Y = ein.RightHand.Pos.Y * 360;

                if (pointerPosition.X > 300 && pointerPosition.X < 468 && pointerPosition.Y > 400 && pointerPosition.Y < 562)
                {
                    Difficulty = 1;
                }

                if (pointerPosition.X > 600 && pointerPosition.X < 768 && pointerPosition.Y > 400 && pointerPosition.Y < 562)
                {
                    Difficulty = 2;
                }

                if (pointerPosition.X > 900 && pointerPosition.X < 1068 && pointerPosition.Y > 400 && pointerPosition.Y < 562)
                {
                    Difficulty = 3;
                }
        }
        public PaddleMiniGame(GraphicsDevice graphicsDevice)
        {
            this.graphicsDevice = graphicsDevice;

            sb = new SpriteBatch(graphicsDevice);

            tutorialTimer = 0;

            ein = Game1.ein;

            circleTexture = CreateCircle(8, graphicsDevice);

            gameState = MiniGameState.Initialized;

            physicsWorld = new World(new Vector2(0, 0.8f));

            paddle = BodyFactory.CreateRectangle(physicsWorld, paddle_width * pixelToUnit, paddle_height * pixelToUnit, 1000f);
            paddle.BodyType = BodyType.Static;
            paddle.Position = new Vector2(320 * pixelToUnit, 240 * pixelToUnit);
            paddle_size = new Vector2(paddle_width * pixelToUnit, paddle_height * pixelToUnit);

            ball = BodyFactory.CreateCircle(physicsWorld, ball_radius * pixelToUnit, 1000f);
            ball.BodyType = BodyType.Dynamic;
            ball.Position = new Vector2(320 * pixelToUnit, 100 * pixelToUnit);
            ball.SleepingAllowed = false;
        }
        public PinballMiniGame(GraphicsDevice graphicsDevice)
        {
            this.graphicsDevice = graphicsDevice;

            sb = new SpriteBatch(graphicsDevice);

            ein = new Kinect(0, 0);
            ein.Init();

            circleTexture = CreateCircle(ball_radius, graphicsDevice);

            gameState = MiniGameState.Initialized;

            physicsWorld = new World(new Vector2(0, .982f));
            paddleSize = new Vector2(300, 16);
            paddleLeft = BodyFactory.CreateRectangle(physicsWorld, paddleSize.X * 2 * pixelToUnit, paddleSize.Y * pixelToUnit, 1000f);
            paddleLeft.BodyType = BodyType.Dynamic;
            paddleLeft.Position = new Vector2(8 * pixelToUnit, (GameConstants.MiniGameCanvasHeight - 100) * pixelToUnit);
            paddleLeft.LocalCenter = new Vector2(0, 0);
            paddleLeft.SleepingAllowed = false;
            paddleLeft.Restitution = 1.0f;
            paddleLeft.IgnoreGravity = true;

            ball = BodyFactory.CreateCircle(physicsWorld, (ball_radius) * pixelToUnit, 1000f);
            ball.BodyType = BodyType.Dynamic;
            ball.Position = new Vector2(100 * pixelToUnit, 100 * pixelToUnit);
            ball.Restitution = 1.0f;
            ball.SleepingAllowed = false;
        }
Example #4
0
	private void GotBackBoard (MiniGameState state)
	{
		BoardData boardData = FindObjectOfType<BoardData>();
		boardData.miniGameState = state;
		LevelLoader.Instance.LoadScene ("DevBoard");
		boardData.gameState = GameState.GiveRewards;
	}
        public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }

            KeyboardState ks = Keyboard.GetState();
        }
        public ColorCallMiniGame(GraphicsDevice graphicsDevice)
        {
            sb = new SpriteBatch(graphicsDevice);

            ein = new Kinect(0, 0);
            ein.Init();

            gameState = MiniGameState.Initialized;
        }
Example #7
0
        public FootGame(GraphicsDevice graphicsDevice)
        {
            this.graphicsDevice = graphicsDevice;

            ein = Game1.ein;

            if ((new Random()).Next() % 2 == 0)
            {
                foot = "left";
            }
            else
            {
                foot = "right";
            }

            sb = new SpriteBatch(graphicsDevice);

            backgroundColor = new Color((float)Game1.GameRandom.NextDouble(), (float)Game1.GameRandom.NextDouble(), (float)Game1.GameRandom.NextDouble(), 1);

            gameState = MiniGameState.Initialized;
        }
Example #8
0
        public void Update(GameTime gameTime)
        {
            //3 seconds to lift foot
            //hold left foot up

            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }

            if (!ShowedTutorial)
            {
                tutorialTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (tutorialTimer > tutorialDuration)
                {
                    ShowedTutorial = true;
                }

                return;
            }

            if (!ein.LeftLegRaised && !ein.RightLegRaised || (foot == "right" && !ein.RightLegRaised && ein.LeftLegRaised) || (foot == "left" && ein.RightLegRaised && !ein.LeftLegRaised))
            {
                holdUpTime = 0.0f;
                initialTime += gameTime.ElapsedGameTime.Milliseconds;
                if (footInProgress)
                    lose = true;
            }
            else
            {
                initialTime = 0.0f;
                holdUpTime += gameTime.ElapsedGameTime.Milliseconds;
                footInProgress = true;
            }

            if (initialTime > 5000)
            {
                lose = true;
            }

            if (holdUpTime > 5000)
            {
                win = true;
            }
        }
Example #9
0
 public MingameBase()
 {
     myState = MiniGameState.NOTSTARTED;
 }
Example #10
0
	public void SetMiniGameByIndex (int indexMiniGame, MiniGameState miniGameState,int miniGamesViewed)
	{
		this.miniGamesView = miniGamesViewed;
		CurrentMiniGame = this.miniGames [indexMiniGame];
		CurrentMiniGame.state = miniGameState;
	}
        public BrickMiniGame(GraphicsDevice graphicsDevice)
        {
            targets = new List<Body>();

            this.graphicsDevice = graphicsDevice;

            sb = new SpriteBatch(graphicsDevice);

            ein = Game1.ein;

            circleTexture = CreateCircle(ballRadius, graphicsDevice);
            paddleTexture = CreateCircle(paddleRadius, graphicsDevice);
            targetTexture = CreateCircle(targetRadius, graphicsDevice);

            gameState = MiniGameState.Initialized;

            physicsWorld = new World(new Vector2(0, 0f));
            Random rand = new Random(DateTime.Now.Ticks.GetHashCode());
            for (int i = 0; i < 2; i++)
            {
                Body body = BodyFactory.CreateCircle(physicsWorld, targetRadius * pixelToUnit, 1000f);
                body.BodyType = BodyType.Static;
                body.Position = new Vector2((float)(32 + rand.NextDouble() * (GameConstants.MiniGameCanvasWidth - 64)) * pixelToUnit,
                    (float)(32 + rand.NextDouble() * (GameConstants.MiniGameCanvasHeight - 150)) * pixelToUnit);
                targets.Add(body);
            }
            paddle = BodyFactory.CreateCircle(physicsWorld, paddleRadius * pixelToUnit, 1000f);
            paddle.BodyType = BodyType.Dynamic;
            paddle.Position = new Vector2(GameConstants.MiniGameCanvasWidth / 2 * pixelToUnit, (GameConstants.MiniGameCanvasHeight+20) * pixelToUnit);
            paddle.SleepingAllowed = false;
            paddle.Restitution = 1.0f;
            paddle.IgnoreGravity = true;
            paddle.Mass = 10000000;
            paddle.Friction = 0;

            wallLeft = BodyFactory.CreateRectangle(physicsWorld, 16 * pixelToUnit, GameConstants.MiniGameCanvasHeight * pixelToUnit, 1000f);
            wallLeft.BodyType = BodyType.Static;
            wallLeft.Position = new Vector2(0, GameConstants.MiniGameCanvasHeight / 2f * pixelToUnit);
            wallLeft.SleepingAllowed = false;
            wallLeft.Restitution = 1.0f;
            wallLeft.Friction = 0;

            wallRight = BodyFactory.CreateRectangle(physicsWorld, 16 * pixelToUnit, GameConstants.MiniGameCanvasHeight * pixelToUnit, 1000f);
            wallRight.BodyType = BodyType.Static;
            wallRight.Position = new Vector2(GameConstants.MiniGameCanvasWidth * pixelToUnit, GameConstants.MiniGameCanvasHeight / 2f * pixelToUnit);
            wallRight.SleepingAllowed = false;
            wallRight.Restitution = 1.0f;
            wallRight.Friction = 0;

            wallTop = BodyFactory.CreateRectangle(physicsWorld, GameConstants.MiniGameCanvasWidth * pixelToUnit, 16 * pixelToUnit, 1000f);
            wallTop.BodyType = BodyType.Static;
            wallTop.Position = new Vector2(GameConstants.MiniGameCanvasWidth / 2 * pixelToUnit, 0);
            wallTop.SleepingAllowed = false;
            wallTop.Restitution = 1.0f;
            wallTop.Friction = 0;

            ball = BodyFactory.CreateCircle(physicsWorld, (ballRadius) * pixelToUnit, 1000f);
            ball.BodyType = BodyType.Dynamic;
            ball.Position = new Vector2(GameConstants.MiniGameCanvasWidth / 2 * pixelToUnit, (GameConstants.MiniGameCanvasHeight - 100) * pixelToUnit);
            ball.Restitution = 1.0f;
            ball.Mass = 200;
            ball.SleepingAllowed = false;
            ball.AngularDamping = 1.0f;
            ball.FixedRotation = true;
            ball.Friction = 0;
            float speed = 8;
            float theta = (float)(Math.PI / 4 + new Random().NextDouble() * Math.PI / 2);
            float x = (float)Math.Cos(theta) * speed;
            float y = (float)-Math.Sin(theta) * speed;
            ball.LinearVelocity = new Vector2(x, y);
            while (Math.Abs(ball.LinearVelocity.X) < 0.1 && Math.Abs(ball.LinearVelocity.Y) < 0.1)
            {
                theta = (float)(Math.PI / 4 + new Random().NextDouble() * Math.PI / 2);
                x = (float)Math.Cos(theta) * speed;
                y = (float)-Math.Sin(theta) * speed;
                ball.LinearVelocity = new Vector2(x, y);

            }
        }
Example #12
0
	public void FinishMiniGame ( MiniGameState state )
	{
		this.miniGameState = state;
		gameState = GameState.GiveRewards;
	}
Example #13
0
        public BrickMiniGame(GraphicsDevice graphicsDevice)
        {
            targets = new List <Body>();

            this.graphicsDevice = graphicsDevice;

            sb = new SpriteBatch(graphicsDevice);

            ein = Game1.ein;

            circleTexture = CreateCircle(ballRadius, graphicsDevice);
            paddleTexture = CreateCircle(paddleRadius, graphicsDevice);
            targetTexture = CreateCircle(targetRadius, graphicsDevice);

            gameState = MiniGameState.Initialized;

            physicsWorld = new World(new Vector2(0, 0f));
            Random rand = new Random(DateTime.Now.Ticks.GetHashCode());

            for (int i = 0; i < 2; i++)
            {
                Body body = BodyFactory.CreateCircle(physicsWorld, targetRadius * pixelToUnit, 1000f);
                body.BodyType = BodyType.Static;
                body.Position = new Vector2((float)(32 + rand.NextDouble() * (GameConstants.MiniGameCanvasWidth - 64)) * pixelToUnit,
                                            (float)(32 + rand.NextDouble() * (GameConstants.MiniGameCanvasHeight - 150)) * pixelToUnit);
                targets.Add(body);
            }
            paddle                 = BodyFactory.CreateCircle(physicsWorld, paddleRadius * pixelToUnit, 1000f);
            paddle.BodyType        = BodyType.Dynamic;
            paddle.Position        = new Vector2(GameConstants.MiniGameCanvasWidth / 2 * pixelToUnit, (GameConstants.MiniGameCanvasHeight + 20) * pixelToUnit);
            paddle.SleepingAllowed = false;
            paddle.Restitution     = 1.0f;
            paddle.IgnoreGravity   = true;
            paddle.Mass            = 10000000;
            paddle.Friction        = 0;

            wallLeft                 = BodyFactory.CreateRectangle(physicsWorld, 16 * pixelToUnit, GameConstants.MiniGameCanvasHeight * pixelToUnit, 1000f);
            wallLeft.BodyType        = BodyType.Static;
            wallLeft.Position        = new Vector2(0, GameConstants.MiniGameCanvasHeight / 2f * pixelToUnit);
            wallLeft.SleepingAllowed = false;
            wallLeft.Restitution     = 1.0f;
            wallLeft.Friction        = 0;

            wallRight                 = BodyFactory.CreateRectangle(physicsWorld, 16 * pixelToUnit, GameConstants.MiniGameCanvasHeight * pixelToUnit, 1000f);
            wallRight.BodyType        = BodyType.Static;
            wallRight.Position        = new Vector2(GameConstants.MiniGameCanvasWidth * pixelToUnit, GameConstants.MiniGameCanvasHeight / 2f * pixelToUnit);
            wallRight.SleepingAllowed = false;
            wallRight.Restitution     = 1.0f;
            wallRight.Friction        = 0;

            wallTop                 = BodyFactory.CreateRectangle(physicsWorld, GameConstants.MiniGameCanvasWidth * pixelToUnit, 16 * pixelToUnit, 1000f);
            wallTop.BodyType        = BodyType.Static;
            wallTop.Position        = new Vector2(GameConstants.MiniGameCanvasWidth / 2 * pixelToUnit, 0);
            wallTop.SleepingAllowed = false;
            wallTop.Restitution     = 1.0f;
            wallTop.Friction        = 0;


            ball                 = BodyFactory.CreateCircle(physicsWorld, (ballRadius) * pixelToUnit, 1000f);
            ball.BodyType        = BodyType.Dynamic;
            ball.Position        = new Vector2(GameConstants.MiniGameCanvasWidth / 2 * pixelToUnit, (GameConstants.MiniGameCanvasHeight - 100) * pixelToUnit);
            ball.Restitution     = 1.0f;
            ball.Mass            = 200;
            ball.SleepingAllowed = false;
            ball.AngularDamping  = 1.0f;
            ball.FixedRotation   = true;
            ball.Friction        = 0;
            float speed = 8;
            float theta = (float)(Math.PI / 4 + new Random().NextDouble() * Math.PI / 2);
            float x     = (float)Math.Cos(theta) * speed;
            float y     = (float)-Math.Sin(theta) * speed;

            ball.LinearVelocity = new Vector2(x, y);
            while (Math.Abs(ball.LinearVelocity.X) < 0.1 && Math.Abs(ball.LinearVelocity.Y) < 0.1)
            {
                theta = (float)(Math.PI / 4 + new Random().NextDouble() * Math.PI / 2);
                x     = (float)Math.Cos(theta) * speed;
                y     = (float)-Math.Sin(theta) * speed;
                ball.LinearVelocity = new Vector2(x, y);
            }
        }
Example #14
0
 public void SetMiniGameByIndex(int indexMiniGame, MiniGameState miniGameState, int miniGamesViewed)
 {
     this.miniGamesView    = miniGamesViewed;
     CurrentMiniGame       = this.miniGames [indexMiniGame];
     CurrentMiniGame.state = miniGameState;
 }
Example #15
0
        public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }
            if (!ShowedTutorial)
            {
                tutorialTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (tutorialTimer > tutorialDuration)
                {
                    ShowedTutorial = true;
                }

                return;
            }
            pushAlienTimer += gameTime.ElapsedGameTime.Milliseconds;
            if (pushAlienTimer > timeBetweenNewAliens)
            {
                pushAlienTimer = 0;
                aliens.Add(new Alien(this));
            }

            if (killCount >= 5)
            {
                gameState = MiniGameState.Win;
            }

            {
                string lastColor = ein.LastColor;

                if (!String.IsNullOrEmpty(lastColor))
                {
                    bool assigned = true;
                    Alien.AlienColor winColor = Alien.AlienColor.Red;

                    switch (lastColor)
                    {
                        case "RED": winColor = Alien.AlienColor.Red; break;
                        case "GREEN": winColor = Alien.AlienColor.Green; break;
                        case "YELLOW": winColor = Alien.AlienColor.Yellow; break;
                        case "BLUE": winColor = Alien.AlienColor.Blue; break;
                        default:
                            assigned = false;
                            break;
                    }

                    if (assigned)
                    {
                        foreach (Alien al in aliens)
                        {
                            if (al.color == winColor)
                            {
                                bullets.Add(new PlayerBullet(playerPosition, al, this));

                                playerAngle = (float)(Math.Atan2(al.position.Y - playerPosition.Y, al.position.X - playerPosition.X));

                                break;
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < 100; i++)
            {
                stars[i].Update(gameTime);
            }

            foreach (PlayerBullet b in bullets)
            {
                b.Update(gameTime);
            }

            foreach (Alien al in aliens)
            {
                al.Update(gameTime);

                if (al.dead)
                {
                    for (int i = 0; i < 7; i++)
                    {
                        particles.Add(new Particle(al.position, (float)(Game1.GameRandom.NextDouble() * Math.PI * 2), 3));
                    }
                }
            }

            for (int i = 0; i < particles.Count; i++)
            {
                particles[i].Update(gameTime);
            }

            bullets.RemoveAll(BulletDead);
            aliens.RemoveAll(AlienDead);
            particles.RemoveAll(ParticleDead);

            #if CHANGE_BG_COLOR
            {
                string lastColor = ein.LastColor;
                if (!string.IsNullOrEmpty(lastColor))
                {
                    switch (lastColor)
                    {
                        case "RED": bgColor = Color.Red; break;
                        case "GREEN": bgColor = Color.Green; break;
                        case "YELLOW": bgColor = Color.Yellow; break;
                        case "BLUE": bgColor = Color.Blue; break;
                        default:
                            break;
                    }
                }
            }
            #endif
        }
Example #16
0
        public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }
            if (!ShowedTutorial)
            {
                tutorialTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (tutorialTimer > tutorialDuration)
                {
                    ShowedTutorial = true;
                }

                return;
            }
            string col = ein.LastColor;
            if (!String.IsNullOrEmpty(col))
            {
                //Check if the text version of the rendered color is said.
                if (col.Equals(colorsStrings[colorIndex]))
                {
                    correct++;
                    resetDisplay();
                    if (correct == 5)
                    {
                        win = true;
                        ein.LastColor = string.Empty;
                    }
                }
                else
                {
                    lose = true;
                }

            }
            time -= gameTime.ElapsedGameTime.Milliseconds;
            if (time <= 0)
            {
                lose = true;
            }
        }
Example #17
0
 public void FinishMiniGame(MiniGameState state)
 {
     this.miniGameState = state;
     gameState          = GameState.GiveRewards;
 }
        public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }

            if (!ShowedTutorial)
            {
                tutorialTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (tutorialTimer > tutorialDuration)
                {
                    ShowedTutorial = true;
                }

                return;
            }

            winTimer += gameTime.ElapsedGameTime.Milliseconds;

            if (winTimer > 10000)
            {
                win = true;
            }

            if (ball.Position.Y * unitToPixel > GameConstants.MiniGameCanvasHeight)
            {
                lost = true;
            }

            KeyboardState ks = Keyboard.GetState();

            if (ks.IsKeyDown(Keys.Tab))
            {
                ball.Position = new Vector2(320 * pixelToUnit, 100 * pixelToUnit);
                ball.AngularVelocity = 0;
                ball.LinearVelocity = Vector2.Zero;
            }

            /*
            if (ks.IsKeyDown(Keys.A))
            {
                paddle.Rotation += 0.01f;
            }
            else if (ks.IsKeyDown(Keys.D))
            {
                paddle.Rotation -= 0.01f;
            }
             */

            //paddle.Rotation -= (ein.RightHandAngle)/50.0f;

            //paddle.Rotation = -ein.RightHandAngle;
            if (Math.Abs(paddle.Rotation - (-1 * ein.RHRSAngle)) > 0.025f)
            {
                if (paddle.Rotation < (-1 * ein.RHRSAngle))
                {
                    paddle.Rotation += 0.051f;
                }
                else if (paddle.Rotation > (-1 * ein.RHRSAngle))
                {
                    paddle.Rotation -= 0.051f;
                }
            }

            // Simulate physics.
            physicsWorld.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
        }
Example #19
0
        public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }

            winTimer += gameTime.ElapsedGameTime.Milliseconds;

            if (winTimer > 10000 && !win)
            {
                lose = true;
            }

            if (score >= 3)
            {
                win = true;
            }

            if (!ShowedTutorial)
            {
                tutorialTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (tutorialTimer > tutorialDuration)
                {
                    ShowedTutorial = true;
                }

                return;
            }


            if (prizeGet)
            {
                body3.Position = new Vector2(random.Next(1, GameConstants.MiniGameCanvasWidth) * pixelToUnit, random.Next(1, GameConstants.MiniGameCanvasHeight) * pixelToUnit);
                prizeGet       = false;
                score++;
            }

            //Console.WriteLine(prizeGet);

            /*if (body.Position.X > body3.Position.X - ((width3 / 2) * pixelToUnit) && body.Position.X < (body3.Position.X + ((width3 / 2) * pixelToUnit)) && body.Position.Y > body3.Position.Y - ((height3 / 2) * pixelToUnit) && body.Position.Y < body3.Position.Y + ((height3 / 2) * pixelToUnit))
             * {
             *  if (leftGripped)
             *      prizeGet = true;
             * }*/

            if (body2.Position.X > body3.Position.X - ((width3 / 2) * pixelToUnit) && body2.Position.X < (body3.Position.X + ((width3 / 2) * pixelToUnit)) && body2.Position.Y > body3.Position.Y - ((height3 / 2) * pixelToUnit) && body2.Position.Y < body3.Position.Y + ((height3 / 2) * pixelToUnit))
            {
                if (rightGripped)
                {
                    prizeGet = true;
                }
            }

            /*if (ein.LeftHand.Gripped)
             * {
             *  PlainTextureLeft.SetData(new[] { Color.Red });
             *  leftGripped = true;
             * }
             * if (ein.LeftHand.Released)
             * {
             *  PlainTextureLeft.SetData(new[] { Color.White });
             *  leftGripped = false;
             * }*/

            if (ein.RightHand.Gripped)
            {
                PlainTextureRight.SetData(new[] { Color.Red });
                rightGripped = true;
            }
            if (ein.RightHand.Released)
            {
                PlainTextureRight.SetData(new[] { Color.White });
                rightGripped = false;
            }

            //if(ein.LeftHand.Active)
            //body.Position = new Vector2(((ein.LeftHand.Pos.X+.5f) * GameConstants.MiniGameCanvasWidth/2 ) * pixelToUnit, ein.LeftHand.Pos.Y * GameConstants.MiniGameCanvasHeight * pixelToUnit);
            if (ein.RightHand.Active)
            {
                body2.Position = new Vector2((ein.RightHand.Pos.X / 2 * GameConstants.MiniGameCanvasWidth / 2 + GameConstants.MiniGameCanvasWidth / 2) * pixelToUnit, ein.RightHand.Pos.Y * GameConstants.MiniGameCanvasHeight * pixelToUnit);
            }



            //Console.WriteLine(ein.LeftHand.Pos.Y);
            // Simulate physics.
            world.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
        }
Example #20
0
        public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }

            winTimer += gameTime.ElapsedGameTime.Milliseconds;

            if (winTimer > 10000 && !win)
            {
                lose = true;
            }

            if (score >= 3)
            {
                win = true;
            }

            if (!ShowedTutorial)
            {
                tutorialTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (tutorialTimer > tutorialDuration)
                {
                    ShowedTutorial = true;
                }

                return;
            }

            if (prizeGet)
            {
                body3.Position = new Vector2(random.Next(1, GameConstants.MiniGameCanvasWidth) * pixelToUnit, random.Next(1, GameConstants.MiniGameCanvasHeight) * pixelToUnit);
                prizeGet = false;
                score++;
            }

            //Console.WriteLine(prizeGet);

            if (body.Position.X > body3.Position.X - ((width3 / 2) * pixelToUnit) && body.Position.X < (body3.Position.X + ((width3 / 2) * pixelToUnit)) && body.Position.Y > body3.Position.Y - ((height3 / 2) * pixelToUnit) && body.Position.Y < body3.Position.Y + ((height3 / 2) * pixelToUnit))
            {
                if (leftGripped)
                    prizeGet = true;
            }

            /*if (body2.Position.X > body3.Position.X - ((width3 / 2) * pixelToUnit) && body2.Position.X < (body3.Position.X + ((width3 / 2) * pixelToUnit)) && body2.Position.Y > body3.Position.Y - ((height3 / 2) * pixelToUnit) && body2.Position.Y < body3.Position.Y + ((height3 / 2) * pixelToUnit))
            {
                if (rightGripped)
                    prizeGet = true;
            }*/

            if (ein.LeftHand.Gripped)
            {
                PlainTextureLeft.SetData(new[] { Color.Red });
                leftGripped = true;
            }
            if (ein.LeftHand.Released)
            {
                PlainTextureLeft.SetData(new[] { Color.White });
                leftGripped = false;
            }

            /*if (ein.RightHand.Gripped)
            {
                PlainTextureRight.SetData(new[] { Color.Red });
                rightGripped = true;
            }
            if (ein.RightHand.Released)
            {
                PlainTextureRight.SetData(new[] { Color.White });
                rightGripped = false;
            }*/

            if(ein.LeftHand.Active)
                body.Position = new Vector2(((ein.LeftHand.Pos.X+.5f) * GameConstants.MiniGameCanvasWidth/2 ) * pixelToUnit, ein.LeftHand.Pos.Y * GameConstants.MiniGameCanvasHeight * pixelToUnit);
            if(ein.RightHand.Active)
                //body2.Position = new Vector2((ein.RightHand.Pos.X/2 * GameConstants.MiniGameCanvasWidth/2 + GameConstants.MiniGameCanvasWidth/2) * pixelToUnit, ein.RightHand.Pos.Y * GameConstants.MiniGameCanvasHeight * pixelToUnit);

            //Console.WriteLine(ein.LeftHand.Pos.Y);
            // Simulate physics.
            world.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
        }
Example #21
0
 public void Start()
 {
     CurrentMiniGameState = MiniGameState.Inactive;
     slingshot.enabled    = false;
 }
        public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }

            KeyboardState ks = Keyboard.GetState();

            if (ks.IsKeyDown(Keys.Tab))
            {
                ball.Position = new Vector2(320 * pixelToUnit, 100 * pixelToUnit);
                ball.AngularVelocity = 0;
                ball.LinearVelocity = Vector2.Zero;
            }

            if (ks.IsKeyDown(Keys.A))
            {
                paddleRight.Rotation += 0.05f;
                paddleLeft.Rotation -= 0.05f;
            }
            else if (ks.IsKeyDown(Keys.D))
            {
                paddleRight.Rotation -= 0.05f;
                paddleLeft.Rotation += 0.05f;
            }

            //paddle.Rotation -= (ein.RightHandAngle)/50.0f;

            //paddle.Rotation = -ein.RightHandAngle;
            /*
            if (Math.Abs(paddle.Rotation - (-1 * ein.RHRSAngle)) > 0.025f)
            {
                if (paddle.Rotation < (-1 * ein.RHRSAngle))
                {
                    paddle.Rotation += 0.051f;
                }
                else if (paddle.Rotation > (-1 * ein.RHRSAngle))
                {
                    paddle.Rotation -= 0.051f;
                }
            }
             * */

            // Simulate physics.
            physicsWorld.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
        }
 public void ResetState()
 {
     RocketLaunchGameState = MiniGameState.NOT_STARTED;
 }
        public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }

            KeyboardState ks = Keyboard.GetState();
            if (!ShowedTutorial)
            {
                tutorialTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (tutorialTimer > tutorialDuration)
                {
                    ShowedTutorial = true;
                }

                return;
            }

            if (Math.Abs(ball.LinearVelocity.X) < .5)
                ball.LinearVelocity = new Vector2(ball.LinearVelocity.X+4,ball.LinearVelocity.Y);

            if (Math.Abs(ball.LinearVelocity.Y) < .5)
                ball.LinearVelocity = new Vector2(ball.LinearVelocity.X, ball.LinearVelocity.Y+4);

            ball.OnCollision +=ball_OnCollision;
            if (ks.IsKeyDown(Keys.Tab))
            {
                ball.Position = new Vector2(320 * pixelToUnit, 100 * pixelToUnit);
                ball.AngularVelocity = 0;
                ball.LinearVelocity = Vector2.Zero;
            }

            float x = (float)(ein.UserX / .5) * (GameConstants.MiniGameCanvasWidth/2.0f) + (GameConstants.MiniGameCanvasWidth) / 2;
            paddle.Position = new Vector2(x * pixelToUnit, paddle.Position.Y);

            if (!win && ball.Position.Y*unitToPixel >= GameConstants.MiniGameCanvasHeight)
            {
                lose = true;
            }

            // Simulate physics.
            physicsWorld.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
        }
Example #25
0
        public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }
            if (!ShowedTutorial)
            {
                tutorialTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (tutorialTimer > tutorialDuration)
                {
                    ShowedTutorial = true;
                }

                return;
            }
            Random random       = new Random();
            int    randomNumber = random.Next(0, 100);

            if (randomNumber > 70 && enemy_body.Position.X < 0)
            {
                enemy_body.ResetDynamics();
                enemy_body.ApplyForce(new Vector2(-.6f, 0));

                enemy_body.Position = new Vector2(GameConstants.MiniGameCanvasWidth * pixelToUnit, (floor_posy - 100) * pixelToUnit);
            }

            if (body.Position.X < 0)
            {
                lost = true;
            }
            else if (body.Position.X * unitToPixel > GameConstants.MiniGameCanvasWidth)
            {
                win = true;
            }


            body.OnCollision += body_OnCollision;
            float   enemyForce = .3f;
            Vector2 force1     = new Vector2(0, 0);
            float   forcePower = 32.5f;

            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Up))
            {
                if (on_Ground)
                {
                    force1 += new Vector2(15f, -forcePower); on_Ground = false;
                }
            }
            //rod_body.ApplyForce(new Vector2(0, -4.7f));
            //rod_body.ApplyTorque(10.0f);
            //floor_body.ApplyForce(force1,new Vector2(floor_width/2,0));

            if (lastForearm != null)
            {
                if ((ein.LHLEVector.Y - lastForearm.Y) > .05f)
                {
                    if (on_Ground)
                    {
                        force1 += new Vector2(3.5f, -forcePower); on_Ground = false;
                    }
                }
            }
            lastForearm = ein.LHLEVector;

            body.ApplyForce(force1);
            enemy_body.ApplyForce(new Vector2(-enemyForce, 0));
            world.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
        }
Example #26
0
        public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }
            if (!ShowedTutorial)
            {
                tutorialTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (tutorialTimer > tutorialDuration)
                {
                    ShowedTutorial = true;
                }

                return;
            }
            winTimer += gameTime.ElapsedGameTime.Milliseconds;

            if (colliding == false)
                body.OnCollision += body_OnCollision;
            else
            {
                body2.Position = new Vector2(random.Next(1, GameConstants.MiniGameCanvasWidth) * pixelToUnit, random.Next(1, GameConstants.MiniGameCanvasHeight) * pixelToUnit);
                //Console.WriteLine("Score +1");
                score++;
                colliding = false;
            }

            if (score >= 2 && !lose)
            {
                win = true;
            }

            if (winTimer > 10000 && !win)
            {
                lose = true;

            }

            body.Position = new Vector2((((ein.UserX / .5f) * GameConstants.MiniGameCanvasWidth / 2) + GameConstants.MiniGameCanvasWidth/2) * pixelToUnit,
                (((ein.UserZ -.9f) * GameConstants.MiniGameCanvasHeight / 2)) * pixelToUnit);

            // Simulate physics.
            world.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
        }
Example #27
0
        public void Update(GameTime gameTime)
        {
            if (gameState == MiniGameState.Initialized)
            {
                gameState = MiniGameState.Running;
            }

            if (!ShowedTutorial)
            {
                tutorialTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (tutorialTimer > tutorialDuration)
                {
                    ShowedTutorial = true;
                }

                return;
            }

            winTimer += gameTime.ElapsedGameTime.Milliseconds;

            if (winTimer > 10000)
            {
                win = true;
            }

            if (ball.Position.Y * unitToPixel > GameConstants.MiniGameCanvasHeight)
            {
                lost = true;
            }

            KeyboardState ks = Keyboard.GetState();

            if (ks.IsKeyDown(Keys.Tab))
            {
                ball.Position        = new Vector2(320 * pixelToUnit, 100 * pixelToUnit);
                ball.AngularVelocity = 0;
                ball.LinearVelocity  = Vector2.Zero;
            }

            /*
             * if (ks.IsKeyDown(Keys.A))
             * {
             *  paddle.Rotation += 0.01f;
             * }
             * else if (ks.IsKeyDown(Keys.D))
             * {
             *  paddle.Rotation -= 0.01f;
             * }
             */


            //paddle.Rotation -= (ein.RightHandAngle)/50.0f;

            //paddle.Rotation = -ein.RightHandAngle;
            if (Math.Abs(paddle.Rotation - (-1 * ein.RHRSAngle)) > 0.025f)
            {
                if (paddle.Rotation < (-1 * ein.RHRSAngle))
                {
                    paddle.Rotation += 0.051f;
                }
                else if (paddle.Rotation > (-1 * ein.RHRSAngle))
                {
                    paddle.Rotation -= 0.051f;
                }
            }

            // Simulate physics.
            physicsWorld.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
        }