static void Generate() { Generator generator = new Generator(50, 50, new Generator.Options()); generator.graph.Print(); generator.AddRoom(new IntVector2(5, 5)); generator.graph.Print(); generator.AddRoom(new IntVector2(5, 5)); generator.graph.Print(); generator.AddRoom(new IntVector2(5, 5)); generator.graph.Print(); generator.AddRoom(new IntVector2(5, 5)); generator.graph.Print(); generator.AddRoom(new IntVector2(5, 5)); generator.graph.Print(); generator.Generate(); }
void Update() { Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit floorHit; if (Physics.Raycast(camRay, out floorHit, camRayLength, floorMask)) { transform.position = floorHit.point; } if (Input.GetMouseButtonDown(0) && Generator.isEmpty(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y)) && Physics.Raycast(camRay, camRayLength, spaceMask)) { SnapToGrid(); GameObject gm = Instantiate(placeRoom, transform.position, transform.rotation); gm.GetComponent <PlacedRoom>().Setup(room); Generator.AddRoom(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y), rotation, id); } if (Input.GetKeyDown("r")) { Rotate(); } if (Input.GetMouseButtonDown(1)) { Destroy(gameObject); holding = false; } }
void Update() { Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit floorHit; if (isFollowing) { if (Physics.Raycast(camRay, out floorHit, camRayLength, floorMask)) { transform.position = floorHit.point; } if (Input.GetMouseButtonDown(0) && Generator.isEmpty(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y)) && Physics.Raycast(camRay, camRayLength, spaceMask)) { gameObject.tag = "PlacedRoom"; GameObject gm = Instantiate(ownRoom); Generator.AddRoom(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y), rotation, id); gm.GetComponent <RoomInteractibility>().isFollowing = false; gm.GetComponent <RoomInteractibility>().SnapToGrid(); } if (Input.GetKeyDown("r")) { Rotate(); } } }
public IEnumerator Checks_If_Can_Add_In_Player_Room() { int x = 1; int y = 1; int rotation = 0; int id = 0; var generator = new GameObject().AddComponent <Generator>(); generator.SetStartingEndingPoints(1, 1, 1, 1); yield return(null); var add = Generator.AddRoom(x, y, rotation, id); Assert.AreEqual(false, add); }
public IEnumerator Adds_Room() { int x = 0; int y = 0; int rotation = 0; int id = 0; var generator = new GameObject().AddComponent <Generator>(); generator.SetStartingEndingPoints(1, 1, 1, 1); yield return(null); Generator.AddRoom(x, y, rotation, id); Assert.AreEqual(false, Generator.isEmpty(x, y)); Assert.AreEqual(rotation, Generator.checkRoomRotation(x, y)); Assert.AreEqual(id, Generator.checkRoomId(x, y)); }