void FixedUpdate() { if (losing == true) { return; } if (Input.GetKey (KeyCode.RightArrow)) { player.rotating(-3f); } if (Input.GetKey (KeyCode.LeftArrow)) { player.rotating(3f); } if (Input.GetKey (KeyCode.UpArrow)) { //player.moving(3f, (Random.value * (drunkeness/2 - (-drunkeness/2)) + -drunkeness/2)/10); player.moving(3f, (Random.value * drunkeness - drunkeness / 2) / 6); } if (Input.GetKey (KeyCode.DownArrow)) { //player.moving(-3f, (Random.value * (drunkeness/2 - (-drunkeness/2)) + -drunkeness/2)/10); player.moving(-3f, (Random.value * drunkeness - drunkeness / 2) / 6); } if (!Input.GetKey (KeyCode.UpArrow) && !Input.GetKey (KeyCode.DownArrow)) { player.stopMoving(); } if (hinderingWalls > 0) { return; } if (carry == false) { if (carryableLawyers.Count > 0) { if (Input.GetKeyDown (KeyCode.Space)) { if(carryableLawyers.Count > 1) { indexCarriedLawyer = closestLawyer(); } else { indexCarriedLawyer = 0; } LawyerScript lawyerInSight = (LawyerScript)carryableLawyers[indexCarriedLawyer].GetComponent("LawyerScript"); if(drunkeness >= lawyerInSight.drunkeness) { carry = true; carryableLawyers[indexCarriedLawyer].gameObject.transform.parent.gameObject.SetActive(false); player.setMyForce (4000); player.changeImage(1); } } } } else if (carry == true) { if (Input.GetKeyDown (KeyCode.Space)) { carry = false; player.setMyForce (6000); player.changeImage(-1); carryableLawyers[indexCarriedLawyer].gameObject.transform.parent.gameObject.SetActive(true); carryableLawyers[indexCarriedLawyer].gameObject.transform.parent.gameObject.transform.position = new Vector2(player.transform.position.x+Mathf.Round(Mathf.Cos(Mathf.Deg2Rad * player.getRotation())*30), player.transform.position.y+Mathf.Round(Mathf.Sin(Mathf.Deg2Rad * player.getRotation())*30)); //carryableLawyers[0].gameObject.transform.parent.gameObject.transform.position = // new Vector2(player.transform.position.x+30, player.transform.position.y); carriedLawyer = (LawyerScript)carryableLawyers[indexCarriedLawyer].GetComponent("LawyerScript"); carriedLawyer.rotationSet(player.getRotation() + 180); carryableLawyers.Remove(carryableLawyers[indexCarriedLawyer]); //rigidBody.velocity = new Vector2(Mathf.Cos(rigidBody.rotation)+10,Mathf.Sin(rigidBody.rotation)+10); } } //print(player.getRotation()); /*print ("Player X: " + player.transform.position.x + "\nPlayer Y: " + player.transform.position.y + "\nPlayer rotation: " + player.getRotation() + "\nResult X: " + (player.transform.position.x+Mathf.Cos(player.getRotation())*30) + "\nResult Y: " + (player.transform.position.y+Mathf.Sin(player.getRotation())*30) + "\nCos: " + (Mathf.Cos(player.getRotation())*30) + "\nSin: " + (Mathf.Sin(player.getRotation())*30) + "\nCos: " + (Mathf.Round(Mathf.Cos(Mathf.Deg2Rad * player.getRotation())*30)) + "\nSin: " + (Mathf.Round(Mathf.Sin(Mathf.Deg2Rad * player.getRotation())*30)));*/ //Mathf.Deg2Rad * /*if (Input.GetKeyUp (KeyCode.RightArrow) && Input.GetKeyUp (KeyCode.LeftArrow)) { rotval = 0; }*/ }
public void wetLawyer(LawyerScript wettedLawyer) { //endTime += wettime; /*if (endTime - Time.time > wettime) { endTime = Time.time + wettime; }*/ if ((endTime + wettime - Time.time) > maxtime) endTime += maxtime + Time.time - endTime; else endTime += wettime; ++wetLawyers; wettedLawyer.iGotSoWet (60f); }