Esempio n. 1
0
        public override IGState Update(GameTime gameTime, BaseGame game)
        {
            if (Game.KeyboardInput.TypedKey(Keys.Escape))
            {
                NextComponent = new MainMenu(Game, null, (Color == Color.Black) ? Color.White : Color.Black);
                voice1.StopNote();
            }
            else
            {
                Wait.Update(gameTime.ElapsedGameTime);
                if (State == 0 && Wait.IsComplete)
                {
                    enemy = GetTarget();
                    Step(ref enemy); // .Update(gameTime);
                    var md  = VectorHelpers.Hypot(Vector2.Zero, new Vector2(Width, Height));
                    var cd  = VectorHelpers.Hypot(FirstVehicle.CurrentPosition, enemy);
                    var pan = 1f - ((FirstVehicle.CurrentPosition.X / Width) * 2f);
                    voice1.PlaySound(Math.Max(25f, (1f - (cd / md)) * 500f), pan);
                    //(Game.UnifiedInput.Location.X / Game.Width)*140);
                    if (cd < 90)
                    {
                        State = 1;
                        Wait  = new Tween(new TimeSpan(0, 0, 0, 1), 0, 1);
                        var       s = BaseGame.Random.Next(3);
                        Texture2D t;
                        if (s == 0)
                        {
                            t = Textures.Splat1;
                        }
                        else if (s == 1)
                        {
                            t = Textures.Splat2;
                        }
                        else
                        {
                            t = Textures.Splat3;
                        }
                        Splats.Add(new Splatter
                        {
                            loc = FirstVehicle.CurrentPosition - new Vector2(t.Width / 2f, t.Height / 2f),
                            tex = t
                        });
                    }
                }
                else if (State == 1)
                {
                    Wait.Reset();
                    Game.Audio.Play(Cues.Splat);
                    Game.Audio.Say(splatAcr[BaseGame.Random.Next(splatAcr.Count())]);
                    voice1.StopNote();
                    DragFrom = Game.UnifiedInput.DragFrom;
                    State    = 2;
                }
                else if (State == 2 && Wait.IsComplete)
                {
                    Wait = new Tween(new TimeSpan(0, 0, 0, 2, 500), 0, 1);
                    Game.Audio.Say(SwipeMSG);
                    SwipeMSG = "swipe up to play, down to leave";
                    State    = 3;
                }
                else if (State == 3)
                {
                }
                else if (State == 4 && Wait.IsComplete)
                {
                    Difficulty = MathHelper.Clamp(Difficulty - 5, 10, 100);
                    Wait       = new Tween(new TimeSpan(0, 0, 0, 1), 0, 1);
                    var k = true;
                    while (k)
                    {
                        var cd = VectorHelpers.Hypot(FirstVehicle.CurrentPosition, enemy);

                        FirstVehicle.CurrentPosition = new Vector2(BaseGame.Random.Next((int)Width),
                                                                   BaseGame.Random.Next((int)Height));
                        if (cd > 180)
                        {
                            k = false;
                        }
                    }
                    State = 0;

                    Wait.Finish();
                }
            }
            return(NextComponent ?? this);
        }
