Example #1
0
 // Start is called before the first frame update
 void Start()
 {
     myRigidbody2D     = GetComponent <Rigidbody2D>();
     myConstantForce2D = GetComponent <ConstantForce2D>();
     myLashHandler     = GetComponent <LashHandler>();
     triggerCollider   = GetComponentInChildren <CapsuleCollider2D>();
 }
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.tag == "Stun Trigger")
        {
            //Debug.Log("Player in stun trigger");

            if (collision.GetComponentInParent <LashHandler>())
            {
                //Debug.Log("Got the lash handler");
                if (Input.GetKey(KeyCode.LeftShift) & grounded)
                {
                    if (!_grabbing)
                    {
                        _grabbing = true;
                        myAnimator.SetBool("grabbing", true);
                        _lashHandler  = collision.gameObject.GetComponentInParent <LashHandler>();
                        grabbedObject = collision.gameObject;
                        //myAnimator.SetBool("grabbing", true);
                    }
                }
                else
                {
                    _grabbing = false;
                    myAnimator.SetBool("grabbing", false);
                }
            }
        }
        else if (collision.tag == "Interactable Trigger")
        {
            if (collision.GetComponentInParent <LashHandler>())
            {
                //Debug.Log("Got the lash handler");
                if (Input.GetKey(KeyCode.LeftShift) & grounded)
                {
                    if (!_grabbing)
                    {
                        _grabbing = true;
                        myAnimator.SetBool("grabbing", true);
                        _lashHandler  = collision.gameObject.GetComponentInParent <LashHandler>();
                        grabbedObject = collision.gameObject;
                    }
                }
                else
                {
                    _grabbing = false;
                    myAnimator.SetBool("grabbing", false);
                }
            }
        }
        else if (collision.tag == "Source")
        {
            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                Debug.Log("Absorbing");
                AbsorbStormlight(collision.gameObject.GetComponent <StormlightSource>().TakeStormlight(_maxStormlight - _stormlight));
            }
        }
    }
Example #3
0
 // Start is called before the first frame update
 void Start()
 {
     myRigidbody2D          = GetComponent <Rigidbody2D>();
     myAnimator             = GetComponent <Animator>();
     myCapsuleCollider2D    = GetComponent <CapsuleCollider2D>();
     _player                = FindObjectOfType <PlayerController>();
     _stunThresholdConstant = _stunThreshold;
     mySpriteRenderer       = GetComponentInChildren <SpriteRenderer>();
     myStunTrigger          = GetComponentInChildren <CircleCollider2D>();
     myLashHandler          = GetComponent <LashHandler>();
     myAudioSource          = GetComponent <AudioSource>();
 }