/// <summary> /// Find the center of the first room that we created and place the Player there /// </summary> private void PlacePlayer() { Player player = Game.Player; if (player == null) { player = new Player(); } player.X = _map.Rooms[0].Center.X; player.Y = _map.Rooms[0].Center.Y; _map.AddPlayer(player); }
private void PlacePlayer() { Player player = Player.GetInstance(); player.X = _map.Rooms[0].Center.X; player.Y = _map.Rooms[0].Center.Y; _map.AddPlayer(player); }
private void PlacePlayer() { Player player = ActorGenerator.CreatePlayer(); player.X = _map.Rooms[0].Center.X; player.Y = _map.Rooms[0].Center.Y; _map.AddPlayer(player); }
void PlacePlayer() { Player player = ActorGenerator.CreatePlayer(); player.X = _map.Rooms[0].Center.X; player.Y = _map.Rooms[0].Center.Y; player.go.transform.position = new Vector2(player.X, player.Y); _map.AddPlayer(player); }
// Placing player on the level private void PlacePlayer() { Player player = Game.Player; if (player == null) { player = new Player(); } player.X = map.Rooms.First()[map.Rooms.First().Count / 2].X; player.Y = map.Rooms.First()[map.Rooms.First().Count / 2].Y; map.AddPlayer(player); }
/// <summary> /// Generate a new map that places rooms randomly. /// </summary> /// <returns></returns> //public DungeonMap CreateMap() //{ // map.Initialize(width, height); // Set the properties of all cells to false // for (int r = 0; r < maxRooms; r++) // Try to place as many rooms as the specified maxRooms // { // int roomWidth = Game.Random.Next(roomMinSize, roomMaxSize); // Determine the size and position of the room randomly // int roomHeight = Game.Random.Next(roomMinSize, roomMaxSize); // int roomXPosition = Game.Random.Next(0, width - roomWidth - 1); // int roomYPosition = Game.Random.Next(0, height - roomHeight - 1); // var newRoom = new Rectangle(roomXPosition, roomYPosition, roomWidth, roomHeight);// All of our rooms can be represented as Rectangles // bool newRoomIntersects = map.Rooms.Any(room => newRoom.Intersects(room)); // Check to see if the room rectangle intersects with any other rooms // if (!newRoomIntersects) // As long as it doesn't intersect add it to the list of rooms // { // map.Rooms.Add(newRoom); // } // } // for (int r = 1; r < map.Rooms.Count; r++) // Iterate through each room that was generated // { // Don't do anything with the first room, so start at r = 1 instead of r = 0 // int previousRoomCenterX = map.Rooms[r - 1].Center.X; // For all remaing rooms get the center of the room and the previous room // int previousRoomCenterY = map.Rooms[r - 1].Center.Y; // int currentRoomCenterX = map.Rooms[r].Center.X; // int currentRoomCenterY = map.Rooms[r].Center.Y; // if (Game.Random.Next(1, 2) == 1) // Give a 50/50 chance of which 'L' shaped connecting hallway to tunnel out // { // CreateHorizontalTunnel(previousRoomCenterX, currentRoomCenterX, previousRoomCenterY); // CreateVerticalTunnel(previousRoomCenterY, currentRoomCenterY, currentRoomCenterX); // } // else // { // CreateVerticalTunnel(previousRoomCenterY, currentRoomCenterY, previousRoomCenterX); // CreateHorizontalTunnel(previousRoomCenterX, currentRoomCenterX, currentRoomCenterY); // } // } // foreach (Rectangle room in map.Rooms) // Iterate through each room that we wanted placed call CreateRoom to make it // { // CreateRoom(room); // CreateDoors(room); // } // CreateStairs(); // PlacePlayer(game); // PlaceMonsters(); // return map; //} /// <summary> /// Find the center of the first room that we created and place the Player there. /// </summary> private void PlacePlayer(Game game) { Player player = game.Player; if (player == null) { player = new Player(game); player.Name = GameData.Data.PlayerName; if (GameData.Data.CurrentLevel == 0 && GameData.Data.LastLevel <= GameData.Data.CurrentLevel) { player.Health = player.Health + (int)(GameData.Data.Difficulty / 2); player.Attack = player.Attack + (int)(GameData.Data.Difficulty / 2); } else { player.Health = GameData.Data.PlayerHealth; player.MaxHealth = GameData.Data.PlayerMaxHealth; player.Attack = GameData.Data.PlayerAttack; player.Moves = GameData.Data.PlayerMoves; player.ItemsFound = GameData.Data.ItemsFound; } } if (GameData.Data.LastLevel > GameData.Data.CurrentLevel) { Rectangle stairArea = new Rectangle(map.StairsDown.X - 2, map.StairsDown.Y - 2, 5, 5); map.SetIsWalkable(map.StairsDown.X, map.StairsDown.Y, false); Point p = map.GetRandomWalkableLocationInRoom(stairArea); map.SetIsWalkable(map.StairsDown.X, map.StairsDown.Y, true); player.X = p.X; player.Y = p.Y; } else { Rectangle stairArea = new Rectangle(map.StairsUp.X - 2, map.StairsUp.Y - 2, 5, 5); map.SetIsWalkable(map.StairsUp.X, map.StairsUp.Y, false); Point p = map.GetRandomWalkableLocationInRoom(stairArea); map.SetIsWalkable(map.StairsUp.X, map.StairsUp.Y, true); player.X = p.X; player.Y = p.Y; } playerXsegment = player.X / MapSegment.SegmentCellWidthHeight; playerYsegment = player.Y / MapSegment.SegmentCellWidthHeight; map.AddPlayer(player); }
private void PlacePlayer() { Player player = MainScreen.GameController.Player; if (player == null) { player = new Player(); } player.X = _map.Rooms[0].Center.X; player.Y = _map.Rooms[0].Center.Y; _map.AddPlayer(player); }
//This method places player on a valid tile, which is on the first room created private void PlacePlayer() { //Add a method to not place a player into a room with monsters Player player = Game.Player; if (player == null) { player = new Player(); } player.X = _map.Rooms[0].Center.X; player.Y = _map.Rooms[0].Center.Y; _map.AddPlayer(player); }
//Place the player inside the first room generated private void PlacePlayer() { //Stores the game's player as a player variable Player player = Game.Player; //If the player doesn't exist, create one if (player == null) { player = new Player(); } //Place the player inside the center of the first // room generated player.X = room.Rooms[0].Center.X; player.Y = room.Rooms[0].Center.Y; //Add the new player to the map room.AddPlayer(player); }