public void PickUpGun(GunController newGun)
 {
     newGun.PickedUp(GetComponent <Rigidbody2D>());
     guns.Add(newGun);
     GameManager.Instance.AddWeapon(newGun.name);
     if (newGun.transform.parent)
     {
         if (newGun.transform.parent.GetComponent <Cupgrade>() != null)
         {
             newGun.transform.parent.GetComponent <Cupgrade>().RemoveItem(newGun.gameObject);
         }
     }
     newGun.transform.parent        = weaponHolder;
     newGun.transform.localPosition = Vector3.zero;
     newGun.transform.localRotation = Quaternion.identity;
     newGun.transform.localScale    = new Vector3(Mathf.Abs(newGun.transform.localScale.x), Mathf.Abs(newGun.transform.localScale.y), Mathf.Abs(newGun.transform.localScale.z));
     if (shooting.GetWeaponHeld() == null)
     {
         SwitchToWeapon(guns.Count - 1);
     }
     else
     {
         newGun.gameObject.SetActive(false);
     }
     return;
 }
    private void Update()
    {
        if (GameManager.gamePaused)
        {
            return;
        }
        // Aiming calculs
        mousePos           = cam.ScreenToWorldPoint(Input.mousePosition);
        crosshair.position = (Vector2)mousePos;
        lookPos            = mousePos - weaponHolder.position;
        angle = Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;

        if (Mathf.Abs(angle) > 100)
        {
            GFX.flipX = true;
        }
        else if (Mathf.Abs(angle) < 80)
        {
            GFX.flipX = false;
        }

        weaponHolder.transform.localPosition = new Vector3(GFX.flipX ? -.2f : .2f, -.16f, 0);
        weaponHolder.transform.localScale    = new Vector3(1, GFX.flipX ? -1 : 1, 1);

        // Shooting
        GunController weaponHeld = shooting.GetWeaponHeld();

        if (weaponHeld != null)
        {
            weaponHeld.MyInput(Input.GetMouseButton(0), Input.GetMouseButtonDown(0), Input.GetKey(KeyCode.R));
            if (weaponHeld.GetReloading())
            {
                reloadingProgress += Time.deltaTime / weaponHeld.GetReloadTime();
            }
            else
            {
                reloadingProgress = 0;
            }

            UIManager.Instance.SetReloadingBar(reloadingProgress);
        }

        // Inventory
        Collider2D collider = Physics2D.Raycast(cam.transform.position, crosshair.position - cam.transform.position, Vector2.Distance(cam.transform.position, crosshair.position), cupgradeLayer | gunLayer).collider;

        if (collider)
        {
            if (Vector2.Distance(transform.position, collider.transform.position) < radius)
            {
                mouseRight.SetActive(true);
                if (Input.GetMouseButtonDown(1))
                {
                    Cupgrade      isCupgrade = collider.GetComponent <Cupgrade>();
                    GunController isGun      = collider.GetComponent <GunController>();
                    if (isCupgrade != null)
                    {
                        inventory.Interact(collider);
                    }
                    else if (isGun)
                    {
                        inventory.PickUpGun(isGun);
                    }
                }
            }
            else
            {
                mouseRight.SetActive(false);
            }
        }
        else
        {
            mouseRight.SetActive(false);
        }


        // Switching
        if (Input.GetAxis("Mouse ScrollWheel") < 0f)
        {
            inventory.SwitchUp();
        }
        if (Input.GetAxis("Mouse ScrollWheel") > 0f)
        {
            inventory.SwitchDown();
        }

        // Moving
        movements.SetMovements(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        anim.SetBool("isRunning", Math.Abs(Input.GetAxisRaw("Horizontal")) > 0 || Math.Abs(Input.GetAxisRaw("Vertical")) > 0);

        if (Input.GetKeyDown(KeyCode.Space))
        {
            StartCoroutine(movements.Dash());
        }
    }