Пример #1
0
    void CastRay()
    {
        RaycastHit info = new RaycastHit();
        Ray        ray  = Camera.main.ScreenPointToRay(target);

        Physics.Raycast(ray, out info, 30);
        if (info.collider == null)
        {
            return;
        }
        BadScript b = info.collider.GetComponent <BadScript> ();

        if (b != null)
        {
            b.Hit();
        }
    }
Пример #2
0
 void SetColors(BadScript b, Colors c)
 {
     b.blue = b.green = b.red = false;
     if (c == Colors.Blue)
     {
         b.blue = true;
         b.gameObject.GetComponent <MeshFilter>().mesh = models[0];
     }
     else if (c == Colors.Green)
     {
         b.green = true;
         b.gameObject.GetComponent <MeshFilter>().mesh = models[1];
     }
     else if (c == Colors.Red)
     {
         b.red = true;
         b.gameObject.GetComponent <MeshFilter>().mesh = models[2];
     }
     else if (c == Colors.Yellow)
     {
         b.red = b.green = true;
         b.gameObject.GetComponent <MeshFilter>().mesh = models[3];
     }
     else if (c == Colors.Cyan)
     {
         b.blue = b.green = true;
         b.gameObject.GetComponent <MeshFilter>().mesh = models[4];
     }
     else if (c == Colors.Magenta)
     {
         b.blue = b.red = true;
         b.gameObject.GetComponent <MeshFilter>().mesh = models[5];
     }
     else if (c == Colors.White)
     {
         b.blue = b.red = b.green = true;
         b.gameObject.GetComponent <MeshFilter>().mesh = models[6];
     }
 }
Пример #3
0
    // Update is called once per frame
    void Spawn()
    {
        safe++;
        if (safe == 5)
        {
            level++;
            safe = 0;
            if (level == dificultys.Length)
            {
                EndGame(true);
                return;
            }
        }
        Invoke("Spawn", spawnRate);
        spawn.Play();
        float pat = Random.value * dificultys [level];

        if (level != 0)
        {
            pat = Random.Range(dificultys [level - 1], dificultys [level]);
        }

        List <Colors> k = colors[Mathf.FloorToInt(pat)];
        Transform     p = pattern[Mathf.FloorToInt(Random.value * pattern.Length)].transform;

        for (int i = 0; i < p.childCount; i++)
        {
            int        j = Mathf.FloorToInt(Random.value * obj.Length);
            GameObject g = Instantiate <GameObject> (obj [j]);
            Vector3    v = p.GetChild(i).localPosition;
            g.transform.position = new Vector3(v.x, v.y, -35);
            BadScript b = g.GetComponent <BadScript> ();
            SetColors(b, k[i % k.Count]);
            b.SetTime(-i * .1f);
        }
    }