예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (!isHolding)
        {
            if (Input.GetMouseButtonDown(1) && timer > 70)
            {
                grabMaster.getClosest(grabMaster.grabs);
                isHolding = true;
            }
            timer++;
        }

        else if (isHolding && Input.GetMouseButtonDown(1))
        {
            child = GameObject.Find("Grabbed");
            rigid = child.GetComponent <Rigidbody2D>();
            if (child.tag == "GrabAble")
            {
                grappleReg = child.GetComponent <GrappleObjectScript>();
                grappleReg.Shot(true);
                rigid.isKinematic = false;
            }
            else if (child.tag == "GrabAbleReflector")
            {
                reflector = child.GetComponent <ReflectorScript>();
                reflector.Shot(true);
                rigid.isKinematic = false;
            }

            currentTimeMulti = GameStateManager.GetTimeMulti();
            rigid.AddForce(child.transform.up * 0.3f * currentTimeMulti);
            grabMaster.removeChild();

            isHolding = false;
            timer     = 0;
        }

        if (grabMaster.transform.childCount == 0)
        {
            isHolding = false;
        }
        //Debug.Log("ChildCount:" + grabMaster.transform.childCount);
    }