private void OnTriggerEnter(Collider other) { // Debug.Log("entered"); //speed = 1; // counter.timeLeft = counter.timeLeft-100; //hdz = true; ++checkhdz; if (checkhdz == 1) { MyDetail2 md = new MyDetail2(); md.player_id = Convert.ToInt32(ros2.id); md.point = -5; // md.topic = "/w_ddzcoordinates"; StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) using (JsonTextWriter writer = new JsonTextWriter(sw)) { writer.QuoteChar = '\''; JsonSerializer ser = new JsonSerializer(); ser.Serialize(writer, md); } playerpointaddition = sb.ToString(); // playerpointdeductdz = sb.ToString(); playerpointdeductionbool = true; } }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "wall") // or if(gameObject.CompareTag("YourWallTag")) { clue = false; ++checkcollision; rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; move = Vector3.zero; bound_x1 = (collision.gameObject.GetComponent <MeshFilter>().mesh.bounds.center.x - collision.gameObject.GetComponent <MeshFilter>().mesh.bounds.extents.x) * -1; bound_x2 = (collision.gameObject.GetComponent <MeshFilter>().mesh.bounds.center.x + collision.gameObject.GetComponent <MeshFilter>().mesh.bounds.extents.x) * -1; bound_z1 = (collision.gameObject.GetComponent <MeshFilter>().mesh.bounds.center.z - collision.gameObject.GetComponent <MeshFilter>().mesh.bounds.extents.z) * -1; bound_z2 = (collision.gameObject.GetComponent <MeshFilter>().mesh.bounds.center.z + collision.gameObject.GetComponent <MeshFilter>().mesh.bounds.extents.z) * -1; foreach (GameObject hc in hcs) { // Debug.Log(bound_x1); // Debug.Log(bound_x2); // Debug.Log(bound_z1); // Debug.Log(bound_z2); // Debug.Log(hc.transform.localPosition); // Debug.Log(hc.transform.position.x); // Debug.Log(hc.transform.position.y); // Debug.Log(hc.transform.position.z); if (bound_x2 < hc.transform.position.x && hc.transform.position.x < bound_x1 && bound_z2 < hc.transform.position.z && hc.transform.position.z < bound_z1) { if (hc.GetComponent <Text>().text == "Treasure") { clue = true; GameObject.Find("gamestatus").GetComponent <Text>().text = "You found the treasure!!!"; ++treasurefound; if (treasurefound == 1) { MyDetail2 md = new MyDetail2(); md.player_id = Convert.ToInt32(ros2.id); md.point = 20; // md.topic = "/w_ddzcoordinates"; StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) using (JsonTextWriter writer = new JsonTextWriter(sw)) { writer.QuoteChar = '\''; JsonSerializer ser = new JsonSerializer(); ser.Serialize(writer, md); } playerpointaddition = sb.ToString(); playerpointadditionbool = true; } } else { if (foundclues.Count(x => x == Convert.ToInt32(getBetween(hc.GetComponent <Text>().text, "\'", "\'"))) == 0) { clue = true; //Debug.Log("here in the clue"); foundclues[foundcluescounter] = Convert.ToInt32(getBetween(hc.GetComponent <Text>().text, "\'", "\'")); ++foundcluescounter; if (GameObject.Find("Clues").GetComponent <Text>().text == "Clues Placeholder") { GameObject.Find("Clues").GetComponent <Text>().text = hc.GetComponent <Text>().text.Substring(hc.GetComponent <Text>().text.LastIndexOf(':') + 1); MyDetail2 md = new MyDetail2(); md.player_id = Convert.ToInt32(ros2.id); md.point = 10; // md.topic = "/w_ddzcoordinates"; StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) using (JsonTextWriter writer = new JsonTextWriter(sw)) { writer.QuoteChar = '\''; JsonSerializer ser = new JsonSerializer(); ser.Serialize(writer, md); } playerpointaddition = sb.ToString(); playerpointadditionbool = true; } else { clue = true; GameObject.Find("Clues").GetComponent <Text>().text = GameObject.Find("Clues").GetComponent <Text>().text + ", " + hc.GetComponent <Text>().text.Substring(hc.GetComponent <Text>().text.LastIndexOf(':') + 1); MyDetail2 md = new MyDetail2(); md.player_id = Convert.ToInt32(ros2.id); md.point = 10; // md.topic = "/w_ddzcoordinates"; StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) using (JsonTextWriter writer = new JsonTextWriter(sw)) { writer.QuoteChar = '\''; JsonSerializer ser = new JsonSerializer(); ser.Serialize(writer, md); } playerpointaddition = sb.ToString(); playerpointadditionbool = true; } } } } } if (checkcollision == 1 && clue == false) { // Debug.Log("here out the clue"); // Debug.Log("Entered"); playerpointadditionbool = true; MyDetail2 md = new MyDetail2(); md.player_id = Convert.ToInt32(ros2.id); md.point = -2; // md.topic = "/w_ddzcoordinates"; StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) using (JsonTextWriter writer = new JsonTextWriter(sw)) { writer.QuoteChar = '\''; JsonSerializer ser = new JsonSerializer(); ser.Serialize(writer, md); } playerpointaddition = sb.ToString(); } } }