/// <summary> /// Gets the horizontal displacement of the user, in the x or z directoin /// </summary> /// <param name="fwdAccel">determines if the player is acceleratig fwds</param> /// <param name="backAccel">determines if the player is accelerating backwards</param> /// <param name="displacementCalculator">which displacement calculator is being used</param> private void HorizontalDisplacement(bool fwdAccel, bool backAccel, CalculateDisplacement displacementCalculator) { //if the player is accelerating fwds and hasnt reached a max velocity of 2 if (fwdAccel && displacementCalculator.ReturnVelocity() < MAX_SPEED) { //updating the displace emnt of the user displacementCalculator.Update(SIDE_WAYS_ACCELERATION); } else if (!fwdAccel && displacementCalculator.ReturnVelocity() > NO_VALUE && !IsJumping) { //updating the displace emnt of the user displacementCalculator.Update(-SIDE_WAYS_DECCELERATION); } //if the player is acceleratting backwards and they are moving less than the max speed if (backAccel && displacementCalculator.ReturnVelocity() > -MAX_SPEED) { //updating the displace emnt of the user displacementCalculator.Update(-SIDE_WAYS_ACCELERATION); } //if the player is not accelerating backwards anfd they are still moving, they are deccelrating else if (!backAccel && displacementCalculator.ReturnVelocity() < NO_VALUE && !IsJumping) { //updating the displace emnt of the user displacementCalculator.Update(SIDE_WAYS_DECCELERATION); } }
// Update is called once per frame /// <summary> /// THIS subprogram updates all aspects of the bomb is the bomb is still active /// otherwise the bomb is no longer active and that is returned to the player so /// a new bomb can be dropped /// </summary> public void Update() { //if the bomb has not exploded if (isBombActive) { //getting the coordinates of bombis refernce to the gameboard bombCoordinate.x = (int)(bombSphere.transform.position.x + 5); bombCoordinate.y = (int)(bombSphere.transform.position.z + 5); //incrementing the bomb time bombTime += Time.deltaTime; //if the bomb has not come in contact with the floor yet if (bombSphere.transform.position.y >= 0.3f) { //updating the y component of the bomb calculateY.Update(GRAVITY); //getting the change in displacement of the bomb in the y direction addBombY = new Vector3(NO_VALUE, calculateY.ReturnCoordinate(), NO_VALUE); //calculating the chnage in displacement of the bomb addBombZ = new Vector3(NO_VALUE, NO_VALUE, (zVelocity * Time.deltaTime)); //calculating the chnage in displacement of the bomb addBombX = new Vector3((xVelocity * Time.deltaTime), NO_VALUE, NO_VALUE); //changing the coordinates of the bomb bombSphere.transform.position += addBombY; bombSphere.transform.position += addBombZ; bombSphere.transform.position += addBombX; } else { //if the bomb has landed on the ground //freezing the position of the bomb bombBody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ; //freezing the rotation of the bomb bombBody.freezeRotation = true; } //checking to see if the bomb is active if (bombTime >= MAX_BOMB_TIME) { //the bomb is no longer active isBombActive = false; //once the time surpasses the ttimer //the bomb is destroyed Destroy(bombSphere); //CALL PARTICLE SYSTEMM HERE Instantiate(explosion1, new Vector3(bombSphere.transform.position.x, bombSphere.transform.position.y, bombSphere.transform.position.z), new Quaternion(0, 0, 0, 0)); //BOOM SOUNDFX } //setting the bombs coordinate bombCoordinate = new Vector2(bombCoordinate.x, bombCoordinate.y); } }