New Version 1.6

New 125 balls & powerups.
Improved graphics.
This commit is contained in:
SkunkStudios 2025-05-07 06:18:40 +07:00
parent b35433ae45
commit 71779ef7ac
9413 changed files with 193360 additions and 264803 deletions

View file

@ -2,24 +2,22 @@
public class Ball : MonoBehaviour
{
public enum BallType { MoveX, ThrowBall, SpinBall, FallBall }
public BallType type;
[Range(8, 16)]
public int lbs = 12;
[Range(10, 100)]
public int speed = 55;
[Range(0, 100)]
public int spin = 50;
public AudioSource throwAudio;
public AudioSource rollAudio;
public AudioSource gutterAudio;
public AudioSource netAudio;
public AudioSource pinAudio;
public AudioSource electricAudio;
public AudioSource splashAudio;
public AudioClip[] tubSplashs;
public Game game;
public GameObject hit;
public GameObject splash;
public GameObject[] explores;
public CameraFollow cameraFollow;
public BoxCollider roll;
public BoxCollider replay;
@ -28,7 +26,10 @@ public class Ball : MonoBehaviour
public bool isGutterAnimation = false;
public bool isGutterAnimation2X = false;
public GameObject controlArrow;
public Renderer meshBall;
public GameObject bombBall;
public GameObject hyperBall;
public GameObject lightningBall;
public Renderer[] meshBalls;
private Vector2 moveMouse;
private Vector2 direction;
@ -54,63 +55,90 @@ public class Ball : MonoBehaviour
// Update is called once per frame
void Update ()
{
bombBall.transform.eulerAngles = Vector3.zero;
hyperBall.transform.eulerAngles = Vector3.zero;
lightningBall.transform.eulerAngles = Vector3.zero;
if (game.powerUps == Game.BallPowerUps.Off)
{
bombBall.SetActive(false);
hyperBall.SetActive(false);
lightningBall.SetActive(false);
}
else if (game.powerUps == Game.BallPowerUps.Bomb)
{
bombBall.SetActive(true);
hyperBall.SetActive(false);
lightningBall.SetActive(false);
}
else if (game.powerUps == Game.BallPowerUps.Hyper)
{
bombBall.SetActive(false);
hyperBall.SetActive(true);
lightningBall.SetActive(false);
}
else if (game.powerUps == Game.BallPowerUps.Lightning)
{
bombBall.SetActive(false);
hyperBall.SetActive(false);
lightningBall.SetActive(true);
}
spinStart = Input.mousePosition;
spinEnd = spinUI.ScreenToWorldPoint(spinStart);
direction = new Vector2(spinEnd.x, spinEnd.y);
controlArrow.transform.up = direction;
controlArrow.transform.rotation = new Quaternion(0, 0, Mathf.Clamp(controlArrow.transform.rotation.z, -90, 90), 1);
if (type == BallType.MoveX && GameManager.type == GameManager.GameState.Game && !game.isComputer && !isMoveY)
if (game.ballType == Game.BallType.MoveX && Game.type == Game.GameState.Game && !game.isComputer && !isMoveY)
{
moveMouse = direction;
}
if (type == BallType.MoveX && GameManager.type == GameManager.GameState.Game && spinEnd.x <= -75 && spinEnd.x >= -150 && spinEnd.y > -125 && !game.isComputer && !isMoveY)
if (game.ballType == Game.BallType.MoveX && Game.type == Game.GameState.Game && spinEnd.x <= -75 && spinEnd.x >= -150 && spinEnd.y > -125 && !game.isComputer && !isMoveY)
{
transform.Translate(30 * Time.deltaTime, 0, 0, Space.World);
transform.Translate(16 * Time.deltaTime, 0, 0, Space.World);
}
if (type == BallType.MoveX && GameManager.type == GameManager.GameState.Game && spinEnd.x >= 75 && spinEnd.x <= 150 && spinEnd.y > -125 && !game.isComputer && !isMoveY)
if (game.ballType == Game.BallType.MoveX && Game.type == Game.GameState.Game && spinEnd.x >= 75 && spinEnd.x <= 150 && spinEnd.y > -125 && !game.isComputer && !isMoveY)
{
transform.Translate(-30 * Time.deltaTime, 0, 0, Space.World);
transform.Translate(-16 * Time.deltaTime, 0, 0, Space.World);
}
if (type == BallType.MoveX && GameManager.type == GameManager.GameState.Game && spinEnd.x <= 150 && spinEnd.y > -125 && !game.isComputer && !isMoveY)
if (game.ballType == Game.BallType.MoveX && Game.type == Game.GameState.Game && spinEnd.x <= 150 && spinEnd.y > -125 && !game.isComputer && !isMoveY)
{
transform.Translate(60 * Time.deltaTime, 0, 0, Space.World);
transform.Translate(32 * Time.deltaTime, 0, 0, Space.World);
}
if (type == BallType.MoveX && GameManager.type == GameManager.GameState.Game && spinEnd.x >= -150 && spinEnd.y > -125 && !game.isComputer && !isMoveY)
if (game.ballType == Game.BallType.MoveX && Game.type == Game.GameState.Game && spinEnd.x >= -150 && spinEnd.y > -125 && !game.isComputer && !isMoveY)
{
transform.Translate(-60 * Time.deltaTime, 0, 0, Space.World);
transform.Translate(-32 * Time.deltaTime, 0, 0, Space.World);
}
if (type == BallType.MoveX && GameManager.type == GameManager.GameState.Game && !game.isComputer)
if (game.ballType == Game.BallType.MoveX && Game.type == Game.GameState.Game && !game.isComputer)
{
transform.position = new Vector3(Mathf.Clamp(transform.position.x, -120, 120), transform.position.y, transform.position.z);
}
if (transform.position.z < GameObject.FindObjectOfType<PinSetter>().ballPos.z && type == BallType.MoveX && GameManager.type == GameManager.GameState.Game && !game.isComputer)
if (transform.position.z < GameObject.FindObjectOfType<PinSetter>().ballPos.z && game.ballType == Game.BallType.MoveX && Game.type == Game.GameState.Game && !game.isComputer)
{
isThrow = true;
}
if (isMoveY && type == BallType.MoveX && GameManager.type == GameManager.GameState.Game && !game.isComputer)
if (isMoveY && game.ballType == Game.BallType.MoveX && Game.type == Game.GameState.Game && !game.isComputer)
{
transform.position = new Vector3(transform.position.x, transform.position.y, GameObject.FindObjectOfType<PinSetter>().ballPos.z + moveMouse.y - direction.y);
}
if (type == BallType.SpinBall && GameManager.type == GameManager.GameState.Game && !game.isComputer)
if (game.ballType == Game.BallType.SpinBall && Game.type == Game.GameState.Game && !game.isComputer)
{
rigidBody.AddForce(-spinEnd.x * spin * rigidBody.mass * 6f * Time.deltaTime, 0, 0);
rigidBody.AddTorque(0, 0, spinEnd.x * spin * rigidBody.mass * 30f * Time.deltaTime);
rigidBody.AddForce(-spinEnd.x * spin * rigidBody.mass * 0.64f * Time.deltaTime, 0, 0);
rigidBody.AddTorque(0, 0, spinEnd.x * spin * rigidBody.mass * 0.32f * Time.deltaTime);
}
if (isGutter)
{
rigidBody.AddForce(0, 0, -rigidBody.mass * 6000);
rigidBody.AddForce(0, 0, -rigidBody.mass * 640);
}
}
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Lane" && type == BallType.ThrowBall && !game.isComputer && GameManager.type == GameManager.GameState.Game)
Collider[] colliders;
if (collision.gameObject.tag == "Lane" && game.ballType == Game.BallType.ThrowBall && !game.isComputer && Game.type == Game.GameState.Game)
{
controlArrow.SetActive(true);
}
if (collision.gameObject.tag == "Lane" && type == BallType.ThrowBall)
if (collision.gameObject.tag == "Lane" && game.ballType == Game.BallType.ThrowBall)
{
rollAudio.Play();
gutterAudio.Stop();
@ -118,18 +146,22 @@ public class Ball : MonoBehaviour
game.isPin = false;
roll.enabled = true;
replay.enabled = true;
type = BallType.SpinBall;
cameraFollow.type = CameraFollow.CameraType.FollowBall;
game.ballType = Game.BallType.SpinBall;
game.camType = Game.CameraType.FollowBall;
if (GameObject.FindObjectOfType<PinSetter>().gutter != null)
{
GameObject.FindObjectOfType<PinSetter>().gutter.enabled = true;
}
}
if (collision.gameObject.tag == "Pin" && collision.relativeVelocity.magnitude > rigidBody.mass * 15 && !game.isPin && !isBackWall)
if (collision.gameObject.tag == "Pin" && collision.relativeVelocity.magnitude > rigidBody.mass * 10 && !game.isPin && !isBackWall && game.ballType == Game.BallType.SpinBall)
{
rollAudio.Stop();
gutterAudio.Stop();
electricAudio.Stop();
if (game.powerUps == Game.BallPowerUps.Bomb || game.powerUps == Game.BallPowerUps.Lightning)
{
game.PlayClip("s.explosion_tnt");
}
isSplash = GameObject.FindObjectOfType<PinSetter>().isSplash;
game.isReplay = true;
controlArrow.SetActive(false);
@ -137,6 +169,54 @@ public class Ball : MonoBehaviour
{
Instantiate(hit, collision.transform.position, Quaternion.identity);
}
if (game.powerUps == Game.BallPowerUps.Bomb)
{
colliders = Physics.OverlapSphere(transform.position, 128);
if (GameManager.isParticle)
{
Instantiate(explores[Random.Range(0, explores.Length)], transform.position, Quaternion.identity);
}
GameObject.FindObjectOfType<CameraShake>().Shake(20);
foreach (Collider hit in colliders)
{
Rigidbody rb = hit.GetComponent<Rigidbody>();
if (rb != null)
{
rb.AddExplosionForce(6400, transform.position, 12800, 256);
}
}
transform.position = new Vector3(0, -5000, -5000);
GameManager.bombBalls--;
}
else if (game.powerUps == Game.BallPowerUps.Hyper)
{
colliders = Physics.OverlapSphere(transform.position, 32);
foreach (Collider hit in colliders)
{
Rigidbody rb = hit.GetComponent<Rigidbody>();
if (rb != null)
{
rb.AddExplosionForce(3200, transform.position, 6400, 0);
}
}
GameManager.hyperBalls--;
}
else if (game.powerUps == Game.BallPowerUps.Lightning)
{
colliders = Physics.OverlapSphere(transform.position, 32);
foreach (Collider hit in colliders)
{
Rigidbody rb = hit.GetComponent<Rigidbody>();
if (rb != null)
{
rb.AddExplosionForce(1600, transform.position, 3200, 0);
}
}
GameManager.lightningBalls--;
}
if (PinCounter.pinCount == 1 || collision.gameObject.GetComponent<Pin>().isHitOne)
{
GameObject.FindObjectOfType<CameraShake>().Shake(1);
@ -166,17 +246,43 @@ public class Ball : MonoBehaviour
if (!GameObject.FindObjectOfType<PinSetter>().isGravity)
{
rigidBody.useGravity = false;
force.force = new Vector3(force.force.x, -rigidBody.mass * 100, -rigidBody.mass * 1000);
force.force = new Vector3(force.force.x, -rigidBody.mass * 50, -rigidBody.mass * 500);
}
game.isPin = true;
type = BallType.FallBall;
game.ballType = Game.BallType.FallBall;
cameraFollow.FallMove(transform.position);
cameraFollow.type = CameraFollow.CameraType.MoveCam;
game.camType = Game.CameraType.MoveCam;
GameObject.FindObjectOfType<PinSetter>().StopScooper();
StartCoroutine(game.PinTimeA(2));
StartCoroutine(game.PinTimeA(6));
}
else if (collision.gameObject.tag == "Pin" && collision.relativeVelocity.magnitude > rigidBody.mass * 15 && game.isPin)
else if (collision.gameObject.tag == "Pin" && collision.relativeVelocity.magnitude > rigidBody.mass * 10 && game.isPin)
{
if (game.powerUps == Game.BallPowerUps.Hyper)
{
colliders = Physics.OverlapSphere(transform.position, 32);
foreach (Collider hit in colliders)
{
Rigidbody rb = hit.GetComponent<Rigidbody>();
if (rb != null)
{
rb.AddExplosionForce(3200, transform.position, 6400, 0);
}
}
}
else if (game.powerUps == Game.BallPowerUps.Lightning)
{
colliders = Physics.OverlapSphere(transform.position, 32);
foreach (Collider hit in colliders)
{
Rigidbody rb = hit.GetComponent<Rigidbody>();
if (rb != null)
{
rb.AddExplosionForce(1600, transform.position, 3200, 0);
}
}
}
if (PinCounter.pinCount == 1 || collision.gameObject.GetComponent<Pin>().isHitOne)
{
GameObject.FindObjectOfType<CameraShake>().Shake(1);
@ -199,38 +305,38 @@ public class Ball : MonoBehaviour
}
}
if (collision.gameObject.tag == "Backwall" && collision.relativeVelocity.magnitude > rigidBody.mass * 30 && !isBackWall)
if (collision.gameObject.tag == "Backwall" && collision.relativeVelocity.magnitude > rigidBody.mass * 7.5f && !isBackWall)
{
rollAudio.Stop();
gutterAudio.Stop();
netAudio.Play();
game.PlayClip("Net");
isBackWall = true;
if (!isNet)
{
if (collision.relativeVelocity.magnitude > rigidBody.mass * 75)
if (collision.relativeVelocity.magnitude > rigidBody.mass * 30)
{
game.isReplay = true;
}
if (GameManager.type == GameManager.GameState.Replay)
if (Game.type == Game.GameState.Replay)
{
GameObject.FindObjectOfType<PinSetter>().LandPins();
game.isReplay = false;
game.isReplayRecord = false;
}
if (GameManager.type != GameManager.GameState.Menu)
if (Game.type != Game.GameState.Menu)
{
game.rollCrowd.Stop();
}
controlArrow.SetActive(false);
isNet = true;
game.StopScooper();
type = BallType.FallBall;
game.ballType = Game.BallType.FallBall;
GameObject.FindObjectOfType<PinSetter>().StopScooper();
if (!game.isPin)
{
cameraFollow.FallMove(transform.position);
cameraFollow.type = CameraFollow.CameraType.MoveCam;
StartCoroutine(game.PinTimeA(2));
game.camType = Game.CameraType.MoveCam;
StartCoroutine(game.PinTimeA(6));
game.isPin = true;
}
}
@ -250,9 +356,9 @@ public class Ball : MonoBehaviour
replay.enabled = false;
game.isReplayRecord = true;
}
if (other.CompareTag("Fall") && isSplash && type == BallType.ThrowBall || other.CompareTag("Fall") && isSplash && type == BallType.SpinBall || other.CompareTag("Fall") && isSplash && type == BallType.FallBall || other.CompareTag("Gutter") && isSplash && type == BallType.SpinBall && !game.isPin && !game.isPin || other.CompareTag("Water") && isSplash && type == BallType.SpinBall || other.CompareTag("Water") && isSplash && type == BallType.FallBall)
if (other.CompareTag("Fall") && isSplash && game.ballType == Game.BallType.ThrowBall || other.CompareTag("Fall") && isSplash && game.ballType == Game.BallType.SpinBall || other.CompareTag("Fall") && isSplash && game.ballType == Game.BallType.FallBall || other.CompareTag("Gutter") && isSplash && game.ballType == Game.BallType.SpinBall && !game.isPin && !game.isPin || other.CompareTag("Water") && isSplash && game.ballType == Game.BallType.SpinBall || other.CompareTag("Water") && isSplash && game.ballType == Game.BallType.FallBall)
{
if (GameManager.isSound && GameManager.type != GameManager.GameState.Menu)
if (GameManager.isSound && Game.type != Game.GameState.Menu)
{
splashAudio.PlayOneShot(tubSplashs[Random.Range(0, tubSplashs.Length)]);
}
@ -262,7 +368,7 @@ public class Ball : MonoBehaviour
}
isSplash = false;
}
if (other.CompareTag("Fall") && type == BallType.ThrowBall || other.CompareTag("Fall") && type == BallType.SpinBall || other.CompareTag("Fall") && type == BallType.FallBall && isGutter)
if (other.CompareTag("Fall") && game.ballType == Game.BallType.ThrowBall || other.CompareTag("Fall") && game.ballType == Game.BallType.SpinBall || other.CompareTag("Fall") && game.ballType == Game.BallType.FallBall && isGutter)
{
if (PinCounter.pinCount == 0)
{
@ -270,7 +376,7 @@ public class Ball : MonoBehaviour
}
rollAudio.Stop();
gutterAudio.Stop();
if (!game.isComputer && game.gutterAnimation == 0 && GameManager.type != GameManager.GameState.Menu)
if (!game.isComputer && game.gutterAnimation == 0 && Game.type != Game.GameState.Menu)
{
game.rollCrowd.Stop();
}
@ -278,11 +384,11 @@ public class Ball : MonoBehaviour
if (!GameObject.FindObjectOfType<PinSetter>().isGravity)
{
rigidBody.useGravity = false;
force.force = new Vector3(force.force.x, -rigidBody.mass * 100, -rigidBody.mass * 1000);
force.force = new Vector3(force.force.x, -rigidBody.mass * 50, -rigidBody.mass * 500);
}
if (transform.position.z >= -3200 || game.isComputer && game.gutterAnimation == 0 || GameManager.type == GameManager.GameState.Menu && game.gutterAnimation == 0)
if (transform.position.z >= -3200 || game.isComputer && game.gutterAnimation == 0 || Game.type == Game.GameState.Menu && game.gutterAnimation == 0)
{
if (type == BallType.SpinBall)
if (game.ballType == Game.BallType.SpinBall)
{
game.VoiceGutterball();
}
@ -304,7 +410,7 @@ public class Ball : MonoBehaviour
{
GameObject.FindObjectOfType<PinSetter>().gutter.enabled = false;
}
type = BallType.FallBall;
game.ballType = Game.BallType.FallBall;
StartCoroutine(game.PinTimeA(0));
}
if (other.CompareTag("Gutter") && !game.isPin)
@ -312,7 +418,7 @@ public class Ball : MonoBehaviour
rollAudio.Stop();
controlArrow.SetActive(false);
game.CrowdStop();
if (type == BallType.ThrowBall)
if (game.ballType == Game.BallType.ThrowBall)
{
game.GutterLaugh();
}
@ -339,33 +445,40 @@ public class Ball : MonoBehaviour
}
isNet = true;
cameraFollow.FallMove(transform.position);
cameraFollow.type = CameraFollow.CameraType.MoveCam;
game.camType = Game.CameraType.MoveCam;
if (GameObject.FindObjectOfType<PinSetter>().gutter != null)
{
GameObject.FindObjectOfType<PinSetter>().gutter.enabled = false;
}
if (type == BallType.SpinBall)
if (game.ballType == Game.BallType.SpinBall)
{
type = BallType.FallBall;
game.ballType = Game.BallType.FallBall;
}
}
}
public void MouseDown()
{
if (type == BallType.MoveX && GameManager.type == GameManager.GameState.Game && !game.isComputer && Input.GetMouseButtonDown(0))
if (game.ballType == Game.BallType.MoveX && Game.type == Game.GameState.Game && !game.isComputer && Input.GetMouseButtonDown(0))
{
isMoveY = true;
}
if (type == BallType.SpinBall && GameManager.type == GameManager.GameState.Game && !game.isComputer && Input.GetMouseButtonDown(0))
if (game.ballType == Game.BallType.SpinBall && Game.type == Game.GameState.Game && !game.isComputer && Input.GetMouseButtonDown(0))
{
rigidBody.AddForce(0, 0, -rigidBody.mass * 25000);
if (game.powerUps == Game.BallPowerUps.Hyper)
{
rigidBody.AddForce(0, 0, -rigidBody.mass * 10000);
}
else
{
rigidBody.AddForce(0, 0, -rigidBody.mass * 5000);
}
}
}
public void MouseUp()
{
if (type == BallType.MoveX && GameManager.type == GameManager.GameState.Game && !game.isComputer && Input.GetMouseButtonUp(0))
if (game.ballType == Game.BallType.MoveX && Game.type == Game.GameState.Game && !game.isComputer && Input.GetMouseButtonUp(0))
{
if (isThrow)
{
@ -387,13 +500,21 @@ public class Ball : MonoBehaviour
public void Bowl()
{
game.chooseBallUI.SetActive(false);
game.powerUpUI.SetActive(false);
rigidBody.isKinematic = false;
game.VoiceStop();
game.CrowdStop();
rigidBody.AddForce(moveMouse.x - direction.x * spin * rigidBody.mass * 6, 0, moveMouse.y - direction.y * speed * 1250);
throwAudio.Play();
type = BallType.ThrowBall;
cameraFollow.type = CameraFollow.CameraType.DropBall;
if (game.powerUps == Game.BallPowerUps.Hyper)
{
rigidBody.AddForce(moveMouse.x - direction.x * spin * rigidBody.mass * 0.64f, 0, moveMouse.y - direction.y * speed * 256f);
}
else
{
rigidBody.AddForce(moveMouse.x - direction.x * spin * rigidBody.mass * 0.64f, 0, moveMouse.y - direction.y * speed * 128f);
}
game.PlayClip("Thumbpop");
game.ballType = Game.BallType.ThrowBall;
game.camType = Game.CameraType.DropBall;
game.throwBall++;
}
@ -407,7 +528,7 @@ public class Ball : MonoBehaviour
if (GameObject.FindObjectOfType<PinSetter>().returnPoint != null)
{
transform.position = GameObject.FindObjectOfType<PinSetter>().returnPoint.position;
rigidBody.velocity = Vector3.forward * 450;
rigidBody.velocity = Vector3.forward * 200;
}
}
@ -427,8 +548,9 @@ public class Ball : MonoBehaviour
isBackWall = false;
isSplash = GameObject.FindObjectOfType<PinSetter>().isSplash;
game.isReplayRecord = false;
type = BallType.MoveX;
cameraFollow.type = CameraFollow.CameraType.MoveX;
game.powerUps = Game.BallPowerUps.Off;
game.ballType = Game.BallType.MoveX;
game.camType = Game.CameraType.MoveX;
if (GameObject.FindObjectOfType<PinSetter>().gutter != null)
{
GameObject.FindObjectOfType<PinSetter>().gutter.enabled = true;
@ -452,40 +574,40 @@ public class Ball : MonoBehaviour
game.isReplayRecord = false;
if (speed <= 30)
{
rigidBody.AddForce(Vector3.forward * -speed * rigidBody.mass * 20000);
rigidBody.AddForce(Vector3.forward * -speed * rigidBody.mass * 2000);
}
else if (speed > 30 && speed <= 40)
{
rigidBody.AddForce(Vector3.forward * -speed * rigidBody.mass * 17500);
rigidBody.AddForce(Vector3.forward * -speed * rigidBody.mass * 1750);
}
else if (speed > 40 && speed <= 50)
{
rigidBody.AddForce(Vector3.forward * -speed * rigidBody.mass * 15000);
rigidBody.AddForce(Vector3.forward * -speed * rigidBody.mass * 1500);
}
else if (speed > 50 && speed <= 60)
{
rigidBody.AddForce(Vector3.forward * -speed * rigidBody.mass * 12500);
rigidBody.AddForce(Vector3.forward * -speed * rigidBody.mass * 1250);
}
else if (speed > 60)
{
rigidBody.AddForce(Vector3.forward * -speed * 120000);
rigidBody.AddForce(Vector3.forward * -speed * 12000);
}
if (transform.position.x < GameObject.FindObjectOfType<PinSetter>().ballPos.x)
{
if (spin < 25)
{
force.force = new Vector3(spin * -rigidBody.mass * 1.5f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(250, 1500));
force.force = new Vector3(spin * -rigidBody.mass * 0.768f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(50, 225));
}
else if (spin >= 25 && spin < 50)
{
force.force = new Vector3(spin * -rigidBody.mass * 1f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(250, 1000));
force.force = new Vector3(spin * -rigidBody.mass * 0.512f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(50, 150));
}
else if (spin >= 50)
{
force.force = new Vector3(spin * -rigidBody.mass * 0.25f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(250, 500));
force.force = new Vector3(spin * -rigidBody.mass * 0.128f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(50, 75));
}
}
else if (transform.position.x == GameObject.FindObjectOfType<PinSetter>().ballPos.x)
@ -493,38 +615,39 @@ public class Ball : MonoBehaviour
force.force = new Vector3(0, 0, 0);
if (spin < 25)
{
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(-1500, 1500));
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(-225, 225));
}
else if (spin >= 25 && spin < 50)
{
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(1000, 1000));
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(-150, 150));
}
else if (spin >= 50)
{
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(-500, 500));
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(-75, 75));
}
}
else if (transform.position.x > GameObject.FindObjectOfType<PinSetter>().ballPos.x)
{
if (spin < 25)
{
force.force = new Vector3(spin * rigidBody.mass * 1.5f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(-1500, -250));
force.force = new Vector3(spin * rigidBody.mass * 0.768f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(-225, -50));
}
else if (spin >= 25 && spin < 50)
{
force.force = new Vector3(spin * rigidBody.mass * 1f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(-1000, -250));
force.force = new Vector3(spin * rigidBody.mass * 0.512f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(-150, -50));
}
else if (spin >= 50)
{
force.force = new Vector3(spin * rigidBody.mass * 0.25f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(-500, -250));
force.force = new Vector3(spin * rigidBody.mass * 0.128f, 0, 0);
rigidBody.AddForce(Vector3.right * spin * rigidBody.mass * Random.Range(-75, -50));
}
}
throwAudio.Play();
type = BallType.ThrowBall;
cameraFollow.type = CameraFollow.CameraType.DropBall;
game.PlayClip("Thumbpop");
game.powerUps = Game.BallPowerUps.Off;
game.ballType = Game.BallType.ThrowBall;
game.camType = Game.CameraType.DropBall;
if (GameObject.FindObjectOfType<PinSetter>().gutter != null)
{
GameObject.FindObjectOfType<PinSetter>().gutter.enabled = true;
@ -539,10 +662,54 @@ public class Ball : MonoBehaviour
public void ChargeBall(Material ballMat, int chargeLbs, int chargeSpeed, int chargeSpin)
{
meshBall.material = ballMat;
foreach(Renderer meshBall in meshBalls)
{
meshBall.material = ballMat;
}
lbs = chargeLbs;
speed = chargeSpeed;
spin = chargeSpin;
rigidBody.mass = lbs;
}
public void BombBall()
{
if (game.powerUps == Game.BallPowerUps.Bomb)
{
game.powerUps = Game.BallPowerUps.Off;
}
else
{
game.powerUps = Game.BallPowerUps.Bomb;
}
}
public void HyperBall()
{
if (game.powerUps == Game.BallPowerUps.Hyper)
{
game.powerUps = Game.BallPowerUps.Off;
}
else
{
game.powerUps = Game.BallPowerUps.Hyper;
}
}
public void LightningBall()
{
if (game.powerUps == Game.BallPowerUps.Lightning)
{
game.powerUps = Game.BallPowerUps.Off;
}
else
{
game.powerUps = Game.BallPowerUps.Lightning;
if (GameManager.isSound && Game.type != Game.GameState.Menu)
{
game.PlayClip("thunder");
}
game.thunderAnimation.Play();
}
}
}