Пример #1
0
        public void Initialize(Rectangle bounds)
        {
            owner.Bounds      = bounds;
            this.GameState    = GameStates.Config;
            this.windowBounds = bounds;
            CreateSurfaces();

            sunLocation.X = windowBounds.Left + windowBounds.Width / 2;
            sunLocation.Y = windowBounds.Top + windowBounds.Height / 2;

            ship = new Ship(this);
            Random random = new Random((int)DateTime.Now.Ticks);

            ship.ScreenBounds = bounds;
            ship.SetRandomPosition(true, sunLocation);

            if ((null != localPlayer.Name) && (localPlayer.Name.Length > 0))
            {
                ship.HostName = localPlayer.Name.ToUpper();
            }
            else
            {
                ship.HostName = System.Environment.MachineName.ToUpper();
            }

            stars = new Stars(bounds, Constants.NumStars);
            sun   = new Sun(sunLocation, Constants.SunSize);

            gameSettings.ControlsEnabled = true;
            if (netPeer.InSession)
            {
                if (netPeer.IsHost)
                {
                    gameSettings.ControlsEnabled = true;
                    netPeer.SendGameState(GameStates.Running);
                }
                else
                {
                    gameSettings.ControlsEnabled = false;
                }
            }
            gameState = GameStates.Running;
        }
        public void Initialize(Rectangle bounds)
        {
            owner.Bounds = bounds;
            this.GameState = GameStates.Config;
            this.windowBounds = bounds;
            CreateSurfaces();

            sunLocation.X = windowBounds.Left + windowBounds.Width / 2;
            sunLocation.Y = windowBounds.Top + windowBounds.Height / 2;

            ship = new Ship(this);
            Random random = new Random((int) DateTime.Now.Ticks);
            ship.ScreenBounds = bounds;
            ship.SetRandomPosition(true, sunLocation);

            if ((null != localPlayer.Name) && (localPlayer.Name.Length > 0))
                ship.HostName = localPlayer.Name.ToUpper();
            else
                ship.HostName = System.Environment.MachineName.ToUpper();

            stars = new Stars(bounds, Constants.NumStars);
            sun = new Sun(sunLocation, Constants.SunSize);

            gameSettings.ControlsEnabled = true;
            if (netPeer.InSession) {
                if (netPeer.IsHost) {
                    gameSettings.ControlsEnabled = true;
                    netPeer.SendGameState(GameStates.Running);
                }
                else {
                    gameSettings.ControlsEnabled = false;
                }
            }
            gameState = GameStates.Running;
        }