void Start() { if (SceneManager.GetActiveScene().name == "Main_Menu") { mainMenu = true; } else { mainMenu = false; } horseClop = HORSECLOP.NONE; carController = GetComponent <Car_Controller>(); body = GetComponent <Rigidbody2D>(); if (carController.playerNumber == 1) { playerNumber = 1; } else if (carController.playerNumber == 2) { playerNumber = 2; } breaking = false; speedMagnitude += acceleration; if (carController.playerNumber == 1) { goRight = KeyCode.B; goLeft = KeyCode.V; goLeftAlt = KeyCode.Joystick1Button0; goRightAlt = KeyCode.Joystick1Button3; boost = "Player1_Boost"; } else { goRight = KeyCode.Keypad2; goLeft = KeyCode.Keypad1; goLeftAlt = KeyCode.Joystick2Button0; goRightAlt = KeyCode.Joystick2Button3; boost = "Player2_Boost"; } }
private void setHorseSpeed() { if (FindObjectOfType <Audio_Manager>()) { if (playerNumber == 1) { if (body.velocity.magnitude < 0.5f) { FindObjectOfType <Audio_Manager>().Stop("Player1_Horse"); horseClop = HORSECLOP.NONE; } else if (body.velocity.magnitude > 0.5f && body.velocity.magnitude < 3f) { if (horseClop != HORSECLOP.ONE) { FindObjectOfType <Audio_Manager>().Stop("Player1_Horse"); } FindObjectOfType <Audio_Manager>().setClip("Player1_Horse", horseSounds[0]); if (!FindObjectOfType <Audio_Manager>().isPlaying(("Player1_Horse"))) { FindObjectOfType <Audio_Manager>().Play("Player1_Horse"); } horseClop = HORSECLOP.ONE; } else if (body.velocity.magnitude > 3f && body.velocity.magnitude < 6f) { if (horseClop != HORSECLOP.TWO) { FindObjectOfType <Audio_Manager>().Stop("Player1_Horse"); } FindObjectOfType <Audio_Manager>().setClip("Player1_Horse", horseSounds[1]); if (!FindObjectOfType <Audio_Manager>().isPlaying(("Player1_Horse"))) { FindObjectOfType <Audio_Manager>().Play("Player1_Horse"); } horseClop = HORSECLOP.TWO; } else if (body.velocity.magnitude > 6f && body.velocity.magnitude < 9f) { if (horseClop != HORSECLOP.THREE) { FindObjectOfType <Audio_Manager>().Stop("Player1_Horse"); } FindObjectOfType <Audio_Manager>().setClip("Player1_Horse", horseSounds[2]); if (!FindObjectOfType <Audio_Manager>().isPlaying(("Player1_Horse"))) { FindObjectOfType <Audio_Manager>().Play("Player1_Horse"); } horseClop = HORSECLOP.THREE; } else if (body.velocity.magnitude > 9f && body.velocity.magnitude < 12f) { if (horseClop != HORSECLOP.FOUR) { FindObjectOfType <Audio_Manager>().Stop("Player1_Horse"); } FindObjectOfType <Audio_Manager>().setClip("Player1_Horse", horseSounds[3]); if (!FindObjectOfType <Audio_Manager>().isPlaying(("Player1_Horse"))) { FindObjectOfType <Audio_Manager>().Play("Player1_Horse"); } horseClop = HORSECLOP.FOUR; } else if (body.velocity.magnitude > 12f) { if (horseClop != HORSECLOP.FIVE) { FindObjectOfType <Audio_Manager>().Stop("Player1_Horse"); } FindObjectOfType <Audio_Manager>().setClip("Player1_Horse", horseSounds[4]); if (!FindObjectOfType <Audio_Manager>().isPlaying(("Player1_Horse"))) { FindObjectOfType <Audio_Manager>().Play("Player1_Horse"); } horseClop = HORSECLOP.FIVE; } } else { if (body.velocity.magnitude < 0.5f) { FindObjectOfType <Audio_Manager>().Stop("Player2_Horse"); horseClop = HORSECLOP.NONE; } else if (body.velocity.magnitude > 0.5f && body.velocity.magnitude < 3f) { if (horseClop != HORSECLOP.ONE) { FindObjectOfType <Audio_Manager>().Stop("Player2_Horse"); } FindObjectOfType <Audio_Manager>().setClip("Player2_Horse", horseSounds[0]); if (!FindObjectOfType <Audio_Manager>().isPlaying(("Player2_Horse"))) { FindObjectOfType <Audio_Manager>().Play("Player2_Horse"); } horseClop = HORSECLOP.ONE; } else if (body.velocity.magnitude > 3f && body.velocity.magnitude < 6f) { if (horseClop != HORSECLOP.TWO) { FindObjectOfType <Audio_Manager>().Stop("Player2_Horse"); } FindObjectOfType <Audio_Manager>().setClip("Player2_Horse", horseSounds[1]); if (!FindObjectOfType <Audio_Manager>().isPlaying(("Player2_Horse"))) { FindObjectOfType <Audio_Manager>().Play("Player2_Horse"); } horseClop = HORSECLOP.TWO; } else if (body.velocity.magnitude > 6f && body.velocity.magnitude < 9f) { if (horseClop != HORSECLOP.THREE) { FindObjectOfType <Audio_Manager>().Stop("Player2_Horse"); } FindObjectOfType <Audio_Manager>().setClip("Player2_Horse", horseSounds[2]); if (!FindObjectOfType <Audio_Manager>().isPlaying(("Player2_Horse"))) { FindObjectOfType <Audio_Manager>().Play("Player2_Horse"); } horseClop = HORSECLOP.THREE; } else if (body.velocity.magnitude > 9f && body.velocity.magnitude < 12f) { if (horseClop != HORSECLOP.FOUR) { FindObjectOfType <Audio_Manager>().Stop("Player2_Horse"); } FindObjectOfType <Audio_Manager>().setClip("Player2_Horse", horseSounds[3]); if (!FindObjectOfType <Audio_Manager>().isPlaying(("Player2_Horse"))) { FindObjectOfType <Audio_Manager>().Play("Player2_Horse"); } horseClop = HORSECLOP.FOUR; } else if (body.velocity.magnitude > 12f) { if (horseClop != HORSECLOP.FIVE) { FindObjectOfType <Audio_Manager>().Stop("Player2_Horse"); } FindObjectOfType <Audio_Manager>().setClip("Player2_Horse", horseSounds[4]); if (!FindObjectOfType <Audio_Manager>().isPlaying(("Player2_Horse"))) { FindObjectOfType <Audio_Manager>().Play("Player2_Horse"); } horseClop = HORSECLOP.FIVE; } } } }