void OnTriggerStay(Collider other) // bara kolla bitarna när man har släppt dem. //if(enter_exit){ { if (!Input.GetMouseButtonDown(0)) { if (other.tag == "PusselBit" && ptrPuzzel_Piece == null) { ptrPuzzel_Piece = other.GetComponent <Puzzel_piece>(); ptrPuzzel_Piece.inUse = true; if (slot_empty && !ptrPuzzel_Piece.holding) { slot_empty = false; ptrPuzzel_Piece.transform.position = areaSnapping(); //Debug.Log("pusselbit"); speaker.clip = insertFuse; speaker.Play(); } //} } else { if (other.tag == "PusselBit" && !slot_empty && other != ptrPuzzel_Piece) { Puzzel_piece temp = other.GetComponent <Puzzel_piece>(); temp.inUse = false; //speaker.Play(); temp.Reposition(); //Debug.LogWarning("Pussel-spot occupied"); } } } }
void OnTriggerStay(Collider other) {// bara kolla bitarna när man har släppt dem. //if(enter_exit){ if(!Input.GetMouseButtonDown(0)){ if(other.tag == "PusselBit" && ptrPuzzel_Piece == null){ ptrPuzzel_Piece = other.GetComponent<Puzzel_piece>(); ptrPuzzel_Piece.inUse = true; if( slot_empty && !ptrPuzzel_Piece.holding){ slot_empty = false; ptrPuzzel_Piece.transform.position = areaSnapping(); //Debug.Log("pusselbit"); speaker.clip = insertFuse; speaker.Play(); } //} }else{ if(other.tag == "PusselBit" && !slot_empty && other != ptrPuzzel_Piece){ Puzzel_piece temp = other.GetComponent<Puzzel_piece>(); temp.inUse = false; //speaker.Play(); temp.Reposition(); //Debug.LogWarning("Pussel-spot occupied"); } } } }
// Update is called once per frame void Update() { if (enabled) // should be ENABLED //on collision enter ////Debug.Log ("mouse " + Input.GetMouseButtonDown(0)); //-------------------------------------------------------------------------------------------------------------------------------------------------- { if (Input.GetMouseButton(0) && tempPiece == null) // if we don't have a piece, try to find one //reset mousecounter //buttonDelayCounter = Time.time; //Input for where the user is pointing { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits; hits = Physics.RaycastAll(ray); int i = 0; while (i < hits.Length) { RaycastHit hit = hits[i]; i++; //--------------------------------------------------------- //Puts object in Inventory if (hit.transform.tag == "PusselBit" && tempPiece == null) { // pressed a pussel piece tempPiece = hit.transform.gameObject.GetComponent <Puzzel_piece>(); tempPiece.holding = true; } } } //----------------------------------------------------------------------------------------------------------------------------------------------------- if (Input.GetMouseButton(0) && tempPiece != null) // We are holding a piece { if (tempPiece.correct) { ////Debug.Log (Input.mousePosition.x + " " + Input.mousePosition.y + " " + Input.mousePosition.z); Vector3 newPos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z)); newPos.z = -2; tempPiece.transform.position = newPos; } } //----------------------------------------------------------------------------------------------------------------------------------------------------- if (!Input.GetMouseButton(0) && tempPiece != null) // we dropped the piece { tempPiece.holding = false; tempPiece = null; } //----------------------------------------------------------------------------------------------------------------------------------------------------- if (CheckIfCorrect() && !Completed) { Completed = true; //Debug.Log("SUCCESS YOU COMPLETED THE PUZZLE!!!"); } } }
// Update is called once per frame void Update () { if(enabled){// should be ENABLED //on collision enter ////Debug.Log ("mouse " + Input.GetMouseButtonDown(0)); //-------------------------------------------------------------------------------------------------------------------------------------------------- if(Input.GetMouseButton(0) && tempPiece == null){// if we don't have a piece, try to find one //reset mousecounter //buttonDelayCounter = Time.time; //Input for where the user is pointing Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits; hits = Physics.RaycastAll(ray); int i = 0; while(i < hits.Length){ RaycastHit hit = hits[i]; i++; //--------------------------------------------------------- //Puts object in Inventory if(hit.transform.tag == "PusselBit" && tempPiece == null){ // pressed a pussel piece tempPiece = hit.transform.gameObject.GetComponent<Puzzel_piece>(); tempPiece.holding = true; } } } //----------------------------------------------------------------------------------------------------------------------------------------------------- if(Input.GetMouseButton(0) && tempPiece != null){// We are holding a piece if(tempPiece.correct){ ////Debug.Log (Input.mousePosition.x + " " + Input.mousePosition.y + " " + Input.mousePosition.z); Vector3 newPos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z)); newPos.z = -2; tempPiece.transform.position = newPos; } } //----------------------------------------------------------------------------------------------------------------------------------------------------- if(!Input.GetMouseButton(0) && tempPiece != null){// we dropped the piece tempPiece.holding = false; tempPiece = null; } //----------------------------------------------------------------------------------------------------------------------------------------------------- if(CheckIfCorrect() && !Completed){ Completed = true; //Debug.Log("SUCCESS YOU COMPLETED THE PUZZLE!!!"); } } }
void OnTriggerExit(Collider other) // om du tar bort en bit från dess rätta plats så får platsen ett "unfinished state" { if (other.tag == "PusselBit") { Puzzel_piece temp = other.GetComponent <Puzzel_piece>(); if (temp == ptrPuzzel_Piece) { slot_empty = true; if (ptrPuzzel_Piece.Piece_KeyValue == correct_slot_value) { Correct = false; } ptrPuzzel_Piece.inUse = false; ptrPuzzel_Piece = null; //enter_exit = false; speaker.clip = removeFuse; speaker.Play(); } } }
void OnTriggerExit(Collider other){// om du tar bort en bit från dess rätta plats så får platsen ett "unfinished state" if(other.tag == "PusselBit"){ Puzzel_piece temp = other.GetComponent<Puzzel_piece>(); if(temp == ptrPuzzel_Piece){ slot_empty = true; if(ptrPuzzel_Piece.Piece_KeyValue == correct_slot_value){ Correct = false; } ptrPuzzel_Piece.inUse = false; ptrPuzzel_Piece = null; //enter_exit = false; speaker.clip = removeFuse; speaker.Play(); } } }
void addPieceElement(Puzzel_piece x) //add a element to the list { Ppiece_list.Add(x); }
void addPieceElement(Puzzel_piece x){ //add a element to the list Ppiece_list.Add(x); }