void OnGUI()
    {
        //scr = this.GetComponent<Score>();
        GUILayout.BeginArea(new Rect(Screen.width / 2 - 120, Screen.height / 2 - 70, 200, 300), "");

        GUI.skin = MyGUISkin;

        GUILayout.Label("Level Completed");
        //GUILayout.Space(1);

        GUILayout.Label("Total Score: " + Global.score);         //+ scr.score);
        //GUILayout.Space(1);
        //GUILayout.Label("1400");

        if (mainMenu == true)
        {
            if (GUILayout.Button("Next Level"))
            {
                audio.PlayOneShot(clickSound);

                BoxCollider2D[] cols = rocket.GetComponents <BoxCollider2D> ();
                foreach (BoxCollider2D c in cols)
                {
                    c.isTrigger = false;
                }

                Application.LoadLevel(4);
                //Global.score = 0;
            }

            if (GUILayout.Button("Restart"))
            {
                audio.PlayOneShot(clickSound);

                BoxCollider2D[] cols = rocket.GetComponents <BoxCollider2D> ();
                foreach (BoxCollider2D c in cols)
                {
                    c.isTrigger = true;
                }

                Application.LoadLevel(2);



                //about = true;
                //mainMenu = false;
            }

            if (GUILayout.Button("Main menu"))
            {
                audio.PlayOneShot(clickSound);
                //Application.Quit();
                Application.LoadLevel(1);
            }
        }


        GUILayout.EndArea();
    }
Пример #2
0
    // For higher performance assumes that slowFractions contains rb
    protected bool SlowDown(Rigidbody2D rb, float frac)
    {
        if (rb == null)
        {
            return(false);
        }
        SlowData slowData = slowFractions[rb];

        if (slowData.isInside && slowData.slowFrac > slowFraction)
        {
            float frac_ = Mathf.Min(frac, slowData.slowFrac - slowFraction);
            rb.velocity        *= 1 - frac_ / slowData.slowFrac;
            rb.angularVelocity *= 1 - frac_ / slowData.slowFrac;

            slowData.slowFrac -= frac_;

            foreach (var keeper in rb.GetComponents <SlowKeeper>())
            {
                keeper.slowFactor = slowData.slowFrac;
            }
            foreach (var keeper in rb.GetComponentsInChildren <SlowKeeper>())
            {
                keeper.slowFactor = slowData.slowFrac;
            }

            return(true);
        }
        return(slowData.isInside);
    }
Пример #3
0
    private void DrillerUpdate()
    {
        if (HeldMaterial != null)
        {
            HeldDrill.position = transform.position;
        }

        if (btn1Down && HeldDrill == null)
        {
            Debug.DrawRay(transform.position, latestLookDirection, Color.red, 1);
            //look for drill to hold

            RaycastHit2D hit = Physics2D.Raycast(transform.position, latestLookDirection, DrillPickupOffset, LayerMask.GetMask("Drill"));
            if (hit && hit.transform.tag == "Drill")
            {
                AimSpriteRenderer.enabled = true;
                HeldDrill      = hit.collider.GetComponent <Rigidbody2D>();
                HeldDrill.mass = 1;
                HeldDrill.drag = 0;
                var colliders = HeldDrill.GetComponents <Collider2D>();
                foreach (Collider2D col in colliders)
                {
                    col.enabled = false;
                }
            }
        }
        else if (btn1Up && HeldDrill != null)
        {
            //release drill in the direction
            FireDrill();
        }

        //other cases are invalid
    }
