public GeffeGenerator(long seed) { _registers = new Register[3]; for (int i = 0; i < 3; i++) { switch (i) { case 0: { _registers[i] = new L11(seed); break; } case 1: { _registers[i] = new L9(seed); break; } case 2: { _registers[i] = new L10(seed); break; } } } var builder = new StringBuilder("\n"); foreach (var reg in _registers) { builder.Append($"{reg.GetType().Name}: {reg.Seed}\n"); } Seed = builder.ToString(); }
public DataGridView Pack_Elements(int Table_length, int Table_width, DataGridView Elements) { // // Packing elements in sequence along X axis of table, // with horizontal orientation exclusively. // // Algorithm has optimisation for adjusting area // of positions along X axes // // // This method needs three arguments and returns one argument. // Table_length, Table_width and DataGridView Elements. // // Structure of DataGridView that is going to be passed as argument, // from caller method, must be the same as structure of // DataGridView ELEMENT_LIST. // // Method returns DataGridView TABLE_LIST with data // of packed elements: index, x, y, length and width. // // // // Initialize_Tables(); // // // Initialize_Variables(); // // Set table length and width // Tl = Table_length; Tw = Table_width; // // Copy element dimensions from DataGridView Elements // to ELEMENT_LIST table and format it's values // // Set elements counter to zero n = 0; // Set table row counter to zero i = 0; // Fill ELEMENT_LIST for (i = 0; i < Elements.RowCount; i++) { if (Elements[1, i].Value != null) { ELEMENT_LIST.Rows.Add(); ELEMENT_LIST[0, i].Value = (int.Parse(Elements[0, i].Value.ToString())).ToString(format); ELEMENT_LIST[1, i].Value = (int.Parse(Elements[1, i].Value.ToString())).ToString(format); ELEMENT_LIST[2, i].Value = (int.Parse(Elements[2, i].Value.ToString())).ToString(format); ELEMENT_LIST[3, i].Value = (int.Parse(Elements[3, i].Value.ToString())).ToString(format); ELEMENT_LIST[4, i].Value = (int.Parse(Elements[4, i].Value.ToString())).ToString(format); // Increase elements counter by one n++; } } // // Sort elements in descending sort order // first by area then by length then by width of elements // ELEMENT_LIST.Sort(ELEMENT_LIST.Columns[3], ListSortDirection.Descending); // Set position coordinates to origin p_X = 0; p_Y = 0; // // Enter coordinates and dimensions // of first position in table 'POSITION_LIST' // POSITION_LIST.Rows.Add(p_X.ToString(format), // X coordinate p_Y.ToString(format), // Y coordinate Tl.ToString(format), // table lenght Tw.ToString(format)); // table width // Set position counter to one k = 1; // Set counter of packed elements to zero p = 0; // // Pack elements while there is free positions and // elements for packing // while (k > 0 && n > 0) { // Sort positions in ascending sort order first by Y, and then by X axes POSITION_LIST.Sort(POSITION_LIST.Columns[1], ListSortDirection.Ascending); // Get length and width of first position in 'POSITION_LIST' Pl = int.Parse(POSITION_LIST[2, 0].Value.ToString()); Pw = int.Parse(POSITION_LIST[3, 0].Value.ToString()); // Calculate fitting factor for each element for the first position for (i = 0; i < n; i++) { // Element length l = int.Parse(ELEMENT_LIST[1, i].Value.ToString()); // Element width w = int.Parse(ELEMENT_LIST[2, i].Value.ToString()); // Set fitting factor initial value f = 0; // Does element fits inside position if (Pl < l || Pw < w) { // If not f = 0; } else { // If yes f++; // if (Pl == l) { // If element fits exactly across lenght of position f++; } // if (Pw == w) { // If element fits exactly across width of position f++; } } // Enter fitting factor value inside ELEMENT_LIST table ELEMENT_LIST[4, i].Value = f.ToString(format); } // // Sort elements in descending sort order first by fitting factor value, // then by area then by length then by width of elements // ELEMENT_LIST.Sort(ELEMENT_LIST.Columns[4], ListSortDirection.Descending); // // Get fitting factor value for the first element // f = int.Parse(ELEMENT_LIST[4, 0].Value.ToString()); // // If fitting factor is greater than zero // element can be packed inside selected position // if (f > 0) { // // Get coordinates of selected position // p_X = int.Parse(POSITION_LIST[0, 0].Value.ToString()); p_Y = int.Parse(POSITION_LIST[1, 0].Value.ToString()); // Get index, length and width of packed element x = int.Parse(ELEMENT_LIST[0, 0].Value.ToString()); l = int.Parse(ELEMENT_LIST[1, 0].Value.ToString()); w = int.Parse(ELEMENT_LIST[2, 0].Value.ToString()); // // Enter coordinates of position, // element dimensions and index, // at TABLE LIST // TABLE_LIST.Rows.Add(); TABLE_LIST[0, p].Value = x.ToString(); // index TABLE_LIST[1, p].Value = p_X.ToString(); // position x TABLE_LIST[2, p].Value = p_Y.ToString(); // position y TABLE_LIST[3, p].Value = l.ToString(); // element length TABLE_LIST[4, p].Value = w.ToString(); // element width // Increase packed elements counter by one p++; // Erase packed element from list of elements ELEMENT_LIST.Rows.RemoveAt(0); // Decrease elements counter by one n--; // // If there is free elements left // seek for new positions // if (n > 0) { // // Sort elements in descending sort order, // first by area then by length then by width of elements // // This step is necessary for faster searching // for element that can fit inside new positions // // And the elements are sorted accordingly to demand of // second restriction in algorithm development // for the next step in packing process // ELEMENT_LIST.Sort(ELEMENT_LIST.Columns[3], ListSortDirection.Descending); // Set new position 'is adequate' state flag P_ok = true; // // New position II with coordinates // at upper left corner of previous // packed element // if (Pw > w) { // // Initialize local variables // X12 = 0; Y12 = 0; L12 = 0; W12 = 0; A12 = 0; // Set new position 'is adequate' state flag P_ok = false; // // Coordinates of new position II // X12 = p_X; Y12 = p_Y + w; // // Length, width and area of new position II // L12 = Tl - X12; W12 = Pw - w; A12 = L12 * W12; // // Find is there element left that can fit inside position // // Set ELEMENT_LIST table counter value i = n - 1; // // Get area of the last element in table // a = int.Parse(ELEMENT_LIST[3, i].Value.ToString()); while (a <= A12 && i > -1) { // // Get next element area // a = int.Parse(ELEMENT_LIST[3, i].Value.ToString()); // // Get element length and width value // Lmin = int.Parse(ELEMENT_LIST[1, i].Value.ToString()); Wmin = int.Parse(ELEMENT_LIST[2, i].Value.ToString()); // // If element can fit // at observed position, // set new position II at list of positions // if (L12 >= Lmin && W12 >= Wmin) { POSITION_LIST.Rows.Add(X12.ToString(format), Y12.ToString(format), L12.ToString(format), W12.ToString(format)); // Increase positions counter by one k++; // Set new position 'is adequate' state flag P_ok = true; // Set counter value to loop exit value i = -1; } // Decrease elements counter by one i--; } } // // New position I with coordinates // at lower right corner of previous // packed element // if (Pl > l) { // // Initialize local variables // X11 = 0; Y11 = 0; L11 = 0; W11 = 0; A11 = 0; // // Coordinates of new position I // X11 = p_X + l; Y11 = p_Y; // // Length, width and area of new position I // L11 = Tl - X11; W11 = w; A11 = L11 * W11; // // If position two is inadeqate, // adjust width of position one // if (!P_ok) { W11 = W11 + W12; A11 = L11 * W11; } // // Find is there element left that can fit inside position // // Set element counter value i = n - 1; // // Get area of the last element in table // a = int.Parse(ELEMENT_LIST[3, i].Value.ToString()); while (a <= A11 && i > -1) { // // Get next element area // a = int.Parse(ELEMENT_LIST[3, i].Value.ToString()); // // Get element length and width value // Lmin = int.Parse(ELEMENT_LIST[1, i].Value.ToString()); Wmin = int.Parse(ELEMENT_LIST[2, i].Value.ToString()); // // If there is element that can fit // at position, // set new position I at list of positions // if (L11 >= Lmin && W11 >= Wmin) { POSITION_LIST.Rows.Add(X11.ToString(format), Y11.ToString(format), L11.ToString(format), W11.ToString(format)); // Increase positions counter by one k++; // Set counter value to loop exit value i = -1; } // Decrease elements counter by one i--; } } } } // // Is there free elements left for packing // if (n > 0) { // // Erase first position from list // POSITION_LIST.Rows.RemoveAt(0); // Decrease positions counter by one k--; } } // // End of packing process // return(TABLE_LIST); }
/// <summary> /// Builds Shipment Status. /// Original from https://ps.nafta.extra.fcagroup.com/sites/itb-ebus/Shared%20Documents/214STARSShipmentStatus.pdf /// </summary> static TS214 BuildShipmentStatus(string controlNumber) { var result = new TS214(); // Start Transaction Set 214 // Control number = 0006 result.ST = new ST(); result.ST.TransactionSetIdentifierCode_01 = "214"; result.ST.TransactionSetControlNumber_02 = controlNumber.PadLeft(9, '0'); // Reference Number = 123456 // Carrier SCAC = BAWC // Route Code = ROUTE1 result.B10 = new B10(); result.B10.ReferenceIdentification_01 = "123456"; result.B10.StandardCarrierAlphaCode_03 = "BAWC"; result.B10.ReferenceIdentificationQualifier_05 = "RU"; result.B10.ReferenceIdentification_06 = "ROUTE1"; // Repeating L11 result.L11 = new List <L11>(); // Power unit = 55555555 var l11 = new L11(); l11.ReferenceIdentification_01 = "55555555"; l11.ReferenceIdentificationQualifier_02 = "EQ"; result.L11.Add(l11); // Repeating N1 Loops result.N1Loop = new List <Loop_N1_214>(); // Begin N1 Loop 1 var n1Loop1 = new Loop_N1_214(); // Pick-up location = 23083C n1Loop1.N1 = new N1(); n1Loop1.N1.EntityIdentifierCode_01 = "SF"; n1Loop1.N1.IdentificationCodeQualifier_03 = "92"; n1Loop1.N1.IdentificationCode_04 = "23083C"; // Pick-up city and state = Decorah, IA // Pick - up country = US(United States) n1Loop1.N4 = new N4(); n1Loop1.N4.CityName_01 = "DECORAH"; n1Loop1.N4.StateorProvinceCode_02 = "IA"; n1Loop1.N4.CountryCode_04 = "US"; // End N1 Loop 1 result.N1Loop.Add(n1Loop1); // Begin N1 Loop 2 var n1Loop2 = new Loop_N1_214(); // Delivery location = 00073 n1Loop2.N1 = new N1(); n1Loop2.N1.EntityIdentifierCode_01 = "ST"; n1Loop2.N1.IdentificationCodeQualifier_03 = "92"; n1Loop2.N1.IdentificationCode_04 = "00073"; // Delivery city and state = Summit, IL // Delivery country = US(United States) n1Loop2.N4 = new N4(); n1Loop2.N4.CityName_01 = "SUMMIT"; n1Loop2.N4.StateorProvinceCode_02 = "IL"; n1Loop2.N4.CountryCode_04 = "US"; // End N1 Loop 2 result.N1Loop.Add(n1Loop2); // Repeating MS3 result.MS3 = new List <MS3>(); // Power SCAC code = BAWC // Origin / Delivery Carrier Transportation Mode // = GG(Geographic Shipping and Receiving) var ms3 = new MS3(); ms3.StandardCarrierAlphaCode_01 = "BAWC"; ms3.RoutingSequenceCode_02 = "B"; ms3.TransportationMethodTypeCode_04 = "GG"; result.MS3.Add(ms3); // Repeating LX Loops result.LXLoop = new List <Loop_LX_214>(); // Begin LX Loop var lxLoop1 = new Loop_LX_214(); // Assigned number = 1 lxLoop1.LX = new LX(); lxLoop1.LX.AssignedNumber_01 = "1"; // Repeating At7 Loops lxLoop1.AT7Loop = new List <Loop_AT7_214>(); // Begin AT7 Loop var at7loop1 = new Loop_AT7_214(); // Arrival at Pick-Up Location // Arrival date = 09 / 25 / 1997 // Arrival time = 08:30AM // Time Zone = Central Time at7loop1.AT7 = new AT7(); at7loop1.AT7.ShipmentStatusCode_01 = "X3"; at7loop1.AT7.ShipmentStatusorAppointmentReasonCode_02 = "NS"; at7loop1.AT7.Date_05 = "19970925"; at7loop1.AT7.Time_06 = "0830"; at7loop1.AT7.TimeCode_07 = "CT"; // Latitude // = 043 Degrees, 18 Minutes, 36 Seconds North // Longitude // = 091 Degrees, 47 Minutes, 26 Seconds West at7loop1.MS1 = new MS1(); at7loop1.MS1.LongitudeCode_04 = "0914726"; at7loop1.MS1.LatitudeCode_05 = "0431836"; at7loop1.MS1.DirectionIdentifierCode_06 = "W"; at7loop1.MS1.DirectionIdentifierCode_07 = "N"; // End AT7 Loop lxLoop1.AT7Loop.Add(at7loop1); // End LX Loop result.LXLoop.Add(lxLoop1); return(result); }
// Update is called once per frame void Update() { NowCursorState = tmpCursor.GetComponent <AnimatedCursor>().tmpCursorState; PlaceBtnState = PlaceButton.GetComponent <ButtonInteraction>().NowButtonState; DeleteBtnState = DeleteButton.GetComponent <ButtonInteraction>().NowButtonState; CancelBtnState = CancelButton.GetComponent <ButtonInteraction>().NowButtonState; lineRenderer = GetComponent <LineRenderer>(); //Debug.Log("Cursor Position: " + tmpCursor.transform.position); //Vector3 CursorPosition = tmpCursor.GetComponent<Transform>().position; if ((ButtonInteraction.PosState == PosButtonType.PLACE) && (NowCursorState == CursorStateEnum.Release) && (PlaceBtnState != ButtonStateEnum.Targeted) && (PlaceBtnState != ButtonStateEnum.Pressed) && (DeleteBtnState != ButtonStateEnum.Observation) && (CancelBtnState != ButtonStateEnum.Observation)) { if (SizeButtonCollection.SizeButtonState == SizeButtonType.MEDIUM) { offset = 6.0f; } else if (SizeButtonCollection.SizeButtonState == SizeButtonType.LARGE) { offset = 8.0f; } else if (SizeButtonCollection.SizeButtonState == SizeButtonType.SMALL) { offset = 5.0f; } Vector3 FinalPos = tmpCursor.transform.position - new Vector3(0f, 0f, 0.1f) * offset; Instantiate(PlaneObject, FinalPos, transform.rotation, this.transform); //Genarate the drone ChildCount = this.transform.childCount; /*Use to process the three Red Light*/ if (ChildCount > 1) { Vector3 pos1, pos2; //the position of two way point(drone) Vector3 p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18; //Red light initial position pos1 = this.gameObject.transform.GetChild(ChildCount - 2).transform.position; pos2 = this.gameObject.transform.GetChild(ChildCount - 1).transform.position; p0 = (pos1 * 1 + pos2 * 19) / 20; p1 = (pos1 * 2 + pos2 * 18) / 20; p2 = (pos1 * 3 + pos2 * 17) / 20; p3 = (pos1 * 4 + pos2 * 16) / 20; p4 = (pos1 * 5 + pos2 * 15) / 20; p5 = (pos1 * 6 + pos2 * 14) / 20; p6 = (pos1 * 7 + pos2 * 13) / 20; p7 = (pos1 * 8 + pos2 * 12) / 20; p8 = (pos1 * 9 + pos2 * 11) / 20; p9 = (pos1 * 10 + pos2 * 10) / 20; p10 = (pos1 * 11 + pos2 * 9) / 20; p11 = (pos1 * 12 + pos2 * 8) / 20; p12 = (pos1 * 13 + pos2 * 7) / 20; p13 = (pos1 * 14 + pos2 * 6) / 20; p14 = (pos1 * 15 + pos2 * 5) / 20; p15 = (pos1 * 16 + pos2 * 4) / 20; p16 = (pos1 * 17 + pos2 * 3) / 20; p17 = (pos1 * 18 + pos2 * 2) / 20; p18 = (pos1 * 19 + pos2 * 1) / 20; L0 = Instantiate(CloneRedLight_0, p0, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L0.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L0.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L0.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L1 = Instantiate(CloneRedLight_1, p1, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L1.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L1.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L1.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L2 = Instantiate(CloneRedLight_2, p2, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L2.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L2.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L2.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L3 = Instantiate(CloneRedLight_3, p3, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L3.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L3.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L3.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L4 = Instantiate(CloneRedLight_4, p4, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L4.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L4.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L4.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L5 = Instantiate(CloneRedLight_5, p5, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L5.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L5.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L5.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L6 = Instantiate(CloneRedLight_6, p6, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L6.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L6.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L6.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L7 = Instantiate(CloneRedLight_7, p7, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L7.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L7.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L7.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L8 = Instantiate(CloneRedLight_8, p8, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L8.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L8.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L8.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L9 = Instantiate(CloneRedLight_9, p9, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L9.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L9.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L9.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L10 = Instantiate(CloneRedLight_10, p10, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L10.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L10.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L10.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L11 = Instantiate(CloneRedLight_11, p11, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L11.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L11.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L11.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L12 = Instantiate(CloneRedLight_12, p12, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L12.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L12.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L12.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L13 = Instantiate(CloneRedLight_13, p13, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L13.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L13.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L13.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L14 = Instantiate(CloneRedLight_14, p14, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L14.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L14.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L14.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; ///////////////////////////////////////// L15 = Instantiate(CloneRedLight_15, p15, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L15.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L15.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L15.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L16 = Instantiate(CloneRedLight_16, p16, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L16.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L16.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L16.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L17 = Instantiate(CloneRedLight_17, p17, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L17.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L17.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L17.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; L18 = Instantiate(CloneRedLight_18, p18, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform); L18.GetComponent <RedLightPos>().Obj1 = this.gameObject.transform.GetChild(ChildCount - 2).gameObject; L18.GetComponent <RedLightPos>().Obj2 = this.gameObject.transform.GetChild(ChildCount - 1).gameObject; L18.GetComponent <RedLightPos>().Current_Num = ChildCount - 2; } //WayPoint.Add(tmp); //Debug.Log("InstantiateInstantiateInstantiateInstantiateInstantiateInstantiate"); } /* Line Process*/ ChildCount = this.transform.childCount; lineRenderer.SetVertexCount(ChildCount); if (ChildCount > 1) { for (int i = 0; i < ChildCount; i++) { tmp = this.gameObject.transform.GetChild(i).gameObject; lineRenderer.SetPosition(i, tmp.transform.position); } /*Obstacle Detect*/ for (int i = 0; i < ChildCount - 1; i++) { Obj1 = this.gameObject.transform.GetChild(i).gameObject; Obj2 = this.gameObject.transform.GetChild(i + 1).gameObject; Ray ray = new Ray(Obj1.transform.position, Obj2.transform.position - Obj1.transform.position); RaycastHit hit; //Debug.Log( i + " -> " + (i+1) + " distance : " + Vector3.Distance(Obj1.transform.position, Obj2.transform.position)); float distance = Vector3.Distance(Obj1.transform.position, Obj2.transform.position) - 0.1f; Physics.Raycast(ray, out hit, distance, mask); //When collision is NOT NULL, there is obstacles if (hit.transform != null) { lineRenderer.material = LineMat2; // if collision the line become red //Debug.Log("BBBBBBBBB"); //LineCollision = false; // Let Other Script Know Collision State //LineCollisionNum = i + 1; Debug.Log("Blocked by : " + hit.transform.name); } //If is NULL -> No Obstacles else if (hit.transform == null) { lineRenderer.material = LineMat1; //LineCollision = true; //LineCollisionNum = -1; //Debug.Log("NNNNNNNNN"); } //Debug.Log("Line color : " + lineRenderer.material); } } //if(ChildCount == 2) lineRenderer.SetPosition(2, new Vector3(0,0,1)); }