public TriviaScene() { Song bgm = Cloud.content.Load <Song>("MilitaireElectronic"); MediaPlayer.Play(bgm); MediaPlayer.IsRepeating = true; Camera2D.cam.Zoom = .5f; animator = new BoneAnimator(null, StaticStanceplayer.GetBoneSet(), StaticStanceplayer.Get(playerStance.Idle), 0, 0); animator.Depth = .6f; //animator.SetAnimation(StaticStanceplayer.GetAnimation(playerAnimation.Idle)); animator.Update(); animator2 = new BoneAnimator(null, StaticStanceplayer2.GetBoneSet(), StaticStanceplayer2.Get(player2Stance.Idle), 0, 0); animator2.Depth = .6f; //animator2.SetAnimation(StaticStanceplayer2.GetAnimation(player2Animation.Idle)); animator2.Update(); answers.Clear(); tr = new StreamReader("../../trivia.txt"); renderables = new RenderableCollection(); Physics.collisions = new CollisionHandler(renderables); toAdd = new List <Renderable>(); toRemove = new List <Renderable>(); TextureStatic.Load("questionBG", @"Art"); TextureStatic.Load("playerAnswerBG", @"Art"); TextureStatic.Load("unknown", @"Art"); TextureStatic.Load("pod", @"Art"); //Ball = new ball(new Vector2(120, 150), this); //renderables.Add(Ball); }
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(); }