Exemplo n.º 1
0
    IEnumerator DoAction( )
    {
        TargetPosition.y = 0;
        Active           = true;

        Vector3 delta = TargetPosition - M_Math.GetCameraCenter();

        MDebug.Log("^cameraStart Panning " + TargetPosition.ToString());
        while (delta.magnitude > 0.1f)
        {
            delta = TargetPosition - M_Math.GetCameraCenter();
            float speed = Speed;

            if (delta.magnitude < DistanceSpeedFalloffStart)
            {
                speed *= SpeedFalloff.Evaluate((DistanceSpeedFalloffStart - delta.magnitude) / DistanceSpeedFalloffStart);
            }

            transform.Translate(Vector3.ClampMagnitude(delta.normalized * speed * Time.deltaTime, delta.magnitude), Space.World);

            Debug.DrawLine(M_Math.GetCameraCenter(), TargetPosition, Color.red);

            yield return(null);
        }
        MDebug.Log("^cameraEndPanning " + TargetPosition.ToString());
        Active = false;
        Callback();
    }
Exemplo n.º 2
0
    IEnumerator Rotate(float delta)
    {
        if (rotating)
        {
            yield break;
        }
        rotating = true;
        float rotated = 0;
        float t       = 0;

        while (Mathf.Abs(rotated) < Mathf.Abs(delta))
        {
            float target_rot = Mathf.Lerp(0, delta, t);
            float dr         = target_rot - rotated;
            rotated += dr;
            t       += Time.deltaTime * 3;
            transform.RotateAround(M_Math.GetCameraCenter(), Vector3.up, dr);
            yield return(null);
        }

        transform.RotateAround(M_Math.GetCameraCenter(), Vector3.up, rotated - delta);


        rotating = false;
    }
Exemplo n.º 3
0
    IEnumerator PanToWorldPos(Vector3 pos, float speed, EventHandler _cb)
    {
        MDebug.Log("Start Pan");
        pos.y          = 0;
        drag           = true;
        event_callback = _cb;
        Vector3 delta = pos - M_Math.GetCameraCenter();

        while (delta.magnitude > 0.1f)
        {
            transform.Translate((pos - M_Math.GetCameraCenter()).normalized * speed * Time.deltaTime, Space.World);

            delta = pos - M_Math.GetCameraCenter();

            Debug.DrawLine(M_Math.GetCameraCenter(), pos, Color.red);
            yield return(null);
        }

        if (event_callback != null)
        {
            event_callback();
            event_callback = null;
        }

        inputEnabled = true;
        drag         = false;
    }
Exemplo n.º 4
0
 protected void AttemptMove(Vector3 move)
 {
     if (Bounds != null)
     {
         transform.AttemptMoveInBounds(Bounds.Bounds(), move, M_Math.GetCameraCenter());
     }
     else
     {
         transform.Translate(move, Space.World);
     }
 }
Exemplo n.º 5
0
 void OnDrawGizmos()
 {
     Debug.DrawLine(transform.position, M_Math.GetCameraCenter());
 }