Exemplo n.º 1
0
    public void OnSetDirection(DragManager.Drag drag)
    {
        Vector2 start = drag.GetStart();
        Vector2 end   = drag.GetEnd();

        DrawLine(start, end);
    }
Exemplo n.º 2
0
    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);
    }
Exemplo n.º 3
0
    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);
    }
Exemplo n.º 4
0
    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;
    }
Exemplo n.º 5
0
 public void OnDragBegan(DragManager.Drag drag)
 {
     dragStartX = drag.GetStart().x;
     isDraged   = true;
 }