public void Update()
 {
     animator.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Idle));
     animator.Update();
 }
        public void Update()
        {
            timer++;
            counter++;

            Camera2D.cam.Zoom = Math.Max(0.2f, 1 - (voidLine / -4000)) - .2f;

            animator.SetOrigin(new Vector2(voidLine - 220, 50));
            animator2.SetOrigin(new Vector2(voidLine - 140, 95));
            animator3.SetOrigin(new Vector2(voidLine - 50, 85));
            animator4.SetOrigin(new Vector2(voidLine - 90, 60));
            animator5.SetOrigin(new Vector2(voidLine - 86, 77));

            animator.Update();
            animator2.Update();
            animator3.Update();
            animator4.Update();
            animator5.Update();

            animator.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Idle));
            animator2.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk));
            animator3.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk2));
            animator4.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk));
            animator5.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk2));


            int mailGen  = Cloud.randCloud.Next(20000);
            int crateGen = Cloud.randCloud.Next(40000);
            int carGen   = Cloud.randCloud.Next(80000);

            if ((float)(mailGen) < 80f + counter / 5f)
            {
                float   randHeight = (float)(Cloud.randCloud.Next((int)roadHeight));
                Mailbox mb         = new Mailbox(new Vector2((Cloud.screenWidth * ((1 / Camera2D.cam.Zoom)) / 2) + 200, randHeight + 100f), this);
                renderables.Add(mb);
            }
            if ((float)(crateGen) < 80f + counter / 5f)
            {
                float randHeight = (float)(Cloud.randCloud.Next((int)roadHeight));
                crate cr         = new crate(new Vector2((Cloud.screenWidth * ((1 / Camera2D.cam.Zoom)) / 2) + 200, randHeight + 100f), this);
                renderables.Add(cr);
            }
            if ((float)(carGen) < 80f + counter / 5f && timer > 600)
            {
                float randHeight = (float)(Cloud.randCloud.Next((int)roadHeight));
                //car c = new car(new Vector2((Cloud.screenWidth + (1 / Camera2D.cam.Zoom)) / 2 + 200, randHeight), this);
                car c = new car(new Vector2((Cloud.screenWidth * (1 / Camera2D.cam.Zoom)) / 2 + 200, randHeight + 100f), this);
                renderables.Add(c);
            }

            //mainbg.velocity= new Vector2(worldSpeed, 0);
            if (vanSpeedA > 0)
            {
                vanSpeedA -= 1;
            }
            else
            {
                vanSpeedA = 0;
            }
            vanSpeed       += 0.5f - vanSpeedA;
            mainbg.velocity = new Vector2(mainbg.velocity.X - (vanSpeed / 1000), mainbg.velocity.Y);
            farbg.velocity  = new Vector2(mainbg.velocity.X / 5, farbg.velocity.Y);
            midbg.velocity  = new Vector2(mainbg.velocity.X / 2, midbg.velocity.Y);
            forebg.velocity = new Vector2(mainbg.velocity.X * 2, forebg.velocity.Y);
            roadbg.velocity = new Vector2(mainbg.velocity.X * 1.25f, farbg.velocity.Y);
            worldSpeed      = mainbg.velocity.X;
            edgeLine       -= vanSpeed;
            voidLine       -= vanSpeed;
            //voidbg.position = new Vector2(voidLine, voidbg.position.Y);

            oscillator = (oscillator + 1.0f) % ((float)Math.PI * 2.0f);

            if (voidLine + 360 > -1080 && !isDead)
            {
                float amt = Math.Min(1 - ((voidLine + 360) / -1080), 1);
                Camera2D.cam.rumble = amt * 10;
                if (amt > 0.3)
                {
                    Cloud.controller.Rumble(
                        amt /* * (((float)Math.Sin(oscillator) + 1) / 2.0f)*/,
                        amt /* * (((float)Math.Sin(oscillator) + 1) / 2.0f)*/,
                        1);
                }
            }

            if (particleTimer <= 0)
            {
                CloudParticle p1 = new CloudParticle(1, new Vector2(edgeLine + 60, 230 + Cloud.randCloud.Next(40) - 20), 0.999f, this);
                CloudParticle p2 = new CloudParticle(2, new Vector2(edgeLine + 60, 150 + Cloud.randCloud.Next(40) - 20), 0.92f, this);
                CloudParticle p3 = new CloudParticle(3, new Vector2(edgeLine + 60, 80 + Cloud.randCloud.Next(40) - 20), 0.7f, this);
                CloudParticle p4 = new CloudParticle(4, new Vector2(edgeLine + 60, -20 + Cloud.randCloud.Next(40) - 20), 0.6f, this);
                //CloudParticle p5 = new CloudParticle(5, new Vector2(edgeLine + 60, 100 + Cloud.randCloud.Next(200) - 100), 0.91f, this);
                renderables.Add(p1);
                renderables.Add(p2);
                renderables.Add(p3);
                renderables.Add(p4);
                //renderables.Add(p5);
                particleTimer = 12 + Cloud.randCloud.Next(10) - 5;
            }
            else
            {
                particleTimer--;
            }
            foreach (Renderable r in renderables)
            {
                if (r is Actor)
                {
                    (r as Actor).Update();
                }
            }

            foreach (Renderable r in toAdd)
            {
                renderables.Add(r);
            }
            toAdd.Clear();

            foreach (Renderable r in toRemove)
            {
                r.Unload();
                renderables.Remove(r);
            }
            toRemove.Clear();
        }
        public GameScene()
        {
            sky   = Color.FromNonPremultiplied(78, 142, 203, 255);
            grass = Color.FromNonPremultiplied(45, 179, 75, 255);

            isDead = false;
            string dir = "BonePix";

            TextureStatic.Load("tentacle_tip_1", dir);
            TextureStatic.Load("tentacle_2", dir);
            TextureStatic.Load("tentacle_3", dir);
            TextureStatic.Load("tentacle_4", dir);
            TextureStatic.Load("tentacle_5", dir);
            TextureStatic.Load("tentacle_base", dir);

            animator       = new BoneAnimator(null, StaticStancetentacle.GetBoneSet(), StaticStancetentacle.Get(tentacleStance.Idle), 0, 0);
            animator.Depth = .6f;

            animator2       = new BoneAnimator(null, StaticStancetentacle.GetBoneSet(), StaticStancetentacle.Get(tentacleStance.Walk1), 0, 0);
            animator2.Depth = .7f;

            animator3       = new BoneAnimator(null, StaticStancetentacle.GetBoneSet(), StaticStancetentacle.Get(tentacleStance.Walk4), 0, 0);
            animator3.Depth = .7f;

            animator4       = new BoneAnimator(null, StaticStancetentacle.GetBoneSet(), StaticStancetentacle.Get(tentacleStance.Walk4), 0, 0);
            animator4.Depth = .6f;

            animator5       = new BoneAnimator(null, StaticStancetentacle.GetBoneSet(), StaticStancetentacle.Get(tentacleStance.Walk4), 0, 0);
            animator5.Depth = .7f;

            roadHeight         = 200;
            counter            = 0;
            worldSpeed         = -10;
            particleTimer      = 0;
            edgeLine           = -250;
            renderables        = new RenderableCollection();
            Physics.collisions = new CollisionHandler(renderables);

            toAdd    = new List <Renderable>();
            toRemove = new List <Renderable>();

            player = new Player(new Vector2(120, 150), this);
            renderables.Add(player);

            mainbg = new Background("road_railing", @"Art\Backgrounds", new Vector2(-360, 60), new Vector2(-10, 0), 0.15f, true, this);
            renderables.Add(mainbg);
            farbg = new Background("far_bg", @"Art\Backgrounds", new Vector2(-360, -370), new Vector2(-10, 0), 0.1f, true, this);
            renderables.Add(farbg);
            midbg = new Background("middle_bg", @"Art\Backgrounds", new Vector2(-360, -340), new Vector2(-10, 0), 0.12f, true, this);
            renderables.Add(midbg);
            forebg = new Background("foreground_railing", @"Art\Backgrounds", new Vector2(-360, 290), new Vector2(-10, 0), 0.999f, true, this);
            renderables.Add(forebg);
            roadbg = new Background("road", @"Art\Backgrounds", new Vector2(-360, 110), new Vector2(-10, 0), 0.11f, true, this);
            renderables.Add(roadbg);

            /*voidbg = new Background("void", @"Art", new Vector2(-360, -202), Vector2.Zero, 0.2f, false, this);
             * renderables.Add(voidbg);*/
            TextureStatic.Load("void", "Art");

            //tentacle tn = new tentacle(new Vector2(0, 0), this);
            //renderables.Add(tn);

            vanSpeed   = 0;
            voidLine   = -360;
            oscillator = 0;

            animator.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Idle));
            animator.Update();
            animator2.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk));
            animator2.Update();
            animator3.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk2));
            animator3.Update();
            animator4.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk3));
            animator4.Update();
            animator5.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk4));
            animator5.Update();
        }
        public void Update()
        {
            if (gameOver && (GamePad.GetState(PlayerIndex.Two).Buttons.A == ButtonState.Pressed | GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed))
            {
            }

            animator.SetOrigin(new Vector2(400, 0));
            animator.Update();

            animator2.SetOrigin(new Vector2(800, 0));
            animator2.Update();



            timer++;
            counter++;
            swTime = sw.ElapsedMilliseconds;
            //Console.WriteLine(swTime/1000);

            if (answered1 == -1)
            {
                animator.SetAnimation(StaticStanceplayer.GetAnimation(playerAnimation.Idle));
            }
            else
            {
                animator.SetAnimation(StaticStanceplayer.GetAnimation(playerAnimation.Answer));
            }
            if (answered2 == -1)
            {
                animator2.SetAnimation(StaticStanceplayer2.GetAnimation(player2Animation.Idle));
            }
            else
            {
                animator2.SetAnimation(StaticStanceplayer2.GetAnimation(player2Animation.Answer));
            }
            sw.Start();
            if (questionsAsked < questions)
            {
                if (!readyToStart)
                {
                    if (sw.ElapsedMilliseconds / 1000 > 3)
                    {
                        readyToStart = true;
                        sw.Restart();
                        //Pick Question
                        tr = new StreamReader("../../trivia.txt");
                        //String allText = tr.ReadToEnd();
                        int q = Cloud.randCloud.Next(1, 72);
                        //q = 27;
                        String qNum     = "<" + q + ">";
                        String textLine = tr.ReadLine();
                        while (!textLine.StartsWith(qNum))
                        {
                            textLine = tr.ReadLine();
                        }
                        question = textLine.Substring(qNum.Length, textLine.Length - (2 * qNum.Length + 1));
                        String temp = tr.ReadLine();
                        right  = temp.Substring(9, temp.Length - 19);
                        temp   = tr.ReadLine();
                        wrong1 = temp.Substring(7, temp.Length - 15);
                        temp   = tr.ReadLine();
                        wrong2 = temp.Substring(7, temp.Length - 15);
                        temp   = tr.ReadLine();
                        wrong3 = temp.Substring(7, temp.Length - 15);

                        answers.Clear();

                        LinkedList <int> taken = new LinkedList <int>();

                        for (int i = 0; i < 4; i++)
                        {
                            int next = Cloud.randCloud.Next(0, 4);
                            while (taken.Contains(next))
                            {
                                next = Cloud.randCloud.Next(0, 4);
                            }
                            taken.AddLast(next);

                            if (next == 0)
                            {
                                rightNum = i;
                                answers.AddLast(right);
                            }
                            if (next == 1)
                            {
                                answers.AddLast(wrong1);
                            }
                            if (next == 2)
                            {
                                answers.AddLast(wrong2);
                            }
                            if (next == 3)
                            {
                                answers.AddLast(wrong3);
                            }
                        }
                    }
                }
                else if (!readyToAsk)
                {
                    if (sw.ElapsedMilliseconds / 1000 > 2)
                    {
                        sw.Restart();
                        readyToAsk = true;
                    }
                }
                else if (!asked && readyToAsk)
                {
                    if (sw.ElapsedMilliseconds / 1000 > 3)
                    {
                        sw.Restart();
                        asked = true;
                    }
                }
                else if (asked && !startTimer)
                {
                    if (sw.ElapsedMilliseconds / 1000 > 2)
                    {
                        sw.Restart();
                        startTimer = true;
                    }
                }


                Console.WriteLine(Cloud.controller.playerIndex + "\t" + Cloud.controller2.playerIndex);
                if (startTimer && answered1 == -1)
                {
                    if (GamePad.GetState(PlayerIndex.One).Buttons.X == ButtonState.Pressed)
                    {
                        answered1  = 0;
                        temp1Score = 10 - (int)sw.ElapsedMilliseconds / 1000;
                        if (temp1Score < 0)
                        {
                            temp1Score = 0;
                        }
                    }
                    if (GamePad.GetState(PlayerIndex.One).Buttons.Y == ButtonState.Pressed)
                    {
                        answered1  = 1;
                        temp1Score = 10 - (int)sw.ElapsedMilliseconds / 1000;
                        if (temp1Score < 0)
                        {
                            temp1Score = 0;
                        }
                    }
                    if (GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)
                    {
                        answered1  = 2;
                        temp1Score = 10 - (int)sw.ElapsedMilliseconds / 1000;
                        if (temp1Score < 0)
                        {
                            temp1Score = 0;
                        }
                    }
                    if (GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Pressed)
                    {
                        answered1  = 3;
                        temp1Score = 10 - (int)sw.ElapsedMilliseconds / 1000;
                        if (temp1Score < 0)
                        {
                            temp1Score = 0;
                        }
                    }
                }
                Console.WriteLine(Cloud.controller.playerIndex + "\t" + Cloud.controller2.playerIndex);
                if (startTimer && answered2 == -1)
                {
                    if (GamePad.GetState(PlayerIndex.Two).Buttons.X == ButtonState.Pressed)
                    {
                        answered2  = 0;
                        temp2Score = 10 - (int)sw.ElapsedMilliseconds / 1000;
                        if (temp2Score < 0)
                        {
                            temp2Score = 0;
                        }
                    }
                    if (GamePad.GetState(PlayerIndex.Two).Buttons.Y == ButtonState.Pressed)
                    {
                        answered2  = 1;
                        temp2Score = 10 - (int)sw.ElapsedMilliseconds / 1000;
                        if (temp2Score < 0)
                        {
                            temp2Score = 0;
                        }
                    }
                    if (GamePad.GetState(PlayerIndex.Two).Buttons.A == ButtonState.Pressed)
                    {
                        answered2  = 2;
                        temp2Score = 10 - (int)sw.ElapsedMilliseconds / 1000;
                        if (temp2Score < 0)
                        {
                            temp2Score = 0;
                        }
                    }
                    if (GamePad.GetState(PlayerIndex.Two).Buttons.B == ButtonState.Pressed)
                    {
                        answered2  = 3;
                        temp2Score = 10 - (int)sw.ElapsedMilliseconds / 1000;
                        if (temp2Score < 0)
                        {
                            temp2Score = 0;
                        }
                    }
                }
                Console.WriteLine(Cloud.controller.playerIndex + "\t" + Cloud.controller2.playerIndex);
                if (startTimer && sw.ElapsedMilliseconds / 1000 > 10)
                {
                    timeUp = true;
                }
                if (timeUp && sw.ElapsedMilliseconds / 1000 > 13)
                {
                    reveal = true;
                }
                if (reveal && sw.ElapsedMilliseconds / 1000 > 18)
                {
                    questionsAsked++;
                    readyToStart = false;
                    readyToAsk   = false;
                    asked        = false;
                    startTimer   = false;
                    timeUp       = false;
                    reveal       = false;


                    //XYAB
                    //AYXB

                    if ((answered1 == 1 && rightNum == 1) | (answered1 == 3 && rightNum == 3) | (answered1 == 0 && rightNum == 2) | (answered1 == 2 && rightNum == 0))
                    {
                        p1Score = p1Score + temp1Score;
                    }
                    if ((answered2 == 1 && rightNum == 1) | (answered2 == 3 && rightNum == 3) | (answered2 == 0 && rightNum == 2) | (answered2 == 2 && rightNum == 0))
                    {
                        p2Score = p2Score + temp2Score;
                    }

                    temp1Score = 0;
                    temp2Score = 0;
                    answered1  = -1;
                    answered2  = -1;
                }
            }
            else
            {
                gameOver = true;
            }



            foreach (Renderable r in renderables)
            {
                if (r is Actor)
                {
                    (r as Actor).Update();
                }
            }

            foreach (Renderable r in toAdd)
            {
                renderables.Add(r);
            }
            toAdd.Clear();

            foreach (Renderable r in toRemove)
            {
                r.Unload();
                renderables.Remove(r);
            }
            toRemove.Clear();
        }