コード例 #1
0
ファイル: MapGenerator.cs プロジェクト: gsakis/377asn4
    private void GenerateConnectedRoomsMap()
    {
        GameObject wallsObject = GameObject.Find("Environment/Walls");
        //GameObject waypointsObject = GameObject.Find("Game/Waypoints");

        var connectedRooms = new ConnectedRooms(columns, rows);

        connectedRooms.BuildMap();

        //TODO: create variable that toggles this
        if (cornerGraph)
        {
            connectedRooms.AddCornerWaypoints();
        }
        else
        {
            connectedRooms.AddPointsOfVisibilityWaypoints();
        }

        connectedRooms.OutputMap("ConnectedRooms.txt");
        ////ConnectedRooms.SaveMap("ConnectedRooms.xml");

        var wallScale = new Vector3(cellWidth, WALL_HEIGHT, cellHeight);

        //const float WAYPOINT_RADIUS = 1.0f; // entity size
        World.Instance.Waypoints = new List <Vector3>();

        for (int column = 0; column < connectedRooms.Columns; column++)
        {
            for (int row = 0; row < connectedRooms.Rows; row++)
            {
                if (connectedRooms.Map[column, row] == (int)ConnectedRooms.MapElements.Wall)
                {
                    var wallPosition =
                        new Vector3(
                            World.Instance.Center.x - World.Instance.Size.x / 2 + column * cellWidth + cellWidth / 2.0f,
                            transform.position.y + transform.localScale.y / 2.0f,
                            World.Instance.Center.y - World.Instance.Size.y / 2 + row * cellHeight + cellHeight / 2.0f);

                    GameObject wall = Instantiate(wallTemplate, wallPosition, Quaternion.identity) as GameObject;
                    wall.transform.localScale = wallScale;
                    wall.name             = "Wall_" + row + "_" + column;
                    wall.transform.parent = wallsObject.transform;
                }
                else if (connectedRooms.Map[column, row] == (int)ConnectedRooms.MapElements.Waypoint)
                {
                    var waypointPosition =
                        new Vector3(
                            World.Instance.Center.x - World.Instance.Size.x / 2 + column * cellWidth + cellWidth / 2.0f,
                            transform.position.y, // + transform.localScale.y / 2.0f,
                            World.Instance.Center.y - World.Instance.Size.y / 2 + row * cellHeight + cellHeight / 2.0f);

                    World.Instance.Waypoints.Add(waypointPosition);

//					var waypoint =  GameObject.CreatePrimitive(PrimitiveType.Sphere);
//					Destroy(waypoint.collider);
//					waypoint.transform.position = waypointPosition;
//					waypoint.transform.localScale = new Vector3(WAYPOINT_RADIUS, WAYPOINT_RADIUS, WAYPOINT_RADIUS);
//					waypoint.name = "povWaypoint_" + row + "_" + column;
//					waypoint.collider.enabled = false;
//					waypoint.renderer.enabled = true;
//					waypoint.transform.parent = waypointsObject.transform;
                }
            }
        }

        wallScale.y *= 3;

        for (int column = -1; column < connectedRooms.Columns + 1; column++)
        {
            for (int row = -1; row < connectedRooms.Rows + 1; row++)
            {
                if (column != -1 && column != connectedRooms.Columns &&
                    row != -1 && row != connectedRooms.Rows)
                {
                    continue;
                }

                var wallPosition =
                    new Vector3(
                        World.Instance.Center.x - World.Instance.Size.x / 2 + column * cellWidth + cellWidth / 2.0f,
                        transform.position.y + transform.localScale.y / 2.0f,
                        World.Instance.Center.y - World.Instance.Size.y / 2 + row * cellHeight + cellHeight / 2.0f);

                GameObject wall = Instantiate(wallTemplate, wallPosition, Quaternion.identity) as GameObject;
                wall.transform.localScale = wallScale;
                wall.name             = "Wall_" + row + "_" + column;
                wall.transform.parent = wallsObject.transform;
            }
        }
    }
コード例 #2
0
 /// <summary>
 /// Shows whether this room is commected to the otherRoom
 /// </summary>
 /// <param name="otherRoom"></param>
 /// <returns></returns>
 public bool IsConnected(Room otherRoom)
 {
     return(ConnectedRooms.Contains(otherRoom));
 }
コード例 #3
0
 public bool IsConnected(Room otherRoom) => ConnectedRooms.Contains(otherRoom);
コード例 #4
0
ファイル: Map.cs プロジェクト: chadng/SuperFantasticSteampunk
 public void ConnectTo(MapRoom room)
 {
     ConnectedRooms.Add(room);
     room.ConnectedRooms.Add(this);
 }