private void Update() { if (updateKill == 1) { MenuDisplay.UpdateKills(); } if (dead) { updateKill++; if (monkey) { GetComponent <Monkey>().enabled = false; } transform.eulerAngles = new Vector3(-180, 0, 0); GetComponent <Transform>().position = new Vector3(GetComponent <Transform>().position.x, (float)(GetComponent <Transform>().position.y - 0.05), GetComponent <Transform>().position.z); GetComponent <Rigidbody2D>().velocity = new Vector2(0, 1); GetComponent <SpriteRenderer>().color = new Color((float)0, 0, 0, deathTimer); GetComponent <BoxCollider2D>().enabled = false; GetComponent <PolygonCollider2D>().enabled = false; GetComponent <BattleModeEnemyPatrol>().enabled = false; GetComponent <BattleModeEnemyPatrol>().chute.SetActive(false); anim.SetBool("dead", true); deathTimer -= Time.deltaTime; } if (deathTimer <= 0) { Destroy(this.gameObject); } }
static void Main(string[] args) { Board = new DemoBuilder().Build(); Writer = Console.Out; TileDisplay = new TileDisplay(new DisplayFactory()); BoardDisplay = new BoardDisplay(Writer, TileDisplay); MenuDisplay = new MenuDisplay(Writer, new List <MenuOption> { new MenuOption("Build"), }); Player = new TerraMysticaPlayer("Player 1", new Mermaids()); Player.Resources.Gold.Add(100); Player.Resources.Workers.Add(100); BoardDisplay.PrintHeader = true; PrintLoop(); Console.WriteLine($"{Player.Name}, Build a damn Dwelling!"); Console.ReadKey(); Console.Clear(); var tile = Board.TileForLocation(new HexLocation(3, 0)); var buildAction = new BuildAction(Board, Player, tile.Location); buildAction.Execute(); PrintLoop(); Console.WriteLine($"Good, good. Now dance for me!"); Console.ReadKey(); }
public void ChangeToShorterPrompt() { var dis = new MenuDisplay <MenuOption <string> >(Console, 3); dis.Options.Add(new MenuOption <string>("first", "first")); dis.Options.Add(new MenuOption <string>("second", "second")); dis.Options.Add(new MenuOption <string>("third", "third")); dis.HandleKey(new ConsoleKeyInfo('\0', ConsoleKey.DownArrow, false, false, false)); AssertConsole.BufferAndWindowLines ( "> first", " second", " third" ); dis.Prompt = ">"; AssertConsole.BufferAndWindowLines ( ">first", " second", " third" ); }
public void LoadMainMenuLevelSelectScene() { SceneManager.LoadSceneAsync("MainMenu"); //SetPortraitRotation(); SetAllOrientations(); menuDisplay = MenuDisplay.LevelSelectMenu; }
// Update is called once per frame void Update() { if (justHit) { Damage.SetActive(true); Damage.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, (float)(immunityTimer * 0.25)); immunityTimer -= Time.deltaTime; } else { Damage.SetActive(false); } if (immunityTimer <= 0) { justHit = false; immunityTimer = 2; } if (currentHP <= 0) { //GameOver HUD.SendMessage("EndGame"); } MenuDisplay.UpdateHealth(currentHP, totalHP); }
public void TopBottomPrefixRemoving() { var display = new MenuDisplay <MenuOption <string> >(Console, 10); display.PrefixesTop.SetKeys(new char[] { '0', '1' }); display.PrefixesBottom.SetKeys(new char[] { 'a', 'b' }); display.Options.Add(new MenuOption <string>("first", "first")); display.Options.Add(new MenuOption <string>("second", "second")); display.Options.Add(new MenuOption <string>("third", "third")); display.Options.Add(new MenuOption <string>("fourth", "fourth")); display.Options.Add(new MenuOption <string>("fifth", "fifth")); AssertConsole.BufferAndWindowLines ( " 0: first", " 1: second", " third", " b: fourth", " a: fifth" ); display.Options.RemoveAt(4); AssertConsole.BufferAndWindowLines ( " 0: first", " 1: second", " b: third", " a: fourth" ); display.Options.RemoveAt(3); AssertConsole.BufferAndWindowLines ( " 0: first", " b: second", " a: third" ); display.Options.RemoveAt(2); AssertConsole.BufferAndWindowLines ( " b: first", " a: second" ); display.Options.RemoveAt(1); AssertConsole.BufferAndWindowLines ( " a: first" ); display.Options.RemoveAt(0); AssertConsole.BufferAndWindowLines(); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("key")) { collision.SendMessage("PickUp", numOfKeys); numOfKeys++; ES3.Save <int>("numOfKeys", numOfKeys, "KeyNumber.es3"); MenuDisplay.AddKeys(numOfKeys); HUD.AddKeys(numOfKeys); } }
public void switchMenu(MenuDisplay menu) { //Deactivate all menus menuList.ForEach(menu => menu.gameObject.SetActive(false)); //Activate selected menu menu.gameObject.SetActive(true); if (!menuList.Contains(menu)) { throw new System.ArgumentException( $"Menu not in the list! menu: {menu.gameObject.name}" ); } }
void Start() { if (ES3.FileExists("KeyNumber.es3")) { numOfKeys = ES3.Load <int>("numOfKeys", "KeyNumber.es3"); } else { numOfKeys = 0; } MenuDisplay.AddKeys(numOfKeys); Debug.Log("Number of keys: " + numOfKeys); }
void Awake() { if (!instance) { DontDestroyOnLoad(this.gameObject); //SetPortraitRotation(); } //Load unlocked LoadUnlocked(); //activate all menus. They deactivate them self after theri initialisation menuDisplay = MenuDisplay.MainMenu; mainMenu.InitializeMainMenu(); }
void Start() { MenuDisplay menuDisplay = GameObject.Find("GameManager").GetComponent <GameManager>().GetMenuDisplay(); InitializeMainMenu(); switch (menuDisplay) { case MenuDisplay.MainMenu: ShowMainMenu(); break; case MenuDisplay.LevelSelectMenu: ShowLevelSelectMenu(); break; } }
// Use this for initialization void Start() { menu = transform.Find("Menu").GetComponent <MenuDisplay> (); targetLocation = transform.position; hideGUI(); if (gameStartedOnce) { menu.hide(); GameObject.Find("Player").GetComponentInChildren <PlayerMovement>().mobile = true; menuOut = false; showGUI(); foreach (GameObject gObject in hideAfterFirstTime) { gObject.GetComponentInChildren <SpriteRenderer>().enabled = false; } } gameStartedOnce = true; }
public void ScrollbackCleanUp() { Console.WindowHeight = 5; Console.WriteLine("Line 1"); Console.WriteLine("Line 2"); var display = new MenuDisplay <MenuOption <string> >(Console, 5); display.Cleanup = InputCleanup.Clean; display.Options.Add(new MenuOption <string>("first", "first")); display.Options.Add(new MenuOption <string>("second", "second")); display.Options.Add(new MenuOption <string>("third", "third")); display.Options.Add(new MenuOption <string>("fourth", "fourth")); display.Options.Add(new MenuOption <string>("fifth", "fifth")); display.Dispose(); AssertConsole.BufferAndWindowLines ( "Line 1", "Line 2" ); }
public void ReducedDisplayLines() { var dis = new MenuDisplay <MenuOption <string> >(Console, 2); dis.Options.Add(new MenuOption <string>("first", "first")); dis.Options.Add(new MenuOption <string>("second", "second")); dis.Options.Add(new MenuOption <string>("third", "third")); AssertConsole.BufferAndWindowLines ( " first", " second" ); dis.HandleKey(new ConsoleKeyInfo('\0', ConsoleKey.UpArrow, false, false, false)); AssertConsole.BufferAndWindowLines ( " second", "> third" ); dis.Options.RemoveAt(0); AssertConsole.BufferAndWindowLines ( " second", "> third" ); dis.Options.RemoveAt(0); AssertConsole.BufferAndWindowLines ( "> third" ); }
public void StayGameYes() { PanelWarning.SetActive(false); MenuDisplay.SetActive(true); }
public void ShowMenu() { Console.WriteLine(MenuDisplay.ToString()); }
public void EnablePanelWarning() { PanelWarning.SetActive(true); MenuDisplay.SetActive(false); }
// Update is called once per frame void Update() { //BASIC MOVEMENT BEGIN if ((Input.GetKey(KeyCode.D) || Input.GetAxis("DPadHorizontal") > 0f) && !airDashingCurrently) { GetComponent <Rigidbody2D>().velocity = new Vector2(moveSpeed, GetComponent <Rigidbody2D>().velocity.y); direction = 1; idle = false; } if ((Input.GetKey(KeyCode.A) || Input.GetAxis("DPadHorizontal") < 0f) && !airDashingCurrently) { GetComponent <Rigidbody2D>().velocity = new Vector2(-moveSpeed, GetComponent <Rigidbody2D>().velocity.y); direction = 2; idle = false; } if ((Input.GetKeyUp(KeyCode.D) || Input.GetKeyUp(KeyCode.A)) && !airDashingCurrently) { GetComponent <Rigidbody2D>().velocity = new Vector2(0, GetComponent <Rigidbody2D>().velocity.y); } if (Input.GetAxis("DPadHorizontal") == 0f && !Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.A)) { GetComponent <Rigidbody2D>().velocity = new Vector2(0, GetComponent <Rigidbody2D>().velocity.y); } if (Input.GetButtonDown("Jump") && grounded) { GetComponent <Rigidbody2D>().velocity = new Vector2(GetComponent <Rigidbody2D>().velocity.x, jumpHeight); //Jump } if (Input.GetButtonDown("Bounce")) { GetComponent <Rigidbody2D>().velocity = new Vector2(GetComponent <Rigidbody2D>().velocity.x, -30); //Barrels towards the ground to maintain bounce momentum if (!grounded) { sPress = true; } } if (bounce) { GetComponent <Rigidbody2D>().velocity = new Vector2(GetComponent <Rigidbody2D>().velocity.x, (float)bounceHeight); bounce = false; bounceHeight = tempBounceHeight; } //BASIC MOVEMENT END if (GetComponent <Rigidbody2D>().velocity.x == 0) { idle = true; } anim.SetBool("Grounded", grounded); anim.SetInteger("Direction", direction); anim.SetBool("Idle", idle); anim.SetBool("Bouncing", sPress); anim.SetBool("HasDashBomb", hasDashBomb); anim.SetBool("DashBomb", airDashingCurrently); anim.SetBool("DoubleJumping", djAnim); //DOUBLE JUMP if (grounded) { hasDoubleJumped = false; djAnim = false; t2 = t; } if (Input.GetButtonDown("Jump") && !hasDoubleJumped && !grounded) //if press space while in the air and the player has not used their double jump yet { GetComponent <Rigidbody2D>().velocity = new Vector2(0, jumpHeight); //Jump hasDoubleJumped = true; djAnim = true; sPress = false; } if (hasDoubleJumped && t2 > 0) { t2 -= Time.deltaTime; if (t2 <= 0) { djAnim = false; t2 = t; } } //AIR DASH if (grounded) { hasAirDashed = false; } if (Input.GetButtonDown("Dash") && !hasAirDashed && !grounded) { airDashingCurrently = true; } if (airDashingCurrently) { hasAirDashed = true; if (dashTime > 0) { dashTime -= Time.deltaTime; if (direction == 1) { GetComponent <Rigidbody2D>().gravityScale = 0; GetComponent <Rigidbody2D>().velocity = new Vector2(dashSpeed, 0); } if (direction == 2) { GetComponent <Rigidbody2D>().gravityScale = 0; GetComponent <Rigidbody2D>().velocity = new Vector2(-dashSpeed, 0); } if (dashTime <= 0) { GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); GetComponent <Rigidbody2D>().gravityScale = 5; dashTime = startDashTime; airDashingCurrently = false; } } } //HEALTH if (justHit) { Damage.SetActive(true); Damage.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, (float)(immunityTimer * 0.25)); immunityTimer -= Time.deltaTime; } else { Damage.SetActive(false); } if (immunityTimer <= 0) { justHit = false; immunityTimer = 2; } if (currentHP <= 0) { //GameOver HUD.SendMessage("EndGame"); } MenuDisplay.UpdateHealth(currentHP, totalHP); }
public void Die() { MenuDisplay.UpdateKills(); dead = true; }
public static void PrintLoop() { BoardDisplay.PrintBoard(Board); MenuDisplay.PrintMenu(); Console.WriteLine(); }
// Update is called once per frame void Awake() { instance = this; }
/// <summary> /// Displays a menu where a single element can be selected from the collection. /// </summary> /// <typeparam name="T">The type of the elements in <paramref name="collection"/>.</typeparam> /// <param name="collection">The collection of element from which the menu should be created.</param> /// <param name="keySelector">A function that gets the <see cref="ConsoleString"/> that should be displayed for an item in the collection.</param> /// <param name="labeling">The type of labeling (option prefix) that should be applied when displaying the menu.</param> /// <param name="cleanup">The cleanup applied after displaying the menu.</param> /// <param name="cancelKey">If not <c>null</c>, this string is displayed as a "cancel option" in the bottom of the menu. /// <paramref name="cancelValue"/> will be returned if this option is selected.</param> /// <param name="cancelValue">The value returned if <paramref name="cancelKey"/> is not <c>null</c>.</param> /// <returns>The element that was selected using the displayed menu.</returns> public static T MenuSelect <T>(this IConsole console, IEnumerable <T> collection, Func <T, ConsoleString> keySelector = null, MenuLabeling labeling = MenuLabeling.NumbersAndLetters, MenuCleanup cleanup = MenuCleanup.None, ConsoleString cancelKey = null, T cancelValue = default(T)) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } if (!collection.Any()) { throw new ArgumentOutOfRangeException(nameof(collection), $"{nameof(MenuSelect)} can not on be executed on non-empty collections."); } if (keySelector == null) { keySelector = x => x.ToString(); } MenuOption <T> result = null; console.CursorVisible = false; using (var display = new MenuDisplay <MenuOption <T> >(console)) { display.Cleanup = cleanup == MenuCleanup.None ? InputCleanup.None : InputCleanup.Clean; display.PrefixesTop.SetKeys(labeling); foreach (var item in collection) { display.Options.Add(new MenuOption <T>(keySelector(item), item)); } if (cancelKey != null || (cancelValue != null && !cancelValue.Equals(default(T)))) { if (labeling != MenuLabeling.None) { display.PrefixesBottom.SetKeys(new char[] { '0' }); } if (cancelKey == null) { cancelKey = keySelector(cancelValue); } display.Options.Add(new MenuOption <T>(cancelKey, cancelValue)); } display.SelectedIndex = 0; bool done = false; ConsoleKeyInfo info; do { info = console.ReadKey(true); switch (info.Key) { case ConsoleKey.DownArrow: case ConsoleKey.UpArrow: display.HandleKey(info); break; case ConsoleKey.Enter: result = display.Options[display.SelectedIndex]; done = true; break; default: var index = display.IndexFromPrefix(info.KeyChar); if (index >= 0) { display.HandleKey(info); result = display.Options[index]; done = true; } break; } } while (!done); if (cleanup == MenuCleanup.None) { console.SetCursorPosition(display.Origin + new ConsoleSize(0, display.Options.Count)); } } if (cleanup == MenuCleanup.RemoveMenuShowChoice) { console.WriteLine(result.Text); } console.CursorVisible = true; return(result.Value); }
/// <summary> /// Displays a menu where a set of elements can be selected from the collection. /// </summary> /// <typeparam name="T">The type of the elements in <paramref name="collection"/>.</typeparam> /// <param name="isSelectionValid">A function that determines if the current selected collection is a valid selection. If the function returns <c>true</c> the done option is enabled.</param> /// <param name="collection">The collection of element from which the menu should be created.</param> /// <param name="onKeySelector">A function that gets the <see cref="ConsoleString"/> that should be displayed for an item in the collection, when the option is selected.</param> /// <param name="offKeySelector">A function that gets the <see cref="ConsoleString"/> that should be displayed for an item in the collection, when the option is not selected.</param> /// <param name="selected">A function that returns a boolean value indicating if an element should be pre-selected when the menu is displayed.</param> /// <param name="labeling">The type of labeling (option prefix) that should be applied when displaying the menu.</param> /// <param name="cleanup">The cleanup applied after displaying the menu.</param> /// <param name="doneText">The <see cref="ConsoleString"/> that is displayed as the bottommost option in the menu. Selecting this option will cause the function to return.</param> /// <returns>The elements that were selected using the displayed menu.</returns> public static T[] MenuSelectMultiple <T>(this IConsole console, IEnumerable <T> collection, Func <IEnumerable <T>, bool> isSelectionValid = null, Func <T, ConsoleString> onKeySelector = null, Func <T, ConsoleString> offKeySelector = null, Func <T, bool> selected = null, MenuLabeling labeling = MenuLabeling.NumbersAndLetters, MenuCleanup cleanup = MenuCleanup.None, ConsoleString doneText = null) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } var items = collection.ToArray(); if (!items.Any()) { throw new ArgumentOutOfRangeException(nameof(collection), $"{nameof(MenuSelect)} can not on be executed on non-empty collections."); } if (isSelectionValid == null) { isSelectionValid = x => true; } if (onKeySelector == null) { onKeySelector = x => x.ToString(); } if (offKeySelector == null) { offKeySelector = x => { var text = onKeySelector(x); if (text.HasColors) { return(text.ClearColors()); } else { return($"[DarkGray:{text.Content}]"); } } } ; if (selected == null) { selected = x => false; } List <MenuOnOffOption <T> > result = null; console.CursorVisible = false; using (var display = new MenuDisplay <MenuOnOffOption <T> >(console)) { display.Cleanup = cleanup == MenuCleanup.None ? InputCleanup.None : InputCleanup.Clean; display.PrefixesTop.SetKeys(labeling); display.PrefixesBottom.SetKeys(new char[] { '0' }); foreach (var item in items) { display.Options.Add(new MenuOnOffOption <T>(onKeySelector(item), offKeySelector(item), selected(item), item)); } if (doneText == null) { doneText = "Done"; } var doneOption = new MenuOnOffOption <T>(doneText, $"[DarkGray:{doneText.Content}]", true, default(T)); display.Options.Add(doneOption); doneOption.On = isSelectionValid(display.Options.Where(x => x != doneOption && x.On).Select(x => x.Value)); display.SelectedIndex = 0; bool done = false; ConsoleKeyInfo info; do { info = console.ReadKey(true); switch (info.Key) { case ConsoleKey.DownArrow: case ConsoleKey.UpArrow: display.HandleKey(info); break; case ConsoleKey.Enter: default: var index = info.Key == ConsoleKey.Enter ? display.SelectedIndex : display.IndexFromPrefix(info.KeyChar); if (index >= 0) { var option = display.Options[index]; if (option == doneOption && doneOption.On) { done = true; } else if (option != doneOption) { option.On = !option.On; doneOption.On = isSelectionValid(display.Options.Where(x => x != doneOption && x.On).Select(x => x.Value)); } } break; } } while (!done); result = new List <MenuOnOffOption <T> >(display.Options.Where(x => x != doneOption && x.On)); if (cleanup == MenuCleanup.None) { console.SetCursorPosition(display.Origin + new ConsoleSize(0, display.Options.Count)); } } if (cleanup == MenuCleanup.RemoveMenuShowChoice) { foreach (var r in result) { console.WriteLine(r.Text); } } console.CursorVisible = true; return(result.Select(x => x.Value).ToArray()); }