void SetExits(bool test = false) { int i = 0; if (numExits > 0 && hasFirstExit == true) { usableExits.Add(exits[0]); i++; } ProceduralDungeonGenerator.ExitDirection new_dir = new ProceduralDungeonGenerator.ExitDirection(); for (; i < numExits; i++) { ExitDirectionPoint temp = new ExitDirectionPoint(); do { new_dir = (ProceduralDungeonGenerator.ExitDirection)Random.Range(0, 4); } while (IsAlreadyExitDirection(new_dir) == true); temp = GetExitInfo(new_dir); if (temp != null) { usableExits.Add(temp); } } }
void PrintExitDoor(ProceduralDungeonGenerator.ExitDirection type) { ExitDirectionPoint exitP = GetExitByDir(type); if (exitP == null) { return; } Vector2 posInstantiate = Vector2.zero; GameObject go = null; switch (exitP.dir) { case ProceduralDungeonGenerator.ExitDirection.LEFT_EXIT: posInstantiate.x = _x_pos + 0.01f; posInstantiate.y = _y_pos + (_tileheight * 0.5f) - 0.5f + 0.01f; go = ProceduralDungeonGenerator.mapGenerator.InstantiateGO(ProceduralDungeonGenerator.mapGenerator.doorPrefabVertical, Room_Go.transform); FlipDoorTiles(go, false, true); go.transform.localPosition = posInstantiate; break; case ProceduralDungeonGenerator.ExitDirection.RIGHT_EXIT: posInstantiate.x = _x_pos + _tilewidth - 1.0f + 0.01f; posInstantiate.y = _y_pos + (_tileheight * 0.5f) - 0.5f + 0.01f; go = ProceduralDungeonGenerator.mapGenerator.InstantiateGO(ProceduralDungeonGenerator.mapGenerator.doorPrefabVertical, Room_Go.transform); go.transform.localPosition = posInstantiate; break; case ProceduralDungeonGenerator.ExitDirection.DOWN_EXIT: posInstantiate.x = _x_pos + (_tilewidth * 0.5f) - 0.5f;; posInstantiate.y = _y_pos; go = ProceduralDungeonGenerator.mapGenerator.InstantiateGO(ProceduralDungeonGenerator.mapGenerator.doorPrefabHorizontal, Room_Go.transform); FlipDoorTiles(go, false, true); go.transform.localPosition = posInstantiate; break; case ProceduralDungeonGenerator.ExitDirection.UP_EXIT: posInstantiate.x = _x_pos + (_tilewidth * 0.5f) - 0.5f;; posInstantiate.y = _y_pos + _tileheight - 1.0f; go = ProceduralDungeonGenerator.mapGenerator.InstantiateGO(ProceduralDungeonGenerator.mapGenerator.doorPrefabHorizontal, Room_Go.transform); go.transform.localPosition = posInstantiate; break; } ProceduralDungeonGenerator.mapGenerator.myDoors.Add(go); }
bool IsColliderExit(ProceduralDungeonGenerator.ExitDirection mydir) { bool ret = false; for (int i = 0; i < colliderFinalColliders.Count; i++) { if (colliderFinalColliders[i] == mydir) { ret = true; } } return(ret); }
ExitDirectionPoint GetExitInfoUsable(ProceduralDungeonGenerator.ExitDirection mydir) { ExitDirectionPoint temp = null; for (int i = 0; i < usableExits.Count; i++) { if (usableExits[i] != null) { if (usableExits[i].dir == mydir) { temp = usableExits[i]; } } } return(temp); }
bool IsAlreadyExitDirection(ProceduralDungeonGenerator.ExitDirection mydir) { bool ret = false; for (int i = 0; i < usableExits.Count; i++) { if (usableExits[i] != null) { if (usableExits[i].dir == mydir) { ret = true; } } } return(ret); }
void PosibleExits(ProceduralDungeonGenerator.ExitDirection dir = ProceduralDungeonGenerator.ExitDirection.NONE_DIR) { if (dir == ProceduralDungeonGenerator.ExitDirection.NONE_DIR) { if (!IsAlreadyExitDirection(ProceduralDungeonGenerator.ExitDirection.RIGHT_EXIT)) { ComprovationRight(); } if (!IsAlreadyExitDirection(ProceduralDungeonGenerator.ExitDirection.LEFT_EXIT)) { ComprovationLeft(); } if (!IsAlreadyExitDirection(ProceduralDungeonGenerator.ExitDirection.DOWN_EXIT)) { ComprovationDown(); } if (!IsAlreadyExitDirection(ProceduralDungeonGenerator.ExitDirection.UP_EXIT)) { ComprovationUp(); } } else { switch (dir) { case ProceduralDungeonGenerator.ExitDirection.RIGHT_EXIT: ComprovationRight(true); break; case ProceduralDungeonGenerator.ExitDirection.LEFT_EXIT: ComprovationLeft(true); break; case ProceduralDungeonGenerator.ExitDirection.DOWN_EXIT: ComprovationDown(true); break; case ProceduralDungeonGenerator.ExitDirection.UP_EXIT: ComprovationUp(true); break; } } }
ExitDirectionPoint GetExitByDir(ProceduralDungeonGenerator.ExitDirection type) { ExitDirectionPoint ret = null; foreach (ExitDirectionPoint exit in usableExits) { if (exit == null) { continue; } if (exit.dir == type) { ret = exit; break; } } return(ret); }
public Procedural_Room(int new_x_pos, int new_y_pos, int new_tilewidth, int new_tileheight, int num_room, ProceduralDungeonGenerator.ExitDirection dir, int levelDepth, bool newWantBoss = false, bool newWantMiniBoss = false) { _x_pos = new_x_pos; _y_pos = new_y_pos; _tilewidth = new_tilewidth; _tileheight = new_tileheight; _mylevel = levelDepth; _myNumRoom = num_room; _wantBoss = newWantBoss; _wantMiniBoss = newWantMiniBoss; Room_Go = new GameObject("Room " + num_room.ToString()); grid = ProceduralDungeonGenerator.mapGenerator.grid; exits = new List <ExitDirectionPoint>(); usableExits = new List <ExitDirectionPoint>(); doors = new Dictionary <BoxCollider2D, ProceduralDungeonGenerator.ExitDirection>(); colliderFinalColliders = new List <ProceduralDungeonGenerator.ExitDirection>(); if (dir != ProceduralDungeonGenerator.ExitDirection.NONE_DIR) { hasFirstExit = true; PosibleExits(dir); } PosibleExits(); int tempExitsNum = exits.Count - 1; if (levelDepth + tempExitsNum <= ProceduralDungeonGenerator.mapGenerator.realDepth) { numExits = tempExitsNum; } else { do { tempExitsNum -= 1; } while (levelDepth + tempExitsNum > ProceduralDungeonGenerator.mapGenerator.realDepth && tempExitsNum > 0); numExits = tempExitsNum; } if (tempExitsNum != 0) { SetExits(); room = new ProceduralDungeonGenerator.TileType[_tilewidth][]; for (int i = 0; i < _tilewidth; i++) { room[i] = new ProceduralDungeonGenerator.TileType[_tileheight]; } SetGroundAndWall(); controlRoom = Room_Go.AddComponent <RunTimeRoomControl>(); } else { wantToDraw = false; } }