// Use this for initialization void Start() { scriptToAccess = Pelota.GetComponent <BallPhysics>(); if (VariableToGet == 0) { LINE_lVelocityFin = scriptToAccess.lVelocityFin; transform.position = new Vector3(LINE_lVelocityFin.x, LINE_lVelocityFin.y, LINE_lVelocityFin.z); } if (VariableToGet == 1) { LINE_lVelocityFin = scriptToAccess.fMagnus; transform.position = new Vector3(LINE_fMagnus.x, LINE_fMagnus.y, LINE_fMagnus.z); } if (VariableToGet == 2) { LINE_fDrag = scriptToAccess.fDrag; transform.position = new Vector3(LINE_fDrag.x, LINE_fDrag.y, LINE_fDrag.z); } if (VariableToGet == 3) { LINE_fTau = scriptToAccess.fTau; transform.position = new Vector3(LINE_fTau.x, LINE_fTau.y, LINE_fTau.z); } }
public virtual void RaycastHit(BallPhysics ball, RaycastHit hitInfo) { if (surfaceType.consideredForBounces) { ball.currentBounces++; } ball.velocity = Vector3.Reflect(ball.velocity, hitInfo.normal) * surfaceType.dampening; if (/*ball.currentBounces >= ball.ballType.bouncesUntilRespawn || */ ball.velocity.magnitude <= ball.ballType.minVelocityToRespawn) { ball.ToggleRenderer(false); ball.stopped = true; //Debug.Log("Ball DESTROYED after " + ball.ballType.bouncesUntilRespawn.ToString()); //TODO: Handle ball spawning if (!GameManager.Instance.gameOver) { StartCoroutine(GameManager.Instance.ballSpawner.WaitBeforeBallSpawn(GameManager.Instance.ballSpawner.spawnTime)); } } if (surfaceType.effectCollection != null) { if (PhotonNetwork.IsConnected) { photonView.RPC(nameof(PlayBounceEffect), RpcTarget.All, hitInfo.point); } else { PlayBounceEffect(hitInfo.point); } } }
private IEnumerator Stun(BallPhysics ball, float time = 0f) { if (ball) { GameAnalytics.AddEvent(character.playerPosition, EventKeys.Stunned); time = (ball.ballSwingPower == SwingPower.Strong ? hitSettings.strongStunTime : hitSettings.lightStunTime); } character.playerStatus = PlayerStatus.Stunned; Color oldColor = sprite.color; stunned = true; character.canMove = false; for (int i = 0; i < hitSettings.fadeIntervals; i++) { sprite.DOColor(new Color(oldColor.r, oldColor.g, oldColor.b, hitSettings.fadePercentage / 100), (time / (hitSettings.fadeIntervals * 2))); yield return(new WaitForSecondsRealtime(time / (hitSettings.fadeIntervals * 2))); sprite.DOColor(new Color(oldColor.r, oldColor.g, oldColor.b, 1), (time / (hitSettings.fadeIntervals * 2))); yield return(new WaitForSecondsRealtime(time / (hitSettings.fadeIntervals * 2))); } character.playerStatus = PlayerStatus.None; stunned = false; character.canMove = true; }
public override void RaycastHit(BallPhysics ball, RaycastHit hitInfo) { if (PhotonNetwork.IsConnected && PhotonNetwork.IsMasterClient) { photonView.RPC(nameof(RpcRaycastHit), RpcTarget.All); } else { if (!stunned) { StartCoroutine(Stun(ball)); if (hitSettings.shakeOnHit) { GameManager.Instance.mainCamera.DOShakePosition(hitSettings.shakeDuration, hitSettings.shakeStrength, hitSettings.shakeVibrato, 90f, true); } if (surfaceType.effectCollection) { surfaceType.effectCollection.Get("Hurt")?.Play(ball.transform.position, Vector3.zero); float stunTime = ball.ballSwingPower == SwingPower.Strong ? hitSettings.strongStunTime : hitSettings.lightStunTime; surfaceType.effectCollection.Get("Stun")?.Play(transform.position, Vector3.zero, sprite.transform, default(Color), stunTime); } } } base.RaycastHit(ball, hitInfo); }
// Use this for initialization void Start() { // make column clone = (Transform)Instantiate(column, new Vector3(0, 0, 0), Quaternion.identity); clone.transform.localScale = new Vector3(1.0f, tiers * segmentspace / 2.0f, 1.0f); towerHeight = clone.GetComponent <MeshRenderer>().bounds.size.y; clone.transform.position += new Vector3(0, (towerHeight / 2.0f) + segmentspace, 0); // make each layer for (int level = 4; level >= 0; level--) { for (int i = 0; i < 12; i++) { if (data[level, i] == 1) { Transform segClone = (Transform)Instantiate(segment, new Vector3(0, towerHeight - level * segmentspace, 0), Quaternion.Euler(0, i * 30, 0)); segClone.transform.localScale = new Vector3(300.0f, 10.0f, 300.0f); segmentHalfHeight = segClone.transform.localScale.y / 50.0f; segClone.gameObject.tag = level.ToString(); segClone.transform.parent = clone.transform; Debug.Log(segmentHalfHeight); } } } BallPhysics BallPhysics = GameObject.Find("Ball").GetComponent <BallPhysics>(); BallPhysics.Init(); }
// Update is called once per frame void Update() { if (ball == null) { ball = FindObjectOfType <BallPhysics>(); } }
public void SpawnBall() { Vector3 spawnDirection = GameManager.Instance.ballSpawner.spawnDirection; Vector3 ballSpawnVelocity = (player == PlayerNumber.Top ? spawnDirection : new Vector3(-spawnDirection.x, spawnDirection.y, -spawnDirection.z)) * GameManager.Instance.ballSpawner.spawnSpeed; if (GameManager.Instance.ballSpawner.currentBall == null) { GameManager.Instance.ballSpawner.currentBall = Instantiate(GameManager.Instance.ballSpawner.regularBallPrefab, transform.position, Quaternion.identity); } else { BallPhysics ball = GameManager.Instance.ballSpawner.currentBall.GetComponent <BallPhysics>(); ball.ToggleRenderer(true); ball.stopped = false; } GameManager.Instance.ballSpawner.lastPlayerDirectionSpawn = player; var ballPhysics = GameManager.Instance.ballSpawner.currentBall.GetComponent <BallPhysics>(); ballPhysics.canDamage = false; ballPhysics.velocity = ballSpawnVelocity; if (ballStatus) { ballStatus.OnApply(ballPhysics); } AudioManager.instance.PlaySound(GameManager.Instance.ballSpawner.spawnAudio, false, .1f); }
// public override void OnTriggerEnter(Collider other) { // if (other.gameObject.CompareTag("Ball")) { // TriggerHit(other.gameObject.GetComponent<BallPhysics>()); // } // } #endregion #region Methods public override void TriggerHit(BallPhysics ball) { if (character.playerStatus == PlayerStatus.Dashing) { GameAnalytics.AddEvent(character.playerPosition, EventKeys.DashAndHit); } if (character.currentSwingStrength == character.swingType.strongSwing) { GameAnalytics.AddEvent(character.playerPosition, EventKeys.SuccessfulChargedStrike); } if (character.currentSwingStrength == character.swingType.lightSwing) { GameAnalytics.AddEvent(character.playerPosition, EventKeys.FailedChargedStrike); } GameAnalytics.AddEvent(character.playerPosition, EventKeys.HitBall); float multiplier = (ball.transform.position.y > transform.position.y ? Mathf.Lerp(character.swingType.highSwingYMultiplier, 1, Mathf.InverseLerp(transform.position.y + (boxCollider.size.y * 0.5f), transform.position.y, ball.transform.position.y)) : Mathf.Lerp(character.swingType.lowSwingYMultiplier, 1, Mathf.InverseLerp(transform.position.y - (boxCollider.size.y * 0.5f), transform.position.y, ball.transform.position.y))); float swingY = character.swingType.swingY * multiplier; Vector3 newDirection = (Vector3.right * character.input.x * character.swingType.swingX) + (Vector3.up * swingY) + ((character.playerPosition == PlayerPosition.Top ? Vector3.back : Vector3.forward) * character.currentSwingStrength); ball.photonView.RequestOwnership(); ball.currentBounces = 0; ball.ballSwingPower = character.currentCharge; //#region Swing VFX //switch (character.currentCharge) { // case SwingPower.Regular: // AudioManager.instance.PlaySound(ball.ballType.ballHitSound,false,0.8f); // vfx = ball.ballType.mediumShotEffect; // break; // case SwingPower.Strong: // AudioManager.instance.PlaySound(ball.ballType.ballHitSoundHard,false, 0.8f); // vfx = ball.ballType.strongShotEffect; // break; // default: // AudioManager.instance.PlaySound(ball.ballType.ballHitSound,false); // vfx = ball.ballType.weakShotEffect; // break; //} //vfx.Play(ball.transform.position, Vector3.zero); //#endregion ball.velocity = ball.transform.position + newDirection; if (PhotonNetwork.IsConnected) { ball.photonView.RPC(nameof(ball.PlayHitEffect), RpcTarget.All, character.currentCharge.ToString(), ball.transform.position); } else { ball.PlayHitEffect(character.currentCharge.ToString(), ball.transform.position); } }
// Update is called once per frame private void Update() { t++; t = t % 50; /*if (controlScript == null) { * GameObject unityChan = GameObject.Find ("Unity-Chan(Clone)/unitychan"); * controlScript = (UnityChanControlScriptWithRgidBody) unityChan.GetComponent("UnityChanControlScriptWithRgidBody"); * }*/ if (Input.GetKeyDown(KeyCode.F) && !show) { if (UserPaddle.started) { BallPhysics.pauseAndResume(); } UserPaddle.menu = true; show = true; menu = true; } else if (Input.GetKeyDown(KeyCode.W) && show) { ind--; if (ind < 0) { ind = 3; } } else if (Input.GetKeyDown(KeyCode.S) && show) { ind++; if (ind > 3) { ind = 0; } } else if (Input.GetKeyDown(KeyCode.F) && show) { if (show) { sel = true; } } if (introShown) { if (introTime < 0.0f) { introShown = false; } else { introTime -= Time.deltaTime; } if (UserPaddle.started) { introShown = false; } } }
// Use this for initialization protected override void Start() { //base.Start(); lives = start_lives; //standard isInGoal = false; b_physics = GetComponent <BallPhysics> (); ballAudio = GetComponent <AudioSource> (); }
// Start is called before the first frame update void Start() { m_BallProjComp = m_Ball.GetComponent <BallPhysics>(); Assert.IsNotNull(m_BallProjComp, "No Projectile Compononet Found"); m_NetBehaviour = m_Net.GetComponent <NetBehaviour>(); Assert.IsNotNull(m_NetBehaviour, "No Net Behaviour Found"); }
// Start is called before the first frame update void Start() { //created ball object ball = GameObject.FindGameObjectWithTag("Player").GetComponent <BallPhysics>(); //created scene object to get current/active scene scene = SceneManager.GetActiveScene(); }
private IEnumerator SpawnBall(BallPhysics ball, Vector3 position, Vector3 velocity) { yield return(new WaitForSeconds(settings.outputWaitTime)); ball.gameObject.SetActive(true); ball.transform.position = position; ball.velocity = velocity; }
private void Awake() { a_BallPhysics = this; cameraEnd = GameObject.Find("EndCamera"); cameraMain = GameObject.Find("Main Camera"); cameraEnd.SetActive(false); cameraMain.SetActive(true); }
private void Start() { rb = GetComponent <Rigidbody>(); ballDur = GetComponent <BallDurability>(); ballPhysics = GetComponent <BallPhysics>(); nameplate = GetComponent <NameplateDisplay>(); //Initialise ballConfig values }
public void DestroyCurrentBall() { //Destroy(currentBall); BallPhysics ball = currentBall.GetComponent <BallPhysics>(); ball.ToggleRenderer(false); ball.stopped = true; //canSpawn = false; }
public void OnTriggerExit(Collider other) { BallPhysics ballPhysics = other.GetComponent <BallPhysics>(); if (ballPhysics) { ballPhysics.Reset(); } }
// Start is called before the first frame update void Start() { //instantiates the ball object to the proper game object ball = GameObject.FindGameObjectWithTag("Player").GetComponent <BallPhysics>(); //instantiates the UI to the proper game object targetsLeft = GameObject.FindGameObjectWithTag("Score").GetComponent <TargetsLeftUI>(); //instantiates the scene object to get the active/current scene scene = SceneManager.GetActiveScene(); }
public BallPhysics(BallPhysics ballPhysics) { radius = ballPhysics.radius; bounciness = ballPhysics.bounciness; groundY = ballPhysics.groundY; _pointManager = ballPhysics._pointManager; _soundManager = ballPhysics._soundManager; _tv = ballPhysics._tv; _isPredictionBall = true; // Constructor only called in this case }
public void Effect() { SetStack(stack + 1); Rigidbody2D ballRidigBody = ball.GetComponent <Rigidbody2D>(); BallPhysics ballPhysics = ball.GetComponent <BallPhysics>(); ballPhysics.SetSpeedX(ballPhysics.speedX * speedFactor); ballPhysics.SetSpeedY(ballPhysics.speedY * speedFactor); SetDuration(30); ballRidigBody.velocity = new Vector2(ballRidigBody.velocity.x * speedFactor, ballRidigBody.velocity.y * speedFactor); }
public void ClearBuff() { Rigidbody2D ballRidigBody = ball.GetComponent <Rigidbody2D>(); BallPhysics ballPhysics = ball.GetComponent <BallPhysics>(); ballPhysics.SetSpeedX(ballPhysics.InitalSpeedX); ballPhysics.SetSpeedY(ballPhysics.InitalSpeedY); ballRidigBody.velocity = new Vector2(ballRidigBody.velocity.x / Mathf.Pow(speedFactor, stack), ballRidigBody.velocity.y / Mathf.Pow(speedFactor, stack)); stack = 0; duration = 0; }
public void DecreaseBallSpeedEffect(float time) { isSlowDown = true; SetDecreaseBallSpeed(DecreaseBallSpeedStack + 1); Rigidbody2D ballRidigBody = ball.GetComponent <Rigidbody2D>(); BallPhysics ballPhysics = ball.GetComponent <BallPhysics>(); ballPhysics.SetSpeedX(ballPhysics.speedX * decreaseBallSpeedFactor); ballPhysics.SetSpeedY(ballPhysics.speedY * decreaseBallSpeedFactor); decreaseBallSpeedDuration = time; ballRidigBody.velocity = new Vector2(ballRidigBody.velocity.x * decreaseBallSpeedFactor, ballRidigBody.velocity.y * decreaseBallSpeedFactor); }
public void ResetBallSpeedBuff() { isSlowDown = false; Rigidbody2D ballRidigBody = ball.GetComponent <Rigidbody2D>(); BallPhysics ballPhysics = ball.GetComponent <BallPhysics>(); ballPhysics.SetSpeedX(ballPhysics.InitalSpeedX); ballPhysics.SetSpeedY(ballPhysics.InitalSpeedY); ballRidigBody.velocity = new Vector2(ballRidigBody.velocity.x / Mathf.Pow(decreaseBallSpeedFactor, DecreaseBallSpeedStack), ballRidigBody.velocity.y / Mathf.Pow(decreaseBallSpeedFactor, DecreaseBallSpeedStack)); DecreaseBallSpeedStack = 0; decreaseBallSpeedDuration = 0; }
// Start is called before the first frame update void Start() { //GetComponent<MeshRenderer>().enabled = false; range = 12.4f; ball = FindObjectOfType <BallPhysics>(); pos.x = ball.transform.position.x + ball.transform.forward.x * range; pos.y = 3.0f; pos.z = ball.transform.position.z + ball.transform.forward.z * range; prepos = pos; transform.position = pos; }
// Use this for initialization void Start() { ballPhysics = GetComponent <BallPhysics>(); // This may have been initialized by the scoring function. // If that's the case, we don't need to override it if (currentMovement == null) { currentMovement = new BallMovement(); } GetComponent <Renderer>().enabled = false; }
private IEnumerator WaitToShoot(BallPhysics ball) { yield return(new WaitForSeconds(1)); if (m_canShoot) { Jump(); ball.transform.position = m_shootPosition.position; ball.LaunchProjectileTo(m_target); m_backboard.material.color = Color.red; m_light.SetActive(true); } }
private void OnCollisionEnter(Collision collision) { BallPhysics biggerBall = this; BallPhysics otherBall = collision.gameObject.GetComponent <BallPhysics>(); if (otherBall._rigidBody.mass > biggerBall._rigidBody.mass) { BallPhysics temp = otherBall; otherBall = biggerBall; biggerBall = temp; } HandleCollistion(biggerBall, otherBall, _ballsCreator); biggerBall.CheckIfSplitBall(); }
private static void HandleCollistion(BallPhysics biggerBall, BallPhysics otherBall, BallsCreator ballsCreator) { if (biggerBall._isDestroyed || otherBall._isDestroyed || ballsCreator.ChangePhysics) { return; } biggerBall._rigidBody.mass += otherBall._rigidBody.mass; biggerBall.GravityRange += otherBall.GravityRange; biggerBall._howManyBallsMarged += otherBall._howManyBallsMarged; biggerBall.gameObject.transform.localScale += otherBall.transform.localScale;; otherBall._isDestroyed = true; Destroy(otherBall.gameObject); }
private void HandleSpecialInput(bool hit, Vector3 hitPosition, Vector3 faceDirection) { if (Input.GetKeyDown(KeyCode.Mouse2)) { if (explosiveBallPrefab != null) { GameObject explosiveBall = Instantiate(explosiveBallPrefab, transform.position + faceDirection + Vector3.up, Quaternion.identity) as GameObject; BallPhysics ballPhysics = explosiveBall.GetComponent <BallPhysics>(); Vector3 force = faceDirection; float tossSpeed = 0.8f; force.x = force.x * tossSpeed; force.y = force.y * tossSpeed; force.z = force.z * tossSpeed; ballPhysics.applyForce(force); } } }
private void Awake() { inputHandler = InputHandler.GetInstance(); if (ball == null) { ball = GameObject.FindGameObjectWithTag("Player"); } if (ball.GetComponent <BallPhysics>() == null) { ball.AddComponent <BallPhysics>(); } ballPhysics = ball.GetComponent <BallPhysics>(); mainCamera = Camera.main; spawn = transform.GetChild(0); }
void Start() { bp = GetComponent<BallPhysics> (); cam = Camera.main.GetComponent<Camera> (); }
// Use this for initialization void Start() { cam = GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<Camera> (); bp = GetComponent<BallPhysics> (); }