public DDoor(DDoor door) { x = door.x; y = door.y; d_ptGlobalPos = new DPointN(door.d_ptGlobalPos.x, door.d_ptGlobalPos.y); d_nPosition = door.d_nPosition; }
private static bool CheckDoorWithRoom(Rect room, DPointN door) { int _minX = (int)room.x; int _maxX = (int)room.x + (int)room.width; int _minY = (int)room.y; int _maxY = (int)room.y + (int)room.height; return(door.x >= _minX && door.x <= _maxX && door.y >= _minY && door.y <= _maxY); }
private static bool CheckRoom(DRoom room, DDoor door, DPointN globalAnchor) { Rect _newRoom, _savedRoom; _newRoom = new Rect( new Vector2(globalAnchor.x - door.x, globalAnchor.y - door.y), new Vector2(room.d_Size.d_nWidth - 1, room.d_Size.d_nHeight - 1) ); //check if is collided with exist rooms foreach (DSavedRoom _sroom in m_RoomList) { _savedRoom = _sroom.d_Rect; if (_newRoom.Overlaps(_savedRoom)) { return(false); } } return(true); }
public bool Equals(DPointN other) { return(x == other.x && y == other.y); }
public DDoor(int xval = 0, int yval = 0, short nPosition = TOP) { x = xval; y = yval; d_nPosition = nPosition; d_ptGlobalPos = new DPointN(); }
private static void RegisterNewRoom(DRoom room, DDoor door /*the one connected with the map*/, DPointN globalAnchor) { //DOC: //recheck the opendoor list with the new room, remove unaccessable doors; //add new doors to opendoorlist Rect _newRoom = new Rect( new Vector2(globalAnchor.x - door.x, globalAnchor.y - door.y), new Vector2(room.d_Size.d_nWidth - 1, room.d_Size.d_nHeight - 1) ); //set position for new room's doors foreach (DDoor _dr in room.d_DoorList) { _dr.d_ptGlobalPos = new DPointN(globalAnchor.x - door.x + _dr.x, globalAnchor.y - door.y + _dr.y); } //check new doors with the opening doors for (LinkedListNode <DDoor> _node = m_OpeningDoorList.First; _node != null;) { LinkedListNode <DDoor> _tempNode = _node.Next; if (CheckDoorWithRoom(_newRoom, _node.Value.d_ptGlobalPos)) { //if (_newRoom.Contains(_node.Value.d_ptGlobalPos.ToVec2())) { //the door should be removed anyway m_OpeningDoorList.Remove(_node); LinkedListNode <DDoor> _rmDoor = room.d_DoorList.First; for (; _rmDoor != null;) { if (_rmDoor.Value.d_ptGlobalPos.Equals(_node.Value.d_ptGlobalPos)) { //door coincided. Form a closed door m_ClosedDoorList.AddLast(_rmDoor.Value); room.d_DoorList.Remove(_rmDoor); break; } _rmDoor = _rmDoor.Next; } } _node = _tempNode; } //add new doors to opening door list for (LinkedListNode <DDoor> _rmDoor = room.d_DoorList.First; _rmDoor != null;) { bool _flag = false; foreach (DSavedRoom _room in m_RoomList) { if (CheckDoorWithRoom(_room.d_Rect, _rmDoor.Value.d_ptGlobalPos)) { //if (_room.d_Rect.Contains(_rmDoor.Value.d_ptGlobalPos.ToVec2())) { _flag = true; break; } } if (!_flag) { m_OpeningDoorList.AddLast(_rmDoor.Value); } _rmDoor = _rmDoor.Next; } //Add the room to roomlist m_RoomList.AddLast(new DSavedRoom(_newRoom, room.d_ID)); }