static void Main(string[] args) { Console.SetWindowSize(consoleWidth, consoleHeight); // Trying to get app to work in a normal console outside of debug // This needs more investigation. Works fine in debug console though Console.SetBufferSize(consoleWidth, consoleHeight); Console.Clear(); Console.WriteLine($"Denna gång har vi {numCitizens} medborgare, {numThief} tjuvar och {numPolices} poliser."); Console.Write("Tryck en tangent för att starta (Escape avslutar pågående spel efter start)..."); Console.ReadKey(true); CurrentBoard = new Gameboard(GameSettings.BoardSizeY, GameSettings.BoardSizeX); PeopleInCity = new List <Person>(); bool running = true; CreatePeople(); Console.Clear(); while (running) { UpdatePeopleOnBoard(); CurrentBoard.Draw(); CurrentBoard.CheckForCollitions(); Prison.TickAndRelease(); Utils.PrintPrison(); Utils.PrintStatusLine(Stats.PrintStatistics() + Prison.GetPrisonStatus()); MovePeople(); running = CheckKeyPresses(); } Console.Clear(); Console.WriteLine("Bye"); }
private static void MovePeople() { foreach (Person person in PeopleInCity) { if (Prison.CheckIfInPrison(person)) { continue; } person.Move(); } }
private static void UpdatePeopleOnBoard() { CurrentBoard.Clear(); foreach (Person person in PeopleInCity) { if (Prison.CheckIfInPrison(person)) { continue; } var cell = CurrentBoard.GetCell(person.Y, person.X); cell.People.Add(person); } }
public override void DoAction(Person destination) { Thief p = (Thief)destination; // Police confiscate action, first check if thief has stolen something if (p.StolenGoods.Count > 0) { int stolenCount = p.StolenGoods.Count; foreach (Item it in p.StolenGoods) { Confiscated.Add(it); } p.StolenGoods.Clear(); Utils.PrintEvent($"Polis sätter tjuv i fängelse och beslagtar allt stöldgods ({stolenCount} saker)"); Stats.AddCatch(); Prison.PutInPrison(p); } else { Utils.PrintEvent("Polisen möter en misstänkt tjuv, men han har inget stöldgods på sig.."); } }
public static void PrintPrison() { Console.SetCursorPosition(0, Console.WindowHeight - 9); var prisoners = Prison.GetCurrentPrisoners(); Console.WriteLine($"Fängelset ({prisoners.Count} fångar)"); Console.SetCursorPosition(0, Console.WindowHeight - 8); for (int j = 0; j < 7; j++) { Console.WriteLine(BlankLine()); } Console.SetCursorPosition(0, Console.WindowHeight - 8); int i = 1; DateTime now = DateTime.Now; foreach (var item in prisoners) { TimeSpan pTime = now - item.StartTime; Console.WriteLine($"Fånge {i}: suttit i: {pTime.Seconds} sekunder"); i++; } }