コード例 #1
0
 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;
 }
コード例 #2
0
    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);
    }
コード例 #3
0
    public bool CheckPair(DDoor other)
    {
        short _result = (short)(d_nPosition | other.d_nPosition);

        return((_result == 0x5) || (_result == 0xA));
    }
コード例 #4
0
    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));
    }