public async Task <IActionResult> Edit(int id, Hallway hallway, IFormCollection collection) { var warehouseId = int.Parse(collection["Warehouse"].ToString()); var warehouse = _context.Warehouses.FirstOrDefault(w => w.Id == warehouseId); if (id != hallway.Id) { return(NotFound()); } if (ModelState.IsValid) { try { hallway.Warehouse = warehouse; hallway.Modified = DateTime.Now; hallway.ModifiedBy = null; //Comms:Modificar a que sea variable _context.Update(hallway); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HallwayExists(hallway.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(hallway)); }
public async Task <IActionResult> Create(Hallway hallway, IFormCollection collection) { var warehouseId = int.Parse(collection["Warehouse"].ToString()); var warehouse = _context.Warehouses.FirstOrDefault(w => w.Id == warehouseId); hallway.Warehouse = warehouse; if (HallwayExists(hallway.Description, hallway.Warehouse)) { ModelState.AddModelError("Error", "Ya existe un pasillo con esa descripción."); } if (ModelState.IsValid) { hallway.Active = true; hallway.Created = DateTime.Now; hallway.CreatedBy = UserLogged; hallway.Modified = DateTime.Now; hallway.ModifiedBy = UserLogged; _context.Add(hallway); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } var listWarehouse = _context.Warehouses.Where(c => c.Active == true).ToList(); ViewBag.Warehouses = new SelectList(listWarehouse, "Id", "Description"); return(View(hallway)); }
public void LoadRoom(DungeonRoom room, HallSector fromSector, bool savedBattle = false) { raidRoom.LoadRoom(room, savedBattle); LastHallway = fromSector == null ? null : fromSector.Hallway; RaidSceneManager.MapPanel.OnRoomEnter(room, LastHallway); }
/*Cette fonction permet de selectionner aleatoirement un hallway parmis les 4 de la salle*/ public Hallway selectRandomLinkableHallway() { /*On creer un list d'hallways avec * 0 : left * 1 : right * 2 : down * 3 : up */ Hallway selectedHallway = new Hallway(); List <Hallway> listHallways = new List <Hallway>(); listHallways.Add(listHorizontalHallways[0]); listHallways.Add(listHorizontalHallways[1]); listHallways.Add(listVerticalHallways[0]); listHallways.Add(listVerticalHallways[1]); bool hallwayFound = false; int hallwayIndex = 0; while (!hallwayFound && listHallways.Count > 0) { hallwayIndex = Random.Range(0, listHallways.Count); selectedHallway = listHallways[hallwayIndex]; listHallways.RemoveAt(hallwayIndex); if (selectedHallway.isReal() && !selectedHallway.HallwayIsLinked()) { /*Debug.Log("Hallway choisi est : "); * selectedHallway.printHallway();*/ hallwayFound = true; } //Debug.Log("listHallwaus count : " + listHallways.Count); } return(selectedHallway); }
private bool RemoveHallway(Room room, Direction direction) { Hallway removableHallway = room.GetHallway(direction); if (removableHallway != null) { Room connectedRoom = removableHallway.GetConnectedRoom(room); room.SetHallway(direction, null); switch (direction) { case Direction.North: connectedRoom.SetHallway(Direction.South, null); break; case Direction.East: connectedRoom.SetHallway(Direction.West, null); break; case Direction.South: connectedRoom.SetHallway(Direction.North, null); break; case Direction.West: connectedRoom.SetHallway(Direction.East, null); break; } return(true); } else { return(false); } }
private static Position createHallwayEntrance(Room previousRoom, Hallway previousHall, int tries, GameMap map, Random random) { Position entrance; if (tries < MAX_ATEMPTS_FOR_EXIT || previousHall == null) { entrance = getPassage(previousRoom.getWallPositions(), map, random); if (previousRoom.getExit() != null) { switchWallFloor((Position)previousRoom.getExit()); } previousRoom.setExit(entrance); } else { entrance = getPassage(previousHall.getWallPositions(), map, random); if (previousHall.getIntersection() != null) { switchWallFloor((Position)previousHall.getIntersection()); } previousHall.setIntersection(entrance); } switchWallFloor(entrance); return(entrance); }
private Room GetNextHall(Room startingRoom) { while (true) { var adjacentRooms = startingRoom.AdjacentRooms; var directionalId = Random.Next(0, 4); var newRoom = adjacentRooms[directionalId]; if (newRoom is null) { var newCoords = GetCoords(startingRoom, directionalId); newRoom = new Hallway { Coords = newCoords }; if (OccupiedCoords.Contains(newCoords)) { if (GetOccupiedSideCount(startingRoom) > 3) { var neighborCell = Rooms.FirstOrDefault(r => r.Coords.Equals(GetCoords(startingRoom, directionalId))); ConnectRoom(neighborCell, startingRoom, directionalId); return(newRoom); } continue; } ConnectRoom(startingRoom, newRoom, directionalId); return(newRoom); } } }
void BoardSetUp(Vector3 ofse, Hallway left, Hallway right, Hallway up, Hallway down) { boardHolder = new GameObject("Board").transform; /*On veut dessiner une salle en prenant en compte les bords situes aux -1 et nombres de lignes ou collones +1*/ /*On itere sur toutes les collones*/ for (int x = -1; x < columns + 1; x++) { /*Puis sur toutes les lignes */ for (int y = -1; y < rows + 1; y++) { /*On creer un objet a instancier que l'on initialise en tant que sol*/ GameObject toInstantiate = floorTiles[Random.Range(0, floorTiles.Length - 1)]; if (x == -1 || x == columns || y == -1 || y == rows) { Vector3 position = new Vector3(x, y, 0); /*Si on est situe sur un des bord qui ne soit pas inclus dans les couloirs, on intancie alors un mur externe*/ if (!left.VectorIsInHallWay(position) && !right.VectorIsInHallWay(position) && !up.VectorIsInHallWay(position) && !down.VectorIsInHallWay(position)) { /*On verifie si il s'agit de mur horizontaux ou verticaux*/ if (x == -1 || x == columns) { toInstantiate = verticalOuterWallTiles[Random.Range(0, verticalOuterWallTiles.Length - 1)]; } else { toInstantiate = horizontalOuterWallTiles[Random.Range(0, horizontalOuterWallTiles.Length - 1)]; } } } GameObject instance = Instantiate(toInstantiate, new Vector3(x + ofse.x, y + ofse.y, 0f), Quaternion.identity) as GameObject; instance.transform.SetParent(boardHolder); } } }
//Creates the hallway GO using the proper elemental floor tiles //Dir is the direction the hallway is in relation to the room you're appending it to //roomPosition is the pos of the room you're appending to void CreateHallway(Direction dir, GameObject room) { GameObject hallway = Instantiate(GameManager.S.hallway); GameManager.S.AddObject(hallway); Vector3 roomPosition = room.transform.position; hallway.transform.position = GetHallwayPosition(dir, roomPosition); //add hallway script Hallway hw = hallway.AddComponent <Hallway>(); hw.dir = dir; hw.hallCover = Instantiate(GameManager.S.hallwayBlocker); hw.hallCover.transform.position = hallway.transform.position; hw.hallCover.SetActive(false); GameManager.S.AddObject(hw.hallCover); if (dir == Direction.Right) { hallway.transform.Rotate(new Vector3(0, 0, -90)); hw.hallCover.transform.Rotate(new Vector3(0, 0, -90)); } }
public static void createRoomsAndHallways(List <Section> sections, GameMap map, Random random) { int id = START_ID_NUM; Room previousRoom = null; Hallway previousHall = null; foreach (Section current in sections) { map.addRoom(String.Format(ROOM_ID_FORMAT_STRING, id), RoomFactory.getRoom(current, String.Format(ROOM_ID_FORMAT_STRING, id++), random, MapFactory.wallPositions, MapFactory.floorPositions)); } id = START_ID_NUM; Hallway currentHall = null; foreach (Room currentRoom in map.getRooms()) { if (previousRoom == null) { previousRoom = currentRoom; continue; } previousHall = currentHall = HallwayFactory.getHallway(String.Format(HALLWAY_ID_FORMAT_STRING, id++), previousRoom, previousHall, currentRoom, map, random, MapFactory.wallPositions, MapFactory.floorPositions); map.addHallway(currentHall.getID(), currentHall); previousRoom = currentRoom; } }
public void LoadHallway(Hallway hallway, Direction direction, DungeonRoom fromRoom, bool loadBattleSave = false) { Hallway = hallway; if (direction == Direction.Bot || direction == Direction.Left) { StartingRoom = hallway.RoomA; TargetRoom = hallway.RoomB; } else { StartingRoom = hallway.RoomB; TargetRoom = hallway.RoomA; } raidHallway.LoadHallway(hallway, direction, loadBattleSave); UpdateEnviroment(); if (fromRoom != null) { if (!(fromRoom.Type == AreaType.BattleTresure || fromRoom.Type == AreaType.BattleCurio || fromRoom.Type == AreaType.Curio)) { fromRoom.Knowledge = Knowledge.Completed; } } RaidSceneManager.MapPanel.OnHallwayEnter(Hallway, StartingRoom, TargetRoom); }
public static Hallway getHallway(string id, Room previousRoom, Hallway previousHall, Room nextRoom, GameMap map, Random random, List <Position> wallPositions, List <Position> floorPositions) { int triesToCreateExit = 0; List <Position> path = new List <Position>(); Position entrance = new Position(); //Αρχικοποιήση πρως ικανοποίηση του compiler Position exit = new Position(); //Το ίδιο while (path.Count == 0) { entrance = createHallwayEntrance(previousRoom, previousHall, triesToCreateExit++, map, random); exit = getExit(nextRoom, map, random); WalkableTile[,] walkableMap = initializeWalkable(map); path = AStar.findPath(entrance, exit, walkableMap); } List <Position> hallWallPositions = createWallPositions(path, entrance, exit, map); foreach (Position wallPosition in hallWallPositions) { if (!wallPositions.Contains(wallPosition)) { wallPositions.Add(wallPosition); } } floorPositions.AddRange(path); return(new Hallway(id, path, hallWallPositions)); }
public void setHallway(Hallway hallway) { /*axe=0 correspond a l'axe vertical*/ if (hallway.getAxe() == 0) { /*direction=0 correspond a left*/ if (hallway.getDirection() == 0) { listHorizontalHallways[0] = hallway; } /*direction=1 correspond a right*/ else { listHorizontalHallways[1] = hallway; } } /*axe=1 correspond a l'axe vertical*/ else { /*direction=0 correspond a down*/ if (hallway.getDirection() == 0) { listVerticalHallways[0] = hallway; } /*direction=1 correspond a up*/ else { listVerticalHallways[1] = hallway; } } }
public void SetHall(Hallway hallway) { for (int i = 1; i < hallway.Halls.Count - 1; i++) { RaidMapHallSectorSlots[i - 1].SetSector(hallway.Halls[i]); } }
Hallway CreateHallway(Room newRoom, Direction heading) { Hallway newHallway = new Hallway(newRoom, heading); hallways.Enqueue(newHallway); return(newHallway); }
public HallSector(string id, int gridX, int gridY, Hallway parentHallway, Knowledge knowledge, AreaType areaType, string textureId) : this(id, gridX, gridY, parentHallway) { Knowledge = knowledge; Type = areaType; TextureId = textureId; }
private IEnumerable <Move> GetAvailableMoves() { for (RoomId roomId = 0; roomId != RoomId.Count; roomId++) { Room room = Rooms[(int)roomId]; if (room.CanMoveOut) { Amphipod occupant = room.Peek(); RoomId destinationRoomId = occupant.Home; Room destinationRoom = Rooms[(int)destinationRoomId]; if (destinationRoom.CanMoveIn && Hallway.IsRoomReachable(roomId, destinationRoomId, out int hallDistance)) { yield return(new Move() { FromRoom = roomId, ToRoom = destinationRoomId, Cost = (room.MoveOutDistance + destinationRoom.MoveInDistance + hallDistance) * occupant.MoveCost, }); } else { foreach ((HallId hallId, int distance) in Hallway.HallsAvailableFrom(roomId)) { yield return(new Move() { FromRoom = roomId, ToHall = hallId, Cost = (room.MoveOutDistance + distance) * occupant.MoveCost, }); } } } } for (HallId hallId = 0; hallId < HallId.Count; hallId++) { Amphipod?occupantNullable = Hallway.Positions[(int)hallId]; if (occupantNullable.HasValue) { Amphipod occupant = occupantNullable.Value; RoomId roomId = occupant.Home; Room room = Rooms[(int)roomId]; if (room.CanMoveIn && Hallway.IsRoomReachable(hallId, roomId, out int hallDistance)) { yield return(new Move() { FromHall = hallId, ToRoom = roomId, Cost = (hallDistance + room.MoveInDistance) * occupant.MoveCost, }); } } } }
public void HideAvailableRooms(DungeonRoom room) { foreach (var door in room.Doors) { Hallway hallway = Dungeon.Hallways[door.TargetArea]; RoomSlots[hallway.OppositeRoom(room).Id].SetMovable(false); } }
public void ItCanAddHallways() { var hallway = new Hallway(); _dungeon.AddHallway(hallway); Assert.Equal(hallway, _dungeon.Hallways.First()); }
public HallSector(string id, int gridX, int gridY, Hallway parentHallway) : this() { Id = id; Hallway = parentHallway; GridX = gridX; GridY = gridY; }
public void SetupScene(int level, Hallway left, Hallway right, Hallway up, Hallway down) { BoardSetUp(offset, left, right, up, down); InitializeList(offset); layoutObjectAtRandom(wallTiles, wallCount.minimum, wallCount.maximum); int ennemyCount = Random.Range(level * 3, level * 5); layoutObjectAtRandom(ennemyTiles, ennemyCount, ennemyCount); }
public void OnRoomEnter(DungeonRoom room, Hallway fromHallway) { UpdateArea(room); SetCurrentIndicator(room); if (fromHallway != null) { UpdateArea(fromHallway.OppositeRoom(room)); } }
internal Puzzle(params string[] rooms) { Hallway = new Hallway(); Rooms = new Room[(int)RoomId.Count]; for (int i = 0; i < rooms.Length; i++) { Rooms[i] = new Room(rooms[i], (RoomId)i); } }
static Dictionary <string, Hallway> GetFinalHallways(Dungeon dungeon, List <GenHall> halls, DungeonGenerationData genData) { Dictionary <string, Hallway> finalHallways = new Dictionary <string, Hallway>(); foreach (var genHall in halls) { Hallway hallway = new Hallway(genHall.Id); hallway.RoomA = dungeon.Rooms[genHall.roomA.Id]; hallway.RoomB = dungeon.Rooms[genHall.roomB.Id]; int hallIncrementX = 0, hallIncrementY = 0; int hallGridX = hallway.RoomA.GridX, hallGridY = hallway.RoomA.GridY; if (hallway.RoomA.GridX < hallway.RoomB.GridX) { hallIncrementX = 1; } else if (hallway.RoomA.GridX > hallway.RoomB.GridX) { hallIncrementX = -1; } if (hallway.RoomA.GridY < hallway.RoomB.GridY) { hallIncrementY = 1; } else if (hallway.RoomA.GridY > hallway.RoomB.GridY) { hallIncrementY = -1; } hallGridX += hallIncrementX; hallGridY += hallIncrementY; hallway.Halls.Add(new HallSector(hallway.Id + "_0", hallGridX, hallGridY, hallway, new Door(hallway.Id, genHall.roomA.Id, Direction.Left))); for (int i = 1; i <= genData.Spacing; i++) { hallGridX += hallIncrementX; hallGridY += hallIncrementY; hallway.Halls.Add(new HallSector(hallway.Id + "_" + i.ToString(), hallGridX, hallGridY, hallway)); } hallGridX += hallIncrementX; hallGridY += hallIncrementY; hallway.Halls.Add(new HallSector(hallway.Id + "_" + (genData.Spacing + 1).ToString(), hallGridX, hallGridY, hallway, new Door(hallway.Id, genHall.roomB.Id, Direction.Right))); finalHallways.Add(hallway.Id, hallway); } return(finalHallways); }
public HallSector(string id, int gridX, int gridY, Hallway parentHallway, Door door) : this() { Id = id; Hallway = parentHallway; GridX = gridX; GridY = gridY; Prop = door; Type = AreaType.Door; }
public Hallway(Vector3 vecLocal1, Vector3 veclocal2, Vector3 vecWorld1, Vector3 vecWorld2, int ax, int dir, Hallway hallwayToLink) { firstLocalSquare = vecLocal1; lastLocalSquare = veclocal2; firstWorldSquare = vecWorld1; lastWorldSquare = vecWorld2; axe = ax; direction = dir; real = true; linked = true; drawable = true; linkedHallway = hallwayToLink; }
public void MinimumSpanningTree(Hallway hallway, Room room, List <Hallway> hallways, List <Room> rooms) { Room otherRoom; if (hallway != null && !hallway.isCollapsed) { otherRoom = room.Equals(hallway.room1) ? hallway.room2 : hallway.room1; if (!rooms.Exists(r => r.Equals(otherRoom))) { hallways.Add(hallway); MinimumSpanningTree(otherRoom, hallways, rooms); } } }
public HallSector(string id, int gridX, int gridY, Hallway parentHallway, Door door) { Id = id; Hallway = parentHallway; GridX = gridX; GridY = gridY; Knowledge = Knowledge.Hidden; Type = AreaType.Door; Prop = door; TextureId = "0"; MashId = 0; }
/*Cette fonction permet de dessiner le portail de fin * menant d'un niveau a un autre*/ public void drawEndPortal(Hallway endPortalHallway) { for (int x = (int)endPortalHallway.getFirstWorldSquare().x; x <= (int)endPortalHallway.getLastWorldSquare().x; x++) { for (int y = (int)endPortalHallway.getFirstWorldSquare().y; y <= (int)endPortalHallway.getLastWorldSquare().y; y++) { if (x == (int)endPortalHallway.getFirstWorldSquare().x) { gridPositions.Add(new Vector3(x, y, 0)); GameObject toInstantiate = endPortal[Random.Range(0, endPortal.Length - 1)]; GameObject instance = Instantiate(toInstantiate, new Vector3(x, y, 0f), Quaternion.identity) as GameObject; } } } }
/*Cette fonction permet pour une salle donner de trouver l'endroit ou se trouvera le portail de fin de niveau*/ public Hallway findHallwayEndPortal() { Hallway endPortal = new Hallway(); int hallwaySize = Random.Range(1, 1); int position = Random.Range(0, (rows - hallwaySize)); Vector3 firstLocalSquare = new Vector3(); Vector3 lastLocalSquare = new Vector3(); /*On peut dessiner un portail de fin sur un hallways si il ne sont pas reel ou si ils sont reel mais relie a aucun autre hallway*/ if ((!listVerticalHallways[0].isReal()) || (listVerticalHallways[0].isReal() && !listVerticalHallways[0].HallwayIsLinked())) { position = Random.Range(0, (columns - hallwaySize)); firstLocalSquare = new Vector3(position, -1, 0); lastLocalSquare = new Vector3(position + hallwaySize, -1, 0); listVerticalHallways[0] = new Hallway(firstLocalSquare, lastLocalSquare, firstLocalSquare + offset, lastLocalSquare + offset, 1, 0); listVerticalHallways[0].setEndPortal(); endPortal = listVerticalHallways[0]; } else if ((!listVerticalHallways[1].isReal()) || (listVerticalHallways[1].isReal() && !listVerticalHallways[1].HallwayIsLinked())) { position = Random.Range(0, (columns - hallwaySize)); firstLocalSquare = new Vector3(position, rows, 0); lastLocalSquare = new Vector3(position + hallwaySize, rows, 0); listVerticalHallways[1] = new Hallway(firstLocalSquare, lastLocalSquare, firstLocalSquare + offset, lastLocalSquare + offset, 1, 1); listVerticalHallways[1].setEndPortal(); endPortal = listVerticalHallways[1]; } else if ((!listHorizontalHallways[0].isReal()) || (listHorizontalHallways[0].isReal() && !listHorizontalHallways[0].HallwayIsLinked())) { position = Random.Range(0, (rows - hallwaySize)); firstLocalSquare = new Vector3(-1, position, 0); lastLocalSquare = new Vector3(-1, position + hallwaySize, 0); listHorizontalHallways[0] = new Hallway(firstLocalSquare, lastLocalSquare, firstLocalSquare + offset, lastLocalSquare + offset, 0, 0); listHorizontalHallways[0].setEndPortal(); endPortal = listHorizontalHallways[0]; } else if ((!listHorizontalHallways[1].isReal()) || (listHorizontalHallways[1].isReal() && !listHorizontalHallways[1].HallwayIsLinked())) { position = Random.Range(0, (rows - hallwaySize)); firstLocalSquare = new Vector3(columns, position, 0); lastLocalSquare = new Vector3(columns, position + hallwaySize, 0); listHorizontalHallways[1] = new Hallway(firstLocalSquare, lastLocalSquare, firstLocalSquare + offset, lastLocalSquare + offset, 0, 1); listHorizontalHallways[1].setEndPortal(); endPortal = listHorizontalHallways[1]; } return(endPortal); }
void Start() { navAgent = gameObject.GetComponent<NavMeshAgent> (); hallRange = hallway.GetComponent<Hallway> (); }