Ejemplo n.º 1
0
 private void OnCollisionEnter(Collision collision)
 {
     if (!PlanetsInfo.pause && PlanetsInfo.destroy)
     {
         Systems.planets.Remove(PlanetsInfo.GetPlanet(gameObject));
         Destroy(gameObject);
     }
 }
Ejemplo n.º 2
0
 private void OnMouseDown()
 {
     if (!ChangeScreens.v2)
     {
         init_pos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y + transform.position.y, Camera.main.transform.position.y - transform.position.y));
     }
     else
     {
         init_pos = Camera.main.ScreenToWorldPoint(new Vector3(-Input.mousePosition.x, -Input.mousePosition.y + transform.position.z, Camera.main.transform.position.z));
     }
     PlanetsInfo.GetPlanet(this.gameObject).moused = true;
 }
Ejemplo n.º 3
0
 private void OnMouseDrag()
 {
     if (!PlanetsInfo.GetPlanet(gameObject).followed)
     {
         if (!ChangeScreens.v2)
         {
             mousePosition       = new Vector3(Input.mousePosition.x, Input.mousePosition.y + transform.position.y, Camera.main.transform.position.y - transform.position.y);
             transform.position += Camera.main.ScreenToWorldPoint(mousePosition) - init_pos;
             init_pos            = Camera.main.ScreenToWorldPoint(mousePosition);
         }
         else
         {
             transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Math.Abs(Camera.main.transform.position.z - transform.position.z)));
         }
     }
 }
Ejemplo n.º 4
0
 void Update()
 {
     if (!PlanetsInfo.pause)
     {
         if (!PlanetsInfo.GetPlanet(gameObject).moused)
         {
             foreach (Planet planet in Systems.planets)
             {
                 if (planet.Game_obj != this.gameObject)
                 {
                     R = this.gameObject.transform.position - planet.Game_obj.transform.position;
                     g = planet.Mass / (R.x * R.x + R.y * R.y + R.z * R.z);
                     PlanetsInfo.GetPlanet(gameObject).delta += R * g;
                 }
             }
             transform.Translate(PlanetsInfo.GetPlanet(gameObject).Initial_Direction *PlanetsInfo.GetPlanet(gameObject).Initial_Speed *dt -
                                 PlanetsInfo.GetPlanet(gameObject).delta *Planet.G *dt *dt / 2, Space.World);
             if (!PlanetsInfo.pause)
             {
                 transform.Rotate(0, PlanetsInfo.GetPlanet(gameObject).Spin *Time.deltaTime, 0, Space.Self);
             }
         }
     }
 }
Ejemplo n.º 5
0
    public void Add()
    {
        if (PlanetsInfo.GetFollowedPlanet() == null)
        {
            Vector3 init_pos = !ChangeScreens.v2 ?
                               new Vector3(Camera.main.transform.position.x, 0, Camera.main.transform.position.z) :
                               new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, 0);

            input_mass.text = input_mass.text == "" ? "1" : input_mass.text;
            if (int.Parse(input_mass.text) > Planet.max_mass)
            {
                input_mass.text = Planet.max_mass.ToString();
            }
            if (int.Parse(input_mass.text) <= 0)
            {
                input_mass.text = "1";
            }

            input_speed.text = input_speed.text == "" ? "0" : input_speed.text;
            if (int.Parse(input_speed.text) > Planet.max_speed)
            {
                input_speed.text = Planet.max_speed.ToString();
            }
            if (int.Parse(input_speed.text) <= 0)
            {
                input_speed.text = "0";
            }

            input_spin.text = input_spin.text == "" ? "30" : input_spin.text;
            if (int.Parse(input_spin.text) > Planet.max_spin)
            {
                input_spin.text = Planet.max_spin.ToString();
            }
            if (int.Parse(input_spin.text) <= 0)
            {
                input_spin.text = "0";
            }

            input_name.text = input_name.text == "" || input_name.text == "Planet" + (Planet.Count - 1) ? "Planet" + Planet.Count : input_name.text;
            if (nameExists(input_name.text))
            {
                input_name.text += "*";
            }
            GameObject g = Instantiate(planet, init_pos, new Quaternion());
            g.GetComponent <MeshFilter>().mesh = form[type.value];
            switch (type.value)
            {
            case 0:
                g.GetComponent <MeshRenderer>().materials = alien;
                break;

            case 1:
                g.GetComponent <MeshRenderer>().materials = desert;
                break;

            case 2:
                g.GetComponent <MeshRenderer>().materials = earth;
                break;

            case 3:
                g.GetComponent <MeshRenderer>().materials = frozen;
                break;

            case 4:
                g.GetComponent <MeshRenderer>().materials = temperate;
                break;

            case 5:
                g.GetComponent <MeshRenderer>().materials = tundra;
                break;
            }

            Systems.planets.Add(new Planet(int.Parse(input_mass.text), int.Parse(input_speed.text), g, input_name.text, int.Parse(input_spin.text), type.value));
            Systems.planets[Systems.planets.Count - 1].selected = true;
            Camera.main.transform.Translate(Vector3.left * int.Parse(input_mass.text) * 2, Space.Self);
        }
    }
Ejemplo n.º 6
0
 private void OnMouseUp()
 {
     PlanetsInfo.GetPlanet(this.gameObject).moused = false;
 }