public void ChangeRoom(room target) { if (abandonment) { int rand = Random.Range(0, 2); if (rand == 0) { this.transform.position = target.getWatcherSpawn().transform.position; Debug.Log("Moving Watcher to Location"); currentRoom = target; Candles = currentRoom.getRoomObject().GetComponentsInChildren <CandleScript>(); } else { Mask.transform.position = target.getWatcherSpawn().transform.position; Debug.Log("Moving Mask to Location"); this.transform.position = maskStartPosition.transform.position; currentRoom = target; Candles = null; } } else { this.transform.position = target.getWatcherSpawn().transform.position; currentRoom = target; Candles = currentRoom.getRoomObject().GetComponentsInChildren <CandleScript>(); } }
public void clientCreateRoom(string roomName, int roomSize, int playerID) { GlobalVariables.instance.players[playerID].Player.SetMessageGroup((ushort)GlobalVariables.instance.messageGroupIncrement); myRoom = new room(new room(GlobalVariables.instance.players[playerID], roomSize, roomName, (ushort)GlobalVariables.instance.messageGroupIncrement)); GlobalVariables.instance.existingRooms.Add(myRoom); BMSLogger.Instance.Log("room exist created"); }
room findClosestRoom(room room) { Vector2 mid = new Vector2(room.x + room.width / 2, room.y + room.height / 2); //room[] neighbors; //ArrayList neighborz = new ArrayList(4); //neighborz.Add(new room()); room closest = new room(); int closest_dist = 1000; for (int i = 0; i < rooms.Length; i++) { room check = rooms[i]; if (check.index == room.index) { continue; } Vector2 check_mid = new Vector2(check.x + check.width / 2, check.y + check.height / 2); int distance = (int)(Mathf.Abs(mid.x - check_mid.x) + Mathf.Abs(mid.y - check_mid.y)); if (distance < closest_dist && room.neighbor != i) { //set to neightbors room.neighbor = i; rooms[room.index].neighbor = i; rooms[i].neighbor = room.index; closest_dist = distance; closest = check; } //else if (distance < 2nd closest) set to 2nd closest } return(closest); }
public void book_noSeat_Click_room() { room r = new room(); r.time = "12:50"; r.button1_Click(r.button1, EventArgs.Empty); }
static void Main(string[] args) { Student s01 = new Student("002"); Student s02 = new Student("001", "Rungrat", "Sriwirun"); s01.setFirstname("Anocha"); s01.setLastname("Prungtaeng"); Console.WriteLine(s01.ToString()); Console.WriteLine(s02.ToString()); Console.WriteLine((new Student("018", "Rene", "Smith")).ToString()); room r433 = new room("433", "433", 8, 8, "Computer"); Console.WriteLine(r433.ToString()); Console.WriteLine("_____________________________________________________________"); Building s05 = new Building("04", "Faculty of Computer Science and Information Technology", "13.7442", "100.4608"); Console.WriteLine(s05.ToString()); Console.WriteLine("_____________________________________________________________"); Subject s06 = new Subject("9022081", "Web Programming", 3, 2, 2); Console.WriteLine(s06.ToString()); Console.WriteLine("_____________________________________________________________"); Lecturer s03 = new Lecturer("Nitat", "Ninchawee", "Master of Sience (Electronic Transactions)"); Console.WriteLine(s03.ToString()); Console.WriteLine("_____________________________________________________________"); Curriculum s04 = new Curriculum("Information Technology", "Bachelor"); Console.WriteLine(s04.ToString()); Console.WriteLine("_____________________________________________________________"); }
void changedoorexistancemakedoor(int side, room newneighbor) { if (!doors[side].exists) { switch (side) { case north: makeNorthwallwithdoor(walls[side].part1); break; case east: makeEastwallwithdoor(walls[side].part1); break; case south: makeSouthwallwithdoor(walls[side].part1); break; case west: makeWestwallwithdoor(walls[side].part1); break; } doors[side].neighbor = newneighbor; } }
//spawns rooms randomly void generateDungeon() { for (int x = 0; x < mapSize; x++) { for (int y = 0; y < mapSize; y++) { map[x, y] = 0; } } //add new rooms to rooms array for (int i = 0; i < numRooms; i++) { room newRoom = new room(); newRoom.index = i; newRoom.width = Random.Range(roomSizeMin, roomSizeMax + 1); newRoom.height = Random.Range(roomSizeMin, roomSizeMax + 1); newRoom.x = Random.Range(1 + newRoom.width, mapSize - newRoom.width - 1); newRoom.y = Random.Range(1 + newRoom.height, mapSize - newRoom.height - 1); newRoom.center = new Vector2(newRoom.x + (newRoom.width) / 2, newRoom.y + (newRoom.height) / 2); newRoom.connected = false; if (doesCollide(newRoom)) { //remake the room i--; continue; } rooms[i] = newRoom; } }
// Add a door or possibly a secret door. Also enters the door in // the exits array of the room. static void door(room rm, Coord cp) { PLACE pp; rm.Exits[rm.NumExits++] = cp; if ((rm.Flags & Room.ISMAZE) == Room.ISMAZE) { return; } pp = PlaceAt(cp.y, cp.x); if (R14.rnd(10) + 1 < Agent.LevelOfMap && R14.rnd(5) == 0) { if (cp.y == rm.PosUL.y || cp.y == rm.PosUL.y + rm.Size.y - 1) { pp.p_ch = '-'; } else { pp.p_ch = '|'; } pp.p_flags &= ~Dungeon.F_REAL; } else { pp.p_ch = Char.DOOR; } }
public door(int SideToBePut, room ParentRoom) { side = SideToBePut; exists = false; neighbor = null; room = ParentRoom; }
public bool cornercheck(room room, Vector2 walltotest) { if((walltotest.x == room.xpos-1) && (walltotest.y == room.ypos-1)) { return true; } if((walltotest.x == room.xpos-1) && (walltotest.y == room.ypos + room.height)) { return true; } if((walltotest.x == room.xpos + room.width) && (walltotest.y == room.ypos + room.height)) { return true; } if((walltotest.x == room.xpos + room.width) && (walltotest.y == room.ypos-1)) { return true; } return false; }
public ResultHelper SetRoom(RoomDto roomDto) { try { room item = new room(); item.FloorID = roomDto.FloorID; if (string.IsNullOrEmpty(roomDto.Map)) { item.Map = roomDto.Map; } item.Name = roomDto.Name; item.RoomID = roomDto.RoomID; item.RoomTypeID = roomDto.RoomTypeID; using (UnitOfWork unitofWork = new UnitOfWork()) { unitofWork.GetRepository <room>().Update(item); unitofWork.saveChanges(); return(new ResultHelper(true, roomDto.RoomID, ResultHelper.SuccessMessage)); } } catch (Exception ex) { return(new ResultHelper(false, roomDto.RoomID, ResultHelper.UnSuccessMessage)); } }
/// <summary> /// Initialize class /// </summary> /// <param name="_copy">Copy element</param> public room(room _copy) { get_name = _copy.get_name; get_access = _copy.get_access; get_room_id = _copy.get_room_id; Settings = _copy.Settings; }
public RoomModel GetById(int id) { room entity = this._repository.GetById(id); RoomModel model = this.ConvertEntityToModel(entity); return(model); }
// Draw a box around a room and lay down the floor for normal // rooms; for maze rooms, draw maze. static void draw_room(room r) { int y, x; if ((r.Flags & Room.ISMAZE) == Room.ISMAZE) { do_maze(r); } else { vert(r, r.PosUL.x); /* Draw left side */ vert(r, r.PosUL.x + r.Size.x - 1); /* Draw right side */ horiz(r, r.PosUL.y); /* Draw top */ horiz(r, r.PosUL.y + r.Size.y - 1); /* Draw bottom */ /* * Put the floor down */ for (y = r.PosUL.y + 1; y < r.PosUL.y + r.Size.y - 1; y++) { for (x = r.PosUL.x + 1; x < r.PosUL.x + r.Size.x - 1; x++) { SetCharAt(y, x, Char.FLOOR); } } } }
public mazegenerator() { quadtable = new block [100,100]; for(int i = 0; i < 2000; i+=20) { for(int j = 0; j < 2000; j+=20) { block currentsquare = new block(19,19,i,j,"earth"); quadtable[i/20,j/20] = currentsquare; } } room newroom = new room(20,20,6,4); rooms.Add(newroom); foreach (Vector2 wall in newroom.walls) { quadtable[(int)wall.x,(int)wall.y] = new block(19,19,wall.x*20,wall.y*20,"wall"); } foreach (Vector2 floor in newroom.floortiles) { quadtable[(int)floor.x,(int)floor.y] = new block(19,19,floor.x*20,floor.y*20,"floor"); } }
// Use this for initialization void Awake() { _animControl = GetComponentInChildren <Animator>(); _boxCollider = GetComponent <BoxCollider>(); _roomParent = transform.parent.parent.GetComponent <room>(); _audioSource = GetComponent <AudioSource>(); }
public override async Task <bool> Reserve(reserve reserve) { IConfigurationRoot configuration = new ConfigurationBuilder() .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .AddJsonFile("appsettings.json") .Build(); string webServiceHilton = configuration.GetValue <string>("WebServiceHilton"); webServiceHilton += "reserveRoom"; room room = new room { order_id = reserve.order_id.ToString(), hotel_id = reserve.hotel_id, room_number = reserve.room_number, check_in_date = reserve.check_in_date, check_out_date = reserve.check_out_date, state = reserve.state, guest_name = reserve.guest_name }; string body = JsonConvert.SerializeObject(room); StringContent stringContent = new StringContent(body, Encoding.UTF8, "application/json"); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync(webServiceHilton, stringContent); if (httpResponseMessage.IsSuccessStatusCode) { return(true); } else { throw new Exception(await httpResponseMessage.Content.ReadAsStringAsync()); } }
public static Room mapToJSON(room item) { Room json = new Room(); json.id = item.id; json.name = item.name; json.branch_fk = (int)item.branch_fk; return json; }
public ActionResult DeleteConfirmed(int id) { room room = db.rooms.Find(id); db.rooms.Remove(room); db.SaveChanges(); return(RedirectToAction("Index")); }
public void UpdateStatus(string status, room room) { var updatedRoom = Find(room.id); updatedRoom.status = "Unclean"; db.SaveChanges(); }
public door(int SideToBePut, room ParentRoom) { side = SideToBePut; exists = true; isOpen = true; neighbor = null; room = ParentRoom; }
public ActionResult DeleteConfirmed(int ID) { room R = db.rooms.Find(ID); db.rooms.Remove(R); db.SaveChanges(); return(RedirectToAction("Index")); }
protected void Page_Load(object sender, EventArgs e) { r = Session["Desc"] as room; if (!Page.IsPostBack) { descTXT.Text = r.description; } }
public ActionResult DeleteConfirmed(int id) { room room = db.rooms.Find(id); room.is_deleted = true; room.modified_on = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); }
public room(room toReplace) { this.partyLeader = toReplace.partyLeader; this.roomName = toReplace.roomName; this.roomSize = toReplace.roomSize; matching = true; players = toReplace.players; mmrs = toReplace.Mmrs; }
// Draw a vertical line static void vert(room rp, int startx) { int y; for (y = rp.PosUL.y + 1; y <= rp.Size.y + rp.PosUL.y - 1; y++) { SetCharAt(y, startx, '|'); } }
public Room(room _room) { InitializeComponent(); this._room = _room; this.id_text.Text = this._room.id.ToString(); this.name_text.Text = this._room.name; this.description_text.Text = this._room.description; this.loadComponent(); }
// Draw a horizontal line static void horiz(room rp, int starty) { int x; for (x = rp.PosUL.x; x <= rp.PosUL.x + rp.Size.x - 1; x++) { SetCharAt(starty, x, '-'); } }
// Draw a vertical line void vert(room rp, int startx) { int y; for (y = rp.r_pos.y + 1; y <= rp.r_max.y + rp.r_pos.y - 1; y++) { chat(y, startx, '|'); } }
// Draw a horizontal line void horiz(room rp, int starty) { int x; for (x = rp.r_pos.x; x <= rp.r_pos.x + rp.r_max.x - 1; x++) { chat(starty, x, '-'); } }
public InsertRoomViewModel() { roomRepository = new BaseRepository <room>(); roomStatusRepository = new BaseRepository <room_status>(); roomTypeRepository = new BaseRepository <room_type>(); _roomStatusList = roomStatusRepository.GetAll(); _roomTypeList = roomTypeRepository.GetAll(); _room = new room(); }
/// <summary> /// Add room to this hotel /// </summary> /// <param name="pic">Picture of the room</param> /// <param name="askedPrice">Asked price for the room. Per day.</param> /// <param name="name">Name of the room</param> /// <param name="quantity">Number of rooms</param> /// <param name="description">Description of room</param> public void addRoom(byte[] pic, double askedPrice, string name, int quantity, string description = null) { room added = new room(pic, askedPrice, name, this, quantity); if (description != null) { added.description = description; } }
public void Delete(room room) { if (room == null) { throw new Exception("Room can not be null"); } db.rooms.Remove(room); db.SaveChanges(); }
public ShowRoomWindow(room room) { InitializeComponent(); _viewModel = DataContext as ShowOneRoomViewModel; if (_viewModel != null) { _viewModel.Initilize(room); _viewModel.RegistrationRoomEvent += viewModel_RegistrationRoomEvent; } }
public void Initilize(room room) { Room = new RoomForRedact { Id = room.Id, Floor = room.Floor, Number = room.Number, Price = room.Price, Status = room.Status, Mark = room.Mark, Beds = room.beds.ToList(), LastServiceDate = room.LastServiceDate, OrderRoom = new List<order_room>() }; Recalck(); PropertyChanged += ShowOneRoomViewModel_PropertyChanged; Title = "Просмотр комнаты №:" + Room.Id; }
protected void submitRoom(Object sender, EventArgs e) { //If selected room is null then creating a new room to add if (selected_room == null) { selected_room = new room(); selected_room.facility_id = facility_id; selected_room.name = RoomName.Text; selected_room.add_date = DateTime.Now; db.rooms.InsertOnSubmit(selected_room); db.SubmitChanges(); } //If not null then we are editing an existing room else { selected_room.name = RoomName.Text; db.SubmitChanges(); } Response.RedirectToRoute("ViewFacility", new { facility_id = facility_id }); }
protected void Page_Load(object sender, EventArgs e) { //If facility_id in values creating a new room if (Page.RouteData.Values["facility_id"] != null) { facility_id = Convert.ToInt32(Page.RouteData.Values["facility_id"]); } //If room id in values then we are editing an existing rooom else if (Page.RouteData.Values["room_id"] != null) { room_id = Convert.ToInt32(Page.RouteData.Values["room_id"]); selected_room = (from r in db.rooms where r.id == room_id select r).Single(); facility_id = selected_room.facility_id; if (!Page.IsPostBack) { RoomName.Text = selected_room.name; } } }
public void generate() { for(int i = 0; i < 100; i++) { Debug.Log("restarting function"); Vector2 roomtotest = new Vector2(UnityEngine.Random.Range(2,10),UnityEngine.Random.Range(2,5)); int roomindex = UnityEngine.Random.Range(0,rooms.Count-1); room currentroom = rooms[roomindex]; int wallindex = UnityEngine.Random.Range(0,currentroom.walls.Count-1); Debug.Log(roomindex); Debug.Log(currentroom.walls.Count-1); Vector2 walltotest = currentroom.walls[wallindex]; bool top = false; bool bottom = false; bool left = false; bool right = false; if (quadtable[(int)walltotest.x,(int)walltotest.y+1].type == "earth") top = true; if (quadtable[(int)walltotest.x+1,(int)walltotest.y].type == "earth") right = true; if (quadtable[(int)walltotest.x-1,(int)walltotest.y].type == "earth") left = true; if (quadtable[(int)walltotest.x,(int)walltotest.y-1].type == "earth") bottom = true; if (Convert.ToInt32(top)+Convert.ToInt32(right)+Convert.ToInt32(left)+Convert.ToInt32(bottom) > 1){ Debug.Log("Corner Selected, Breaking Out"); continue; } if (Convert.ToInt32(top)+Convert.ToInt32(right)+Convert.ToInt32(left)+Convert.ToInt32(bottom) < 1){ Debug.Log("Corner Selected, Breaking Out"); continue; } Vector2 scandir = walltotest - currentroom.center; Vector2 scanend = new Vector2 (0,0); Vector2 scanstart = new Vector2 (0,0); Vector2 doorcheck= new Vector2 (0,0); //all this ugliness is because of how I am iterating from start to end and the inclusion rules of python range function if (top == true){ scanend = walltotest + new Vector2((int)(Math.Floor(roomtotest.x/2)+1),1*roomtotest.y+2); scanstart = new Vector2(walltotest.x - (int)(Math.Floor(roomtotest.x/2)),walltotest.y+1); doorcheck = new Vector2(0,-1); //Debug.Log( "top"); } else if (bottom == true){ scanend = new Vector2(walltotest.x + (int)(Math.Floor(roomtotest.x/2)+1),walltotest.y); scanstart = walltotest + new Vector2(-1*(int)(Math.Floor(roomtotest.x/2)),-1*(roomtotest.y)); doorcheck = new Vector2(0,1); //Debug.Log( "bottom"); } else if (left == true) { scanstart = walltotest + new Vector2(-1*roomtotest.x,-1*(int)(Math.Floor(roomtotest.y/2))); scanend = new Vector2(walltotest.x,walltotest.y + (int)(Math.Floor(roomtotest.y/2))+1); doorcheck = new Vector2(1,0); //Debug.Log( "left"); } else if (right == true){ scanend= (walltotest + new Vector2(1*(roomtotest.x+2),1*(int)(Math.Floor(roomtotest.y/2))+1)); scanstart = new Vector2(walltotest.x + 1,walltotest.y -1*(int)(Math.Floor(roomtotest.y/2))); doorcheck = new Vector2(-1,0); //Debug.Log( "right"); } bool die = false; for(int j =(int) scanstart.x; j < (int)scanend.x; j++) { if (die != true) { for(int k = (int)scanstart.y; k < (int)scanend.y; k++) { block o = quadtable[j,k]; if (o != null) { if (o.type == "earth") Debug.Log( "earth"); else{ Debug.Log( "something is here"); die = true; } } } } } if (die == false){ room newroom3 = new room(scanstart.x,scanstart.y,roomtotest.x,roomtotest.y); rooms.Add(newroom3); foreach (Vector2 walli in newroom3.walls) { Debug.Log(new Vector2(walli.x,walli.y)); quadtable[(int)walli.x,(int)walli.y] = new block(19,19,walli.x*20,walli.y*20,"wall"); } foreach (Vector2 floori in newroom3.floortiles) { quadtable[(int)floori.x,(int)floori.y] = new block(19,19,floori.x*20,floori.y*20,"floor"); } quadtable[(int)walltotest.x,(int)walltotest.y] = new block(19,19,walltotest.x*20,walltotest.y*20,"floor"); quadtable[(int)walltotest.x + (int)doorcheck.x,(int)walltotest.y+(int)doorcheck.y] = new block(19,19,((int)walltotest.x+doorcheck.x)*20,((int)walltotest.y+doorcheck.y)*20,"floor"); } } }
public void gotoRoom(room r) { if (previousRoom != null) { currentRoom.players.Remove(this); } previousRoom = currentRoom; scroller.addTextObject("--------------------------------", ColorStory, 50, myFont); scroller.addTextObject(r.enterMessage, ColorStory, 20, myFont); bool firefly = false; if (r._items.Count > 0) { print ("room has items"); string itemString = "Room contains : "; for (int i=0; i<r._items.Count; i++) { item it = r._items[i].GetComponent<item>(); itemString += " " + it.name; if (it.playerName.Length > 0) itemString += "("+it.playerName+")"; if (i != r._items.Count-1) itemString += ","; if (it.name.ToLower() == "firefly") { firefly = true; } } scroller.addTextObject(itemString, ColorItems, 30, myFont); } else { print ("room has no items"); } if (firefly) { warningMessage ("Oh no, it's a firefly! I hope I have my trusty blaster to shoot him on his face!'"); } if (r._rooms.Count > 0) { string roomString = "Connected rooms : "; for (int i=0; i<r._rooms.Count; i++) { room it = r._rooms[i].GetComponent<room>(); roomString += " " + it.name; if (i != r._rooms.Count-1) roomString += ","; } scroller.addTextObject(roomString, ColorItems, 30, myFont); } scroller.addTextObject("--------------------------------", ColorStory, 20, myFont); //print (r.enterMessage); currentRoom = r; currentRoom.players.Add(this); PhotonNetwork.playerName = playerName + "("+ currentRoom.name +")"; }
// Find a valid floor spot in this room. If rp is NULL, then // pick a new room each time around the loop. bool find_floor(room rp, out coord cp, int limit, bool monst) { cp = new coord(); PLACE pp; int cnt; char compchar = '\0'; bool pickroom; pickroom = (bool)(rp == null); if (!pickroom) compchar = (((rp.r_flags & ISMAZE) == ISMAZE) ? PASSAGE : FLOOR); cnt = limit; for (; ; ) { if (limit != 0 && cnt-- == 0) return false; if (pickroom) { rp = rooms[rnd_room()]; compchar = (((rp.r_flags & ISMAZE) == ISMAZE) ? PASSAGE : FLOOR); } rnd_pos(rp, out cp); pp = INDEX(cp.y, cp.x); if (monst) { if (pp.p_monst == null && step_ok(pp.p_ch)) return true; } else if (pp.p_ch == compchar) return true; } }
// Draw a horizontal line void horiz(room rp, int starty) { int x; for (x = rp.r_pos.x; x <= rp.r_pos.x + rp.r_max.x - 1; x++) chat(starty, x, '-'); }
// Pick a random spot in a room void rnd_pos(room rp, out coord cp) { cp = new coord(); cp.x = rp.r_pos.x + rnd(rp.r_max.x - 2) + 1; cp.y = rp.r_pos.y + rnd(rp.r_max.y - 2) + 1; }
// Draw a vertical line void vert(room rp, int startx) { int y; for (y = rp.r_pos.y + 1; y <= rp.r_max.y + rp.r_pos.y - 1; y++) chat(y, startx, '|'); }
// Called to illuminate a room. If it is dark, remove anything // that might move. void door_open(room rp) { int y, x; if (!((rp.r_flags & ISGONE) == ISGONE)) for (y = rp.r_pos.y; y < rp.r_pos.y + rp.r_max.y; y++) for (x = rp.r_pos.x; x < rp.r_pos.x + rp.r_max.x; x++) if (char.IsUpper(winat(y, x))) wake_monster(y, x); }
void addRooms() { List<room> houseRooms = new List<room>(); int indexX =0; int indexY =0; int minSize = Mathf.RoundToInt(minRoomSize * (sizeX+ sizeY)/2f); bool[,] legalStarts = new bool[sizeX,sizeY]; #region initalize array for(int y =0; y < sizeY; y++) { for(int x =0; x < sizeX; x++) { if(floorValues[x,y] == FLOORTYPE.HALLWAY) { legalStarts[x,y] = false; } else { legalStarts[x,y] = true; } } } #endregion bool finished = false; while(finished == false) { int maxX = Mathf.RoundToInt(maxRoomSize * (sizeX+ sizeY)/2f); int maxY = Mathf.RoundToInt(maxRoomSize * (sizeX+ sizeY)/2f); getRoomCoordinates(ref indexX,ref indexY,ref legalStarts,ref finished,ref maxX,ref maxY); room roomToAdd =new room(indexX,indexY,Random.Range(minSize,maxX),Random.Range(minSize,maxY)); addRoomToArray(roomToAdd); houseRooms.Add(roomToAdd); //finished = true; } }
public RoomForSelect(room room) { Room = room; Status = ProjectSettings.DbContext.status.Where(item => item.ForRoom && item.Id == room.Status).Select(item => item.Text).FirstOrDefault(); }
public void generate(int iterations, int xcenter, int ycenter, int xsd, int ysd, bool doormaxalways, bool doorminalways, bool doorrandomize, int desiredDoorWidth, bool flatlevel, int heightmin, int heightmax) { for(int i = 0; i < iterations; i++) { Debug.Log("restarting function"); Vector2 roomtotest = new Vector2(gaussint(xcenter,xsd),gaussint(ycenter,ysd)); int roomindex = UnityEngine.Random.Range(0,rooms.Count-1); room currentroom = rooms[roomindex]; int wallindex = UnityEngine.Random.Range(0,currentroom.walls.Count-1); //Debug.Log(roomindex); //Debug.Log(currentroom.walls.Count-1); Vector2 walltotest = currentroom.walls[wallindex]; bool top = false; bool bottom = false; bool left = false; bool right = false; if (quadtable[(int)walltotest.x,(int)walltotest.y+1].type == "earth") top = true; if (quadtable[(int)walltotest.x+1,(int)walltotest.y].type == "earth") right = true; if (quadtable[(int)walltotest.x-1,(int)walltotest.y].type == "earth") left = true; if (quadtable[(int)walltotest.x,(int)walltotest.y-1].type == "earth") bottom = true; if (Convert.ToInt32(top)+Convert.ToInt32(right)+Convert.ToInt32(left)+Convert.ToInt32(bottom) > 1){ Debug.Log("Corner Selected, Breaking Out"); continue; } if (Convert.ToInt32(top)+Convert.ToInt32(right)+Convert.ToInt32(left)+Convert.ToInt32(bottom) < 1){ Debug.Log("Corner Selected, Breaking Out"); continue; } Vector2 scandir = walltotest - currentroom.center; Vector2 scanend = new Vector2 (0,0); Vector2 scanstart = new Vector2 (0,0); Vector2 doorcheck= new Vector2 (0,0); //all this ugliness is because of how I am iterating from start to end and the inclusion rules of python range function if (top == true){ scanend = walltotest + new Vector2((int)(Math.Floor(roomtotest.x/2)+1),1*roomtotest.y+2); scanstart = new Vector2(walltotest.x - (int)(Math.Floor(roomtotest.x/2)),walltotest.y+1); doorcheck = new Vector2(0,-1); //Debug.Log( "top"); } else if (bottom == true){ scanend = new Vector2(walltotest.x + (int)(Math.Floor(roomtotest.x/2)+1),walltotest.y); scanstart = walltotest + new Vector2(-1*(int)(Math.Floor(roomtotest.x/2)),-1*(roomtotest.y)); doorcheck = new Vector2(0,1); //Debug.Log( "bottom"); } else if (left == true) { scanstart = walltotest + new Vector2(-1*roomtotest.x,-1*(int)(Math.Floor(roomtotest.y/2))); scanend = new Vector2(walltotest.x,walltotest.y + (int)(Math.Floor(roomtotest.y/2))+1); doorcheck = new Vector2(1,0); //Debug.Log( "left"); } else if (right == true){ scanend= (walltotest + new Vector2(1*(roomtotest.x+2),1*(int)(Math.Floor(roomtotest.y/2))+1)); scanstart = new Vector2(walltotest.x + 1,walltotest.y -1*(int)(Math.Floor(roomtotest.y/2))); doorcheck = new Vector2(-1,0); //Debug.Log( "right"); } bool die = false; for(int j =(int) scanstart.x; j < (int)scanend.x; j++) { if (die != true) { for(int k = (int)scanstart.y; k < (int)scanend.y; k++) { //Debug.Log(new Vector2(j,k)); if ((j >=2) && (k >=2)) { block o = quadtable[j,k]; if (o != null) { if (o.type == "earth") Debug.Log( "earth"); else{ //Debug.Log( "something is here"); die = true; } } } else { die = true; Debug.Log ("Outside of Level Borders"); } } } } if (die == false){ room newroom3 = new room(scanstart.x,scanstart.y,roomtotest.x,roomtotest.y); currentroom.neighbors.Add(newroom3); newroom3.neighbors.Add(currentroom); List<Vector2> overlapped = new List<Vector2>(); foreach (Vector2 wall in currentroom.walls) { if (newroom3.walls.Contains(wall)) { overlapped.Add(wall); } } overlapped.RemoveAll(wall => cornercheck(newroom3,wall)); overlapped.RemoveAll(wall => cornercheck(currentroom,wall)); // foreach (Vector2 wall in overlapped) // { // if (cornercheck(newroom3,wall)) // { // overlapped.Remove(wall); // } // } // foreach (Vector2 wall in overlapped) // { // if (cornercheck(currentroom,wall)) // { // overlapped.Remove(wall); // } // } if(flatlevel) { newroom3.zheight = currentroom.zheight; } else { newroom3.zheight = currentroom.zheight + UnityEngine.Random.Range(heightmin,heightmax); } rooms.Add(newroom3); foreach (Vector2 walli in newroom3.walls) { //Debug.Log(new Vector2(walli.x,walli.y)); quadtable[(int)walli.x,(int)walli.y] = new block(19,19,walli.x*20,walli.y*20,"wall"); if (heightsTable[(int)walli.x,(int)walli.y] > newroom3.zheight) { heightsTable[(int)walli.x,(int)walli.y] = heightsTable[(int)walli.x,(int)walli.y]; } else { heightsTable[(int)walli.x,(int)walli.y] = newroom3.zheight; } } foreach (Vector2 floori in newroom3.floortiles) { quadtable[(int)floori.x,(int)floori.y] = new block(19,19,floori.x*20,floori.y*20,"floor"); if (heightsTable[(int)floori.x,(int)floori.y] > newroom3.zheight) { heightsTable[(int)floori.x,(int)floori.y] = heightsTable[(int)floori.x,(int)floori.y]; } else { heightsTable[(int)floori.x,(int)floori.y] = newroom3.zheight; } } quadtable[(int)walltotest.x,(int)walltotest.y] = new block(19,19,walltotest.x*20,walltotest.y*20,"floor"); quadtable[(int)walltotest.x + (int)doorcheck.x,(int)walltotest.y+(int)doorcheck.y] = new block(19,19,((int)walltotest.x+doorcheck.x)*20,((int)walltotest.y+doorcheck.y)*20,"floor"); room lastroom = rooms[rooms.Count-1]; if (doormaxalways) { doorwidth = overlapped.Count; } else if (doorminalways) { doorwidth = 1; } else if (doorrandomize) { if (overlapped.Count > 1) { doorwidth = UnityEngine.Random.Range(1,overlapped.Count); } else { doorwidth = 1; } } else { doorwidth = Math.Min(desiredDoorWidth,overlapped.Count); } for (int doorindex = 0; doorindex < doorwidth; doorindex++) { Vector2 walltodelete = overlapped[doorindex]; if (currentroom.walls.Contains(walltodelete)) { currentroom.walls.Remove(walltodelete); currentroom.floortiles.Add(walltodelete); //guessing gid rid of this to fix double floor bug } if (lastroom.walls.Contains(walltodelete)) { lastroom.walls.Remove(walltodelete); lastroom.floortiles.Add(walltodelete); //guessing gid rid of this to fix double floor bug } } if(lastroom.walls.Contains(new Vector2(walltotest.x + doorcheck.x, walltotest.y + doorcheck.y))) { lastroom.walls.Remove(new Vector2(walltotest.x + doorcheck.x, walltotest.y + doorcheck.y)); lastroom.floortiles.Remove(new Vector2(walltotest.x + doorcheck.x, walltotest.y + doorcheck.y)); } if(currentroom.walls.Contains(new Vector2(walltotest.x + doorcheck.x, walltotest.y + doorcheck.y))) { currentroom.walls.Remove(new Vector2(walltotest.x + doorcheck.x, walltotest.y + doorcheck.y)); currentroom.floortiles.Remove(new Vector2(walltotest.x + doorcheck.x, walltotest.y + doorcheck.y)); } } } convertedQuadTable = new int[2000,2000]; foreach (block currentblock in quadtable) { if (currentblock.type == "earth") { // Debug.Log(currentblock.xpos); // Debug.Log(currentblock.ypos); convertedQuadTable[(int)currentblock.xpos,(int)currentblock.ypos] = 1; } else if (currentblock.type == "floor") { convertedQuadTable[(int)currentblock.xpos,(int)currentblock.ypos] = 2; } else if (currentblock.type == "wall") { convertedQuadTable[(int)currentblock.xpos,(int)currentblock.ypos] = 3; } else { convertedQuadTable[(int)currentblock.xpos,(int)currentblock.ypos] = 0; } } }
public void addRoom(room Room) { this.roomsList.add(room); }
void useItems(item itemToUse, room roomToUseWith) { //if (itemToUse == roomToUseWith.itemToUnlock) { roomToUseWith.isLocked = false; scroller.addTextObject(roomToUseWith.name + " is has been unlocked!", ColorAction, 30, myFont); //} }
// Dig a maze void do_maze(room rp) { SPOT sp; int starty, startx; coord pos = new coord(); for (int i = 0; i < NUMLINES / 3; i++) for (int j = 0; j < NUMCOLS / 3; j++) { maze[i, j] = new SPOT(); } Maxy = rp.r_max.y; Maxx = rp.r_max.x; Starty = rp.r_pos.y; Startx = rp.r_pos.x; starty = (rnd(rp.r_max.y) / 2) * 2; startx = (rnd(rp.r_max.x) / 2) * 2; pos.y = starty + Starty; pos.x = startx + Startx; putpass(pos); dig(starty, startx); }
// Erase the area shown by a lamp in a dark room. void erase_lamp(coord pos, room rp) { int y, x, ey, sy, ex; if (!(see_floor && (rp.r_flags & (ISGONE|ISDARK)) == ISDARK && !on(player,ISBLIND))) return; ey = pos.y + 1; ex = pos.x + 1; sy = pos.y - 1; for (x = pos.x - 1; x <= ex; x++) for (y = sy; y <= ey; y++) { if (y == hero.y && x == hero.x) continue; move(y, x); if (inch() == FLOOR) addch(' '); } }
//untested public bool isColliding(room otherRoom) { return(x + sizeX >= otherRoom.x && x <= otherRoom.x + otherRoom.sizeX&&y + sizeY >= otherRoom.y && y <= otherRoom.y + otherRoom.sizeY); }
// Draw a box around a room and lay down the floor for normal // rooms; for maze rooms, draw maze. void draw_room(room rp) { int y, x; if ((rp.r_flags & ISMAZE) == ISMAZE) do_maze(rp); else { vert(rp, rp.r_pos.x); /* Draw left side */ vert(rp, rp.r_pos.x + rp.r_max.x - 1); /* Draw right side */ horiz(rp, rp.r_pos.y); /* Draw top */ horiz(rp, rp.r_pos.y + rp.r_max.y - 1); /* Draw bottom */ /* * Put the floor down */ for (y = rp.r_pos.y + 1; y < rp.r_pos.y + rp.r_max.y - 1; y++) for (x = rp.r_pos.x + 1; x < rp.r_pos.x + rp.r_max.x - 1; x++) chat(y, x, FLOOR); } }
void addRoomToArray(room r) { for(int y =0; y < r.sizeY; y++) { for(int x =0; x < r.sizeX; x++) { floorValues[r.x + x,r.y + y] = FLOORTYPE.BASIC; } } }
// Create rooms and corridors with a connectivity graph public void do_rooms() { int i; THING tp; int left_out; coord top = new coord(); coord bsze = new coord(); /* maximum room size */ coord mp; bsze.x = NUMCOLS / 3; bsze.y = NUMLINES / 3; /* * Clear things for a new level */ for (i = 0; i < rooms.Length; i++) { var rp = new room(); rooms[i] = rp; rp.r_goldval = 0; rp.r_nexits = 0; rp.r_flags = 0; } /* * Put the gone rooms, if any, on the level */ left_out = rnd2(4, "gone rooms"); for (i = 0; i < left_out; i++) rooms[rnd_room()].r_flags |= ISGONE; /* * dig and populate all the rooms on the level */ for (i = 0; i < MAXROOMS; i++) { var rp = rooms[i]; /* * Find upper left corner of box that this room goes in */ top.x = (i % 3) * bsze.x + 1; top.y = (i / 3) * bsze.y; if ((rp.r_flags & ISGONE) == ISGONE) { /* * Place a gone room. Make certain that there is a blank line * for passage drawing. */ do { rp.r_pos.x = top.x + rnd(bsze.x - 2) + 1; rp.r_pos.y = top.y + rnd(bsze.y - 2) + 1; rp.r_max.x = -NUMCOLS; rp.r_max.y = -NUMLINES; } while (!(rp.r_pos.y > 0 && rp.r_pos.y < NUMLINES - 1)); continue; } /* * set room type */ if (rnd2(10, "is dark room") < level - 1) { rp.r_flags |= ISDARK; /* dark room */ if (rnd2(15, "is maze room") == 0) rp.r_flags = ISMAZE; /* maze room */ } /* * Find a place and size for a random room */ if ((rp.r_flags & ISMAZE) == ISMAZE) { rp.r_max.x = bsze.x - 1; rp.r_max.y = bsze.y - 1; if ((rp.r_pos.x = top.x) == 1) rp.r_pos.x = 0; if ((rp.r_pos.y = top.y) == 0) { rp.r_pos.y++; rp.r_max.y--; } } else do { rp.r_max.x = rnd(bsze.x - 4) + 4; rp.r_max.y = rnd(bsze.y - 4) + 4; rp.r_pos.x = top.x + rnd(bsze.x - rp.r_max.x); rp.r_pos.y = top.y + rnd(bsze.y - rp.r_max.y); } while (!(rp.r_pos.y != 0)); draw_room(rp); /* * Put the gold in */ if (rnd2(2, "has gold") == 0 && (!amulet || level >= max_level)) { THING gold; gold = new_item(); gold.o_goldval = rp.r_goldval = GOLDCALC(); find_floor(rp, out rp.r_gold, 0, false); gold.o_pos = rp.r_gold; chat(rp.r_gold.y, rp.r_gold.x, GOLD); gold.o_flags = ISMANY; gold.o_group = GOLDGRP; gold.o_type = GOLD; attach(ref lvl_obj, gold); } /* * Put the monster in */ if (rnd2(100, "has monster") < (rp.r_goldval > 0 ? 80 : 25)) { tp = new_item(); find_floor(rp, out mp, 0, true); new_monster(tp, randmonster(false), mp); give_pack(tp); } } }