Example #1
0
 public void ActivateReceiver(GrabbableObjectType requestedItem)
 {
     IsActive       = true;
     DemandedObject = requestedItem.Type;
     _demandedObjectImage.sprite = requestedItem.ItemSprite;
     _neighborImage.SetActive(true);
 }
Example #2
0
        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);
 }
Example #4
0
 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;
     }
 }
Example #6
0
 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;
 }