예제 #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Items"))
        {
            if (_playerState != PlayerState.Grabbed)
            {
                _playerState = PlayerState.Grabbed;
                _grabbedItem = other.gameObject;
                other.gameObject.GetComponent <Item>().SetGrabbed(transform);

                if (_playerState == PlayerState.Head)
                {
                    _playerState = PlayerState.GrabbedAndHead;
                }
                else
                {
                    _playerState = PlayerState.Grabbed;
                }

                gamePlaying.SubtractWeight(other.gameObject.GetComponent <Item>().weight);
                gamePlaying.SubtractStamina(other.gameObject.GetComponent <Item>().weight *gamePlaying.weightGrabCoef);
            }
        }

        if (other.gameObject.CompareTag("Finish"))
        {
            DeliveryItems();
        }
    }
예제 #2
0
파일: Item.cs 프로젝트: leoska/discord
    private void Caught(GameObject parent)
    {
        Destroy(_rigidbody2D);
        Destroy(_boxCollider2D);

        transform.parent = parent.transform;

        parent.GetComponent <PlayerController>().Caught(gameObject);

        if (_gamePlaying)
        {
            _gamePlaying.SubtractStamina(weight);
        }
    }