public static void Ask(string prompt, Action onYes, Action onNo) { if (me == null) { me = new ConfirmScreen(Kafe.Me); } me.prompt = prompt; me.onYes = onYes; me.onNo = onNo; me.animTime = 0; me.onRight = false; Kafe.PauseAll(false, me); Kafe.Me.Components.Add(me); }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (animTime < 8) { animTime++; return; } var control = Input.Controls[0]; if (Input.WasJustReleased(Keys.Y)) { Kafe.PauseAll(true, null); Kafe.Me.Components.Remove(this); onYes(); } else if (Input.WasJustReleased(Keys.N) || Input.WasJustReleased(Keys.Escape)) { Kafe.PauseAll(true, null); Kafe.Me.Components.Remove(this); onNo(); } else if (Input.WasJustReleased(Keys.Enter)) { Kafe.PauseAll(true, null); Kafe.Me.Components.Remove(this); if (!onRight) { onYes(); } else { onNo(); } } else if (control.TrgLeft || control.TrgRight) { onRight = !onRight; } }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (gameTime.TotalGameTime.Seconds > 2 || skipLogo) { if (anim < 128) { anim++; } } if (anim < 64) { return; } if (Input.Controls[0].TrgUp) { if (selection == 0) { selection = captions.Length; } selection--; } else if (Input.Controls[0].TrgDown) { selection++; if (selection == captions.Length) { selection = 0; } } else if (Input.WasJustReleased(Keys.Escape)) { Input.Flush(); if (selection < 2) { selection = 2; } else { Kafe.AskToQuit(); } } else if (Input.WasJustReleased(Keys.Enter) || Input.Controls[0].TrgA) { Input.Flush(); switch (selection) { case 0: //Story Mode Kafe.DoTransition(false, () => { Kafe.Me.Components.Remove(this); LoadingScreen.Start(() => { var charSelect = new CharacterSelect(false) { Enabled = false }; Kafe.Me.Components.Add(charSelect); Kafe.DoTransition(true, () => { charSelect.Enabled = true; }); }); }); break; case 1: //Versus Mode Kafe.DoTransition(false, () => { Kafe.Me.Components.Remove(this); LoadingScreen.Start(() => { var charSelect = new CharacterSelect(true) { Enabled = false }; Kafe.Me.Components.Add(charSelect); Kafe.DoTransition(true, () => { charSelect.Enabled = true; }); }); }); break; case 2: //Quit Kafe.AskToQuit(); break; } } }
public override void Update(GameTime gameTime) { if (Subject != null) { if (!stepMode) { timer += (int)gameTime.ElapsedGameTime.Milliseconds; if (timer > Kafe.Speed) { timer = 0; Subject.Update(); } } if (Input.WasJustReleased(Keys.Tab)) { stepMode = !stepMode; } if (Input.IsHeld(Keys.Q)) { if (Input.WasJustReleased(Keys.Down)) { Subject.CycleAnims(1); } else if (Input.WasJustReleased(Keys.Up)) { Subject.CycleAnims(-1); } } if (Input.WasJustReleased(Keys.W)) { stepMode = true; Subject.FrameDelay = 0; Subject.Update(); } if (Input.WasJustReleased(Keys.E)) { Subject.Position = new Vector2(Kafe.ScreenWidth / 2, Kafe.Ground); } if (Input.WasJustReleased(Keys.R)) { Subject.ShowBoxes = !Subject.ShowBoxes; } if (Input.WasJustReleased(Keys.OemPlus) && Subject.ColorSwap < Subject.ColorSwaps) { Subject.ColorSwap++; } else if (Input.WasJustReleased(Keys.OemMinus) && Subject.ColorSwap > 1) { Subject.ColorSwap--; } if (stepMode && Input.IsHeld(Keys.LeftAlt)) { Subject.HandleOffsetEdit(); } else if (stepMode && Input.IsHeld(Keys.RightAlt)) { Subject.HandleBoxEdit(); } if (Input.IsHeld(Keys.D1)) { var shift = Input.IsHeld(Keys.LeftControl) ? 16 : 8; if (Input.IsHeld(Keys.LeftShift)) { if (Input.WasJustReleased(Keys.Left)) { Kafe.Camera.X -= shift; } if (Input.WasJustReleased(Keys.Right)) { Kafe.Camera.X += shift; } } else { if (Input.IsHeld(Keys.Left)) { Kafe.Camera.X -= shift; } if (Input.IsHeld(Keys.Right)) { Kafe.Camera.X += shift; } } Kafe.Me.Window.Title = Kafe.Camera.X.ToString(); } if (Input.WasJustReleased(Keys.Escape)) { Kafe.AskToQuit(); } } base.Update(gameTime); }
public override void Update(GameTime gameTime) { base.Update(gameTime); for (var i = 0; i < numPlayers; i++) { if (locked[i]) { continue; } var control = Input.Controls[i]; var oldCursor = cursor[i]; if (control.TrgLeft) { cursor[i]--; if (cursor[i] < 0) { cursor[i] = Kafe.Characters.Length - 1; } } else if (control.TrgRight) { cursor[i]++; if (cursor[i] >= Kafe.Characters.Length) { cursor[i] = 0; } } else if (control.TrgUp) { cursor[i] -= 5; if (cursor[i] < 0) { cursor[i] = Kafe.Characters.Length - 1; } } else if (control.TrgDown) { cursor[i] += 5; if (cursor[i] >= Kafe.Characters.Length) { cursor[i] = 0; } } else if (control.TrgA || control.TrgB || control.TrgC || control.TrgD || control.TrgE || control.TrgF) { locked[i] = true; if (control.TrgA) { selection[i].ColorSwap = 1; } else if (control.TrgB) { selection[i].ColorSwap = 2; } else if (control.TrgC) { selection[i].ColorSwap = 3; } else if (control.TrgD) { selection[i].ColorSwap = 4; } else if (control.TrgE) { selection[i].ColorSwap = 5; } else if (control.TrgF) { selection[i].ColorSwap = 6; } selection[i].SwitchTo(StandardAnims.Select); //For single-player games, select another character at random for now. if (numPlayers == 1) { var j = i ^ 1; var rand = new Random(); while (cursor[j] == cursor[i]) { cursor[j] = rand.Next(Kafe.Characters.Length); } selection[j] = Kafe.Characters[cursor[j]]; selection[j].ColorSwap = 0; selection[j].SwitchTo(StandardAnims.Select); //selection[j].Computer = true; locked[j] = true; showTwo = true; } } if (numPlayers > 1 && cursor[i] == cursor[i ^ 1]) { cursor[i] = oldCursor; } else { selection[i] = Kafe.Characters[cursor[i]]; } } if (Input.WasJustReleased(Keys.Escape)) { Kafe.DoTransition(false, () => { Kafe.Me.Components.Remove(this); LoadingScreen.Start(() => { var title = new TitleScreen(true) { Enabled = false }; Kafe.Me.Components.Add(title); Kafe.DoTransition(true, () => { title.Enabled = true; }); }); }); } if (lockTimer == -1) { if (locked[0] && locked[1]) { lockTimer = 1000; } } else { lockTimer -= gameTime.ElapsedGameTime.Milliseconds; if (lockTimer <= 0) { this.Enabled = false; Kafe.DoTransition(false, () => { Kafe.Me.Components.Remove(this); for (var i = 0; i < Kafe.Me.Components.Count; i++) { if (Kafe.Me.Components[i] is TitleBackground) { Kafe.Me.Components.RemoveAt(i); break; } } LoadingScreen.Start(() => { //TODO: base this on the other character. var arena = new Arena("locales\\mci_corridor.bg.json", selection[0], selection[1]) { Enabled = false }; Kafe.Me.Components.Add(arena); Kafe.DoTransition(true, () => { arena.Enabled = true; }); }); }); } } }