bool Check_All_Superimpose(Vector2 startpos, Vector2 endpos) { foreach (Room temproom in Map.roomObjs) { if (SimpleFunctions.Check_Superimpose(temproom.start, temproom.end, startpos, endpos, 2) == true || transform.position.x <= 0 || transform.position.y <= 0) { return(true); } } return(false); }
bool Check_All_Superimpose(Vector2 startpos, Vector2 endpos, List <Room> exceptions) { foreach (Room temproom in Map.roomObjs) { bool ok = true; foreach (Room r in exceptions) { if (temproom == r) { ok = false; break; } } if (ok) { if (SimpleFunctions.Check_Superimpose(temproom.start, temproom.end, startpos, endpos, 2) == true || transform.position.x <= 0 || transform.position.y <= 0) { return(true); } } } return(false); }
private static bool CreateShopToRight(Room room, GameObject shop) { Vector3 position = new Vector3(room.end.x - 5, room.end.y - 4, 0); Vector3 endposition = new Vector3(position.x + 4, position.y + 4); GameObject s = room.CreateEnvironmentObject(shop, position); foreach (GameObject d in room.Doors) { if (SimpleFunctions.Check_Superimpose(position, endposition, d.transform.position, d.transform.position, 2)) { GameObject.Destroy(s); return(false); } } Transform[] shopsEnv = s.GetComponentsInChildren <Transform>(); foreach (Transform t in shopsEnv) { room.EnvironmentTiles.Add(new EnvironmentTile(t.gameObject, room)); } return(true); }
// Start is called before the first frame update void LateUpdate() { if (Time.timeScale != 0) { if (Player.instance != null) { if (bigMap) { sightMousePos = Player.instance.sightCamera.ScreenToWorldPoint(Input.mousePosition); if (teleport != null) { Vector2 worldMousePos = cam.ScreenToWorldPoint(Input.mousePosition); foreach (Room r in Map.roomObjs) { if (SimpleFunctions.Check_Superimpose(worldMousePos, r.start, r.end)) { if (r.hereWasPlayer) { r.HighLight(true); if (Input.GetButton("Fire1")) { teleport.TeleportTo(r); TurnOffBigMap(false); } break; } } else { r.HighLight(false); } } } Vector3 v = transform.position; if (sightMousePos.x < Player.instance.transform.position.x - 4) { v.x -= sightMousePos.normalized.x; } else if (sightMousePos.x > Player.instance.transform.position.x + 4) { v.x += sightMousePos.normalized.x; } if (sightMousePos.y < Player.instance.transform.position.y - 3) { v.y -= sightMousePos.normalized.y; } else if (sightMousePos.y > Player.instance.transform.position.y + 3) { v.y += sightMousePos.normalized.y; } v.x = Mathf.Clamp(v.x, Map.lowestVector.x, Map.highestVector.x); v.y = Mathf.Clamp(v.y, Map.lowestVector.y, Map.highestVector.y); transform.position = Vector3.MoveTowards(transform.position, v, 1f); } } } }