/// <summary> /// Update is called every frame, if the MonoBehaviour is enabled. /// </summary> void Update() { if (timerToMove.Finished) { StartMoving(); timerToMove.Stop(); } if (lifetimeBall.Finished && SpawnBall()) { ballSpawner.SpawnBall();///aqui invocar al listener deadBallEvent.Invoke() Destroy(gameObject); } if (!EffectsUtils.EffectActive && isSpeedup) { rigidbody2D.velocity /= EffectsUtils.FactorSpeedup; isSpeedup = false; } if (rigidbody2D.velocity.magnitude > 0 && EffectsUtils.EffectActive && !isSpeedup) { isSpeedup = true; rigidbody2D.velocity *= EffectsUtils.FactorSpeedup; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.TryGetComponent(out Bonus bonus)) { switch (bonus.BonusEnchantment) { case Bonus.BonusType.positiveSpeed: StartCoroutine(BoostMoveSpeed(true)); break; case Bonus.BonusType.negativeSpeed: StartCoroutine(BoostMoveSpeed(false)); break; case Bonus.BonusType.positiveSize: StartCoroutine(ChangeSize(true)); break; case Bonus.BonusType.negativeSize: StartCoroutine(ChangeSize(false)); break; case Bonus.BonusType.aditionalBalls: _ballSpawner.SpawnBall(_ballCount); break; default: break; } } Destroy(collision.gameObject); }
void SpawnBall() { GameObject ball = balls; ball.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>("wallHit"); ball.GetComponent <AudioSource>().playOnAwake = false; Vector3 spawnPosition; if (player1turn) { spawnPosition = new Vector3(0.0f, 50.0f, 0.0f); } else { spawnPosition = new Vector3(0.0f, 50.0f, -8000.0f); } Quaternion spawnRotation = Quaternion.identity; if (isOnlineMode && isHost) { ballSpawner = GameObject.FindObjectOfType <BallSpawner>(); ballSpawner.SpawnBall(); ballCount += 2; } else if (isOnlineMode && !isHost) { } else { Instantiate(ball, spawnPosition, spawnRotation); ballCount += 1; } }
void ApplyEffect() { BallSpawner ballSpawner = GameObject.FindGameObjectWithTag("GameController").GetComponent <BallSpawner>(); Vector3 force = new Vector3(Mathf.Abs(Random.Range(-100, 100)) + 1, Mathf.Abs(Random.Range(-100, 100)) + 1, Mathf.Abs(Random.Range(-200, 200)) + 1); ballSpawner.SpawnBall(force); }
public void StartCountdown() { if ((countdownRunning == true) && (timerRunning == false) && (countdownTime > 0)) { _countdownText.enabled = true; countdownTime -= Time.deltaTime; DisplayTime(countdownTime); if (countdownTime > 9 && countdownTime < 10) { player.GetComponent <PlayerControllerRB>().gameRunning = true; boxPlayerList[0].gameObject.SetActive(true); robotList[0].gameObject.SetActive(true); } else if (countdownTime > 8 && countdownTime < 9) { boxPlayerList[1].gameObject.SetActive(true); robotList[1].gameObject.SetActive(true); } else if (countdownTime > 7 && countdownTime < 8) { boxPlayerList[2].gameObject.SetActive(true); robotList[2].gameObject.SetActive(true); } else if (countdownTime > 6 && countdownTime < 7) { boxPlayerList[3].gameObject.SetActive(true); robotList[3].gameObject.SetActive(true); } else if (countdownTime > 5 && countdownTime < 6) { boxPlayerList[4].gameObject.SetActive(true); robotList[4].gameObject.SetActive(true); } else if (countdownTime > 4 && countdownTime < 5) { boxPlayerList[5].gameObject.SetActive(true); robotList[5].gameObject.SetActive(true); } } else if (countdownTime < 0) { timerRunning = true; countdownRunning = false; _countdownText.enabled = false; countdownTime = 0; ColorCountActivator.ActivateColorCount(); // Calling the ColorCounter script to activate the counter BallSpawnActivator.SpawnBall(); ColorSwitchActivator.StartColorSwitch(); startZoneR.SetActive(false); _throwingSoundRobot.mute = false; _throwingSoundCube.mute = false; _fireworkSound.mute = false; _fallingSound.mute = false; _startSound.mute = false; } }
void OnBecameInvisible() { if (gameObject.transform.position.y < ScreenUtils.ScreenBottom) { ballSpawner.SpawnBall(); } Destroy(gameObject); }
/// <summary> /// Create a new ball /// </summary> private void CreateNewBall(Vector3 newPosition) { BallSpawner ballSpawner = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <BallSpawner>(); GameObject newBall = ballSpawner.SpawnBall(newPosition); newBall.transform.position = newPosition; Debug.Log(ballSpawner.gameObject.name); }
// Update is called once per frame void Update() { cameraTransform.position += new Vector3(Input.GetAxis("Horizontal") * speed, Input.GetAxis("Mouse ScrollWheel"), Input.GetAxis("Vertical") * speed); if (Input.GetButtonDown("Fire1")) { ballSpawner.SpawnBall(); } cameraTransform.eulerAngles += new Vector3(-Input.GetAxis("Mouse Y") * 1.2f, Input.GetAxis("Mouse X") * 1.2f, 0f); }
// Update is called once per frame void Update() { if (aM.enabled) { if (Time.fixedTime > (time + (aM.GetCurrentAnimatorStateInfo(0).length * 0.5)) && going) { theSpawner.SpawnBall(); going = false; } } }
private void OnTriggerEnter2D(Collider2D other) { if (gameObject.CompareTag("PlayerWall")) { score.AddScore("ai"); } else if (gameObject.CompareTag("AIWall")) { score.AddScore("player"); } Destroy(other.gameObject); ballSpawner.SpawnBall(); }
private void SpawnBall() { // make sure we don't spawn into a collision if (Physics2D.OverlapArea(ballSpawner.SpawnLocationMin, ballSpawner.SpawnLocationMax) == null) { retrySpawn = false; ballSpawner.SpawnBall(); Destroy(gameObject); } else { retrySpawn = true; } }
void Update() { if (timer.Finished) { //ballsLeftEvent.Invoke(); ballSpawner.SpawnBall(); Destroy(gameObject); } else if (rigidBody2D.position.y < (ScreenUtils.ScreenBottom - 0.2f)) { ballsLeftEvent.Invoke(); ballSpawner.SpawnBall(); Destroy(gameObject); } if (speedupBall) { if (speedupTimer.Finished) { rigidBody2D.velocity = rigidBody2D.velocity / speedupFactor; speedupBall = false; } } }
public void Initialize(BallSpawner ballSpawner, Vector3 currentBallSpawnPosition, Vector3 nextBallSpawnPosition) { _ballSpawner = ballSpawner; _currentBallSpawnPosition = currentBallSpawnPosition; _nextBallSpawnPosition = nextBallSpawnPosition; _currentBall = SpawnRandomBall(_currentBallSpawnPosition); _currentBall.name = "CurrentBall"; _nextBall = SpawnRandomBall(_nextBallSpawnPosition); _nextBall.name = "NextBall"; _previewBall = _ballSpawner.SpawnBall(BIG_NUMBER, _currentBall.GetComponent <Ball>().GetValue()); _previewBall.name = "PreviewBall"; }
/// <summary> /// Spawn new ball and destroy self when out of game /// </summary> void OnBecameInvisible() { // death timer destruction is in Update if (!deathTimer.Finished) { // only spawn a new ball if below screen float halfColliderHeight = gameObject.GetComponent <BoxCollider2D>().size.y / 2; if (transform.position.y - halfColliderHeight < ScreenUtils.ScreenBottom) { ballSpawner.SpawnBall(); HUD.ReduceBallsLeft(); } Destroy(gameObject); } }
private void Update() { if (m_CooldownActive) { ++m_CooldownCounter; if (m_CooldownCounter >= m_SpawnCooldown) { m_CooldownActive = false; } } if (m_BallsList.Count == 0 && !m_CooldownActive) { m_Spawner.SpawnBall(); m_CooldownCounter = 0; m_CooldownActive = true; } }
private void OnTriggerEnter(Collider other) { if (!other.CompareTag("BowlingBall")) { return; } if (_pinManager != null) { _pinManager.countTurn(); } if (gameObject.transform.parent.name == "LANE 1") { StartCoroutine(_ballSpawner.SpawnBall(_ballSpawner.Lane1Spawn)); } if (gameObject.transform.parent.name == "LANE 2") { StartCoroutine(_ballSpawner.SpawnBall(_ballSpawner.Lane2Spawn)); } if (gameObject.transform.parent.name == "LANE 3") { StartCoroutine(_ballSpawner.SpawnBall(_ballSpawner.Lane3Spawn)); } if (gameObject.transform.parent.name == "LANE 4") { StartCoroutine(_ballSpawner.SpawnBall(_ballSpawner.Lane4Spawn)); } if (gameObject.transform.parent.name == "LANE 5") { StartCoroutine(_ballSpawner.SpawnBall(_ballSpawner.Lane5Spawn)); } if (gameObject.transform.parent.name == "LANE 6") { StartCoroutine(_ballSpawner.SpawnBall(_ballSpawner.Lane6Spawn)); } }
public void SpawnSport() { int temp; temp = teamDrpDwn.GetComponent <Dropdown>().value; if (temp == 0) { isTeam = true; } else { isTeam = false; } ballSize = ballSizeDrpDwn.GetComponent <Dropdown>().value; temp = inWaterDrpDwn.GetComponent <Dropdown>().value; if (temp == 0) { inWater = true; } else { inWater = false; } SportRequirements requirements = new SportRequirements(); requirements.isTeam = isTeam; requirements.ballSize = ballSize; requirements.inWater = inWater; ISport s = GetSport(requirements); sportTxt.text = s.ToString(); if (s.ToString() == "Golf") { spawner.SpawnBall(golf); } else if (s.ToString() == "WaterPolo") { spawner.SpawnBall(waterPolo); } else if (s.ToString() == "WaterFootBall") { spawner.SpawnBall(waterFootBall); } else if (s.ToString() == "BeachBall") { spawner.SpawnBall(beachBall); } else if (s.ToString() == "SpikeBall") { spawner.SpawnBall(spikeBall); } else if (s.ToString() == "VolleyBall") { spawner.SpawnBall(volleyBall); } else if (s.ToString() == "KinBall") { spawner.SpawnBall(kinBall); } else if (s.ToString() == "DivingBall") { spawner.SpawnBall(divingBall); } else if (s.ToString() == "WaterBasketBall") { spawner.SpawnBall(waterBasketBall); } else if (s.ToString() == "WaterBall") { spawner.SpawnBall(waterBall); } else if (s.ToString() == "Bowling") { spawner.SpawnBall(bowlingBall); } else { spawner.SpawnBall(yardPong); } }
void OnTriggerEnter2D(Collider2D other) { Destroy(this.gameObject); spawner.SpawnBall(); }
private GameObject SpawnRandomBall(Vector3 position) { return(_ballSpawner.SpawnBall(position, Ball.GenerateCappedRandomValue())); }
void SpawnBall() { ballSpawner.SpawnBall(); }
protected override void OnCreate() { CreateRectilinearPlane(100, 100, 0.1f); BallSpawner.SpawnBall(new float3(5f, 2f, 1.5f), 0.25f); }
internal void SpawnBall() { ballSpawner.SpawnBall(); }
private void Start() { _ballSpawner.SpawnBall(); RestartGame(); }
/// <summary> /// Destroys current ball and spawns new /// </summary> private void DestroyAndSpawn() { Destroy(gameObject); _ballSpawner.SpawnBall(); }