Example #1
0
 public void SetMap(Map newMap)
 {
     map = newMap;
 }
Example #2
0
 public Map GetMap(Map map)
 {
     return map;
 }
Example #3
0
 /// <summary>
 /// Initializes the entity on the map
 /// </summary>
 public void SetMap(Map map)
 {
     ownerMap = map;
 }
Example #4
0
        // Runs when the game state starts for the first time
        public override void Start()
        {
            player = new Player(cam);

            map = new Map(1, MapType.dungeon, this);
            raycaster.SetMap(map);

            cam.SetPosition(map.GetStairUpLoc());
            player.CreateStartingItems();

            AddMessage("You step down into the musty air of the dungeon.");
        }
Example #5
0
        // Loads the next map in the dungeon
        public void GoDownLevel()
        {
            // Unload the old map
            map.entities.Clear();

            // Load a new map
            map = new Map(map.level + 1, MapType.dungeon, this);

            // Let everything know about the new map
            cam.SetPosition(map.GetStairUpLoc());
            raycaster.SetMap(map);
        }
Example #6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            background = new RenderTarget2D(GraphicsDevice, 320, 240, 1, SurfaceFormat.Color);

            playstate.LoadTexture(@"Walls\brick-grey");
            playstate.LoadTexture(@"Walls\brick-mossy");
            playstate.LoadTexture(@"Walls\brick-bloody");
            playstate.LoadTexture(@"Walls\brick-torch");
            playstate.LoadTexture(@"Walls\door");
            playstate.LoadTexture(@"Walls\door-grate");
            playstate.LoadTexture(@"Deco\column");
            playstate.LoadTexture(@"Actors\goblin");
            playstate.LoadTexture(@"Actors\kobold");
            playstate.LoadTexture(@"Actors\rat");

            playstate.LoadFont(@"Gebrider");

            //map = new Map(1, MapType.dungeon);
            map = new Map(1, MapType.dungeon);
            playstate.SetMap(map);
            raycaster.SetMap(map);

            cam.SetPosition(map.GetStairUpLoc());

            base.LoadContent();
        }
Example #7
0
        public MapGenerator(MapType Type, Map Map)
        {
            // List of map connections available
            available_conns = new List<Connector>();
            rnd = new Random();

            type = Type;
            map = Map;

            width = 50;
            height = 50;

            map.mapData = new int[width, height];
            map.Width = width;
            map.Height = height;

            map.entities = new List<Entity>();

            SetTypeTextures();
            monsters = map.Gamestate.MonsterData.Where(i => i.level <= map.level).ToList();
            weapons = map.Gamestate.WeaponData.Where(i => i.level <= map.level).ToList();
            armor = map.Gamestate.ArmorData.Where(i => i.level <= map.level).ToList();

            // Build the total chance of all weapons
            weapon_total_chance = 0;
            foreach (WeaponData d in weapons) weapon_total_chance += d.chance;

            // Build the total chance of all armor
            armor_total_chance = 0;
            foreach (ArmorData d in armor) armor_total_chance += d.chance;

            // Fills map
            FillRandRect(0, 0, width - 1, height - 1, 1, 3);

            // Randomly place the first connector
            Connector connection = new Connector();
            connection.posX = width / 2;
            connection.posY = height / 2;
            connection.dir = GetRandomDirection();
            connection.noDoor = true;

            available_conns.Add(connection);

            // Generate some rooms
            int numGenerated = 0;
            int tries = 0;
            while (numGenerated < 16 && tries < 30 && available_conns.Count > 0)
            {
                // Attempt to make a room with the first connector
                Connector tryThis = available_conns.First();
                bool didGenerate = MakeRoom(tryThis);
                if (didGenerate)
                {
                    // This connection generated fine, remove the connector
                    numGenerated++;
                    available_conns.Remove(tryThis);
                }
                else
                {
                    // Check to see if we've tried too many times already
                    if (tries++ > 2)
                    {
                        tries = 0;
                        available_conns.Remove(tryThis);
                    }
                }
            }

            PlaceStairsUp();
            PlaceStairsDown();
        }