Пример #1
0
 protected virtual void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.GetComponent <Actor>() != null)
     {
         OnPickedUp?.Invoke(other.gameObject.GetComponent <Actor>());
     }
 }
    protected override void PickUp(Vector2 position, Collider2D col)
    {
        if (col != null && col.gameObject == this.gameObject && EquipmentManager.Instance.EquipmentFreeContainersAvailable && !_picked)
        {
            Vector3 tgt = Vector3.zero, scl = Vector3.zero;

            if (EquipmentManager.Instance.CurrentMode == EquipmentManager.EquipmentMode.USABLES &&
                !EquipmentManager.Instance.PanelPickableList.GetComponent <PanelGeneric>().Hidden)
            {
                tgt = Camera.main.ScreenToWorldPoint(EquipmentManager.Instance.PanelPickableList.transform.position);
            }
            else
            {
                tgt = Camera.main.ScreenToWorldPoint(EquipmentManager.Instance.ButtonEquipmentPickableToggle.transform.position);
            }
            tgt.z = transform.position.z;

            StartCoroutine(FlyToTarget(tgt, scl, FADE_OUT_TIME_SEC));

            AudioManager.Instance.PlayClip(PickUpSound);

            EquipmentManager.Instance.AddObjectToPool(this, FADE_OUT_TIME_SEC);
            InputManager.Instance.OnInputClickUp.RemoveListener(PickUp);

            _picked = true;
            OnPickedUp.Invoke(this);

            // here will play professional animation, for now just simple coroutine
            // destruction will also be performed somewhat smarter

            // yeah right.
        }
    }
Пример #3
0
 public void PickUp(OnPickedUp callback)
 {
     if (!isStillExists)
     {
         return;
     }
     callback(this);
 }
Пример #4
0
        protected virtual void PickedUp()
        {
            showPreview = true;
            if (isSnapped)
            {
                Unsnapped();
            }
            // TODO trigger Prise Module
            AkSoundEngine.PostEvent("Play_Prendre_Module", gameObject);

            OnPickedUp?.Invoke();
            SendMessage("OnHintInteraction", SendMessageOptions.DontRequireReceiver);
        }
Пример #5
0
    /**
     * Let the given player pick up this object.
     */
    public void Pickup(PlayerController carrier)
    {
        if (!IsBeingCarried)
        {
            // A player who is already carrying something can not pickup something else
            if (!carrier.IsCarryingSomething)
            {
                _carrier       = carrier;
                IsBeingCarried = true;

                foreach (var interactive in GetComponents <Interactive>())
                {
                    interactive.enabled = false;
                }

                // Cache original layer and change layer to "Carried", see description of _cachedLayer field for explanation
                _cachedLayer          = this.gameObject.layer;
                this.gameObject.layer = LayerMask.NameToLayer("Carried");

                // Cache original mass and change mass to 0, see description of _cachedMass field for explanation
                _cachedMass = _physicsEffects.rigidbody2D.mass;
                _physicsEffects.rigidbody2D.mass = 0;

                _hingeJoint2D.connectedBody = _carrier.Rigidbody2D;
                Physics2D.IgnoreCollision(_collider, _carrier.Collider);
                // temporally change sorting order to draw carried gameobject on top
                _renderer.sortingOrder++;
                _physicsEffects.Teleport(_carrier.CarryPosition);

                _carrier.InitCarryingState(this);
                _carrier.Input.EnableButtons((Button.Throw, true));

                // While being thrown, we might loose contact to safe terrain, so we register this behavior as terrain unsafe
                // for respawning
                if (TryGetComponent <Spawnable>(out var spawnable))
                {
                    spawnable.RegisterTouchingUnsafeTerrain(this);
                }

                OnPickedUp?.Invoke(_carrier);

                StartCoroutine(PickUpCoroutine());
            }
        }

        else
        {
            Debug.LogWarning("Tried to pick up object, which is already being carried.");
        }
    }
Пример #6
0
        private void OnTriggerEnter(Collider other)
        {
            if (WasPickedUp)
            {
                return;
            }

            var inventory = other.GetComponent <Inventory>();

            if (inventory != null)
            {
                inventory.Pickup(this);
                OnPickedUp?.Invoke();
            }
        }
Пример #7
0
        private void OnAttachedToHand(Hand hand)
        {
            if (_stopUnwindingSequence != null)
            {
                StopCoroutine(_stopUnwindingSequence);
                _stopUnwindingSequence = null;
            }

            _state             = CubimalState.Held;
            _currentSettleTime = 0f;
            _isSettling        = false;

            StopMoving();

            OnPickedUp?.Invoke();
        }
Пример #8
0
    private void OnMouseDown()
    {
        if (isLocked)
        {
            return;
        }
        isBeingDragged = true;

        if (dragged == null)
        {
            dragged = this;
        }
        else
        {
            throw new System.Exception("Error: Multiple PlaceableGameObjects are being dragged at once: '" + name + "' and '" + dragged.name + "'");
        }

        currentPlacementLocation?.Remove(this);
        transform.parent = null;
        //if (currentPlacementLocation != null) placementLocationQueue.Add(currentPlacementLocation);
        OnPickedUp?.Invoke(this);
    }
Пример #9
0
 //When the object is clicked, start dragging it
 void OnMouseDown()
 {
     isPickedUp = true;
     OnPickedUp?.Invoke(this);
 }
Пример #10
0
    // Fires Picked up event
    public void InvokeOnPickedUp()
    {
        OnPickedUp?.Invoke(this);

        Debug.Log($"picked up..");
    }
Пример #11
0
 public void PickUp(PlayerInputComponent inInputComponent)
 {
     _inputComponent = inInputComponent;
     OnPickedUp?.Invoke();
 }