// 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;
    }
Beispiel #2
0
    // 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;
    }
Beispiel #3
0
    // 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);
                }
            }
        }
    }
Beispiel #4
0
    public void UpdateEndgame(NewBall nb)
    {
        int endgameIndex = 8;

        if (_ballCount == endgameIndex)
        {
            if (!AllBallsUnitedAtIndex(endgameIndex))
            {
                if (nb.ballColorIndex < endgameIndex)
                {
                    nb.ballColorIndex++;
                    nb.UpdateColor();
                }
            }
        }
    }
Beispiel #5
0
    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>());
    }
Beispiel #6
0
    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>());
    }
Beispiel #7
0
 // Use this for initialization
 void Start()
 {
     m_Ball = GetComponentInParent <NewBall>();
 }
Beispiel #8
0
 void OnBallDied()
 {
     scoreIndex = 0;
     firstBall  = null;
 }
Beispiel #9
0
 void ThrowBall()
 {
     m_Ball.GetThrown(m_GrabThrowVector);
     m_Ball = null;
     HandleDeath();
 }
Beispiel #10
0
 void SetBall(NewBall caughtBall)
 {
     m_Ball = caughtBall;
     // Debug.Break();
 }