// Vector2 targetScale; // Use this for initialization void Start() { ball = GetComponentInParent <NewBall>(); m_Sprite = GetComponent <SpriteRenderer>(); m_Sprite.enabled = false; EventManager.StartListening("BallCaught", DoCatch); EventManager.StartListening("BallThrown", DoThrow); EventManager.StartListening("BallDied", OnGameOver); target = transform.parent; }
// Use this for initialization void Start() { m_Ball = GetComponentInParent <NewBall>(); m_Rigidbody = GetComponentInParent <Rigidbody2D>(); m_LinePointList = new List <Vector3>(); m_LineSegment = new List <Vector3>(); line.sortingLayerName = "Default"; line.useWorldSpace = true; line.startWidth = transform.root.localScale.x; line.endWidth = transform.root.localScale.y; }
// void CheckForBall() // { // float radius = GetComponent<CircleCollider2D>().radius; // RaycastHit2D hit = Physics2D.CircleCast(m_Transform.position, radius, Vector2.zero); // // Only catch one ball at a time // if (hit && m_Ball == null) // { // if (hit.collider.gameObject.CompareTag("Ball")) // { // // Debug.Log("Hit a ball"); // NewBall ballToJuggle = hit.collider.gameObject.GetComponent<NewBall>(); // // only catch balls that are not launching // if (!ballToJuggle.m_Launching) // { // // Debug.Log("Setting ball"); // SetBall(ballToJuggle); // } // } // } // } void OnTriggerEnter2D(Collider2D other) { if (m_Ball == null) { if (other.CompareTag("Ball")) { NewBall ballToJuggle = other.gameObject.GetComponent <NewBall>(); if (!ballToJuggle.m_Launching) { // Debug.Log("Set a new ball"); SetBall(ballToJuggle); } } } }
public void UpdateEndgame(NewBall nb) { int endgameIndex = 8; if (_ballCount == endgameIndex) { if (!AllBallsUnitedAtIndex(endgameIndex)) { if (nb.ballColorIndex < endgameIndex) { nb.ballColorIndex++; nb.UpdateColor(); } } } }
void SpawnBall() { Vector2 ballSpawnPos = new Vector2(Random.Range(-2.25f, 2.25f), -6); NewBall ball = Instantiate(m_BallPrefab); ball.transform.position = ballSpawnPos; ball.m_Launching = true; ball.canBeCaught = false; ball.GetComponent <Rigidbody2D>().velocity = Vector2.up * ballLaunchForce; ball.GetComponentInChildren <NewBallArtManager>().SetInfo(_ballCount); balls.Add(ball); _ballCount++; ballsSortedByDepth.Add(ball.GetComponent <NewBallArtManager>()); }
public void SpawnFirstBall() { if (firstBall) { return; } Vector2 ballSpawnPos = new Vector2(0, -2); NewBall ball = Instantiate(m_BallPrefab); ball.transform.position = ballSpawnPos; ball.m_Launching = false; ball.canBeCaught = false; ball.GetComponent <Rigidbody2D>().velocity = Vector2.zero; ball.GetComponent <Rigidbody2D>().gravityScale = 0; ball.GetComponentInChildren <NewBallArtManager>().SetInfo(_ballCount); firstBall = ball; balls.Add(ball); _ballCount++; NewScoreManager._numBalls = _ballCount; ballsSortedByDepth.Add(ball.GetComponent <NewBallArtManager>()); }
// Use this for initialization void Start() { m_Ball = GetComponentInParent <NewBall>(); }
void OnBallDied() { scoreIndex = 0; firstBall = null; }
void ThrowBall() { m_Ball.GetThrown(m_GrabThrowVector); m_Ball = null; HandleDeath(); }
void SetBall(NewBall caughtBall) { m_Ball = caughtBall; // Debug.Break(); }