Пример #4
0
    void Update()
    {
        // If the fire button is pressed...
        if (Input.GetButton("Fire1"))
        {
            // ... set the animator Shoot trigger parameter and play the audioclip.
            //anim.SetTrigger("Shoot");
            //anim.SetBool ("Shoot", true);
            //audio.Play ();

            // If the player is facing right...
            if (playerCtrl.facingRight)
            {
                // ... instantiate the rocket facing right and set it's velocity to the right.
                Rigidbody2D bulletInstance = Instantiate(rocket, transform.position, Quaternion.Euler(new Vector3(0, 0, 0))) as Rigidbody2D;
                bulletInstance.velocity = new Vector2(0, 0);
            }
            else
            {
                // Otherwise instantiate the rocket facing left and set it's velocity to the left.
                Rigidbody2D bulletInstance = Instantiate(rocket, transform.position, Quaternion.Euler(new Vector3(0, 0, 180f))) as Rigidbody2D;
                bulletInstance.velocity = new Vector2(-0, 0);
            }
        }


        if (lb.bombCount > 0)
        {
            if (Input.GetKey(KeyCode.Delete))
            {
                BoxCollider2D[] cols = rocket.GetComponents <BoxCollider2D> ();
                foreach (BoxCollider2D c in cols)
                {
                    c.isTrigger = false;
                }
            }

            if (Input.GetKey(KeyCode.End))
            {
                BoxCollider2D[] cols = rocket.GetComponents <BoxCollider2D> ();
                foreach (BoxCollider2D c in cols)
                {
                    c.isTrigger = true;
                }
            }
        }
    }
Пример #5
0
 // Update is called once per frame
 private void FixedUpdate()
 {
     if (carBody.velocity.magnitude <= 10f)
     {
         carBody.AddForce(transform.right * 15000);
         foreach (WheelJoint2D wheelJoint in carBody.GetComponents <WheelJoint2D>())
         {
             JointMotor2D motor = wheelJoint.motor;
             motor.motorSpeed -= 10f;
             wheelJoint.motor  = motor;
         }
     }
     else
     {
         foreach (WheelJoint2D wheelJoint in carBody.GetComponents <WheelJoint2D>())
         {
             JointMotor2D motor = wheelJoint.motor;
             motor.motorSpeed = originalSpeed;
             wheelJoint.motor = motor;
         }
     }
     if (Input.GetKeyDown(KeyCode.F))
     {
         isExploding = true;
     }
     if (carBody == null)
     {
         return;
     }
     if (!isExploding)
     {
         CheckCarFlippedOrWillExplode();
     }
     else
     {
         AnimateCarExplosion();
     }
 }
Пример #6
0
 private void SetRbDead(Rigidbody2D rb)
 {
     rb.constraints  = RigidbodyConstraints2D.None;
     rb.drag         = 0;
     rb.gravityScale = 3;
     rb.GetComponents <HingeJoint2D>()
     .Where(j => j.connectedBody.tag != "head")
     .ToList()
     .ForEach(
         j => j.limits = new JointAngleLimits2D {
         min = -180, max = 180
     }
         );
 }
Пример #7
0
    private void FireDrill()
    {
        AimSpriteRenderer.enabled = false;

        var colliders = HeldDrill.GetComponents <Collider2D>();

        foreach (Collider2D col in colliders)
        {
            col.enabled = true;
        }
        HeldDrill.velocity = this.transform.up * DrillLaunchSpeed;
        HeldDrill.GetComponent <Drill>().Drilling = true;

        CameraSFXPlayer.PlayClip("DRILL SHORT");
        //TO CHANGE ?
        GameObject.Destroy(HeldDrill.gameObject, DrillLifeTime);
        HeldDrill = null;
    }
Пример #8
0
    void OnTriggerEnter2D(Collider2D col)
    {
        // If the player hits the trigger...
        if (col.gameObject.tag == "Player")
        {
            // .. stop the camera tracking the player
            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFollow>().enabled = false;

            // .. stop the Health Bar following the player
            if (GameObject.FindGameObjectWithTag("HealthBar").activeSelf)
            {
                GameObject.FindGameObjectWithTag("HealthBar").SetActive(false);
            }

            // ... instantiate the splash where the player falls in.
            Instantiate(splash, col.transform.position, transform.rotation);
            // ... destroy the player.



            Destroy(col.gameObject);

            BoxCollider2D[] cols = rocket.GetComponents <BoxCollider2D> ();
            foreach (BoxCollider2D c in cols)
            {
                c.isTrigger = false;
            }

            // ... reload the level.
            StartCoroutine("ReloadGame");
        }
        else
        {
            // ... instantiate the splash where the enemy falls in.
            Instantiate(splash, col.transform.position, transform.rotation);

            // Destroy the enemy.
            Destroy(col.gameObject);
        }
    }
Пример #9
0
 // Use this for initialization
 void Start()
 {
     legsW = body.GetComponents <WheelJoint2D>();
 }