コード例 #1
0
ファイル: Game.cs プロジェクト: planetmalone/Wumpus
        /******************************************************************************************
         * Constructors
         *****************************************************************************************/
        // No parameters
        public Game()
        {
            map = new Map();
            wumpus = new Wumpus();
            player = new Player();
            superbats = new Hazard[]{
                new Hazard("superbat"),
                new Hazard("superbat"),
            };
            pits = new Hazard[] {
                new Hazard("pit"),
                new Hazard("pit"),
            };

            // Initialize the game pieces
            initBoard();
        }
コード例 #2
0
ファイル: GameScreen.cs プロジェクト: cragmire/MVA
        public GameScreen(ContentManager content, Rectangle screenBounds)
        {
            _hudFont = content.Load<SpriteFont>("Segoe24");

            _wallNorthOpen = content.Load<Texture2D>("wall-north-open");
            _wallNorthSolid = content.Load<Texture2D>("wall-north-solid");
            _wallEastOpen = content.Load<Texture2D>("wall-east-open");
            _wallEastSolid = content.Load<Texture2D>("wall-east-solid");
            _wallSouthOpen = content.Load<Texture2D>("wall-south-open");
            _wallSouthSolid = content.Load<Texture2D>("wall-south-solid");
            _wallWestOpen = content.Load<Texture2D>("wall-west-open");
            _wallWestSolid = content.Load<Texture2D>("wall-west-solid");

            _groundTex = content.Load<Texture2D>("floor");

            _goopTex = content.Load<Texture2D>("alien/goop");
            _alienTex = content.Load<Texture2D>("alien/alien");

            _trapTex = content.Load<Texture2D>("trap");
            _trapWarnTex = content.Load<Texture2D>("ui/beep-beep");

            _healthTex = content.Load<Texture2D>("ui/health");

            _flamethrowerTex = content.Load<Texture2D>("flamethrower");
            _flamesTex = content.Load<Texture2D>("flames");

            _gameLossTex = content.Load<Texture2D>("ui/text_gameover");
            _gameWinTex = content.Load<Texture2D>("ui/text_alienterminated");

            _footstepsSound = content.Load<SoundEffect>("sounds/footsteps");
            _trapHurtSound = content.Load<SoundEffect>("sounds/trap_hurt");
            _trapNearSound = content.Load<SoundEffect>("sounds/trap_near").CreateInstance();
            _alienNearSound = content.Load<SoundEffect>("sounds/alien-near").CreateInstance();
            _deathStingSound = content.Load<SoundEffect>("sounds/death-sting");
            _playerDeathAlienSound = content.Load<SoundEffect>("sounds/player-death-alien");
            _famethrowerStingSound = content.Load<SoundEffect>("sounds/flamethrower-pickup");
            _famethrowerSound = content.Load<SoundEffect>("sounds/flamethrower");
            _shipAmbienceSound = content.Load<SoundEffect>("sounds/ship-ambience").CreateInstance();
            _alienDeathSound = content.Load<SoundEffect>("sounds/alien-death");

            {
                var buttonNorthTex = content.Load<Texture2D>("ui/button_north");
                var buttonEastTex = content.Load<Texture2D>("ui/button_east");
                var buttonSouthTex = content.Load<Texture2D>("ui/button_south");
                var buttonWestTex = content.Load<Texture2D>("ui/button_west");

                _buttonNorth = new Button(buttonNorthTex, screenBounds.Center.X - (buttonNorthTex.Width / 2), 0);
                _buttonEast = new Button(buttonEastTex, screenBounds.Center.X + (_wallNorthSolid.Width / 2) - buttonEastTex.Width, screenBounds.Center.Y - (buttonNorthTex.Height / 2));
                _buttonSouth = new Button(buttonSouthTex, screenBounds.Center.X - (buttonSouthTex.Width / 2), screenBounds.Bottom - buttonSouthTex.Height);
                _buttonWest = new Button(buttonWestTex, screenBounds.Center.X - (_wallNorthSolid.Width / 2), screenBounds.Center.Y - (buttonWestTex.Height / 2));
            }

            {
                var flameThrowerBtnTex = content.Load<Texture2D>("ui/flamethrower");
                _flameThrowerButton = new Button(flameThrowerBtnTex, screenBounds.Right - flameThrowerBtnTex.Width, screenBounds.Bottom - flameThrowerBtnTex.Height);

                var buttonNorthTex = content.Load<Texture2D>("ui/attack_north");
                var buttonEastTex = content.Load<Texture2D>("ui/attack_east");
                var buttonSouthTex = content.Load<Texture2D>("ui/attack_south");
                var buttonWestTex = content.Load<Texture2D>("ui/attack_west");

                _attackButtonNorth = new Button(buttonNorthTex, screenBounds.Center.X - (buttonNorthTex.Width / 2), 0);
                _attackButtonEast = new Button(buttonEastTex, screenBounds.Center.X + (_wallNorthSolid.Width / 2) - buttonEastTex.Width, screenBounds.Center.Y - (buttonNorthTex.Height / 2));
                _attackButtonSouth = new Button(buttonSouthTex, screenBounds.Center.X - (buttonSouthTex.Width / 2), screenBounds.Bottom - buttonSouthTex.Height);
                _attackButtonWest = new Button(buttonWestTex, screenBounds.Center.X - (_wallNorthSolid.Width / 2), screenBounds.Center.Y - (buttonWestTex.Height / 2));
            }

            // Setup the player.
            _player = new Player();

            // Setup the map.
            _map = new Map(Environment.TickCount);
            OnEnterRoom();
        }
コード例 #3
0
ファイル: WumpusGame.cs プロジェクト: Zopherus/Wumpus
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        /// 
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            Cave.InitializeMap();
            Map.InitializeMap();
            TriviaList.InitializeTriviaList();
            GameState = GameState.Menu;
            Player = new Player(new Rectangle(375, 180, Player.rectangleSize, Player.rectangleSize), 3, 0);
            base.Initialize();
        }