Ejemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (outsideColl != null)
        {
            //Debug.Log ("OutsideColl not null: " + outsideColl.gameObject);
            Destroy(outsideColl.gameObject.GetComponent <FixedJoint2D> ());
        }
        GameObject launcher = col.gameObject;

        //if nothing has been identified as the launchee and the launcher isn't the launche(if billie walks across it), do nothing
        //Debug.Log("Trigger script. Launchee= " + launchee + "Launcher= " + launcher);
        if (launcher.tag == "simplemachine")
        {
            //Destroy (launcher);
        }
        if (launchee != null && launchee != launcher && launcher.tag != "Bullet")
        {
            //if (launcher.name == "Billie" && launchee.tag == "canmovepulley") {
            //	launchee.transform.Translate
            //}
            //else {
            rb.constraints = RigidbodyConstraints2D.None;
            blowUp         = launchee.GetComponent <ForceExperiments> ();
            //Move the launchee up so it doesn't get affected by the lever sprite switch

            if (applyItOnce == true)
            {
                //applyItOnce = false;
                launchee.transform.Translate(Vector3.up * 7);
            }
            //if the launchee is to the right of the fulcrum (child of the lever object), pass false to ForceExperiments
            //if to the left, pass true.
            //Debug.Log("Fulcrum pos: " + fulcrum.position.x);
            //Debug.Log("launchee x pos: " + launchee.transform.position.x);
            if (launchee.transform.position.x + 1.0f > fulcrum.position.x)
            {
                //if there is something to be launched, launch it
                if (applyItOnce == true)
                {
                    blowUp.goFlying(false);
                    applyItOnce = false;
                }

                this.transform.localRotation = Quaternion.Euler(0, 180, 0);
            }
            else
            {
                if (applyItOnce == true)
                {
                    blowUp.goFlying(true);
                    applyItOnce = false;
                }
                this.transform.localRotation = Quaternion.Euler(0, 0, 0);
            }
            //once launched, the lauchee is no longer the launchee
            //launchee = null;
            stopExit = false;
            //}
        }
    }
Ejemplo n.º 2
0
    public bool isGrounded;                // Whether or not the player is grounded.


    // Awake is used to initialize any variables before the game starts
    // Called after all objects are initialized so you can safely communicate with other objects
    //
    void Awake()
    {
        originalRotate    = transform.rotation;
        appliedForce      = GetComponent <ForceExperiments> ();
        rb                = GetComponent <Rigidbody2D>();
        col               = GetComponent <CapsuleCollider2D> ();
        groundCheckRadius = .1f;         //col.size.x * .5f
        animator          = GetComponent <Animator>();
        //isGrounded = Physics2D.OverlapCircle (groundCheckPoint.position, groundCheckRadius, groundLayers);
        spriteRenderer = GetComponent <SpriteRenderer>();
        pos            = RigidbodyConstraints2D.FreezeRotation;
    }