Exemplo n.º 1
0
    void OnFetch(Throwable other)
    {
        Debug.Log("Fetching object at: " + other.transform.position);
        // if (IsThirsty() || IsHungry()) return;
        if (BusyState == BusyType.SearchingForResource)
        {
            return;
        }
        else
        {
            SetBusy(BusyType.Fetching);
        }
        var pos = other.transform.position;

        agent.SetDestination(pos);
        var distance = Vector3.Distance(pos, transform.position);

        // Debug.Log(distance);
        if (distance < 1.0f)
        {
            var fetch = transform.Find("FetchLoc");
            if (fetch == null)
            {
                other.transform.parent = transform;
            }
            else
            {
                var scale = other.transform.localScale;
                other.transform.position      = Vector3.zero;
                other.transform.parent        = fetch;
                other.transform.localRotation = Quaternion.identity;
                other.transform.localPosition = Vector3.zero;
            }
            other.Reset();
        }
    }