Esempio n. 1
0
 private void OnTriggerEnter(Collider other)
 {
     if (pieza != null)
     {
         return;
     }
     if (other.tag == "CPU")
     {
         MecanicoPieza p = other.GetComponent <MecanicoPieza>();
         if (p.type == type)
         {
             //Debug.Log("correcto");
             p.initPos            = transform.position;
             p.finished           = true;
             p.transform.rotation = transform.rotation;
             p.StopRotation();
             other.GetComponent <BoxCollider>().isTrigger = true;
             pieza = p;
             MecanicoGM.Instance.CorrectPart();
         }
         else
         {
             //Debug.Log("incorrecto");
         }
         p.trapped = false;
         MecanicoGM.Instance.mano.part = null;
     }
 }
Esempio n. 2
0
 void OnTriggerEnter(Collider c)
 {
     if (c.tag == "CPU" && part == null)
     {
         pieza = c.GetComponent <MecanicoPieza>();
         if (!pieza.finished)
         {
             part          = c.transform;
             pieza.trapped = true;
         }
     }
 }
Esempio n. 3
0
    public void Init()
    {
        int index = (int)dificultad;

        correct = 0;
        time    = 0;
        switch (dificultad)
        {
        case Dificultad.Nivel.facil:
            stageTime = 5;
            numSlots  = 2;
            numParts  = 3;
            score     = 200;
            stageTime = 5;
            break;

        case Dificultad.Nivel.medio:
            stageTime = 4;
            numSlots  = 3;
            numParts  = 5;
            score     = 400;
            stageTime = 4;
            break;

        case Dificultad.Nivel.dificil:
            stageTime = 3;
            numSlots  = 5;
            numParts  = 10;
            score     = 500;
            stageTime = 3;
            break;
        }
        SetTimeLabel(stageTime * 60);
        MecanicoPieza[] parts = GameObject.FindObjectsOfType <MecanicoPieza> ();
        for (int i = 0; i < parts.Length; i++)
        {
            Destroy(parts[i].gameObject);
        }
        //partSlots = new MecanicoSlot[numSlots];
        EnableSlots(index);

        /* for(int i = 0; i < partSlots.Length; i++){
         *      partSlots[i].type = (PartType)(i+1);
         * }*/
        spawnedParts.Clear();
        for (int i = 0; i < numSlots; i++)
        {
            GameObject    g = (GameObject)Instantiate(partPrefab, partPrefab.transform.position, partPrefab.transform.rotation);
            MecanicoPieza p = g.GetComponent <MecanicoPieza> ();
            spawnedParts.Add(p);

            Vector3 randPos = randomPosition();
            int     iter    = 0;
            while (iter < 20 && !CheckPos(randPos, randomDistance))
            {
                randPos = randomPosition();
                iter++;
            }
            g.transform.position = randPos;
            if (i < numSlots)
            {
                p.type = (PartType)(i + 1);
            }
            else
            {
                p.type = PartType.None;
            }
            p.initPos = g.transform.position;
        }
    }