// Use this for initialization void Start() { distMoved = 0; mainCamera = GameObject.FindWithTag("MainCamera"); mainCameraScript = mainCamera.GetComponent <TunnelCameraController> (); gameController = GameObject.FindWithTag("GameController"); gameControllerScript = gameController.GetComponent <TunnelGameController> (); }
//################################################################ // Use this for initialization void Start() { // parameters not exposed in the editor ntracks = 4; // number of tracks (levels) maxOutChars = 5; // max number of sequence characters (max preview characters is 3) nCarriages = 4; sequence = new string[100]; typed_sequence = new string[100]; track = new string[ntracks][]; trainStationDispX = new float[ntracks][]; umin = new float[ntracks][]; nLowSpeed = new int[ntracks][]; // track 0 details // R = right side sequence, L=left side, E=empty, P=preview // track[0] =new string[5]{"","FP1",".R2","IL3","IE"}; track[0] = new string[] { "", ".R2", "IR3", "IR2", ".R2", "IE" }; trainStationDispX[0] = new float[] { 33.3f, 32, 0, 0, 0, 5 }; // first is start station umin[0] = new float[] { 0, 0, 0.07f, 0.07f, 0.07f, 0 }; // first and last not used nLowSpeed[0] = new int[] { 0, 100, 250, 250, 250, 0 }; // first and last not used track[1] = new string[] { "", ".R3", "IP1", ".L3", "IP2", ".R2", ".L2", "IE" }; trainStationDispX[1] = new float[] { 33.3f, 0, 0, 0, 0, 0, 0, 5 }; // first is start station umin[1] = new float[] { 0, 0, 0.1f, 0.1f, 0.1f, 0, 0, 0 }; // first and last not used nLowSpeed[1] = new int[] { 0, 100, 300, 300, 200, 0, 0, 0 }; // first and last not used track[2] = new string[] { "", ".R3", ".E", ".R2", "IE", ".R2", ".P2", ".L2", "IE", ".R3", "IE" }; trainStationDispX[2] = new float[] { 33.3f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5 }; // first is start station umin[2] = new float[] { 0, 0.2f, 0.8f, 0.2f, 0.6f, 0.2f, 0.2f, 0.2f, 0.5f, 0.3f, 0 }; // first and last not used nLowSpeed[2] = new int[] { 0, 100, 50, 100, 50, 100, 100, 100, 50, 70, 0 }; // first and last not used track[3] = new string[] { "", ".P3", "FL2", "FE", "IL3", "FL2", "IL4", "IE", "FE" }; trainStationDispX[3] = new float[] { 33.3f, 0, 0, 0, 0, 0, 0, 0, 5 }; // first is start station umin[3] = new float[] { 0, 0, 0.3f, 0.3f, 0.3f, 0.3f, 0.3f, 0.8f, 0 }; // first and last not used nLowSpeed[3] = new int[] { 0, 100, 70, 70, 70, 70, 50, 20, 0 }; // first and last not used //-------------------------------------------------------------------------------------- inputMenu.SetActive(false); messageBox.SetActive(false); mainMenu.SetActive(false); controls.SetActive(false); mainCamera = GameObject.FindWithTag("MainCamera"); mainCameraScript = mainCamera.GetComponent <TunnelCameraController>(); GameObject tunnelSection; tunnelSection = Instantiate(TunnelSectionPrefab) as GameObject; tunnelCollider = tunnelSection.GetComponent <BoxCollider>() as BoxCollider; tunnelLength = tunnelCollider.bounds.size.x; tunnelWidth = tunnelCollider.bounds.size.z; Destroy(tunnelSection); station = Instantiate(StationPrefab) as GameObject; station.transform.position = new Vector3(0, -3, -1.6f); stationCollider = station.GetComponent <BoxCollider>() as BoxCollider; stationLength = stationCollider.bounds.size.x; stationWidth = stationCollider.bounds.size.z; Renderer rend = station.transform.Find("LeftStation").Find("pillar").GetComponent <Renderer>(); rend.material.color = Color.red; print("Tunnel length=" + tunnelLength); print("Tunnel width=" + tunnelWidth); print("Station length=" + stationLength); print("Station width=" + stationWidth); train = new GameObject(); carriages = new GameObject[nCarriages]; for (int i = 0; i < nCarriages; i++) { GameObject trainCabin = Instantiate(TrainCabinPrefab) as GameObject; carriages[i] = trainCabin; trainCabin.transform.localPosition = new Vector3(-tunnelLength / 4 - tunnelLength * i / 2, 0, 0); trainCabin.transform.parent = train.transform; } print(train.transform.childCount); tunnel = new GameObject(); tunnel.transform.position = new Vector3(stationLength / 2, 0, 0); for (int i = 0; i < 3; i++) { GameObject t = Instantiate(TunnelSectionPrefab) as GameObject; t.transform.parent = tunnel.transform; t.transform.localPosition = new Vector3(tunnelLength * (i + 0.5f), 0, 0); } outChars = new GameObject[maxOutChars]; outCharGroup = new GameObject(); for (int i = 0; i < maxOutChars; i++) { GameObject outChar = Instantiate(OutCharPrefab) as GameObject; outChars[i] = outChar; outChar.transform.parent = outCharGroup.transform; outChar.transform.localPosition = new Vector3(-4 + i * 4, 1, -6); } outCharGroup.SetActive(false); previewChars = new GameObject[2, 3]; // [0=left, 1=right; 1,2,3...], maximum 3 preview characters previewCharGroup = new GameObject(); for (int j = 0; j < 2; j++) { for (int i = 0; i < 3; i++) { GameObject previewChar = Instantiate(OutCharPrefab) as GameObject; previewChars[j, i] = previewChar; previewChar.transform.parent = previewCharGroup.transform; previewChar.transform.localPosition = new Vector3(-4 + i * 4, 1, -8 + j * 16); if (j == 1) { previewChar.transform.rotation = Quaternion.Euler(0, 180, 0); } } } previewCharGroup.SetActive(false); StartCoroutine(MainMenu()); }