/// <summary>
    /// Sets the position fo the neighbouting vertex based on the direction in which it lies
    /// </summary>
    /// <param name="vertexIndex"> Index of current vertex</param>
    /// <param name="neighbourVertex"> Neighbouring LevelGraphVertex object</param>
    /// <param name="direction"> Direction in which the neighbouring vertex lies in reference to current vertex </param>
    /// <param name="roomSpawnInfo">List of RoomSpawnParameters</param>
    private void Setposition(int vertexIndex, LevelGraphVertex neighbourVertex, GraphDirection direction, List <RoomSpawnParameters> roomSpawnInfo)
    {
        switch (direction)
        {
        case GraphDirection.North:
            roomSpawnInfo[neighbourVertex.ID].X = roomSpawnInfo[vertexIndex].X;
            roomSpawnInfo[neighbourVertex.ID].Y = roomSpawnInfo[vertexIndex].Y + _settings.roomSize;
            break;

        case GraphDirection.South:
            roomSpawnInfo[neighbourVertex.ID].X = roomSpawnInfo[vertexIndex].X;
            roomSpawnInfo[neighbourVertex.ID].Y = roomSpawnInfo[vertexIndex].Y - _settings.roomSize;
            break;

        case GraphDirection.East:
            roomSpawnInfo[neighbourVertex.ID].X = roomSpawnInfo[vertexIndex].X + _settings.roomSize;
            roomSpawnInfo[neighbourVertex.ID].Y = roomSpawnInfo[vertexIndex].Y;
            break;

        case GraphDirection.West:
            roomSpawnInfo[neighbourVertex.ID].X = roomSpawnInfo[vertexIndex].X - _settings.roomSize;
            roomSpawnInfo[neighbourVertex.ID].Y = roomSpawnInfo[vertexIndex].Y;
            break;
        }
    }
Esempio n. 2
0
    public int AddVertex(ushort roomId)
    {
        var vertex = new LevelGraphVertex(roomId);

        nodes.Add(vertex);
        vertex.ID = nodes.IndexOf(vertex);
        return(vertex.ID);
    }
Esempio n. 3
0
    public void AddVertex(short roomid, short north, short west, short east, short south)
    {
        var vertex = new LevelGraphVertex((ushort)roomid);

        vertex.AddNeighbour(north, GraphDirection.North);
        vertex.AddNeighbour(west, GraphDirection.West);
        vertex.AddNeighbour(east, GraphDirection.East);
        vertex.AddNeighbour(south, GraphDirection.South);
        nodes.Add(vertex);
        vertex.ID = nodes.IndexOf(vertex);
    }
Esempio n. 4
0
 /// <summary>
 /// Removes all edges originating from the room and despawns doors.
 /// </summary>
 /// <param name="node">Node which represents the room</param>
 public void OpenAllDoorsInRoom(LevelGraphVertex node)
 {
     for (int i = 0; i < node.neighbours.Length; i++)
     {
         if (node.neighbours[i] >= 0)
         {
             if (Exists(node.ID, node.neighbours[i]))
             {
                 DeleteEdge(node.ID, node.neighbours[i]);
             }
         }
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Add all possible edges where the room has a neighbour and spawns the doors.
 /// </summary>
 /// <param name="node">Node which represents the room</param>
 public void CloseAllDoorsInRoom(LevelGraphVertex node)
 {
     // check which doors are closed and
     for (int i = 0; i < node.neighbours.Length; i++)
     {
         if (node.neighbours[i] >= 0)
         {
             if (Exists(node.ID, node.neighbours[i]) == false)
             {
                 AddEdge(node.ID, node.neighbours[i],
                         i == (int)GraphDirection.East || i == (int)GraphDirection.West);
             }
         }
     }
 }