Exemplo n.º 1
0
    private void Update()
    {
        thing = loadData.data.sun;
        if (con.getHydrogen() < con.getMaxHydrogen())
        {
            spaceLeft = true;
        }
        if (hLeft && spaceLeft && draining && Input.GetKey(KeyCode.Space))
        {
            hLeft     = plan.reduceHydrogen();
            spaceLeft = con.vacuum();
            if (thing.tag == "Sun")
            {
                Quaternion targetRotation = Quaternion.LookRotation(ship.transform.GetChild(2).transform.position - thing.transform.GetChild(0).transform.position);

                // Smoothly rotate towards the target point.
                thing.transform.GetChild(0).transform.rotation = Quaternion.Slerp(thing.transform.GetChild(0).transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);
                thing.transform.GetChild(0).gameObject.GetComponent <ParticleSystem>().Play();
            }
            else
            {
                thing.GetComponent <ParticleSystem>().Play();
            }
        }
        else if (!empty && transferring && station)
        {
            if (Input.GetAxis("Vacuum") != 0)
            {
                if (station.checkSpace())
                {
                    con.transfer();
                    station.transfer();
                }
            }
            else if (Input.GetKeyDown(KeyCode.E))
            {
                menu.activated = true;
            }
        }
        else
        {
            if (thing.tag.Equals("Sun"))
            {
                thing.transform.GetChild(0).gameObject.GetComponent <ParticleSystem>().Pause();
                //  thing.transform.GetChild(0).gameObject.GetComponent<ParticleSystem>().Clear();
            }
            else
            {
                thing.GetComponent <ParticleSystem>().Pause();
                thing.GetComponent <ParticleSystem>().Clear();
            }
        }
        if (con.getHydrogen() <= con.getMaxHydrogen() / 10)
        {
            empty = true;
        }
        else
        {
            empty = false;
        }
    }