public void OnGarbageLanded(GarbageItem item)
 {
     GarbageCount++;
     if (GarbageCount > API.Current.Globals.MaxGarbagePerArea && !HasTriggeredAreaFull)
     {
         HasTriggeredAreaFull = true;
         API.Current.GlobalEvents.TriggerGarbageAreaFull(this);
     }
 }
Пример #2
0
    public void Register(GarbageItem item)
    {
        if (item == null)
        {
            Debug.LogError("attempted to register null");
            return;
        }

        TotalItems++;
        toCleanGarbargeItems.Add(item);
    }
Пример #3
0
    void OnItemLanded(GarbageItem item)
    {
        var area = _GetAreaOfItem(item);

        if (area == null)
        {
            Destroy(item.gameObject);
            return;
        }

        area.OnGarbageLanded(item);
    }
Пример #4
0
    GarbageArea _GetAreaOfItem(GarbageItem item)
    {
        for (int c = 0; c < AllAreas.Count; c++)
        {
            var area = AllAreas[c];
            if (area.HasItem(item))
            {
                return(area);
            }
        }

        return(null);
    }
Пример #5
0
    public void ItemCleaned(GarbageItem item)
    {
        if (item.GetGroup() != this)
        {
            Debug.LogWarning("Item is not part of this group");
            return;
        }

        if (toCleanGarbargeItems.Remove(item))
        {
            TotalCleaned++;
            OnCleanedEvent.Invoke(this, PercentageCleaned());
            Destroy(item.gameObject);
        }
    }
Пример #6
0
    public void Tick()
    {
        HealthMeter.value = Health / 100f;

        if (_pickedUpItem && Input.GetKeyUp(KeyCode.E))
        {
            _pickedUpItem.Drop();
            _pickedUpItem = null;

            return;
        }

        var        ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
        RaycastHit hitInfo;


        if (Physics.Raycast(ray, out hitInfo))
        {
            if (_pickedUpItem != null)
            {
                return;
            }

            if (hitInfo.distance > 5.0f || hitInfo.collider.gameObject.layer != LayerMask.NameToLayer("GarbageItem"))
            {
                return;
            }

            var item = hitInfo.collider.GetComponent <GarbageItem>();
            item.Highlight(Color.green);

            if (Input.GetKeyUp(KeyCode.E) && item != _pickedUpItem)
            {
                _pickedUpItem = item;
                item.Pickup(ItemSlot.transform);
            }
        }
    }
 public bool HasItem(GarbageItem item)
 {
     return(OwnBoxCollider.bounds.Intersects(item.OwnCollider.bounds));
 }