//Array list of components for observer // Start is called before the first frame update void Start() { for (int i = 0; i < -1; i++) { //Randomise position GameObject new_piece = new GameObject("Component"); new_piece.transform.position = new Vector3(Random.Range(-100.0f, 100.0f), 0f, Random.Range(-100.0f, 100.0f)); ComponentControl new_component = new_piece.AddComponent <ComponentControl>(); //Load an object (1-3 Thrusters, Hull, Wings) + a subset of the object (1-5 hull1, hull2, hull3...) new_component.you_are_a((ComponentControl.Slot)UnityEngine.Random.Range(0, 3), UnityEngine.Random.Range(1, 4)); Rigidbody r = new_piece.AddComponent <Rigidbody>(); r.isKinematic = true; Collider c = new_piece.AddComponent <BoxCollider>(); c.isTrigger = true; } for (int i = 0; i < 20; i++) { GameObject cargo = new GameObject(); cargo.transform.position = new Vector3(Random.Range(-100.0f, 100.0f), 0f, Random.Range(-100.0f, 100.0f)); }//End for }
// Start is called before the first frame update void Start() { GameObject new_piece = new GameObject("Dummy Hull"); new_piece.transform.parent = transform; new_piece.transform.localPosition = new Vector3(1, 0, 1); basic_hull = new_piece.AddComponent <ComponentControl>(); //Load an object (1-3 Thrusters, Hull, Wings) + a subset of the object (1-5 hull1, hull2, hull3...) basic_hull.you_are_a(ComponentControl.Slot.Hull, 1); basic_hull.transform.localScale = new Vector3(.1f, 0.1f, 0.1f); basic_hull.you_are_a_dummy(); /* * GameObject new_piece1 = new GameObject("Dummy Thruster"); * new_piece1.transform.parent = transform; * //new_piece1.transform.localPosition = new Vector3(1, 0, 1); * basic_thruster = new_piece.AddComponent<ComponentControl>(); * basic_thruster.you_are_a(ComponentControl.Slot.Thrusters, 1); * basic_thruster.transform.localScale = new Vector3(.1f, 0.1f, 0.1f); * basic_thruster.you_are_a_dummy(); */ GameObject new_piece2 = new GameObject("Dummy Wing"); new_piece2.transform.parent = transform; new_piece2.transform.localPosition = new Vector3(1, 0, 1); basic_wing = new_piece.AddComponent <ComponentControl>(); basic_wing.you_are_a(ComponentControl.Slot.Wings, 1); basic_wing.transform.localScale = new Vector3(.1f, 0.1f, 0.1f); basic_wing.you_are_a_dummy(); basic_wing.transform.SetParent(basic_hull.transform); basic_thruster.transform.SetParent(basic_hull.transform); }//End Start