Ejemplo n.º 1
0
    //orbit radius
    // Use this for initialization
    void Start()
    {
        //note - for finding exit point when leaving orbit, raycasting?

        //God(?)
        e = Instantiate (earth, new Vector3 (-70, -50, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        GameObject d = Instantiate (direction, new Vector3 (-70, -55, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        d.transform.parent = e.transform;
        ghost = new GameObject ();
        ghost.transform.parent = e.transform;
        ghost.transform.Translate (new Vector3 (e.transform.position.x, e.transform.position.y + .1f, e.transform.position.z));

        ear = e.GetComponent<Earth_Behavior> ();
        //attach ghost to earth
        ear.ghost = ghost;

        s = Instantiate (star, new Vector3 (-100, 80, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s2 = Instantiate (star, new Vector3 (-100, -80, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s3 = Instantiate (star, new Vector3 (-75, 45, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s4 = Instantiate (star, new Vector3 (-50, 0, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s5 = Instantiate (star, new Vector3 (0, 50, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s6 = Instantiate (star, new Vector3 (25, -75, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s7 = Instantiate (star, new Vector3 (50, -40, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s8 = Instantiate (star, new Vector3 (75, 50, 0), new Quaternion (0, 0, 0, 0)) as GameObject;

        s9 = Instantiate (star, new Vector3 (0, 200, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s10 = Instantiate (star, new Vector3 (-50, 250, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s11 = Instantiate (star, new Vector3 (-75, 150, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s12 = Instantiate (star, new Vector3 (25, 100, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s13 = Instantiate (star, new Vector3 (75, 180, 0), new Quaternion (0, 0, 0, 0)) as GameObject;

        s14 = Instantiate (star, new Vector3 (200, 0, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s15 = Instantiate (star, new Vector3 (180, -40, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s16 = Instantiate (star, new Vector3 (250, 50, 0), new Quaternion (0, 0, 0, 0)) as GameObject;
        s17 = Instantiate (star, new Vector3 (280, 50, 0), new Quaternion (0, 0, 0, 0)) as GameObject;

        Star_Behavior sb = s.GetComponent<Star_Behavior> ();
        Star_Behavior sb2 = s2.GetComponent<Star_Behavior> ();
        Star_Behavior sb3 = s3.GetComponent<Star_Behavior> ();
        Star_Behavior sb4 = s4.GetComponent<Star_Behavior> ();
        Star_Behavior sb5 = s5.GetComponent<Star_Behavior> ();
        Star_Behavior sb6 = s6.GetComponent<Star_Behavior> ();
        Star_Behavior sb7 = s7.GetComponent<Star_Behavior> ();
        Star_Behavior sb8 = s8.GetComponent<Star_Behavior> ();
        Star_Behavior sb9 = s9.GetComponent<Star_Behavior> ();
        Star_Behavior sb10 = s10.GetComponent<Star_Behavior> ();
        Star_Behavior sb11 = s11.GetComponent<Star_Behavior> ();
        Star_Behavior sb12 = s12.GetComponent<Star_Behavior> ();
        Star_Behavior sb13 = s13.GetComponent<Star_Behavior> ();
        Star_Behavior sb14 = s14.GetComponent<Star_Behavior> ();
        Star_Behavior sb15 = s15.GetComponent<Star_Behavior> ();
        Star_Behavior sb16 = s16.GetComponent<Star_Behavior> ();
        Star_Behavior sb17 = s17.GetComponent<Star_Behavior> ();

        sb.earth = e;
        sb2.earth = e;
        sb3.earth = e;
        sb4.earth = e;
        sb5.earth = e;
        sb6.earth = e;
        sb7.earth = e;
        sb8.earth = e;
        sb9.earth = e;
        sb10.earth = e;
        sb11.earth = e;
        sb12.earth = e;
        sb13.earth = e;
        sb14.earth = e;
        sb15.earth = e;
        sb16.earth = e;
        sb17.earth = e;

        //	e.transform.position = Vector3.Lerp (e.transform.position, Quaternion.Euler (0, 90, 0) * s.transform.position, speed * Time.deltaTime);
        /*	float hyp = Vector3.Distance (s.transform.position, e.transform.position);
        theta = Mathf.Asin (orbit_radius / hyp);
        e.transform.LookAt(e.transform);

        */

        /*x3 = e.transform.position.x + ((Mathf.Pow (e_const, theta) + Mathf.Pow (e_const, -1 * theta)) / 2);
        y3 = s.transform.position.y - ((Mathf.Pow (e_const, theta) + Mathf.Pow (e_const, -1 * theta)) / 2);

            */

        //calculate lerp
        //float hyp = Vector3.Distance (s.transform.position, e.transform.position);
        //	float theta = Mathf.Asin(orbit_radius/hyp);

        //what should behavior be when planet is inside orbit radius?
        //random note: earth should gain more velocity the less their vector has to rotate to become tangent to the orbit_radius
        //and if it's going too fast for too steep a rotation, the planet should not enter orbit, but shift direction toward the system and travel past it
        //a2 = c2-b2
        //float a = Mathf.Sqrt (Mathf.Pow (hyp, 2) - Mathf.Pow (orbit_radius, 2));

        //better idea: don't worry about lerping to the right place - just use arcsine to find the angle, rotate e vector to point at s, then rotate angle degrees more and fly that direction
        //Stars will grab earth when it's tangential and slow enough
    }
Ejemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     earth_script = earth.GetComponent<Earth_Behavior> ();
 }