// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { Menu.SetActive(true); Emeth.SendMessage("GiveCoordinates", new Stack <Vector2> ()); Inventory.SetActive(false); gameObject.SetActive(false); } if (Input.GetMouseButtonDown(0)) { Vector2 Position = Camera.main.ScreenToWorldPoint(Input.mousePosition); for (int i = 0; i < activeArea.CurrentArea().giveDoorCount(); i++) { if (activeArea.CurrentArea().GiveDoor(i).giveDoorObject().GetComponent <Collider2D> () != null && activeArea.CurrentArea().GiveDoor(i).giveDoorObject().GetComponent <Collider2D> ().OverlapPoint(Position)) { temporary.setClicked(false); activeArea.CurrentArea().GiveDoor(i).setClicked(true); temporary = activeArea.CurrentArea().GiveDoor(i); Emeth.SendMessage("GiveCoordinates", activeArea.CurrentArea().Pathfinder(Emeth.transform.position, activeArea.CurrentArea().GiveDoor(i).givePoint())); wasClicked = true; operateObject = ""; Inventory.SendMessage("CombItemNull"); break; } } for (int i = 0; i < activeArea.CurrentArea().giveOperablesCount(); i++) { if (activeArea.CurrentArea().GiveOperable(i).giveOperableObject() != null && activeArea.CurrentArea().GiveOperable(i).giveOperableObject().GetComponent <Collider2D> () != null && activeArea.CurrentArea().GiveOperable(i).giveOperableObject().GetComponent <Collider2D> ().OverlapPoint(Position)) { temporary.setClicked(false); activeArea.CurrentArea().GiveOperable(i).setClicked(true); temporary = activeArea.CurrentArea().GiveOperable(i); Emeth.SendMessage("GiveCoordinates", activeArea.CurrentArea().Pathfinder(Emeth.transform.position, activeArea.CurrentArea().GiveOperable(i).givePoint())); wasClicked = true; break; } } if (operateObject != "" && Emeth.GetComponent <Collider2D> ().OverlapPoint(Position)) { temporary.setClicked(false); Emeth.SendMessage("GiveCoordinates", new Stack <Vector2> ()); Emeth.SendMessage("Operate", operateObject); wasClicked = true; operateObject = ""; Inventory.SendMessage("CombItemNull"); } if (wasClicked == false) { Emeth.SendMessage("GiveCoordinates", activeArea.CurrentArea().Pathfinder(Emeth.transform.position, Position)); temporary.setClicked(false); operateObject = ""; Inventory.SendMessage("CombItemNull"); } wasClicked = false; } if (temporary.isNear(Emeth.transform.position)) { for (int i = 0; i < activeArea.CurrentArea().giveDoorCount(); i++) { Door tt = activeArea.CurrentArea().GiveDoor(i); if (tt.isNear(Emeth.transform.position)) { if (BoolsInts.boolies[tt.giveDoorObject().GetComponent <DoorScript> ().unlocked]) { Emeth.SendMessage("GiveCoordinates", new Stack <Vector2> ()); Vector2 teleport = tt.giveTargetPoint(); activeArea.setArea(tt.giveTargetArea()); Emeth.transform.position = teleport; if (Emeth.transform.position.x < tt.giveDoorObject().transform.position.x&& Emeth.transform.localScale.x < 0) { Emeth.transform.localScale = new Vector3(Emeth.transform.localScale.x * -1, Emeth.transform.localScale.y, Emeth.transform.localScale.z); } else if (Emeth.transform.position.x > tt.giveDoorObject().transform.position.x&& Emeth.transform.localScale.x > 0) { Emeth.transform.localScale = new Vector3(Emeth.transform.localScale.x * -1, Emeth.transform.localScale.y, Emeth.transform.localScale.z); } } else { CommentController.SetActive(true); CommentController.SendMessage("StartComment", "It's locked."); } break; } } for (int i = 0; i < activeArea.CurrentArea().giveOperablesCount(); i++) { Operable tt = activeArea.CurrentArea().GiveOperable(i); if (tt.isNear(Emeth.transform.position) && tt.giveOperableObject() != null) { Emeth.SendMessage("GiveCoordinates", new Stack <Vector2>()); if (Emeth.transform.position.x < tt.giveOperableObject().transform.position.x&& Emeth.transform.localScale.x > 0) { Emeth.transform.localScale = new Vector3(Emeth.transform.localScale.x * -1, Emeth.transform.localScale.y, Emeth.transform.localScale.z); } else if (Emeth.transform.position.x > tt.giveOperableObject().transform.position.x&& Emeth.transform.localScale.x < 0) { Emeth.transform.localScale = new Vector3(Emeth.transform.localScale.x * -1, Emeth.transform.localScale.y, Emeth.transform.localScale.z); } Inventory.SendMessage("CombItemNull"); tt.giveOperableObject().SendMessage("Operate", operateObject); operateObject = ""; break; } } temporary.setClicked(false); } // examining if (Input.GetMouseButtonDown(1)) { Vector2 Position = Camera.main.ScreenToWorldPoint(Input.mousePosition); for (int i = 0; i < activeArea.CurrentArea().giveDoorCount(); i++) { if (activeArea.CurrentArea().GiveDoor(i).giveDoorObject().GetComponent <Collider2D> ().OverlapPoint(Position)) { Emeth.SendMessage("GiveCoordinates", new Stack <Vector2>()); activeArea.CurrentArea().GiveDoor(i).giveDoorObject().SendMessage("Comment"); break; } } for (int i = 0; i < activeArea.CurrentArea().giveOperablesCount(); i++) { if (activeArea.CurrentArea().GiveOperable(i).giveOperableObject() != null && activeArea.CurrentArea().GiveOperable(i).giveOperableObject().GetComponent <Collider2D> ().OverlapPoint(Position)) { Emeth.SendMessage("GiveCoordinates", new Stack <Vector2>()); activeArea.CurrentArea().GiveOperable(i).giveOperableObject().SendMessage("Comment"); break; } } } // kamera Camera.main.transform.position = new Vector3(Emeth.transform.position.x, Emeth.transform.position.y + 2.5f, Camera.main.transform.position.z); if (Camera.main.transform.position.x + Camera.main.orthographicSize * Camera.main.aspect >= activeArea.CurrentArea().giveMaxX()) { Camera.main.transform.position = new Vector3(activeArea.CurrentArea().giveMaxX() - Camera.main.orthographicSize * Camera.main.aspect, Camera.main.transform.position.y, Camera.main.transform.position.z); } else if (Camera.main.transform.position.x - Camera.main.orthographicSize * Camera.main.aspect <= activeArea.CurrentArea().giveMinX()) { Camera.main.transform.position = new Vector3(activeArea.CurrentArea().giveMinX() + Camera.main.orthographicSize * Camera.main.aspect, Camera.main.transform.position.y, Camera.main.transform.position.z); } if (Camera.main.transform.position.y + Camera.main.orthographicSize >= activeArea.CurrentArea().giveMaxY()) { Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, activeArea.CurrentArea().giveMaxY() - Camera.main.orthographicSize, Camera.main.transform.position.z); } else if (Camera.main.transform.position.y - Camera.main.orthographicSize <= activeArea.CurrentArea().giveMinY()) { Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, activeArea.CurrentArea().giveMinY() + Camera.main.orthographicSize, Camera.main.transform.position.z); } }