Beispiel #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Ball")
     {
         currentColor = other.GetComponent <Ball>().color;
         transform.gameObject.GetComponent <MeshRenderer>().material.color = other.GetComponent <Ball>().ballColor;
         boxParticle.SetActive(true);
         audioSource.Play();
         StartCoroutine(DisableEffect());
         if (currentColor == Targetcolor)
         {
             if (!colored)
             {
                 GameManager.Instance.trueColor++;
             }
             colored = true;
         }
         else
         {
             if (colored)
             {
                 GameManager.Instance.trueColor--;
             }
             colored = false;
         }
     }
 }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        dir     = GetComponentInParent <Transform>().forward;
        ball    = GetComponent <MeshRenderer>();
        shooter = GetComponentInParent <Shooter>();
        rb      = GetComponent <Rigidbody>();

        color = shooter.shooterColor;

        if (shooter.shooterColor == ShooterColor.Red)
        {
            ballColor = ball.material.color = shooter.colors[0];
        }
        else if (shooter.shooterColor == ShooterColor.Green)
        {
            ballColor = ball.material.color = shooter.colors[1];
        }
        else if (shooter.shooterColor == ShooterColor.Blue)
        {
            ballColor = ball.material.color = shooter.colors[2];
        }

        Destroy(gameObject, 3f);
    }