public void OnSetDirection(DragManager.Drag drag) { Vector2 start = drag.GetStart(); Vector2 end = drag.GetEnd(); DrawLine(start, end); }
public void OnSelection(DragManager.Drag drag) { Vector2 start = drag.GetStart(); Vector2 end = drag.GetEnd(); if ((start - end).magnitude < .2f) { return; } DrawBox(start, end); selectedUnits = CheckBoxForUnits(start, end); }
public void OnDrag(DragManager.Drag drag) { float delta = drag.GetEnd().x - dragStartX; Vector2 position = transform.position; position.x += delta; dragStartX += delta; dragVelocity = +delta / Time.deltaTime; position.x = Mathf.Clamp(position.x, -(selectables.Length - 1) * spacing, 0); transform.position = position; isDraged = true; }
public void SpawnPlane(DragManager.Drag drag) { Vector2 start = drag.GetStart(); Vector2 end = drag.GetEnd(); Vector2 dif = end - start; DragManager.drags[1].OnDragEnded -= SpawnPlane; if ((dif).magnitude < 0.1f) { return; } planeButton.interactable = false; planeButton.image.fillAmount = 0; GameObject planeObject = Instantiate(planePrefab, start - dif.normalized * 100, Quaternion.identity); planeObject.GetComponent <FirePlane>().SetUp(start, dif); }
public void OnSetDirectionEnded(DragManager.Drag drag) { Vector2 start = drag.GetStart(); Vector2 end = drag.GetEnd(); Vector2 dif = (end - start); Vector2 dir = dif.magnitude < 0.1f ? Vector2.up : dif.normalized; Vector2 right = Vector3.Cross(dir.normalized, Vector3.forward).normalized; Vector2 offset = Vector2.zero; if (selectedUnits.Length > 1) { offset = -right.normalized * (selectedUnits[0].radius * selectedUnits.Length) / 2; } for (int i = 0; i < selectedUnits.Length; i++) { selectedUnits[i].CommandPosition(start + offset + right * i * selectedUnits[i].radius * 2, dif); } lineRenderer.enabled = false; }