private static void MainLoop() { while (true) { Rendering.RenderAll(); Constants.PlayerAction action = Controls.HandleKeys(); if (action == Constants.PlayerAction.ExitGame || action == Constants.PlayerAction.ExitWithoutSave) { if (GameWorld.State == Constants.GameState.Playing && action == Constants.PlayerAction.ExitGame) { File.SaveGame(); } if (GameWorld.State == Constants.GameState.Playing && action == Constants.PlayerAction.ExitWithoutSave) { if (System.IO.File.Exists("World.bin")) { System.IO.File.Delete("World.bin"); } } MainMenu(); break; } if (GameWorld.State == Constants.GameState.Playing && action == Constants.PlayerAction.UsedTurn) { foreach (GameObject obj in GameWorld.Objects) { if (obj != GameWorld.Player && obj.Fighter != null) { obj.Fighter.TakeTurn(); } } } } Terminal.Close(); }
public static Constants.PlayerAction DisplayInventory() { Constants.PlayerAction actionTaken = Constants.PlayerAction.NotUsedTurn; while (true) { int?selected = Menu.Inventory("Inventory", Rogue.GameWorld.Player.Fighter.Inventory, "Close"); if (selected != null) { GameObject selectedItem = Rogue.GameWorld.Player.Fighter.Inventory[selected.Value]; if (selectedItem.Item.UseMethod == Constants.UseFunctions.Equip) { int?itemAction = Menu.ItemMenu(selectedItem.Name, new List <string> { "Equip/Unequip", "Drop" }, "Return"); if (itemAction == 0) { selectedItem.Item.Equipment.EquipToggle(Rogue.GameWorld.Player); actionTaken = Constants.PlayerAction.UsedTurn; break; } if (itemAction == 1) { selectedItem.Item.Drop(Rogue.GameWorld.Player); actionTaken = Constants.PlayerAction.UsedTurn; break; } } else if (selectedItem.Item.UseMethod != Constants.UseFunctions.None) { int?itemAction = Menu.ItemMenu(selectedItem.Name, new List <string> { "Use", "Throw", "Drop" }, "Return"); if (itemAction == 0) { selectedItem.Item.Use(Rogue.GameWorld.Player); actionTaken = Constants.PlayerAction.UsedTurn; break; } if (itemAction == 1) { selectedItem.Item.Throw(Rogue.GameWorld.Player); actionTaken = Constants.PlayerAction.UsedTurn; break; } if (itemAction == 2) { selectedItem.Item.Drop(Rogue.GameWorld.Player); actionTaken = Constants.PlayerAction.UsedTurn; break; } } } else { break; } } return(actionTaken); }