Exemplo n.º 1
0
 public List <SP_Bulb> Build(List <SP_Bulb> bulbs)
 {
     tempContainer = new GameObject();
     for (int i = 0; i < amount; i++)
     {
         SP_Bulb b        = Instantiate(bulb) as SP_Bulb;
         float   rotation = (float)i / (float)amount * 360;
         Vector3 pos      = new Vector3(
             radius * Mathf.Cos(((float)i / (float)amount) * Mathf.PI * 2),
             radius * Mathf.Sin(((float)i / (float)amount) * Mathf.PI * 2),
             0);
         b.transform.localPosition    = pos;
         b.transform.localEulerAngles = new Vector3(0, 0, rotation);
         b.transform.parent           = tempContainer.transform;
         bulbs.Add(b);
     }
     tempContainer.transform.position   = container.transform.position;
     tempContainer.transform.rotation   = container.transform.rotation;
     tempContainer.transform.localScale = container.transform.localScale;
     for (int i = 0; i < amount; i++)
     {
         tempContainer.transform.GetChild(0).transform.parent = container.transform;
     }
     Destroy(tempContainer);
     return(bulbs);
 }
Exemplo n.º 2
0
        public void MakeStroke(SP_Stroke stroke, SP_Brush brush)
        {
            SP_Bulb b = layers[0].FindClosestBulb(brush.transform.position);

            //stroke.container = layers[0].GetComponent<SP_BuildBulbs>().container;
            b.strokes.Add(stroke);
            stroke.transform.parent = b.transform;
        }
Exemplo n.º 3
0
        public SP_Bulb FindClosestBulb(Vector3 v)
        {
            SP_Bulb closestBulb = null;
            float   min         = 1e6f;

            foreach (SP_Bulb bulb in bulbs)
            {
                float dist = Vector3.Distance(bulb.transform.position, v);
                if (dist < min)
                {
                    min         = dist;
                    closestBulb = bulb;
                }
            }
            return(closestBulb);
        }