Exemplo n.º 1
0
 void Update()
 {
     if (isActive)
     {
         climber.doClimb();
     }
 }
Exemplo n.º 2
0
 void Update()
 {
     if (isActive)
     {
         climber.doClimb();
         //snip off extra?
     }
 }
Exemplo n.º 3
0
    void Update()
    {
        if (changeGravity)
        {
                        #if UNITY_IPHONE && !UNITY_EDITOR
            h     = Input.acceleration.x;
            v     = Input.acceleration.y;
            other = Input.acceleration.z;
                        #else
            h = Input.GetAxis("Horizontal");
            v = Input.GetAxis("Vertical");
                        #endif
            //
            gravDir = new Vector3(h, v, 0);
            //angle = Vector3.Angle(gravDir, Vector3.down);
            if (h != 0 || v != 0)
            {
                Physics2D.gravity = gravDir.normalized * 5;
            }
        }

        Vector3 pointTouched = Vector3.zero;

        //
                #if UNITY_IPHONE && !UNITY_EDITOR
        if (Input.touchCount > 0 && !fireRestraint)
        {
            Touch touch = Input.GetTouch(0);
            pointTouched = Camera.main.ScreenToWorldPoint(touch.position);
                        #else
        if (Input.GetButton("Fire1") && !fireRestraint)
        {
            pointTouched = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                                #endif
            RaycastHit2D hit = Physics2D.Raycast(pointTouched, Vector2.zero);
            if (hit.transform != null)
            {
                if (hit.transform.gameObject.tag == "Box" || hit.transform.gameObject.tag == "Ground")
                {
                    fireRestraint = true;
                    fireChain(pointTouched);
                }
            }
        }
                        #if UNITY_IPHONE && !UNITY_EDITOR
        if (Input.touchCount == 0)
                                #else
        if (!Input.GetButton("Fire1"))
                                        #endif
        {
            fireRestraint = false;
        }
        if (Input.GetButtonDown("Jump"))
        {
            fireRestraint = true;
            fireChain();
        }
        GetComponent <Rigidbody2D>().AddForce(transform.right * Input.GetAxis("Horizontal") * 1000);
        //rigidbody2D.velocity = Vector2.ClampMagnitude(rigidbody2D.velocity, 4);

        float turnDir = Input.GetAxis("Vertical");
        climber.chains[climber.whichChain].chain.turnDir = turnDir;


        if (Input.GetKey("a"))
        {
            releaseChain1();
        }
        if (Input.GetKey("s"))
        {
            releaseChain2();
        }
        if (Input.GetKeyDown("v"))
        {
            launchClimber();
        }
        if (Input.GetKeyDown("c"))
        {
            combineChains();
        }
        climbFlag(0, Input.GetKey("z"));
        //climbFlag(1,Input.GetKey("x"));

        climber.doClimb();
    }
}