예제 #1
0
        public override IGState Update(GameTime gameTime, BaseGame grid)
        {
            if (Game.KeyboardInput.TypedKey(Keys.Escape))
            {
                NextComponent = new MainMenu(Game, null, (Color == Color.Black) ? Color.White : Color.Black);
                voice1.StopNote();
            }
            else
            {
                if (State == 1 || State == 1.4 || IsLeft)
                {
                    sl = MathHelper.Clamp(sl + 0.05f, 0f, 1f);
                }
                else if (State == 1.5 || State == 1.6 || IsRight)
                {
                    sr = MathHelper.Clamp(sr + 0.05f, 0f, 1f);
                }

                sl = MathHelper.Clamp(sl - 0.025f, 0f, 1f);
                sr = MathHelper.Clamp(sr - 0.025f, 0f, 1f);

                Wait.Update(gameTime.ElapsedGameTime);
                if (State == 0 && Wait.IsComplete)
                {
                    Wait  = new Tween(new TimeSpan(0, 0, 0, 1), 0, 1);
                    State = 1;
                }
                else if (State == 1 && Wait.IsComplete)
                {
                    Game.Audio.Say("Tap Left for 2 Players");
                    Wait  = new Tween(new TimeSpan(0, 0, 0, 3), 0, 1);
                    State = 1.4;
                }
                else if (State == 1.4 && Wait.IsComplete)
                {
                    State = 1.5;
                }
                else if (State == 1.5 && Wait.IsComplete)
                {
                    Game.Audio.Say("Or Right for 1 Player");
                    Wait  = new Tween(new TimeSpan(0, 0, 0, 1), 0, 1);
                    State = 1.6;
                }
                else if (State == 1.6 && Wait.IsComplete)
                {
                    Wait  = new Tween(new TimeSpan(0, 0, 0, 1), 0, 1);
                    State = 2;
                }
                else if (State == 2 && Wait.IsComplete)
                {
                    if (Game.UnifiedInput.Action && Game.UnifiedInput.Location.X > Width / 2f)
                    {
                        TwoPlayer = false;
                        State     = 3;
                        Game.Audio.Say("Go, Get Ready " + ((Xspeed > 0)?"Player 1":"Player 2"));
                    }
                    else if (Game.UnifiedInput.Action)
                    {
                        TwoPlayer = true;
                        State     = 3;
                        Game.Audio.Say("Go, Get Ready " + ((Xspeed > 0) ? "Player 1" : "Player 2"));
                    }
                }
                else if (State == 3 && Wait.IsComplete)
                {
                    if (ball.Center.X < Width / 2f)
                    {
                        IsLeft  = true;
                        IsRight = false;
                    }
                    else
                    {
                        IsLeft  = false;
                        IsRight = true;
                    }
                    var   pan = 1f - ((ball.X / Width) * 2f);
                    var   mf  = Height;
                    var   cf  = ball.Center.Y;
                    var   mv  = Width / 2f;
                    float cv;
                    if (ball.Center.X < (Width / 2f))
                    {
                        cv = mv - ball.Center.X;
                    }
                    else
                    {
                        cv = ball.Center.X - (Width / 2f);
                    }

                    voice1.PlaySound(Math.Max(25f, (1f - (cf / mf)) * 500f), pan, (cv / mv));
                    MoveBall(gameTime); //Moves the ball
                    CheckScore();       //Check if one player scored
                    CheckIfMoving();
                    CheckInput();
                }
                else if (State == 4)
                {
                    if (ball.X < 1)
                    {
                        p2p += 1; State = 7;
                    }
                    else if (ball.X > Width)
                    {
                        p1p += 1; State = 7;
                    }

                    voice1.StopNote();
                    IsLeft   = false;
                    IsRight  = false;
                    DragFrom = Game.UnifiedInput.DragFrom;

                    if (ball.X < 1)
                    {
                        Game.Audio.Say("Point Right Player " + p1p + " verse " + p2p);
                    }
                    else
                    {
                        Game.Audio.Say("Point Left Player" + p2p + " verse " + p1p);
                    }

                    Wait  = new Tween(new TimeSpan(0, 0, 0, 2, 500), 0, 1);
                    State = 5;
                }
                else if (State == 5 && Wait.IsComplete)
                {
                    Wait = new Tween(new TimeSpan(0, 0, 0, 2, 500), 0, 1);
                    Game.Audio.Say("swipe up to play, down to leave");
                    State = 6;
                }
                else if (State == 6)
                {
                }
                else if (State == 7 && Wait.IsComplete)
                {
                    Restart();
                    State = 3;
                    Wait.Finish();
                }
            }
            return(NextComponent ?? this);
        }
예제 #2
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);
        }