public void ActivateReceiver(GrabbableObjectType requestedItem) { IsActive = true; DemandedObject = requestedItem.Type; _demandedObjectImage.sprite = requestedItem.ItemSprite; _neighborImage.SetActive(true); }
private void GenerateNeighbors(int amount) { _timeSinceLastSpawn = 0.0f; for (int i = 0; i < amount; i++) { int randomIndex; GrabbableReceiver receiver; while (true) { randomIndex = Random.Range(0, _windows.Length - 1); receiver = _windows[randomIndex].GetComponent <GrabbableReceiver>(); if (!receiver.IsActive) { _currentReceivers.Add(receiver); EGrabbableObjects randomObject = (EGrabbableObjects)Random.Range(1, (int)(EGrabbableObjects.COUNT - 1)); receiver.ActivateReceiver(_scenePool.GetGrabbableObjectType(randomObject)); break; } } if (_currentReceivers.Count == _settings.MaxNeighborAmount) { return; } } }
public GrabbableObjectType GetGrabbableObjectType(EGrabbableObjects type) { foreach (var got in GrabbableObjectReferences) { if (got.Type == type) { return(got); } } Debug.LogError("BUG BUG BUG BUG"); return(null); }
public void OnObjectReceived(EGrabbableObjects receivedObject) { if (receivedObject == DemandedObject) { new OnSlingshotHit(this); _neighborImage.SetActive(false); DemandedObject = EGrabbableObjects.None; GameManager.Instance.AddPoint(1); } else { new OnSlingshotMiss(); } // TODO Add point or whatever }
private void ReleaseOrGrab(UnityEngine.InputSystem.InputAction.CallbackContext obj) { // User can grab if (ClosestGrabbable != null && ClosestGrabbable.Type != EGrabbableObjects.None && CurrentlyGrabbedObject == EGrabbableObjects.None) { CurrentlyGrabbedObject = ClosestGrabbable.Type; ChangePlayerObjectActivation(true); ClosestGrabbable = null; } // We try to release else { ReleaseObject(); CurrentlyGrabbedObject = EGrabbableObjects.None; } }
public OnObjectWasGrabbed(EGrabbableObjects newlyGrabbedObject) : base("Event raised when the user grabbed an object") { NewlyGrabbedObject = newlyGrabbedObject; FireEvent(this); }
private void ReleaseSlingshot(UnityEngine.InputSystem.InputAction.CallbackContext obj) { CurrentlyGrabbedObject = EGrabbableObjects.None; }