/* * Interface theInterface; * Zoo theZoo; * * long lastTime; * long elapsedTime; */ static void Main(string[] args) { int CYCLE_TIME = 100; Interface theInterface = new Interface(); Zoo theZoo = new Zoo(theInterface); Boolean isGameAlive = true; DateTime lastTime = DateTime.Now; double elapsedTime; GameState State = GameState.GS_STATUS; Console.WindowHeight = Screen.High + 1; Console.WindowWidth = Screen.Wide; Console.BufferHeight = Screen.High + 1; Console.BufferWidth = Screen.Wide; /* * theInterface.DisplayBanner("Welcome to Zoo Game!"); * theInterface.Write("What is your zoo called?"); * * String tempName = Console.ReadLine(); * if (tempName != "") * { theZoo.name = tempName; * } */ lastTime = DateTime.Now; State = GameState.GS_MAP; //theZoo.AddLion(); for (int i = 0; i < 5; i++) { theZoo.AddZebra(); } //Lion l1 = theZoo.GetAnimalsOfType<Lion>().First<Lion>(); //Zebra z1 = theZoo.GetAnimalsOfType<Zebra>().First<Zebra>(); //l1.MoveTo(40,20); //z1.MoveTo(41,21); while (isGameAlive) { elapsedTime = DateTime.Now.Subtract(lastTime).TotalMilliseconds; if (Console.KeyAvailable) { // check for command ConsoleKeyInfo key = Console.ReadKey(true); switch (key.Key) { // take action case ConsoleKey.Q: isGameAlive = false; break; case ConsoleKey.Z: theZoo.AddZebra(); break; case ConsoleKey.L: theZoo.AddLion(); break; case ConsoleKey.M: if (State == GameState.GS_STATUS) { State = GameState.GS_MAP; } else if (State == GameState.GS_MAP) { State = GameState.GS_STATUS; } break; case ConsoleKey.O: theZoo.map.waterLevel += 0.1; break; case ConsoleKey.P: theZoo.map.waterLevel -= 0.1; break; } } if (elapsedTime > CYCLE_TIME) { theZoo.Update(elapsedTime); if (State == GameState.GS_STATUS) { theInterface.DisplayStatus(theZoo); } else { theInterface.DisplayMap(theZoo); } lastTime = DateTime.Now; } } }