Ejemplo n.º 1
0
    public void OnBallReachedBucket(MarbleBehaviour ball)
    {
        // Check if we've won!
        int fullBucketsCount = 0;

        foreach (var bucket in buckets)
        {
            if (bucket.hasReceivedMarble)
            {
                fullBucketsCount++;
            }
        }

        pedestalCountText.text = string.Format("{0}/{1}", fullBucketsCount, buckets.Length);

        if (fullBucketsCount == buckets.Length)
        {
            Debug.Log("YOU WINS!");
            isPlaying = false;
            overlay.SetActive(true);
            beforePlayingOverlay.SetActive(false);
            gameOver.SetActive(true);
        }
        else
        {
            Debug.Log("Not won yet. :(");
            spawners[Random.Range(0, spawners.Length)].SpawnBall(ball);
        }
    }
Ejemplo n.º 2
0
    // Pass in a ball to reuse it, or null to create a new one.
    public void SpawnBall(MarbleBehaviour existingBall)
    {
        MarbleBehaviour ball = existingBall ?? Instantiate(ballPrefab);

        ball.AppearAt(new Vector3(transform.position.x, transform.position.y + 0.00f, 0));
        //sound.Play();
    }
Ejemplo n.º 3
0
    public IEnumerator EatMarble(GameObject marble)
    {
        MarbleBehaviour behaviour = marble.GetComponent <MarbleBehaviour>();

        if (!behaviour.pendingEndMe)
        {
            behaviour.pendingEndMe = true;
            score += behaviour.GetPointValue();
            yield return(new WaitForSeconds(0.5f));

            behaviour.endMe = true;
        }
    }
Ejemplo n.º 4
0
 public void addMarble(MarbleBehaviour marble)
 {
     if (marbles.Count < relativePositions.Count)
     {
         marbles.Add(marble);
         if (marble.marbleMaxVelocity < maxVelocity)
         {
             maxVelocity = marble.marbleMaxVelocity;
         }
         if (marble.marbleStrength / marble.myRigidbody.mass < maxAccelleration)
         {
             maxAccelleration = marble.marbleStrength / marble.myRigidbody.mass;
         }
         marble.f = this;
     }
 }
Ejemplo n.º 5
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Ball"))
        {
            // We caught a ball!
            if (!hasReceivedMarble)
            {
                hasReceivedMarble = true;
                animator.SetBool("isDown", true);
                sound.Play();

                caughtMarble = collision.GetComponent <MarbleBehaviour>();
                caughtMarble.gameObject.SetActive(false);
            }
        }
    }
Ejemplo n.º 6
0
    public IEnumerator EatMarble(GameObject marble)
    {
        MarbleBehaviour behaviour = marble.GetComponent <MarbleBehaviour>();

        if (behaviour.pendingEndMe != true)
        {
            behaviour.pendingEndMe = true;
            if (animator)
            {
                animator.Play("Base Layer.NeckAnim", 0, 0);
            }
            score += behaviour.GetPointValue();
            yield return(new WaitForSeconds(0.2f));

            behaviour.endMe = true;
        }
    }