Exemplo n.º 1
0
        /// <summary>
        /// On load event handler. Runs after form is constructed.
        /// </summary>
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Enabled = false;

            //Set up animals
            AddAnimals();
            SetRandomAnimal();

            //Set up audio players
            musicPlayer = new Helpers.MusicPlayer(this);
            soundPlayer = new System.Media.SoundPlayer();

            //Set up the player
            player = new PlayerViewModel(this);
            player.PropertyChanged += new PropertyChangedEventHandler(OnPlayerPropertyChanged);

            //Set up the scenes
            scenes = new List<AbstractScene>();
            scenes.Add(new Scene1(this));
            scenes.Add(new Scene2(this));
            scenes.Add(new Scene3(this));
            currentSceneIndex = 0;
            currentScene = scenes[currentSceneIndex];
            InitializeScene(currentScene);

            PlaySound(soundPlayer, currentAnimal.Sound);

            this.Enabled = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets up scene object locations and data.
        /// </summary>
        private void InitializeScene(AbstractScene scene)
        {
            if (scene == null)
                return;

            scoreLabel.Location = GetControlOffsetPoint(scene.ScoreLabelLocation, scoreLabel);
            levelLabel.Location = GetControlOffsetPoint(scene.LevelLabelLocation, levelLabel);
            whoSaysLabel.Location = GetControlOffsetPoint(scene.WhoSaysLabelLocation, whoSaysLabel);
            soundLabel.Location = GetControlOffsetPoint(scene.AnimalSoundLabelLocation, soundLabel);

            musicPlayer.PlayMP3(scene.SoundTrackFilename);

            this.BackgroundImage = currentScene.BackgroundImage;

            levelLabel.Text = "Level: " + player.Level;
            levelLabel.Invalidate();

            scoreLabel.Text = "Score: " + player.Score;
            scoreLabel.Invalidate();
        }
Exemplo n.º 3
0
 private void ContinueSceneChange()
 {
     currentScene = GetNextScene();
     InitializeScene(currentScene);
     SceneChanged(currentScene, null);
     this.Enabled = true;
     fadeOutTimer.Start();
 }