private void DetectClampPoint()
    {
        Ray        clampRay = Camera.main.ScreenPointToRay(currentFingerPosition);
        RaycastHit hit;

        if (Physics.Raycast(clampRay, out hit, 100f, pickableLayers))
        {
            ClampPoint possiblePoint = hit.collider.gameObject.GetComponent <ClampPoint>();
            if (hit.collider.gameObject.tag == "ClampPoint" && !possiblePoint.Clamped)
            {
                selectedPoint = hit.collider.gameObject.GetComponent <ClampPoint>();
                clampMovingIconImage.color = OverClampPointColor;
            }
            else
            {
                selectedPoint = null;
                clampMovingIconImage.color = NeutralMovingIconColor;
            }
        }
        else
        {
            if (selectedPoint != null)
            {
                selectedPoint = null;
                clampMovingIconImage.color = NeutralMovingIconColor;
            }
        }
    }
    private void AttachClamp()
    {
        GameObject clamp = Instantiate(ClampPrefab);

        clamp.GetComponent <Clamp>().ClampAt(selectedPoint);
        clampManager.UpdateClampedPoints(selectedPoint);
        selectedPoint = null;
    }
Ejemplo n.º 3
0
 public void UpdateClampedPoints(ClampPoint point)
 {
     ClampPoints.Remove(point);
     if (ClampPoints.Count <= 0 || ClampPoints == null)
     {
         dryingTimeEnd = System.DateTime.Now.AddSeconds(dryTimeInSeconds);
         UI_Manager.DisplayResultsPanel("Your project will be dry in " + dryTimeInSeconds + " seconds.\nCome back then to continue the project");
     }
 }
 void Start()
 {
     selectedPoint = null;
     //clampIconImage = ClampIcon.GetComponent<Image>();
     clampMovingIconImage = MovingClampIcon.GetComponent <Image>();
     MovingClampIcon.SetActive(false);
     positioningClamp      = false;
     currentFingerPosition = Vector2.zero;
     clampManager          = GetComponent <ClampManager>();
 }
Ejemplo n.º 5
0
    public void ClampAt(ClampPoint point)
    {
        transform.parent        = point.GetParentTransform();
        transform.localRotation = Quaternion.Euler(point.LocalConnectionRotation);

        Vector3 position      = ClampHead.position;
        Vector3 nextPosition  = Vector3.Lerp(position, point.Position, 1.0f);
        Vector3 totalMovement = CalculateMovementVector(position, nextPosition);

        transform.position += totalMovement;

        ConnectHandle();
        point.Clamped = true;
    }
Ejemplo n.º 6
0
 public void AddClampPoint(GameObject clampPoint)
 {
     if (transform.parent != null)
     {
         clampPoint.transform.position = ClampHead.position;
         clampPoint.transform.parent   = transform.parent;
         ClampPoint point = clampPoint.GetComponent <ClampPoint>();
         float      x     = Mathf.Round(transform.rotation.eulerAngles.x);
         float      y     = Mathf.Round(transform.rotation.eulerAngles.y);
         float      z     = Mathf.Round(transform.rotation.eulerAngles.z);
         point.LocalConnectionRotation = new Vector3(x, y, z);
     }
     else
     {
         Debug.LogError("Make sure clamp is parented to the object it will be clamping to.");
     }
 }