Esempio n. 1
0
        public void CleanUp()
        {
            while (GameObjects.Count() > 0)
            {
                GameObjects.RemoveAt(0);
            }

            while (HUDItems.Count() > 0)
            {
                HUDItems.RemoveAt(0);
            }
        }
Esempio n. 2
0
        public override bool Init()
        {
            try
            {
                _gameTimer  = new Timer();
                ControlType = ControlType.Absolute;
                rand        = new Random();

                _bonusSoundUri  = new Uri("pack://application:,,,/" + AssemblyName + ";component/audio/bonus.wav");
                _buzzerSoundUri = new Uri("pack://application:,,,/" + AssemblyName + ";component/audio/buzzer.wav");

                AddRink();
                AddPuck();

                _scoreHUD = new HUDItem();
                _scoreHUD.DefaultValue       = 0;
                _scoreHUD.HorizontalPosition = HorizontalAlignment.Right;
                _scoreHUD.VerticalPosition   = VerticalAlignment.Top;
                _scoreHUD.ItemType           = HUDItemType.Numeric;
                _scoreHUD.Name  = "Score";
                _scoreHUD.Label = "Score:";

                _countdownHUD = new HUDItem();
                _countdownHUD.DefaultValue       = 3;
                _countdownHUD.Value              = 3;
                _countdownHUD.HorizontalPosition = HorizontalAlignment.Center;
                _countdownHUD.VerticalPosition   = VerticalAlignment.Center;
                _countdownHUD.ItemType           = HUDItemType.Numeric;
                _countdownHUD.Name = "Countdown";
                _countdownHUD.Size = 4;


                _gameTimeHUD = new HUDItem();
                _gameTimeHUD.HorizontalPosition = HorizontalAlignment.Center;
                _gameTimeHUD.VerticalPosition   = VerticalAlignment.Top;
                _gameTimeHUD.DefaultValue       = 30;
                _gameTimeHUD.Value    = 30;
                _gameTimeHUD.Visible  = false;
                _gameTimeHUD.ItemType = HUDItemType.Numeric;
                _gameTimeHUD.Name     = "TimeRemaining";
                _gameTimeHUD.Size     = 2;

                HUDItems.Add(_gameTimeHUD);
                HUDItems.Add(_countdownHUD);
                HUDItems.Add(_scoreHUD);

                return(true);
            }
            catch (Exception)
            {
                if (_gameTimeHUD != null)
                {
                    _gameTimeHUD.Dispose();
                }
                if (_countdownHUD != null)
                {
                    _countdownHUD.Dispose();
                }
                if (_gameTimer != null)
                {
                    _gameTimer.Dispose();
                }
                if (_scoreHUD != null)
                {
                    _scoreHUD.Dispose();
                }

                throw;
            }
        }