Example #1
0
        public EditorScreen(ScreenManager manager)
            : base(manager, "Editor")
        {
            // Create crosshair
            _Crosshair = new Crosshair(this);

            Application.AppReference.DynamicLighting = false;
            Tile.TileWidth  = 8.0f;
            Tile.TileHeight = 8.0f;

            // Setup tiles
            _Tiles = new Tile[TileRows, TileCols];
            for (row = 0; row < TileRows; row++)
            {
                for (col = 0; col < TileCols; col++)
                {
                    _Tiles[row, col] = Tile.TileGen[0](this, row, col, 0);
                }
            }

            // Setup screen behavior
            Depth                = 0.7f;
            _BackBehaviour       = ActionOnBack.ExitApplication;
            _FadeInTime          = 0.0f;
            _FadeOutTime         = 0.0f;
            _Message             = "Left Click/Right Click, Press (F) to Close Browser";
            _MessageFont         = Application.AppReference.Content.Load <SpriteFont>("Font");
            _MessageColour       = Color.White;
            _BackgroundDrawingOn = true;

            LoadPort = new LoadPort(this, new Vector2(), new Vector2(1050, 750), 100f);

            _ViewPort.TargetLocation = new Vector2(TileCols * Tile.TileWidth, TileRows * Tile.TileHeight);
        }
Example #2
0
        public WorldScreen(ScreenManager manager, String worldMap)
            : base(manager, "World")
        {
            // Load world
            _WorldMap = worldMap;
            FileStream   fs  = File.OpenRead(_WorldMap);
            BinaryReader bin = new BinaryReader(fs);

            TileRows        = bin.ReadInt32();
            TileCols        = bin.ReadInt32();
            Tile.TileWidth  = bin.ReadSingle();
            Tile.TileHeight = bin.ReadSingle();

            for (int row = 0; row < TileRows; row++)
            {
                for (int col = 0; col < TileCols; col++)
                {
                    int index = bin.ReadInt32();
                    Tile.TileGen[index](this, row, col, index);
                }
            }

            bin.Close();
            fs.Close();

            // Create player
            _Player = new Marine(this);
            _Player.Geometry.Position.X = TileCols * Tile.TileWidth / 2;
            _Player.Geometry.Position.Y = TileRows * Tile.TileHeight / 2;

            // Create crosshair
            _Crosshair = new Crosshair(this);

            // Create aliens
            for (int i = 0; i < NumAliens; i++)
            {
                float dist = (float)Application.AppReference.Random.NextDouble() * 300 + 200f;
                Alien.CreateNearbyAlien(this, _Player, dist, _Player);
            }


            // Setup screen behavior
            Depth                = 0.9f;
            _BackBehaviour       = ActionOnBack.ExitApplication;
            _FadeInTime          = 0.0f;
            _FadeOutTime         = 0.0f;
            _Message             = _HelpMessage;
            _MessageFont         = Application.AppReference.Content.Load <SpriteFont>("Font");
            _MessageColour       = Color.White;
            _BackgroundDrawingOn = true;
            //Application.AppReference.DynamicLighting = false;

            // Create loadport
            LoadPort = new LoadPort(this, new Vector2(), new Vector2(1050, 750), 100f);

            //music time
            Random random = new Random();
            int    song   = random.Next(0, 2);

            MediaPlayer.Play(Application.AppReference.Content.Load <Song>("Sounds\\03 - Teardrop"));
            //if (song == 1)
            //    MediaPlayer.Play(Application.AppReference.Content.Load<Song>("Sounds\\leanonme"));
            StartBackgroundThread();
        }