Beispiel #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                Gorgon.Initialize(true, false);

                VideoMode videoMode;
                bool fullScreen;

                using (Configuration configuration = new Configuration())
                {
                    configuration.FillResolutionList();
                    configuration.ShowDialog(this);
                    if (configuration.DialogResult != DialogResult.OK)
                    {
                        Close();
                        return;
                    }
                    videoMode = configuration.VideoMode;
                    fullScreen = configuration.FullScreen;
                }

                Gorgon.SetMode(this, videoMode.Width, videoMode.Height, BackBufferFormats.BufferRGB888, !fullScreen);

                Gorgon.Idle += Gorgon_Idle;

                //Gorgon.FrameStatsVisible = true;

                _input = Input.LoadInputPlugIn(Environment.CurrentDirectory + @"\GorgonInput.DLL", "Gorgon.RawInput");
                _input.Bind(this);

                _keyboard = _input.Keyboard;
                _keyboard.Enabled = true;
                _keyboard.Exclusive = true;
                _keyboard.KeyDown += KeyboardOnKeyDown;

                _gameMain = new GameMain();

                string reason;
                if (!_gameMain.Initialize(Gorgon.Screen.Width, Gorgon.Screen.Height, this, out reason))
                {
                    MessageBox.Show(string.Format("Error loading game resources, error message: {0}", reason));
                    Close();
                    return;
                }

                Gorgon.Go();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                Close();
            }
        }
Beispiel #2
0
        public bool Initialize(GameMain gameMain, out string reason)
        {
            _gameMain = gameMain;
            _backGroundStar = SpriteManager.GetSprite("BackgroundStar", _gameMain.Random);
            if (_backGroundStar == null)
            {
                reason = "Star sprite doesn't exist.";
                return false;
            }

            int numOfStars = (_gameMain.ScreenSize.X * _gameMain.ScreenSize.Y) / 500;

            _backGroundStars = new BackgroundStar[numOfStars];
            List<BackgroundStar> orderedBackgroundStars = new List<BackgroundStar>();
            for (int i = 0; i < numOfStars; i++)
            {
                Color color = Color.White;
                switch (_gameMain.Random.Next(6))
                {
                    case 0:
                        color = Color.OrangeRed;
                        break;
                    case 1:
                        color = Color.LightBlue;
                        break;
                    case 2:
                        color = Color.Violet;
                        break;
                    case 3:
                        color = Color.LightGreen;
                        break;
                    case 4:
                        color = Color.Yellow;
                        break;
                }
                BackgroundStar newStar = new BackgroundStar(gameMain.Random.Next(gameMain.ScreenSize.X), gameMain.Random.Next(gameMain.ScreenSize.Y), _gameMain.Random.Next(1, 20), color);
                orderedBackgroundStars.Add(newStar);
            }
            orderedBackgroundStars.Sort((a, b) => { return a.Layer.CompareTo(b.Layer); });
            _backGroundStars = orderedBackgroundStars.ToArray();

            reason = null;
            return true;
        }
Beispiel #3
0
 public PlayerManager(GameMain gameMain)
 {
     _gameMain = gameMain;
 }
Beispiel #4
0
 public ObjectManager(GameMain gameMain)
 {
     Bullets = new List<Bullet>();
     Explosions = new List<Explosion>();
     Shockwaves = new List<Shockwave>();
     _gameMain = gameMain;
     BulletSprite = SpriteManager.GetSprite("Bullet", _gameMain.Random);
     ShockwaveSprite = SpriteManager.GetSprite("Shockwave", _gameMain.Random);
 }
Beispiel #5
0
 public AsteroidManager(GameMain gameMain)
 {
     _gameMain = gameMain;
     Asteroids = new List<Asteroid>();
 }