//turn on the scan void ScanOn() { scanningObject = select.selectedObject; scan = scanningObject.GetComponent <ObjectScannable>(); if (scan == null) { return; } //if it's a door, check if we scanned it before and after neutralisation ObjectDoor door = scanningObject.GetComponent <ObjectDoor>(); if (door != null) { if (door.isScannedOnce == false) { door.isScannedOnce = true; } else if (scan.number == 0) { door.isScannedAfterNeutralise = true; } } isScanning = true; //get the scanning readout on the scanner screen UpdateUIText(scan.number.ToString()); //start a coroutine that keeps the scan readout up on the screen for readingsTimer seconds timerCoroutine = StartCoroutine(CountDown(readingsTimer)); //if we have audio components, play the scanning sound if (scanSound != null && audios != null) { audios.clip = scanSound; audios.Play(); } }
public bool CheckIfLoseLife(GameObject selectedGameObject, int ringValue) { ObjectDoor door = selectedGameObject.GetComponent <ObjectDoor>(); if (door != null && (door.isScannedAfterNeutralise == false || door.isScannedOnce == false)) { return(true); } return(false); }
//链接区域 void connectArea() { int beginroomID = rooms [Random.Range(0, rooms.Count)].ID; //Debug.Log ("Pick first object ID "+ beginroomID); List <int> connectAreasID = new List <int>(); List <int[]> connector = new List <int[]>(); List <int[]> connectorInfo = new List <int[]>(); connectAreasID.Add(beginroomID); //Find ALL connector for (int i = 1; i < MapHeight - 1; i++) { for (int j = 1; j < MapWidth - 1; j++) { if (map [i, j] == -1) { if (map [i - 1, j] != -1 && map [i + 1, j] != -1 && map [i, j - 1] == -1 && map [i, j + 1] == -1 && map [i - 1, j] != map [i + 1, j]) { int[] pos = { i, j }; connector.Add(pos); int[] IDtoID = { map [i - 1, j], map [i + 1, j] }; connectorInfo.Add(IDtoID); } else if (map [i - 1, j] == -1 && map [i + 1, j] == -1 && map [i, j - 1] != -1 && map [i, j + 1] != -1 && map [i, j - 1] != map [i, j + 1]) { int[] pos = { i, j }; connector.Add(pos); int[] IDtoID = { map [i, j + 1], map [i, j - 1] }; connectorInfo.Add(IDtoID); } } } } List <int> connectorRemoveID = new List <int> (); int numofRoomAndMaze = rooms.Count + mazesID.Count; while (connectAreasID.Count <= numofRoomAndMaze || connectorRemoveID.Count < connectorInfo.Count) { //FindAllconnectorinAreas List <int> connectorIDtoAreas = new List <int>(); List <int> connectorIDtoAreasID = new List <int>(); for (int i = 0; i < connectorInfo.Count; i++) //all Connector { for (int j = 0; j < connectAreasID.Count; j++) //all MainAreas ID { bool isInRemove = false; for (int l = 0; l < connectorRemoveID.Count; l++) { if (connectorRemoveID [l] == i) { isInRemove = true; } } if (!isInRemove) { if (connectorInfo [i] [0] == connectAreasID [j]) { connectorIDtoAreas.Add(i); connectorIDtoAreasID.Add(connectorInfo [i] [1]); } else if (connectorInfo [i] [1] == connectAreasID [j]) { connectorIDtoAreas.Add(i); connectorIDtoAreasID.Add(connectorInfo [i] [0]); } } } } if (connectorIDtoAreas.Count == 0) { break; } int pick = Random.Range(0, connectorIDtoAreas.Count); int pickconntorID = connectorIDtoAreas [pick]; int pickconntorAreasID = connectorIDtoAreasID [pick]; connectAreasID.Add(pickconntorAreasID); int x = connector [pickconntorID] [0]; int y = connector [pickconntorID] [1]; map [x, y] = numOfObj; idtype.Add(numOfObj, "MAZE"); ObjectDoor adoor = new ObjectDoor(x, y); obj_list.addObj(adoor); // DoorData d = new DoorData (); // d.ID = numOfObj; // d.x = x; // d.y = y; // doors.Add (d); numOfObj++; //Debug.Log (" connect object ID "+ pickconntorAreasID+" From["+x+","+y+"]"); for (int k = 0; k < connectorIDtoAreas.Count; k++) { int delconntorID = connectorIDtoAreas [k]; int delconntorAreasID = connectorIDtoAreasID [k]; if (pickconntorAreasID == delconntorAreasID) { connectorRemoveID.Add(delconntorID); //Debug.Log (" del connect"+ k+" From["+delx+","+dely+"]"); } } } Debug.Log("ObecjtNum = " + numOfObj + " , ROOM NUM = " + rooms.Count + " , MAZE NUM = " + mazesID.Count); }