Пример #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);
        }
    }
Пример #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();
    }
Пример #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;
        }
    }
Пример #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;
     }
 }
Пример #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);
            }
        }
    }
Пример #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;
        }
    }