public void OnGarbageLanded(GarbageItem item) { GarbageCount++; if (GarbageCount > API.Current.Globals.MaxGarbagePerArea && !HasTriggeredAreaFull) { HasTriggeredAreaFull = true; API.Current.GlobalEvents.TriggerGarbageAreaFull(this); } }
public void Register(GarbageItem item) { if (item == null) { Debug.LogError("attempted to register null"); return; } TotalItems++; toCleanGarbargeItems.Add(item); }
void OnItemLanded(GarbageItem item) { var area = _GetAreaOfItem(item); if (area == null) { Destroy(item.gameObject); return; } area.OnGarbageLanded(item); }
GarbageArea _GetAreaOfItem(GarbageItem item) { for (int c = 0; c < AllAreas.Count; c++) { var area = AllAreas[c]; if (area.HasItem(item)) { return(area); } } return(null); }
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); } }
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)); }