Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (rot.GetRotate())
        {
            GameObject r = rot.GetRot();
            if (r.name.Contains("finish"))
            {
                if (!fin)
                {
                    t   = Time.time;
                    fin = true;
                }
                if (r.GetComponent <Light>().range < range)
                {
                    r.GetComponent <Light>().range += Time.deltaTime * 2;
                    r.GetComponent <orbit>().SetOrb(r.GetComponent <Light>().range);
                }
                if (Time.time - t > cooldown && Vector3.Distance(r.transform.position, transform.position) < dist && r.GetComponent <Light>().range > range)
                {
                    fin = false;
                    GameObject[] objs = Resources.FindObjectsOfTypeAll <GameObject>();
                    foreach (GameObject obj in objs)
                    {
                        if (obj.name == "Finish" && obj.layer == 5)
                        {
                            gameObject.GetComponent <rotor>().SetTyp(-7);
                            GameObject.FindWithTag("level");
                            enabled = false;
                            obj.SetActive(true);
                            gameObject.GetComponent <rotor>().enabled         = false;
                            gameObject.GetComponent <TrailRenderer>().enabled = false;
                            stat st = GameObject.FindWithTag("stat").GetComponent <stat>();


                            if (st.GetLevel() <= LevelHandle.GetLoadedLevelId() && st.GetLevel() >= 0)
                            {
                                GameObject.FindWithTag("stat").GetComponent <stat>().PlusOne();
                                GameObject.FindWithTag("stat").GetComponent <stat>().SaveStats();
                            }
                            break;
                        }
                    }
                }
            }
            else
            {
                fin = false;
            }
        }
        else
        {
            fin = false;
        }
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void FixedUpdate()
 {
     z = -ro.GetVelMagnitude() * z_multiplier - min_z;
     if (ro.GetRotate())
     {
         cam.transform.position = Vector3.MoveTowards(cam.transform.position, new Vector3(ro.GetRot().transform.position.x, ro.GetRot().transform.position.y, z), Time.deltaTime * moveToNewRotSpeed);
     }
     else
     {
         if (Vector3.Distance(new Vector3(cam.transform.position.x, cam.transform.position.y, 0), new Vector3(transform.position.x, transform.position.y, 0)) < 0.1)
         {
             cam.transform.position = new Vector3(transform.position.x, transform.position.y, z);
         }
         else
         {
             cam.transform.position = Vector3.MoveTowards(cam.transform.position, new Vector3(transform.position.x, transform.position.y, z), (Vector3.Magnitude(gameObject.GetComponent <Rigidbody>().velocity) + 10) * Time.deltaTime * moveToBallSpeed);
         }
     }
 }