예제 #1
0
    // Update is called once per frame
    void Update()
    {
        //if player changes color then they mute colors
        if (player.GetComponent <SpriteRenderer>().color == green)
        {
            // Debug.Log("player green " );
            for (int i = 0; i < bar.Length; i++)
            {
                // Debug.Log("checking bars ");
                if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == blue.ToString())
                {
                    //     Debug.Log("muted blue");
                    bar[i].GetComponent <SpriteRenderer>().color  = MutedBlue;
                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == red.ToString())
                {
                    //    Debug.Log("muted red");
                    bar[i].GetComponent <SpriteRenderer>().color  = MutedRed;
                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }

                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == yellow.ToString())
                {
                    //   Debug.Log("muted yellow");
                    bar[i].GetComponent <SpriteRenderer>().color  = MutedYellow;
                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == MutedGreen.ToString())
                {
                    //   Debug.Log("reg green");
                    bar[i].GetComponent <SpriteRenderer>().color  = green;
                    bar[i].GetComponent <BoxCollider2D>().enabled = true;
                }
            }
        }
        if (player.GetComponent <SpriteRenderer>().color == blue)
        {
            //Debug.Log("player green " );
            for (int i = 0; i < bar.Length; i++)
            {
                // Debug.Log("checking bars ");
                if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == MutedBlue.ToString())
                {
                    //    Debug.Log("muted blue");
                    bar[i].GetComponent <SpriteRenderer>().color  = blue;
                    bar[i].GetComponent <BoxCollider2D>().enabled = true;
                }
                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == red.ToString())
                {
                    //  Debug.Log("muted red");
                    bar[i].GetComponent <SpriteRenderer>().color  = MutedRed;
                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }

                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == yellow.ToString())
                {
                    //  Debug.Log("muted yellow");
                    bar[i].GetComponent <SpriteRenderer>().color  = MutedYellow;
                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == green.ToString())
                {
                    //  Debug.Log("reg green");
                    bar[i].GetComponent <SpriteRenderer>().color  = MutedGreen;
                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
            }
        }
        if (player.GetComponent <SpriteRenderer>().color == red)
        {
            //Debug.Log("player green " );
            for (int i = 0; i < bar.Length; i++)
            {
                // Debug.Log("checking bars ");
                if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == blue.ToString())
                {
                    //  Debug.Log("muted blue");
                    bar[i].GetComponent <SpriteRenderer>().color  = MutedBlue;
                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == MutedRed.ToString())
                {
                    // Debug.Log("muted red");
                    bar[i].GetComponent <SpriteRenderer>().color  = red;
                    bar[i].GetComponent <BoxCollider2D>().enabled = true;
                }

                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == yellow.ToString())
                {
                    //  Debug.Log("muted yellow");
                    bar[i].GetComponent <SpriteRenderer>().color = MutedYellow;

                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == green.ToString())
                {
                    // Debug.Log("reg green");
                    bar[i].GetComponent <SpriteRenderer>().color  = MutedGreen;
                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
            }
        }
        if (player.GetComponent <SpriteRenderer>().color == yellow)
        {
            //Debug.Log("player green " );
            for (int i = 0; i < bar.Length; i++)
            {
                // Debug.Log("checking bars ");
                if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == blue.ToString())
                {
                    // Debug.Log("muted blue");
                    bar[i].GetComponent <SpriteRenderer>().color  = MutedBlue;
                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == red.ToString())
                {
                    // Debug.Log("muted red");
                    bar[i].GetComponent <SpriteRenderer>().color  = MutedRed;
                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }

                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == MutedYellow.ToString())
                {
                    // Debug.Log("muted yellow");
                    bar[i].GetComponent <SpriteRenderer>().color  = yellow;
                    bar[i].GetComponent <BoxCollider2D>().enabled = true;
                }
                else if (bar[i].GetComponent <SpriteRenderer>().color.ToString() == green.ToString())
                {
                    // Debug.Log("reg green");
                    bar[i].GetComponent <SpriteRenderer>().color  = MutedGreen;
                    bar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
            }
        }
    }
예제 #2
0
    void Update()
    {
        Vector3 v = startPos;

        v.x += delta * Mathf.Sin(Time.time * speed);
        transform.position = v;

        // Debug.Log("v " + v.x + " speed " + speed + " math?: " + Mathf.Sin(Time.time * speed));
        // Debug.Log("player pos " + player.transform.position.x);
        // //Debug.Log("what would be posX+speed: "+ player.transform.position.x + speed);
        // Debug.Log("rb velocity " + player.GetComponent<Rigidbody2D>().velocity);
        //if player changes color then they mute colors
        if (player.GetComponent <SpriteRenderer>().color == green)
        {
            // Debug.Log("player green " );
            for (int i = 0; i < MovingBar.Length; i++)
            {
                // Debug.Log("checking bars ");
                if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == blue.ToString())
                {
                    //     Debug.Log("muted blue");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = MutedBlue;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == red.ToString())
                {
                    //    Debug.Log("muted red");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = MutedRed;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }

                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == yellow.ToString())
                {
                    //   Debug.Log("muted yellow");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = MutedYellow;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == MutedGreen.ToString())
                {
                    //   Debug.Log("reg green");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = green;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = true;
                }
            }
        }
        if (player.GetComponent <SpriteRenderer>().color == blue)
        {
            //Debug.Log("player green " );
            for (int i = 0; i < MovingBar.Length; i++)
            {
                // Debug.Log("checking bars ");
                if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == MutedBlue.ToString())
                {
                    //    Debug.Log("muted blue");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = blue;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = true;
                }
                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == red.ToString())
                {
                    //  Debug.Log("muted red");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = MutedRed;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }

                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == yellow.ToString())
                {
                    //  Debug.Log("muted yellow");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = MutedYellow;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == green.ToString())
                {
                    //  Debug.Log("reg green");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = MutedGreen;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
            }
        }
        if (player.GetComponent <SpriteRenderer>().color == red)
        {
            //Debug.Log("player green " );
            for (int i = 0; i < MovingBar.Length; i++)
            {
                // Debug.Log("checking bars ");
                if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == blue.ToString())
                {
                    //  Debug.Log("muted blue");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = MutedBlue;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == MutedRed.ToString())
                {
                    // Debug.Log("muted red");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = red;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = true;
                }

                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == yellow.ToString())
                {
                    //  Debug.Log("muted yellow");
                    MovingBar[i].GetComponent <SpriteRenderer>().color = MutedYellow;

                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == green.ToString())
                {
                    // Debug.Log("reg green");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = MutedGreen;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
            }
        }
        if (player.GetComponent <SpriteRenderer>().color == yellow)
        {
            //Debug.Log("player green " );
            for (int i = 0; i < MovingBar.Length; i++)
            {
                // Debug.Log("checking bars ");
                if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == blue.ToString())
                {
                    // Debug.Log("muted blue");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = MutedBlue;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == red.ToString())
                {
                    // Debug.Log("muted red");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = MutedRed;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }

                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == MutedYellow.ToString())
                {
                    // Debug.Log("muted yellow");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = yellow;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = true;
                }
                else if (MovingBar[i].GetComponent <SpriteRenderer>().color.ToString() == green.ToString())
                {
                    // Debug.Log("reg green");
                    MovingBar[i].GetComponent <SpriteRenderer>().color  = MutedGreen;
                    MovingBar[i].GetComponent <BoxCollider2D>().enabled = false;
                }
            }
        }

        if (onMovingBar)
        {
            //player.transform.localScale = new Vector3(0.3F, 3.4F, 0.4F);
            //  Debug.Log("scale: "+ player.transform.localScale);
        }
    }