예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (c.Equals(Color.gray))
        {
            GetComponent <BoxCollider2D>().isTrigger = false;
        }
        else
        {
            GetComponent <BoxCollider2D>().isTrigger = true;
        }
        if (coll.bounds.Intersects(player.GetComponent <BoxCollider2D>().bounds))
        {
            if (c.Equals(Color.green))
            {
                player.Regen = true;
            }
            else
            {
                player.Regen = false;
            }

            if (c.Equals(Color.red))
            {
                player.Dot = true;
            }
            else
            {
                player.Dot = false;
            }

            if (c.Equals(purple))
            {
                player.MoreDmg = true;
            }
            else
            {
                player.MoreDmg = false;
            }

            if (c.Equals(orange))
            {
                player.MoreShots = true;
            }
            else
            {
                player.MoreShots = false;
            }

            if (c.Equals(Color.yellow))
            {
                player.MoreFireRate = true;
            }
            else
            {
                player.MoreFireRate = false;
            }
            if (c.Equals(Color.white))
            {
                player.Invis = true;
            }
            else
            {
                player.Invis = false;
            }
            if (c.Equals(Color.black))
            {
                player.Regen        = false;
                player.Dot          = false;
                player.MoreDmg      = false;
                player.MoreShots    = false;
                player.MoreFireRate = false;
                player.Invis        = false;
                GetComponent <BoxCollider2D>().isTrigger = true;
                player.MoreSpeed = false;
            }
            if (c.Equals(Color.blue))
            {
                player.MoreSpeed = true;
            }
            else
            {
                player.MoreSpeed = false;
            }
        }
        else
        {
            if (c.Equals(Color.gray))
            {
                GetComponent <BoxCollider2D>().isTrigger = false;
            }
            else
            {
                GetComponent <BoxCollider2D>().isTrigger = true;
            }
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if ((Mathf.Abs(player.GetComponent <Rigidbody2D>().velocity.x) > 1f || Mathf.Abs(player.GetComponent <Rigidbody2D>().velocity.y) > 1f))
        {
            timeUntilNextTiles -= Time.deltaTime;
        }
        timee = timeUntilNextTiles / timeUntilTileChange;

        if (timeUntilNextTiles <= 0)
        {
            //if (!firstDone)
            //{
            //    timeUntilNextTiles = timeUntilTileChange;
            //    firstDone = true;
            //    tempRand = Random.value;
            //    tempRand2 = Random.value;
            //    tempRand3 = Random.value;
            //    tempRand4 = Random.value;
            //    for (int i = 0; i < tiles.Length; i++)
            //    {
            //        if (tiles[i].transform.position.x > 0 && tiles[i].GetComponent<BoxCollider2D>().transform.position.y > 0)
            //        {
            //            list1.Add(tiles[i]); //x and y are positive
            //            tiles[i].setColor(tempRand);
            //        }
            //        tiles1=list1.ToArray();

            //        if (tiles[i].transform.position.x < 0 && tiles[i].GetComponent<BoxCollider2D>().transform.position.y > 0)
            //        {
            //            list2.Add(tiles[i]); //x is negative and y is positive
            //            tiles[i].setColor(tempRand2);
            //        }
            //        tiles2 = list2.ToArray();

            //        if (tiles[i].transform.position.x > 0 && tiles[i].GetComponent<BoxCollider2D>().transform.position.y < 0)
            //        {
            //            list3.Add(tiles[i]); //y is negative and x is positive
            //            tiles[i].setColor(tempRand3);
            //        }
            //        tiles3 = list2.ToArray();

            //        if (tiles[i].transform.position.x < 0 && tiles[i].GetComponent<BoxCollider2D>().transform.position.y < 0)
            //        {
            //            list4.Add(tiles[i]); //both negative
            //            tiles[i].setColor(tempRand4);
            //        }
            //        tiles4 = list4.ToArray();

            //    }
            //}


            //if((!secondDone&&firstDone)&&timeAfterFirst>= timeUntilTileChange*2)
            //{
            //    timeUntilNextTiles = timeUntilTileChange * 2;
            //    secondDone = true;
            //    tempRand = Random.value;
            //    tempRand2 = Random.value;
            //    tempRand3 = Random.value;
            //    tempRand4 = Random.value;
            //    for (int i = 0; i < tiles1.Length; i++)
            //    {

            //        if ((Mathf.Abs(tiles1[i].transform.position.x) < 5.5) && (Mathf.Abs(tiles1[i].transform.position.y) < 3.7))
            //        {
            //            tiles1[i].setColor(tempRand);
            //        }

            //        if ((Mathf.Abs(tiles1[i].transform.position.x) > 5.5) && (Mathf.Abs(tiles1[i].transform.position.y) < 3.7))
            //        {
            //            tiles1[i].setColor(tempRand2);
            //        }

            //        if ((Mathf.Abs(tiles1[i].transform.position.x) < 5.5) && (Mathf.Abs(tiles1[i].transform.position.y) > 3.7))
            //        {
            //            tiles1[i].setColor(tempRand3);
            //        }

            //        if ((Mathf.Abs(tiles1[i].transform.position.x) > 5.5) && (Mathf.Abs(tiles1[i].transform.position.y) > 3.7))
            //        {
            //            tiles1[i].setColor(tempRand4);
            //        }
            //    }
            //    tempRand = Random.value;
            //    tempRand2 = Random.value;
            //    tempRand3 = Random.value;
            //    tempRand4 = Random.value;
            //    for (int i = 0; i < tiles2.Length; i++)
            //    {
            //        if ((Mathf.Abs(tiles2[i].transform.position.x) < 5.5) && (Mathf.Abs(tiles2[i].transform.position.y) < 3.7))
            //        {
            //            tiles2[i].setColor(tempRand);
            //        }

            //        if ((Mathf.Abs(tiles2[i].transform.position.x) > 5.5) && (Mathf.Abs(tiles2[i].transform.position.y) < 3.7))
            //        {
            //            tiles2[i].setColor(tempRand2);
            //        }

            //        if ((Mathf.Abs(tiles2[i].transform.position.x) < 5.5) && (Mathf.Abs(tiles2[i].transform.position.y) > 3.7))
            //        {
            //            tiles2[i].setColor(tempRand3);
            //        }

            //        if ((Mathf.Abs(tiles2[i].transform.position.x) > 5.5) && (Mathf.Abs(tiles2[i].transform.position.y) > 3.7))
            //        {
            //            tiles2[i].setColor(tempRand4);
            //        }
            //    }
            //    tempRand = Random.value;
            //    tempRand2 = Random.value;
            //    tempRand3 = Random.value;
            //    tempRand4 = Random.value;
            //    for (int i = 0; i < tiles3.Length; i++)
            //    {
            //        if ((Mathf.Abs(tiles3[i].transform.position.x) < 5.5) && (Mathf.Abs(tiles3[i].transform.position.y) < 3.7))
            //        {
            //            tiles3[i].setColor(tempRand);
            //        }

            //        if ((Mathf.Abs(tiles3[i].transform.position.x) > 5.5) && (Mathf.Abs(tiles3[i].transform.position.y) < 3.7))
            //        {
            //            tiles3[i].setColor(tempRand2);
            //        }

            //        if ((Mathf.Abs(tiles3[i].transform.position.x) < 5.5) && (Mathf.Abs(tiles3[i].transform.position.y) > 3.7))
            //        {
            //            tiles3[i].setColor(tempRand3);
            //        }

            //        if ((Mathf.Abs(tiles3[i].transform.position.x) > 5.5) && (Mathf.Abs(tiles3[i].transform.position.y) > 3.7))
            //        {
            //            tiles3[i].setColor(tempRand4);
            //        }
            //    }
            //    tempRand = Random.value;
            //    tempRand2 = Random.value;
            //    tempRand3 = Random.value;
            //    tempRand4 = Random.value;
            //    for (int i = 0; i < tiles4.Length; i++)
            //    {
            //        if ((Mathf.Abs(tiles4[i].transform.position.x) < 5.5) && (Mathf.Abs(tiles4[i].transform.position.y) < 3.7))
            //        {
            //            tiles4[i].setColor(tempRand);
            //        }

            //        if ((Mathf.Abs(tiles4[i].transform.position.x) > 5.5) && (Mathf.Abs(tiles4[i].transform.position.y) < 3.7))
            //        {
            //            tiles4[i].setColor(tempRand2);
            //        }

            //        if ((Mathf.Abs(tiles4[i].transform.position.x) < 5.5) && (Mathf.Abs(tiles4[i].transform.position.y) > 3.7))
            //        {
            //            tiles4[i].setColor(tempRand3);
            //        }

            //        if ((Mathf.Abs(tiles4[i].transform.position.x) > 5.5) && (Mathf.Abs(tiles4[i].transform.position.y) > 3.7))
            //        {
            //            tiles4[i].setColor(tempRand4);
            //        }
            //    }
            //}

            //if((secondDone&&firstDone)&&timeAfterFirst>= timeUntilTileChange*4)
            //{

            for (int i = 0; i < tiles.Length; i++)
            {
                tiles[i].setColor(Random.value);
            }
            timeUntilNextTiles = timeUntilTileChange;
            //}
        }
    }