/// <summary> /// Displays the header /// </summary> private void DisplayHeader() { // Set the color to red BufferEditor.WriteWithColor(0, 0, " ", ConsoleColor.Red); BufferEditor.WriteWithColor(0, 5, " ", ConsoleColor.Red); // Loop 100 times for (int i = 0; i < 100; i++) { // Write to the buffer BufferEditor.Write(i, 0, "-"); BufferEditor.Write(i, 5, "-"); } // Change the color to blue BufferEditor.WriteWithColor(0, 1, " ", ConsoleColor.Blue); // Write to the buffer BufferEditor.Write(1, 1, "Score:"); BufferEditor.Write(30, 1, "Level:"); BufferEditor.Write(47, 1, "Lifes:"); // Write the numbers to the buffer NumberManager.WriteScore(score); NumberManager.WriteLevel(level); NumberManager.WriteLifes(lifes); }
/// <summary> /// The player lost a life /// </summary> private void LifeLost() { // Int with the time ammount the blinking will last int timer = (lifes == 0) ? 50 : 150; // Create a new timer counter = new Timer(timer); // How long it takes for each blink blinkCounter = new Timer(8); // If we wan't to display the lifes bool displayLife = true; // Decrease the ammount of lifes lifes--; // Set the life lost to true ship.LifeLost = true; // Reset the Enemies Move Up enemies.ResetMoveUp(); // Set the ship destroyed true enemies.shipDestroyed = true; // Add an explosion explosions.Add(ship.Coordinates, ExplosionType.LARGE); // While the counter is counting while (counter.IsCounting()) { // Go through all objects in the collection for (int i = 0; i < objectsCollection.Count; i++) { // Update them (objectsCollection[i] as GameObject).Update(); } // Delay the thread by a certain ammout of time so the game can be precieved Thread.Sleep(BASE_DELAY); // If the blink counter has stopped counting if (!blinkCounter.IsCounting()) { // If display life is true if (displayLife) { // Set it to false displayLife = false; // Display the lifes NumberManager.WriteLifes(lifes + 1); BufferEditor.DisplayRender(); NumberManager.WriteLifes(lifes + 1); } // Else else { // Set it to true displayLife = true; // Delete the lifes NumberManager.DeleteLifes(); } } // Check for hits EnemyDestroyedCheck(); BarrierHitCheck(); /// Render the frame /// BufferEditor.DisplayRender(); } // Reset the ship values ship.Init(level); // Set the life lost to false ship.LifeLost = false; // Set the ship destroyed to false enemies.shipDestroyed = false; // Display the lifes NumberManager.WriteLifes(lifes); }