void Awake() { if (Connected_GameObj.GetComponent <Puzzle_Hologram>() != null) { script_P = Connected_GameObj.GetComponent <Puzzle_Hologram>(); } if (Connected_GameObj.GetComponent <Puzzle_Hologram_2>() != null) { script_P2 = Connected_GameObj.GetComponent <Puzzle_Hologram_2>(); } if (script_P == null && script_P2 == null) { Debug.Log("From Door_2 변수 오류 " + this.gameObject); } StartCoroutine(Cyclic_Check()); }
} //인식기 각도 변경 void Get_target_hologram_Info() { RaycastHit hit; Ray ray = new Ray(cam_Head.transform.position, cam_Head.transform.forward); if (Physics.Raycast(ray, out hit, cam_Check_Distance)) { if (hit.transform.GetComponent <Puzzle_Part_Hologram>() != null) { script_PH = hit.transform.GetComponent <Puzzle_Part_Hologram>().script_PH; script_PH2 = null; } else if (hit.transform.GetComponent <Puzzle_Hologram_2>() != null) { script_PH2 = hit.transform.GetComponent <Puzzle_Hologram_2>(); script_PH = null; } else { script_PH = null; script_PH2 = null; } } else { script_PH = null; script_PH2 = null; } //Debug.Log("From function_CNN get signal Check : " + cam_Head + " " + cam_Check_Angle + " " + cam_Check_Distance); int i = 0; Collider[] overlapped_Obj = Physics.OverlapSphere(transform.position, cam_Check_Distance); // 나중에 여기에 레이어 마스크 먹이자 foreach (Collider node in overlapped_Obj) { if (node.GetComponent <Puzzle_Node>() != null) { if (node.GetComponent <Puzzle_Node>().Get_Signal(cam_Head, cam_Check_Angle, cam_Check_Distance)) { node_in_Distance[i++] = node.gameObject; //Debug.Log("From function_CNN nodeCheck True node"); } //else Debug.Log("From function_CNN nodeCheck false node"); } } } //일정 거리 &각도 안에 노드에게 인식 정보 전달 및 노드 정보 받음
public void GetSignal(Vector3 contact_Point, GameObject target_Obj) { //Debug.Log("From function_CNN Get Signal"); contact_point_Received = contact_Point; if (target_Obj.GetComponent <Puzzle_Part_Hologram>() != null) { script_PH = target_Obj.GetComponent <Puzzle_Part_Hologram>().script_PH; script_PH2 = null; } else if (target_Obj.GetComponent <Puzzle_Hologram_2>() != null) { script_PH2 = target_Obj.GetComponent <Puzzle_Hologram_2>(); script_PH = null; } cam_head_position = cam_Head.transform.position; Quaternion_cam_will_Look = Quaternion.LookRotation((contact_Point - cam_head_position).normalized); Cam_Look(); //Debug.Log("From function_CNN Get Cam head position : " + cam_head_position); //Debug.Log("From function_CNN Get Cam head global position : " + transform.TransformPoint(cam_head_position)); } // 플레이어의 전기탄이 홀로그램에 부딪혀서 그 정보가 이곳으로
} //일정 거리 &각도 안에 노드에게 인식 정보 전달 및 노드 정보 받음 IEnumerator Cyclic_Result_Check() { while (true) { //Debug.Log("From function_CNN Corouting Running" + this.gameObject ); yield return(new WaitForSeconds(1.0f)); if (script_T.Circuit_On) { Get_target_hologram_Info(); //주기적으로 노드에게 인식 정보 전달 } else { script_PH = null; script_PH2 = null; } int i = 0, j; if (script_PH != null) { for (j = 0; j < 4; j++) { if (script_PH.Node_Check_result[j]) { if (!script_PH.Node_Check_Cleared[j]) { Send_order_to_Hologram(i++); script_PH.Node_Check_Cleared[j] = true; } GetComponent <Line_Connection>().ScriptOnOff(true); } } } else if (script_PH2 != null) { for (j = 0; j < 4; j++) { if (script_PH2.Node_Check_result[j]) { if (!script_PH2.Node_Check_Cleared[j]) { Send_order_to_Hologram(i++); script_PH2.Node_Check_Cleared[j] = true; } GetComponent <Line_Connection>().ScriptOnOff(true); } } } /*if (script_PH != null) foreach (bool result in script_PH.Node_Check_result) { * if (result) Send_order_to_Hologram(i); * i++; * } * else if(script_PH2 != null) foreach (bool result in script_PH2.Node_Check_result) * { * if (result) Send_order_to_Hologram(i); * i++; * }*/ else { GetComponent <Line_Connection>().ScriptOnOff(false); } //Debug.Log("From function_CNN coroutine Check"); } } // 주기적으로 노드 인식 정보 전달 및 체크