using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Basket : MonoBehaviour
{
    public float edge = 16;
    private int numApple;
    public Text strApple;
    // Start is called before the first frame update
    void Start()
    {
        numApple = 0;
        strApple.text = "Apple Picked: " + numApple.ToString();
    }

    // Update is called once per frame
    void Update()
    {
        Vector3 posWorld;
        posWorld = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        transform.position = new Vector3(
            Mathf.Clamp(posWorld.x, -edge, edge), 
            transform.position.y, 
            transform.position.z
        );

    }

    void OnCollisionEnter(Collision other)
    {
        Destroy(other.gameObject, 0.5f);
        numApple++;
        strApple.text = "Apple Picked: " + numApple.ToString();
    }
}
