void SpawnCollectible(string color, int position, Vector3 savedPosition = default(Vector3), Vector3 savedRotation = default(Vector3)) { //print ("Spawning " + color + " " + CollectibleType + " in position " + position + " [" + savedPosition + "]" + " with rotation [" + savedRotation + "]"); GameObject InstanciatedObject; InstanciatedObject = Instantiate(CollectiblePrefab); if (position == -2) { if (!Menu.Instance.HasBeenCollected(CollectibleType, color)) { InstanciatedObject.GetComponent <Collectible> ().Type(CollectibleType, color, savedPosition, savedRotation); } } else { InstanciatedObject.GetComponent <Collectible> ().Type(CollectibleType, color, _WaypointManager.GetComponent <WaypointManager> ().path_objs[position].transform.position, _WaypointManager.GetComponent <WaypointManager> ().path_objs[position].transform.rotation.eulerAngles); if (AlreadySpawned[0] == -1) { AlreadySpawned[0] = position; SpawnerManager.Instance.CollectiblePositions[CollectibleType][0] = _WaypointManager.GetComponent <WaypointManager> ().path_objs[position].transform.position; SpawnerManager.Instance.CollectibleRotations[CollectibleType][0] = _WaypointManager.GetComponent <WaypointManager> ().path_objs[position].transform.rotation.eulerAngles; } else if (AlreadySpawned[1] == -1) { AlreadySpawned[1] = position; SpawnerManager.Instance.CollectiblePositions[CollectibleType][1] = _WaypointManager.GetComponent <WaypointManager> ().path_objs[position].transform.position; SpawnerManager.Instance.CollectibleRotations[CollectibleType][1] = _WaypointManager.GetComponent <WaypointManager> ().path_objs[position].transform.rotation.eulerAngles; } else if (AlreadySpawned[2] == -1) { AlreadySpawned[2] = position; SpawnerManager.Instance.CollectiblePositions[CollectibleType][2] = _WaypointManager.GetComponent <WaypointManager> ().path_objs[position].transform.position; SpawnerManager.Instance.CollectibleRotations[CollectibleType][2] = _WaypointManager.GetComponent <WaypointManager> ().path_objs[position].transform.rotation.eulerAngles; } else if (AlreadySpawned[3] == -1) { AlreadySpawned[3] = position; SpawnerManager.Instance.CollectiblePositions[CollectibleType][3] = _WaypointManager.GetComponent <WaypointManager> ().path_objs[position].transform.position; SpawnerManager.Instance.CollectibleRotations[CollectibleType][3] = _WaypointManager.GetComponent <WaypointManager> ().path_objs[position].transform.rotation.eulerAngles; } } Spawned++; }
public override void OnInspectorGUI() { DrawDefaultInspector(); string buttontext = (manager.Waypoints.Count == 0) ? "Create spawnpoint" : "Create waypoint"; if (GUILayout.Button(buttontext)) { manager.CreateNewWaypoint(); Selection.activeGameObject = manager.Waypoints.Last().gameObject; } if (GUILayout.Button("Convert last to endpoint")) { manager.ConvertLastToEndpoint(); } if (GUILayout.Button("Edit waves/spawns")) { WaveEditor.BeginWaveEditing(manager.GetSpawnPoint().gameObject, manager.GetComponent <WavesManager>()); } }