/// <summary> /// Initializes the game plane wars. /// </summary> public MainWindow() { // Create a connection object for database connection. conn = new MySqlConnection(Settings.ConnectionString); // Initialize the MySql command object. cmd = new MySqlCommand(); cmd.Connection = conn; /* Load sounds. */ musicPlayerShoot = new MediaPlayer(); musicPlayerShoot.Open(new Uri("Sounds/bullet.wav", UriKind.Relative)); musicPlayerGetBomb = new MediaPlayer(); musicPlayerGetBomb.Open(new Uri("Sounds/get_bomb.wav", UriKind.Relative)); musicPlayerGetBullet = new MediaPlayer(); musicPlayerGetBullet.Open(new Uri("Sounds/get_bullet.wav", UriKind.Relative)); musicSmallEnemyDestroy = new MediaPlayer(); musicSmallEnemyDestroy.Open(new Uri("Sounds/enemy1_down.wav", UriKind.Relative)); musicMiddleEnemyDestroy = new MediaPlayer(); musicMiddleEnemyDestroy.Open(new Uri("Sounds/enemy2_down.wav", UriKind.Relative)); musicLargeEnemyDestroy = new MediaPlayer(); musicLargeEnemyDestroy.Open(new Uri("Sounds/enemy3_down.wav", UriKind.Relative)); musicPlayerUseBomb = new MediaPlayer(); musicPlayerUseBomb.Open(new Uri("Sounds/use_bomb.wav", UriKind.Relative)); musicPlayerClicked = new MediaPlayer(); musicPlayerClicked.Open(new Uri("Sounds/button.wav", UriKind.Relative)); musicBGM = new MediaPlayer(); musicBGM.Open(new Uri("Sounds/game_music.mp3", UriKind.Relative)); // Initialize timer. timer = new Timer(15); timer.Elapsed += ElapsedHandler; // Initialize linked lists. enemies = new LinkedList <Enemy>(); bullets = new LinkedList <Bullet>(); bulletsToRemove = new LinkedList <Bullet>(); enemiesToRemove = new LinkedList <Enemy>(); enemiesToDestroy = new LinkedList <Enemy>(); // Initialize random number generator. random = new Random(); // This game is running. running = false; // No supply now. supply = null; // The space key is not being pressed now. spaceKeyPressed = false; // Player score is 0 now. score = 0; // Current difficult level is 0. level = 0; // Double-bullet count starts from 0. bullet2Count = 0; // Initialize components in the window. InitializeComponent(); }