private void ShowHPBar(Unit unit) { hitPointsLabel = string.Format("{0}/{1} ", unit.Attributes.CurrentHealth, unit.Attributes.MaxHealth); ConsoleTools.WriteOnPosition(hitPointsLabel.ToString(), topRight.X + HIT_POINTS_STRING.Length, topRight.Y + 4, ConsoleColor.Cyan); int bars = (int)(unit.Attributes.CurrentHealth / ((double)unit.Attributes.MaxHealth / (double)HPBarLength)); hitPointsBar.Append('\u2588', bars); hitPointsBar.Append('\u2591', HPBarLength - bars); if (bars < HPBarLength) hitPointsBar.Append(' ', Globals.CONSOLE_WIDTH - (topRight.X + HIT_POINTS_STRING.Length + hitPointsLabel.Length + hitPointsBar.Length)); ConsoleColor color = ConsoleColor.Red; if (((double)unit.Attributes.CurrentHealth / (double)unit.Attributes.MaxHealth) > 0.9) color = ConsoleColor.DarkGreen; else if (((double)unit.Attributes.CurrentHealth / (double)unit.Attributes.MaxHealth) > 0.7) color = ConsoleColor.Green; else if (((double)unit.Attributes.CurrentHealth / (double)unit.Attributes.MaxHealth) > 0.5) color = ConsoleColor.Yellow; else if (((double)unit.Attributes.CurrentHealth / (double)unit.Attributes.MaxHealth) > 0.3) color = ConsoleColor.DarkYellow; ConsoleTools.WriteOnPosition(hitPointsBar.ToString(), topRight.X + HIT_POINTS_STRING.Length + hitPointsLabel.Length, topRight.Y + 4, color); hitPointsBar.Clear(); }
//other bag slots to be implemented public Inventory(Equipment equipmentToConnect) { this.equipmentConnected = equipmentToConnect; for (int i = 0; i < BASE_BAG_SLOTS; i++) { this.inventory[i] = null; this.isSlotUsed[i] = false; } this.owner = equipmentConnected.Owner; }
private void ShowGameTime(Unit unit) { ConsoleTools.WriteOnPosition(string.Format("\t{0} year", GameEngine.GameTime.Year), Globals.GAME_FIELD_BOTTOM_RIGHT.X + GAME_TIME_STRING.Length + 2, Globals.CONSOLE_HEIGHT - 2); timeLabel.Append(' ', ((Globals.CONSOLE_WIDTH - Globals.GAME_FIELD_BOTTOM_RIGHT.X) - GameEngine.GameTime.ToString().Length) - 2); timeLabel.Append(GameEngine.GameTime.ToString()); ConsoleTools.WriteOnPosition(timeLabel.ToString(), Globals.GAME_FIELD_BOTTOM_RIGHT.X + 1, Globals.CONSOLE_HEIGHT - 1); timeLabel.Clear(); }
public Equipment(Unit owner) { this.equipment = new Item[ITEM_SLOTS]; this.isSlotUsed = new bool[ITEM_SLOTS]; this.unitOwner = owner; for (int i = 0; i < equipment.Length; i++) { this.equipment[i] = null; this.isSlotUsed[i] = false; } }
public SideBar(Unit unit) { this.unit = unit; this.width = Globals.CONSOLE_WIDTH - topRight.X; this.name = CutStringIfTooLong(unit.Name); ConsoleTools.WriteOnPosition(CutStringIfTooLong(GameEngine.MapName), XCoordToCenterString(GameEngine.MapName, true), topRight.Y, ConsoleColor.DarkGray); ConsoleTools.WriteOnPosition(name, XCoordToCenterString(name), topRight.Y + 2, ConsoleColor.Yellow); ConsoleTools.WriteOnPosition(HIT_POINTS_STRING, topRight.X, topRight.Y + 4, ConsoleColor.Cyan); ConsoleTools.WriteOnPosition(GAME_TIME_STRING, Globals.GAME_FIELD_BOTTOM_RIGHT.X + 2, Globals.CONSOLE_HEIGHT - 2, ConsoleColor.Cyan); Update(this.unit); }
/// <summary> /// Default constructor for creating a window over the game field. /// </summary> /// <param name="pc">Information for this unit is used in the window.</param> /// <param name="title">Window title.</param> public Window(Unit pc, string title) { this.pc = pc; this.title = title.ToUpper(); //save window coordinates this.bottomLeft = new Coordinate((windowBottomLeftX + windowMargin) - 1, windowBottomLeftY - windowMargin); this.topLeft = new Coordinate((windowHeight - windowBottomLeftY) + windowMargin - 1, windowBottomLeftX + windowMargin); this.bottomRight = new Coordinate((windowBottomLeftX + windowWidth) - windowMargin, windowBottomLeftY - windowMargin); this.topRight = new Coordinate((windowBottomLeftX + windowWidth) - windowMargin, (windowHeight - windowBottomLeftY) + windowMargin); this.linePosition = this.TopLeft.Y + 2; activeWindows.Add(this); }
/// <summary> /// Constructor for manually setting the size/position of the window. /// </summary> /// <param name="pc">Information for this unit is used in the window.</param> /// <param name="title">Window title.</param> /// <param name="windowBottomLeftX">Bottom-left window corner 'x' coordinate.</param> /// <param name="windowBottomLeftY">Bottom-left window corner 'y' coordinate.</param> public Window(Unit pc, string title, int windowBottomLeftX, int windowBottomLeftY, int windowWidth, int windowHeight) { this.pc = new Unit(pc); this.title = title.ToUpper(); if (windowBottomLeftX <= Globals.CONSOLE_WIDTH && windowBottomLeftX >= 0) { this.windowBottomLeftX = windowBottomLeftX; } else { throw new ArgumentOutOfRangeException(string.Format("windowBottomLeftX = {0}. windowBottomLeftX should be in range 0 - {1}.", windowBottomLeftX, Globals.CONSOLE_WIDTH)); } if (windowBottomLeftY <= Globals.CONSOLE_HEIGHT && windowBottomLeftY > 0) { this.windowBottomLeftY = windowBottomLeftY; } else { throw new ArgumentOutOfRangeException(string.Format("windowBottomLeftY = {0}. windowBottomLeftY should be in range 0 - {1}.", windowBottomLeftY, Globals.CONSOLE_HEIGHT)); } if (windowWidth <= Globals.CONSOLE_WIDTH && windowWidth >= 0) { this.windowWidth = windowWidth; } else { throw new ArgumentOutOfRangeException(string.Format("windowWidth = {0}. windowWidth should be in range 0 - {1}.", windowWidth, Globals.CONSOLE_WIDTH)); } if (windowHeight <= Globals.CONSOLE_HEIGHT && windowHeight > 0) { this.windowHeight = windowHeight; } else { throw new ArgumentOutOfRangeException(string.Format("windowHeight = {0}. windowHeight should be in range 0 - {1}.", windowHeight, Globals.CONSOLE_HEIGHT)); } this.linePosition = this.TopLeft.Y + 1; activeWindows.Add(this); }
public static void ItemTest(Unit unit) { var amuletType = new ItemType(JewelleryType.Amulet, EquipSlot.AmuletA); var anotherAmulet = new ItemType(JewelleryType.Amulet, EquipSlot.AmuletA); var chestArmorType = new ItemType(ArmorType.Leather, EquipSlot.Chest); var hoodArmorType = new ItemType(ArmorType.Leather, EquipSlot.Head); var swordType = new ItemType(WeaponType.OneHandedSwords, EquipSlot.MainHand); Item[] itemArr = new Item[] { new Item("Lucky Charm", new ItemAttributes(amuletType, 0.2f, 1, 1, 1, 1, 1, 5)), new Item("Undead's Claw", new ItemAttributes(anotherAmulet, 0.2f, str: 2, wis: 4, luck: -1)), new Item("Rugged L.Chest", new ItemAttributes(chestArmorType, 2.2f, str: 2, con: 3)), new Item("Assassins Hood", new ItemAttributes(hoodArmorType, 1f, dex:5, luck:1)), new Item("Dark Sword", new ItemAttributes(swordType, 3.5f, 30, "2d5", 30, 24, str: 5, con: 3)) }; GameEngine.GameField[unit.X, unit.Y].ItemList.AddRange(itemArr); }
public static void CheckForEffect(Unit unit, int objX, int objY) { if (gameField[objX, objY].IngameObject != null) { if (gameField[objX, objY].IngameObject.Flags.HasFlag(Flags.HasEffect)) { switch (gameField[objX, objY].IngameObject.Name) { //add hit/walk related objects+events here case "savepoint": if (unit.Flags.HasFlag(Flags.IsPlayerControl)) SaveLoadTools.SaveGame(gameField); break; default: break; } } } }
public void ShowLogFile(Unit pc) { //create a window Window logWindow = new Window(pc, "log"); logWindow.Show(); using (var sReader = new System.IO.StreamReader(LOG_FILE, ENCODING)) { while (sReader.Peek() != -1) logWindow.Write(sReader.ReadLine()); } ConsoleKeyInfo key; bool loop = true; do { key = Console.ReadKey(true); switch (key.Key) { case ConsoleKey.Escape: loop = false; logWindow.CloseWindow(); break; default: break; } } while (loop); }
/// <summary> /// Update the Side Pane information for the unit. /// </summary> /// <param name="unit">The unit for which is displayed information.</param> public void Update(Unit unit) { ShowHPBar(unit); ShowGameTime(unit); ShowAttributes(unit); }
public Unit(Unit unit) : this(unit.X, unit.Y, unit.Flags, unit.VisualChar, unit.Color, unit.Name, unit.unitAttr) { }
public static void UnitSpawn(int x = 10, int y = 10) { while (GameEngine.GameField[x, y].Terrain.Flags.HasFlag(Flags.IsCollidable) || GameEngine.GameField[x, y].Unit != null || GameEngine.GameField[x, y].IngameObject != null) { x += mt.Next(2); y += mt.Next(2); } Flags unitFlags = Flags.IsCollidable | Flags.IsMovable; char randChar = (char)mt.Next(97, 123); ConsoleColor randColor = (ConsoleColor)mt.Next(1, 16); string name = "_" + (char)mt.Next(65, 91) + (char)mt.Next(65, 91) + (char)mt.Next(65, 91); UnitAttributes uAttr = new UnitAttributes(18); Unit testUnit = new Unit(x, y, unitFlags, randChar, randColor, name, uAttr); GameEngine.AddUnit(testUnit); }
//!!!POTENTIAL BUG!!! REMOVES THE UNIT AFTER TimeTick() FOREACH HAS FINISHED //do NOT use for killing a unit! public static void RemoveUnit(Unit unit) { removedUnits.Add(unit); }
public void PrintUnit(Unit unit) { GameEngine.GameField[unit.X, unit.Y].Unit = unit; if (unit.VisualChar == '@') { this.range += unit.Attributes.EyeSight; ConsoleTools.WriteOnPosition(unit); this.PrintFOVMap(unit.X, unit.Y); } else if (unit.X >= xStart && unit.X <= xEnd && unit.Y >= yStart && unit.Y <= yEnd) if (GameEngine.GameField[unit.X, unit.Y].IsVisible) ConsoleTools.WriteOnPosition(unit); this.range = DEFAULT_RANGE; }
private static void RefreshInventoryScreen(Unit unit) { for (int i = 0; i < Window.ActiveWindows.Count; i++) { if (Window.ActiveWindows[i].Title == "INVENTORY") { Window.ActiveWindows[i].ResetLinePosition(); ShowInvWindow(unit, Window.ActiveWindows[i]); } } }
private static void ItemActions(Unit unit, Item item) { if (item != null) if (item.isEquipped) { GameEngine.MessageLog.SendMessage(string.Format("{0} -- [T] Take off, [D] Drop", item.ToString())); ConsoleKeyInfo key = Console.ReadKey(true); switch (key.Key) { case ConsoleKey.D: unit.Equipment.Unequip(item); GameField[unit.X, unit.Y].ItemList.Add(unit.Inventory.DropItem(item)); RefreshInventoryScreen(unit); MessageLog.SendMessage(string.Format("{0} ({1}) dropped.", item.ToString(), item.Slot)); break; case ConsoleKey.T: unit.Equipment.Unequip(item); RefreshInventoryScreen(unit); MessageLog.SendMessage(string.Format("You are taking off {0} ({1}).", item.ToString(), item.Slot)); break; default: case ConsoleKey.Escape: GameEngine.MessageLog.SendMessage("No action taken."); break; } } else { GameEngine.MessageLog.SendMessage(string.Format("{0} -- [E] Equip, [D] Drop", item.ToString())); ConsoleKeyInfo key = Console.ReadKey(true); switch (key.Key) { case ConsoleKey.D: GameField[unit.X, unit.Y].ItemList.Add(unit.Inventory.DropItem(item)); RefreshInventoryScreen(unit); MessageLog.SendMessage(string.Format("{0} dropped.", item.ToString())); break; case ConsoleKey.E: unit.Equipment.EquipItem(item); RefreshInventoryScreen(unit); MessageLog.SendMessage(string.Format("Equipping {0} to {1}.", item.ToString(), item.Slot)); break; default: GameEngine.MessageLog.SendMessage("No action taken."); break; } } }
public static List<Unit> LoadUnitsXML(string file = UNITS_FILE) { List<Unit> unitList = new List<Unit>(); XDocument unitsXML = XDocument.Load(UNITS_FILE); var units = unitsXML.Element("units").Elements(); foreach (var unit in units) { //unit info int x = int.Parse(unit.Attribute("x").Value); int y = int.Parse(unit.Attribute("y").Value); int z = int.Parse(unit.Attribute("z").Value); int flags = int.Parse(unit.Attribute("flags").Value); char visualChar = char.Parse(unit.Attribute("char").Value); ConsoleColor color = unit.Attribute("color").Value.ToColor(); string name = unit.Attribute("name").Value; int id = int.Parse(unit.Attribute("id").Value); int age = int.Parse(unit.Attribute("age").Value); //attributes info XElement unitAttr = unit.Element("attributes"); int str = int.Parse(unitAttr.Attribute("str").Value); int dex = int.Parse(unitAttr.Attribute("dex").Value); int con = int.Parse(unitAttr.Attribute("con").Value); int wis = int.Parse(unitAttr.Attribute("wis").Value); int spi = int.Parse(unitAttr.Attribute("spi").Value); int luck = int.Parse(unitAttr.Attribute("luck").Value); Unit currentUnit; UnitAttributes unitAttributes = new UnitAttributes(age, str, dex, con, wis, spi, luck); unitList.Add(currentUnit = new Unit(x, y, (Flags)flags, visualChar, color, name, id, unitAttributes)); //load equipment XElement equipment = unit.Element("equipment"); var equipmentItems = equipment.Elements("item_id"); foreach (var itemID in equipmentItems) { Item equippedItem = new Item(Database.ItemDatabase[int.Parse(itemID.Value)]); currentUnit.Equipment.EquipItem(equippedItem); } //load inventory XElement inventory = unit.Element("inventory"); var inventoryItems = inventory.Elements("item_id"); foreach (var itemID in inventoryItems) { Item storedItem = new Item(Database.ItemDatabase[int.Parse(itemID.Value)]); currentUnit.Inventory.StoreItem(storedItem); } } return unitList; }
private static void OpenInventory(Unit pc) { Window invWindow = new Window(pc, "inventory"); ShowInvWindow(pc, invWindow); ConsoleKeyInfo key; bool loop = true; do { key = Console.ReadKey(true); int letterCode = key.KeyChar; int itemPosition; if (char.IsLower(key.KeyChar)) { if (!key.Modifiers.HasFlag(ConsoleModifiers.Control)) { itemPosition = letterCode - 97; if (itemPosition < pc.Inventory.IsSlotUsed.Length && pc.Inventory[itemPosition] != null) { ItemActions(pc, pc.Inventory[itemPosition]); } } else { itemPosition = letterCode + 25 - 97; if (itemPosition < pc.Inventory.IsSlotUsed.Length && pc.Inventory[itemPosition] != null) { ItemActions(pc, pc.Inventory[itemPosition]); } } } else if (char.IsUpper(key.KeyChar)) { itemPosition = letterCode - 65; if (itemPosition < pc.Equipment.IsSlotUsed.Length && pc.Equipment[itemPosition] != null) { ItemActions(pc, pc.Equipment[itemPosition]); } } if (key.Key == ConsoleKey.Escape) { loop = false; invWindow.CloseWindow(); } } while (loop); }
private static int PlayerControl(Unit pc) { bool loop = true; while (loop) { if (Console.KeyAvailable) { loop = false; ConsoleKeyInfo key = Console.ReadKey(true); switch (key.Key) { case ConsoleKey.T: //Tests Tests.Testing.ItemTest(pc); return 0; /*case ConsoleKey.U: Tests.Testing.UnitSpawn(); return 0;*/ case ConsoleKey.F1: MessageLog.SendMessage(string.Format("[{0}, {1}]", pc.X, pc.Y)); return 0; /*case ConsoleKey.H: MessageLog.ShowLogFile(pc); return 0;*/ #region PickUpItem case ConsoleKey.G: case ConsoleKey.OemComma: //pick up item if (GameField[pc.X, pc.Y].ItemList != null && GameField[pc.X, pc.Y].ItemList.Count > 0) { if (GameField[pc.X, pc.Y].ItemList.Count == 1) { pc.Inventory.StoreItem(GameField[pc.X, pc.Y].ItemList[0]); MessageLog.SendMessage(string.Format("Picked up {0}.", GameField[pc.X, pc.Y].ItemList[0].ToString())); GameField[pc.X, pc.Y].ItemList.Remove(GameField[pc.X, pc.Y].ItemList[0]); } else { bool itemLoop = true; while (itemLoop) { for (int i = 0; i < GameField[pc.X, pc.Y].ItemList.Count; i++) { MessageLog.SendMessage(string.Format("Pick up {0}? [Y]es/ [N]o/ [A]ll/ [C]ancel", GameField[pc.X, pc.Y].ItemList[i].ToString())); ConsoleKeyInfo itemKey = Console.ReadKey(true); switch (itemKey.Key) { case ConsoleKey.Y: pc.Inventory.StoreItem(GameField[pc.X, pc.Y].ItemList[i]); MessageLog.SendMessage(string.Format("Picked up {0}.", GameField[pc.X, pc.Y].ItemList[i].ToString())); GameField[pc.X, pc.Y].ItemList.Remove(GameField[pc.X, pc.Y].ItemList[i]); i--; break; case ConsoleKey.A: MessageLog.SendMessage("Picking up all items."); for (int k = i; k < GameField[pc.X, pc.Y].ItemList.Count; k++) { pc.Inventory.StoreItem(GameField[pc.X, pc.Y].ItemList[k]); MessageLog.SendMessage(string.Format("Picked up {0}.", GameField[pc.X, pc.Y].ItemList[k].ToString())); GameField[pc.X, pc.Y].ItemList.Remove(GameField[pc.X, pc.Y].ItemList[k]); k--; } itemLoop = false; i = GameField[pc.X, pc.Y].ItemList.Count; break; case ConsoleKey.C: case ConsoleKey.Escape: itemLoop = false; i = GameField[pc.X, pc.Y].ItemList.Count; MessageLog.SendMessage("Action canceled."); break; case ConsoleKey.N: break; default: i--; break; } } break; } } } return 100; #endregion case ConsoleKey.I: OpenInventory(pc); return 100; case ConsoleKey.X: pc.Experience.GainXP(15); return 0; case ConsoleKey.UpArrow: case ConsoleKey.NumPad8: case ConsoleKey.K: if (!ModifierPressed(key)) pc.MakeAMove(CardinalDirection.North); break; case ConsoleKey.DownArrow: case ConsoleKey.NumPad2: case ConsoleKey.J: if (!ModifierPressed(key)) pc.MakeAMove(CardinalDirection.South); break; case ConsoleKey.LeftArrow: case ConsoleKey.NumPad4: case ConsoleKey.H: if (!ModifierPressed(key)) pc.MakeAMove(CardinalDirection.West); break; case ConsoleKey.RightArrow: case ConsoleKey.NumPad6: case ConsoleKey.L: if (!ModifierPressed(key)) pc.MakeAMove(CardinalDirection.East); break; case ConsoleKey.NumPad7: case ConsoleKey.Y: if (!ModifierPressed(key)) pc.MakeAMove(CardinalDirection.NorthWest); break; case ConsoleKey.NumPad9: case ConsoleKey.U: if (!ModifierPressed(key)) pc.MakeAMove(CardinalDirection.NorthEast); break; case ConsoleKey.NumPad1: case ConsoleKey.B: if (!ModifierPressed(key)) pc.MakeAMove(CardinalDirection.SouthWest); break; case ConsoleKey.NumPad3: case ConsoleKey.N: if (!ModifierPressed(key)) pc.MakeAMove(CardinalDirection.SouthEast); break; case ConsoleKey.Escape: loop = false; UIElements.MainMenu(); return 0; default: loop = true; break; } if (GameField[pc.X, pc.Y].ItemList != null && GameField[pc.X, pc.Y].ItemList.Count > 0) { if (GameField[pc.X, pc.Y].ItemList.Count == 1) MessageLog.SendMessage(string.Format("You see a {0} here.", GameField[pc.X, pc.Y].ItemList[0].ToString())); else { StringBuilder itemsPresentSB = new StringBuilder(); for (int i = 0; i < GameField[pc.X, pc.Y].ItemList.Count; i++) { itemsPresentSB.Append(GameField[pc.X, pc.Y].ItemList[i].ToString()); if (i + 1 < GameField[pc.X, pc.Y].ItemList.Count) itemsPresentSB.Append(", "); } MessageLog.SendMessage(string.Format("You see {0} items here: {1}.", GameField[pc.X, pc.Y].ItemList.Count, itemsPresentSB.ToString())); } } } } return 100; }
private static void TimeTick(Unit pc) { bool loop = true; //int turns = 0; while (loop) { //add queued units foreach (Unit queuedUnit in queuedUnits) { Units.Add(queuedUnit); } queuedUnits.Clear(); //remove units foreach (Unit unitToRemove in removedUnits) { Units.Remove(unitToRemove); } removedUnits.Clear(); gameTime.Tick(); //make regen & effects that act each turn/every n-turns here, not ext.to Unit... if (GameTime.Ticks % 50 == 0) pc.EffectsPerFive(); sideBar.Update(pc); foreach (Unit unit in Units) { unit.Attributes.Energy += unit.Attributes.ActionSpeed; int energyCost = 0; if (unit.Attributes.Energy >= 100) { if (unit.Flags.HasFlag(Flags.IsPlayerControl)) { energyCost = PlayerControl(pc); //turns++; //if (turns == 1000) // MessageLog.SendMessage(string.Format("Time for 1k turns = {0}", gameTime.ToString())); //energyCost = AI.ArtificialIntelligence.DrunkardWalk(unit); //for performance testing purposes } else { energyCost = AI.ArtificialIntelligence.DrunkardWalk(unit); } unit.Attributes.Energy -= energyCost; } } } }
private static void Initialize(Unit pc) { sideBar = new SideBar(pc); VEngine = new VisualEngine(GameField); VEngine.PrintUnit(pc); TimeTick(pc); }
public void ClearGameObject(Unit unit) { if (map[unit.X, unit.Y].IsVisible == true) ConsoleTools.WriteOnPosition(GameEngine.GameField[unit.X, unit.Y].Terrain, unit.X, unit.Y); else ConsoleTools.WriteOnPosition(' ', unit.X, unit.Y); GameEngine.GameField[unit.X, unit.Y].Unit = null; }
private void ShowAttributes(Unit unit) { string del = new string(' ', width); int attributesPrint = 1; for (int i = 0; i < 6; i++) attributesPrint *= unit.Attributes[i] + 1; attributesPrint += unit.Experience.Level; int mid = topRight.X + ((Globals.CONSOLE_WIDTH - topRight.X) / 2); if (attributesPrint != this.oldAttrPrint) { //clear the rows for the new info print ConsoleTools.WriteOnPosition(del, topRight.X, topRight.Y + 10); ConsoleTools.WriteOnPosition(del, topRight.X, topRight.Y + 11); ConsoleTools.WriteOnPosition(del, topRight.X, topRight.Y + 12); //print the new attributes ConsoleTools.WriteOnPosition(string.Format("STR: {0}", unit.Attributes[0]), topRight.X, topRight.Y + 10, ConsoleColor.DarkGray); ConsoleTools.WriteOnPosition(string.Format("DEX: {0}", unit.Attributes[1]), mid, topRight.Y + 10, ConsoleColor.DarkGray); ConsoleTools.WriteOnPosition(string.Format("CON: {0}", unit.Attributes[2]), topRight.X, topRight.Y + 11, ConsoleColor.DarkGray); ConsoleTools.WriteOnPosition(string.Format("WIS: {0}", unit.Attributes[3]), mid, topRight.Y + 11, ConsoleColor.DarkGray); ConsoleTools.WriteOnPosition(string.Format("SPI: {0}", unit.Attributes[4]), topRight.X, topRight.Y + 12, ConsoleColor.DarkGray); ConsoleTools.WriteOnPosition(string.Format("LUCK: {0}", unit.Attributes[5]), mid, topRight.Y + 12, ConsoleColor.DarkGray); this.oldAttrPrint = attributesPrint; } ConsoleTools.WriteOnPosition(del, topRight.X, topRight.Y + 14); ConsoleTools.WriteOnPosition(string.Format("LVL: {0}", unit.Experience.Level), topRight.X, topRight.Y + 14, ConsoleColor.White); ConsoleTools.WriteOnPosition(string.Format("EXP: {0} / {1}", unit.Experience.XP, unit.Experience.ExpPointsArray[unit.Experience.Level]), mid, topRight.Y + 14, ConsoleColor.White); }
public static void NewGame() { string pcName = "SCiENiDE_TESTING"; //for testing purposes we set the char name manually; //else use the bottom row. //string pcName = UIElements.PromptForName(); UIElements.InGameUI(); messageLog = new MessageLog(0, Globals.CONSOLE_HEIGHT - 1, Globals.GAME_FIELD_BOTTOM_RIGHT.X, (Globals.CONSOLE_HEIGHT - (Globals.GAME_FIELD_BOTTOM_RIGHT.Y + 1)), true); MessageLog.SendMessage("~w13!Message ~W2!log ~l11!i~l3!n~s11!itialized."); MessageLog.DeleteLog(); Units.Clear(); gameField = SaveLoadTools.LoadMap(); //load map; change it to generate map! MapFileName = @"../../maps/0.wocm"; Item.LastItemID = SaveLoadTools.LastItemID(); Flags pcFlags = Flags.IsCollidable | Flags.IsMovable | Flags.IsPlayerControl; Unit pc = new Unit(10, 10, pcFlags, '@', ConsoleColor.White, pcName, new UnitAttributes()); Units.Add(pc); GameTime = new GameTime(); Initialize(pc); }
private static void ShowInvWindow(Unit unit, Window invWindow) { int letterCount = 0; bool CTRLMod = false; int letterSize = 65; int itemsCount = 0; int itemTypeCode = -1; //unexisting item type Item[] itemsOwned = new Item[unit.Inventory.Count + unit.Equipment.Count]; invWindow.Show(); invWindow.WriteLine("Equipment:", ConsoleColor.Green); for (int i = 0; i < unit.Equipment.IsSlotUsed.Length; i++) { if (unit.Equipment.IsSlotUsed[i] == true) { itemsOwned[itemsCount++] = unit.Equipment[i]; invWindow.Write(string.Format("{0} - {1}: {2}", (char)(unit.Equipment[i].Slot + letterSize), unit.Equipment[i].Slot, unit.Equipment[i].ToString()), ConsoleColor.Yellow); } } letterCount = 0; letterSize = 97; invWindow.WriteLine("Inventory:", ConsoleColor.Green); for (int i = 0; i < unit.Inventory.IsSlotUsed.Length; i++) { if (unit.Inventory.IsSlotUsed[i] == true) { if (itemTypeCode != (int)unit.Inventory[i].ItemAttr.ItemType.BaseType) { itemTypeCode = (int)unit.Inventory[i].ItemAttr.ItemType.BaseType; invWindow.WriteLine(string.Format("{0}:", unit.Inventory[i].ItemAttr.ItemType.BaseType)); } itemsOwned[itemsCount++] = unit.Inventory[i]; if (!CTRLMod) invWindow.Write(string.Format("{0} - {1}", (char)(unit.Inventory[i].InventorySlot + letterSize), unit.Inventory[i].ToString()), ConsoleColor.White); else invWindow.Write(string.Format("^{0} - {1}", (char)(unit.Inventory[i].InventorySlot + letterSize), unit.Inventory[i].ToString()), ConsoleColor.White); if (letterCount > 25 && !CTRLMod) { letterCount = 0; CTRLMod = true; } } } }
public static void AddUnit(Unit unit) { queuedUnits.Add(unit); }