Esempio n. 2
0
        public override IGState Update(GameTime gameTime, BaseGame game)
        {
            Timer.Update(gameTime.ElapsedGameTime);
            Wait.Update(gameTime.ElapsedGameTime);
            if (Game.KeyboardInput.TypedKey(Keys.Escape))
            {
                NextComponent = new MainMenu(Game, null, (Color == Color.Black) ? Color.White : Color.Black);
            }
            if (Timer.IsComplete)
            {
                TapTimer.Update(gameTime.ElapsedGameTime);
                if (TapTimer.IsComplete)
                {
                    TapTimer.Reset();
                    if (Location != new Vector2(-10, -10))
                    {
                        if (Marco)
                        {
                            Game.Audio.Say("Marco", pan);
                        }
                        else
                        {
                            Game.Audio.Say("Polo", pan);
                        }
                    }
                    Marco = !Marco;
                }
                if (state > 0 && state < 3)
                {
                    woosh.Update(gameTime.ElapsedGameTime);
                    if (woosh.IsComplete)
                    {
                        woosh.Reset();
                        game.Audio.Play(Cues.Swish);
                    }
                }
                switch (state)
                {
                case 0:
                {
                    Location = new Vector2(BaseGame.Random.Next((int)Width), BaseGame.Random.Next((int)Height));
                    pan      = MathHelper.Clamp((Location.X / (Width / 2f)) - 1f, -.8f, .8f);
                    state    = 1;
                    break;
                }

                case 1:
                {
                    Tap = new Vector2(-10, -10);

                    state = 2;
                    break;
                }

                case 2:
                {
                    if (Tap != new Vector2(-10, -10))
                    {
                        var d = VectorHelpers.Hypot(Location, Tap);                            //Math.Abs(Vector2.Distance(Location, Tap));
                        var m = VectorHelpers.Hypot(Vector2.Zero, new Vector2(Width, Height)); //Math.Abs(Vector2.Distance(new Vector2(0, 0), new Vector2(Width, Height)));

                        var p = d / m;
                        if (lastDistance == -1f)
                        {
                            lastDistance = p;
                        }
                        var c = MathHelper.Distance(p, lastDistance);
                        if (d < 40f)
                        {
                            lastDistance = -1f;
                            game.Audio.Say("You Got Me");
                            Wait.Reset();
                            state = 3;
                        }
                        else
                        {
                            //If within proximity of last the hotter colder warmer
                            if (c < CloseD)
                            {
                                if (p < HotD)
                                {
                                    if (p < lastDistance)
                                    {
                                        if (lastDistance < HotD)
                                        {
                                            game.Audio.Say("hotter", pan);
                                        }
                                        else
                                        {
                                            game.Audio.Say("hot", pan);
                                        }
                                    }
                                    else
                                    {
                                        game.Audio.Say("hot", pan);
                                    }
                                }
                                else if (p < WarmD)
                                {
                                    if (p < lastDistance)
                                    {
                                        if (lastDistance < WarmD)
                                        {
                                            game.Audio.Say("warmer", pan);
                                        }
                                        else
                                        {
                                            game.Audio.Say("warm", pan);
                                        }
                                    }
                                    else
                                    {
                                        game.Audio.Say("warm", pan);
                                    }
                                }
                                else if (p < ColdD)
                                {
                                    if (p < lastDistance)
                                    {
                                        game.Audio.Say("cooler", pan);
                                    }
                                    else
                                    {
                                        game.Audio.Say("cold", pan);
                                    }
                                }
                                else
                                {
                                    game.Audio.Say("freezing", pan);
                                }
                            }
                            else
                            {
                                lastDistance = -1f;
                                if (p < HotD)
                                {
                                    game.Audio.Say("hot", pan);
                                }
                                else if (p < WarmD)
                                {
                                    game.Audio.Say("warm", pan);
                                }
                                else if (p < ColdD)
                                {
                                    game.Audio.Say("cold", pan);
                                }
                                else
                                {
                                    game.Audio.Say("freezing", pan);
                                }
                            }


                            lastDistance = p;
                        }
                    }
                    Tap = new Vector2(-10, -10);
                    break;
                }

                case 3:
                {
                    Wait = new Tween(new TimeSpan(0, 0, 0, 1, 500), 0, 1);
                    Game.Audio.Say("Swipe up to play again, Down to leave");
                    DragFrom = Game.UnifiedInput.DragFrom;
                    state    = 4;
                    break;
                }

                case 4:
                {
                    break;
                }

                case 5:
                {
                    Wait  = new Tween(new TimeSpan(0, 0, 0, 1), 0, 1);
                    state = 0;

                    if (Wait.IsComplete)
                    {
                        NextComponent = new MainMenu(Game, null, (Color == Color.Black) ? Color.White : Color.Black);
                    }
                    break;
                }

                default:
                {
                    state = 0;
                    break;
                }
                }
            }
            return(NextComponent ?? this);
        }