public override void OnInspectorGUI()
 {
     DrawDefaultInspector();
     if (GUILayout.Button("Orient to Planet"))
     {
         foreach (Object t in targets)
         {
             EnvironmentOrienter po = t as EnvironmentOrienter;
             Debug.Log("Orienting " + po.gameObject.name + "...");
             po.OrientToPlanet();
         }
         Debug.Log("Done orienting objects.");
     }
     if (GUILayout.Button("Invert Orientation"))
     {
         foreach (Object t in targets)
         {
             EnvironmentOrienter po = t as EnvironmentOrienter;
             po.InvertOrientation();
         }
         Debug.Log("Done inverting orientations.");
     }
     if (GUILayout.Button("Drop to Planet"))
     {
         foreach (Object t in targets)
         {
             EnvironmentOrienter po = t as EnvironmentOrienter;
             po.DropToPlanet();
         }
         Debug.Log("Done dropping objects to planet.");
     }
 }
Exemple #2
0
    void Start()
    {
        // When adding a new pickup type, don't forget to add 1 to the size of the array
        this.Type = new template[9];

        // A function to initialize the array
        this.initializePickupTypes();

        // Orient to the planet
        EnvironmentOrienter orienter = GetComponent <EnvironmentOrienter>();

        orienter.OrientToPlanet();
        orienter.DropToPlanet();
    }
Exemple #3
0
    /// <summary>
    /// Generates objects at eaach sample point at once.
    /// </summary>
    public IEnumerator generateAll()
    {
        SystemLogger.write("Creating objects for all sample points...");
        Object[]    largeObjects   = Resources.LoadAll(folder + "/Large");
        Object[]    mediumObjects  = Resources.LoadAll(folder + "/Medium");
        Object[]    smallObjects   = Resources.LoadAll(folder + "/Small");
        Object[]    powerUpObjects = Resources.LoadAll(powerupFolder);
        List <long> keys           = new List <long> (samplePoints.Keys);
        long        key;

        for (int j = 0; j < keys.Count; j++)
        {
            key = keys[j];

            for (int i = 0; i < samplePoints[key].Count; i++)
            {
                GameObject ob;

                if (samplePoints[key][i].objectName == null || !objectByName.ContainsKey(samplePoints[key][i].objectName))
                {
                    GameObject selection;
                    if (samplePoints[key][i].size == small)
                    {
                        selection = (GameObject)smallObjects[Random.Range(0, smallObjects.Length)];
                        ob        = GameObject.Instantiate(selection);
                    }
                    else if (samplePoints[key][i].size == medium)
                    {
                        selection = (GameObject)mediumObjects[Random.Range(0, mediumObjects.Length)];
                        ob        = GameObject.Instantiate(selection);
                    }
                    else if (samplePoints[key][i].size == large)
                    {
                        selection = (GameObject)largeObjects[Random.Range(0, largeObjects.Length)];
                        ob        = GameObject.Instantiate(selection);
                    }
                    else
                    {
                        selection = (GameObject)powerUpObjects[Random.Range(0, powerUpObjects.Length)];
                        ob        = GameObject.Instantiate(selection);
                    }

                    ob.transform.localPosition = samplePoints[key][i].position + medium * faceNormals[samplePoints[key][i].triangleIndex];
                    //ob.transform.localPosition = samplePoints[key][i].position ;
                    ob.gameObject.name              = selection.name;
                    ob.transform.parent             = transform;
                    samplePoints[key][i].objectName = ob.gameObject.name;
                }
                else
                {
                    ob      = GameObject.Instantiate(objectByName[samplePoints[key][i].objectName]);
                    ob.name = samplePoints[key][i].objectName;
                    ob.transform.localPosition = samplePoints[key][i].position + medium * faceNormals[samplePoints[key][i].triangleIndex];
                }

                EnvironmentOrienter orienter = ob.GetComponent <EnvironmentOrienter>();
                orienter.OrientToPlanet();
                orienter.DropToPlanet();
            }

            yield return(null);
        }

        serializeSamplePoints();
        SystemLogger.write("Generated objects!");
    }