Exemplo n.º 1
0
    public void CollectDataFromConsole()
    {
        DataConsole dc = target.GetComponent <DataConsole>();

        if (collectTime > collectCooldown)
        {
            if (dc != null && dc.CollectData(antennaTransform))
            {
                collectTime = 0.0f;
                data.CollectData(1);
            }
            else
            {
                finishCollectingEvent.Invoke();

                if (dc != null)
                {
                    dc.CloseStream(antennaTransform);
                }

                collecting      = false;
                target          = null;
                collectionPoint = null;
            }
        }
    }
    public void PlayerCollectData()
    {
        if (Input.GetKey(InputManager.Instance.GetInteractKey()) && collectTime > collectCooldown)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                DataConsole dataConsole = hit.collider.transform.gameObject.GetComponent <DataConsole>();
                float       distance    = Vector3.Distance(hit.transform.position, player.transform.position);

                if (distance <= collectRange)
                {
                    if (dataConsole && dataConsole.CollectData(dataCollectPoint))
                    {
                        collectTime = 0.0f;
                        data.CollectData(1);
                        // Debug.Log("CollectData");
                    }
                }
            }
        }
    }