Esempio n. 1
0
        public DifficultyPage(SoundHandler sentSoundHandler)
        {
            // Class Initializer
            // Returns: nothing
            // Params:
            // - SoundHandler sentSoundHandler : a reference to our already prepared SoundHandler from the splash screen

            InitializeComponent();
            soundHandler = sentSoundHandler;

            // Start the difficulty page music
            soundHandler.PlayMusic(SoundHandler.MusicType.DifficultyMenu);
        }
Esempio n. 2
0
 public MainMenu(SoundHandler sentSoundHandler)
 {
     InitializeComponent();
     soundHandler = sentSoundHandler;
     soundHandler.PlayMusic(SoundHandler.MusicType.MainMenu);
 }
Esempio n. 3
0
        HighScore hs;                     // instance of the highscore class for the game

        // constructor for GameWindow sets all instance variables, decides difficulty, what map is being played,
        // loads the saved game if load is true, starts the game timer.
        public GameWindow(bool cheat, bool isLoad, int diff, SoundHandler sentSoundHandler, int mapId)
        {
            InitializeComponent();
            if (diff == 1)
            {
                numWavesToWin = 10;
            }
            else if (diff == 2)
            {
                numWavesToWin = 20;
            }
            else
            {
                numWavesToWin = 30;
            }
            hs                  = new HighScore();
            selectedRing        = new Image();
            soundHandler        = sentSoundHandler;
            selectedRing.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/tower select.png"));
            selectedRing.RenderTransformOrigin = new Point(0.5, 0.5);
            selectedRing.MouseDown            += Deselect;
            btnFlakLaserBuy.Click       += Deselect;
            btnFlakLaserBuy.Click       += Deselect;
            btnMachineGunTeslaBuy.Click += Deselect;
            btnNextWave.Click           += Deselect;
            btnPauseGame.Click          += Deselect;
            btnSaveGame.Click           += Deselect;
            btn_Sell_Turret.Click       += Deselect;
            side_menu.MouseDown         += Deselect;
            btn_fast_forward.Click      += Deselect;
            MapImage.MouseDown          += Deselect;
            turrets = new List <Image>();
            enemies = new List <Image>();

            eImageSources = new List <string>();
            eImageSources.Add("pack://application:,,,/Resources/Basic Ground Unit.png");
            eImageSources.Add("pack://application:,,,/Resources/Basic Ground Vehicle.png");
            eImageSources.Add("pack://application:,,,/Resources/Basic Aircraft.png");
            eImageSources.Add("pack://application:,,,/Resources/Ground Boss.png");
            eImageSources.Add("pack://application:,,,/Resources/Advanced Ground Unit.png");
            eImageSources.Add("pack://application:,,,/Resources/Advanced Ground Vehicle.png");
            eImageSources.Add("pack://application:,,,/Resources/Advanced Aircraft.png");
            eImageSources.Add("pack://application:,,,/Resources/Aircraft Boss.png");

            tImageSources = new List <string>();
            tImageSources.Add("pack://application:,,,/Resources/machine gun tower.png");
            tImageSources.Add("pack://application:,,,/Resources/flak tower.png");
            tImageSources.Add("pack://application:,,,/Resources/laser tower.png");
            tImageSources.Add("pack://application:,,,/Resources/mortar tower.png");
            tImageSources.Add("pack://application:,,,/Resources/stun tower.png");
            tImageSources.Add("pack://application:,,,/Resources/tesla tower.png");

            if (isLoad)
            {
                game = Game.LoadGame("..\\..\\Resources\\SavedGame3.txt", AddEnemy, RemoveEnemy);
                if (game.isWaveOver == false)
                {
                    btnNextWave.IsEnabled = false;
                }
                LoadTurretImgs();
            }
            else
            {
                game = new Game(mapId, cheat, AddEnemy, RemoveEnemy, diff);
            }
            if (game.difficulty == 1)
            {
                numWavesToWin = 10;
            }
            else if (game.difficulty == 2)
            {
                numWavesToWin = 20;
            }
            else
            {
                numWavesToWin = 30;
            }
            if (Game.map.mapID == 1)
            {
                MapImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/path2.png"));
            }
            else if (Game.map.mapID == 2)
            {
                MapImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/path3.png"));
            }
            gameTimer              = new DispatcherTimer();
            gameTimer.Interval     = new TimeSpan(0, 0, 0, 0, 16);
            nextWaveTimer          = new Timer();
            nextWaveTimer.Interval = 1000;
            gameTimer.Tick        += UpdateGame;
            gameTimer.Tick        += updateTowerPlace;
            nextWaveTimer.Elapsed += SetWaveTimer;
            Turret.RotateTurret   += RotateTurret;
            Enemy.RotateEnemy     += RotateEnemy;
            Spawner.DisplayWave   += DisplayWave;
            Turret.PlaySound      += soundHandler.Play;
            Turret.ChangeImage    += ChangeTowerImage;
            btnBasic.IsEnabled     = false;
            basic          = true;
            txtMoney.Text += Game.money;
            txtLives.Text  = "Lives: " + Game.lives;
            gameTimer.Start();
            soundHandler.PlayMusic(SoundHandler.MusicType.Game);
        }