// Update is called once per frame private void Update() { //Left Click if (Input.GetMouseButtonDown(0)) { //Stupidly complicated interact code Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition) + new Vector3(0, 0, 10); Debug.Log(pos); Shape interactedShape; if (TryGetClosestShape(pos, out interactedShape)) { if (interactedShape.Speed < maxSpeed) { interactedShape.Speed += 1; } Debug.Log("Interacted at: " + interactedShape.Center); draggedShape = interactedShape; } } if (Input.GetMouseButton(0) && draggedShape != null) { if (curDragCooldown > 0) { curDragCooldown -= Time.deltaTime; } else { float distance = Camera.main.ScreenToWorldPoint(Input.mousePosition).y - draggedShape.Center.y; Debug.Log(distance); Matrix3x3 T = IGB283Transform.Translate(new Vector2(0, distance)); draggedShape.ApplyTransformation(T); } } if (Input.GetMouseButtonUp(0)) { draggedShape = null; curDragCooldown = DragCooldown; } //Right Click if (Input.GetMouseButtonDown(1)) { //Stupidly complicated interact code Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition) + new Vector3(0, 0, 10); Debug.Log(pos); Shape interactedShape; if (TryGetClosestShape(pos, out interactedShape)) { if (interactedShape.Speed > 0) { interactedShape.Speed -= 1; } Debug.Log("Interacted at: " + interactedShape.Center); } } RotateAndTranslate(shapes[0], -1, 1); RotateAndTranslate(shapes[1], -1, 1); RotateAndTranslate(shapes[2], -1, 1); RotateAndTranslate(shapes[3], -1, 1); RotateAndTranslate(shapes[4], -1, 1); UpdateMesh(); }
public void MoveTo(Vector2 location) { meshTransform.Translate(location - pos); }