Example #1
0
 public virtual void mouseUp(VectorXY worldPoint)
 {
     if (cursorUp != null)
     {
         cursorUp(worldPoint);
     }
 }
Example #2
0
 public virtual void mouseDown(VectorXY worldPoint)
 {
     if (cursorDown != null)
     {
         cursorDown(worldPoint);
     }
 }
Example #3
0
 public virtual void drag(VectorXY worldPoint)
 {
     if (cursorDrag != null)
     {
         cursorDrag(worldPoint);
     }
 }
Example #4
0
 private void click(VectorXY worldPoint)
 {
     if (mouseIsHoveringOverUs())
     {
         AudioManager.Instance.play(clickAudio);
         paramUpdaterSet.Invoke();
     }
 }
Example #5
0
    public float angleRadians()
    {
        //swapping components so that the resulting angle "a" satisfies:
        // (cos(a), sin(a)) == this vector normalized
        VectorXY p_vector2 = swapped;

        if (p_vector2.x < 0)
        {
            return(Mathf.PI * 2f - Mathf.Atan2(p_vector2.x, p_vector2.y) * -1f);
        }
        else
        {
            return(Mathf.Atan2(p_vector2.x, p_vector2.y));
        }
    }
Example #6
0
    public static T findClosestToMainCameraXY <T>() where T : Component
    {
        if (!Camera.main)
        {
            return(null);
        }
        VectorXY dist = new VectorXY(999999f); VectorXY next;
        T        result = null;

        foreach (T t in Object.FindObjectsOfType <T>())
        {
            next = Camera.main.transform.position - t.transform.position;
            if (next.magnitudeSquared < dist.magnitudeSquared)
            {
                dist   = next;
                result = t;
            }
        }
        return(result);
    }
Example #7
0
    private static Vector3 nextOpenNodePosition()
    {
        Node[] nodes = FindObjectsOfType <Node>();
        if (nodes.Length == 0)
        {
            return(Vector3.zero);
        }

        VectorXY lowerRight = new VectorXY(-9999f);
        VectorXY upperLeft  = new VectorXY(9999f);

        foreach (Node n in nodes)
        {
            lowerRight = VectorXY.max(lowerRight, new VectorXY(n.transform.position));
            upperLeft  = VectorXY.min(upperLeft, new VectorXY(n.transform.position));
        }
        Vector3 target = lowerRight.vector3() + Vector3.right * 16f;

        if (nodes.Length % COLUMNS == 0)
        {
            target = new Vector3(upperLeft.x, lowerRight.y - 16f, 0f);
        }
        return(target);
    }
Example #8
0
 public bool contains(VectorXY v)
 {
     return(v > min && v < max);
 }
Example #9
0
 public static VectorXY min(VectorXY a, VectorXY b)
 {
     return(new VectorXY(a.x < b.x ? a.x : b.x, a.y < b.y ? a.y : b.y));
 }
Example #10
0
 public static VectorXY max(VectorXY a, VectorXY b)
 {
     return(new VectorXY(a.x > b.x ? a.x : b.x, a.y > b.y ? a.y : b.y));
 }
Example #11
0
 public bool sympatheticDirection(VectorXY other)
 {
     return(dot(other) > 0f);
 }
Example #12
0
 public float dot(VectorXY other)
 {
     return(Vector2.Dot(v, other.v));
 }