Пример #1
0
    private void changeEffectsState(Arista a, bool canDeactivate)
    {
        Cable spriteToActive = cableToActive.GetComponent <Cable>();

        if (spriteToActive.arista._1().Equals(a._1()) && spriteToActive.arista._2().Equals(a._2()) && !canDeactivate)
        {
            spriteToActive.changeColliderState(false);
            for (int i = 0; i < spriteToActive.transform.childCount; i++)
            {
                spriteToActive.transform.GetChild(i).gameObject.SetActive(true);
            }
        }
        else
        {
            Debug.Log("Desactivamos los efectos");
            //Desactivamos todos los efectos porque nos hemos equivocado
            Vertex[] vert = FindObjectsOfType <Vertex>();
            for (int i = 0; i < vert.Length; i++)
            {
                vert[i].depush();
            }
            Cable[] allCables = FindObjectsOfType <Cable>();
            for (int i = 0; i < allCables.Length; i++)
            {
                allCables[i].changeColliderState(true);
                for (int j = 0; j < allCables[i].transform.childCount; j++)
                {
                    allCables[i].transform.GetChild(j).gameObject.SetActive(false);
                }
            }
        }
    }
Пример #2
0
    public void tryAristaActivation(Arista a)
    {
        if (nextCorrectArista != null && a._1().Equals(nextCorrectArista._1()) && a._2().Equals(nextCorrectArista._2()) && a._3() == nextCorrectArista._3() && connectedPorts.Contains(a._1()) && connectedPorts.Contains(a._2()))
        {
            Debug.Log("Hemos accedido a la siguiente arista correcta" + a.toString());

            changeEffectsState(a, false);
            visitArista(a);
            //Debug.Log("Visitados: " + visited.ToString());
            //Debug.Log("No Visitados: " + notVisited.ToString());
            aristasActivadas += 1;
            if (checkEnd())
            {
                return;
            }
            calculateNextCorrectArista(a._1());
            calculateNextCorrectArista(a._2());
        }
        else
        {
            Debug.Log("Se reinicia el puzzle");
            visited.Clear();
            notVisited.Clear();
            conjuntoVertices.Clear();
            connectedPorts.Clear();
            initialVertex    = null;
            aristasActivadas = 0;
            changeEffectsState(a, true);
            failed += 1;
            //Se ha equivocado 3 veces, la mandamos a una zona de enemigos.
            if (failed == 3)
            {
                eventManager.transportToEnemyZone();
                failed = 0;
            }
        }
    }
Пример #3
0
    private bool notVisitedContains(Arista a)
    {
        bool contains = false;

        Arista[] varray = notVisited.ToArray();
        int      i      = 0;

        while (!contains && (i < varray.Length))
        {
            if (a._1().Equals(varray[i]._1()) && a._2().Equals(varray[i]._2()) && a._3() == varray[i]._3())
            {
                contains = true;
            }
            i++;
        }
        return(contains);
    }
Пример #4
0
    private bool removeNotVisited(Arista a)
    {
        bool contains = false;

        Arista[] varray   = notVisited.ToArray();
        Arista   toRemove = null;
        int      i        = 0;

        while (!contains && (i < varray.Length))
        {
            if (a._1().Equals(varray[i]._1()) && a._2().Equals(varray[i]._2()) && a._3() == varray[i]._3())
            {
                contains = true;
                toRemove = varray[i];
            }
            i++;
        }
        notVisited.Remove(toRemove);
        return(contains);
    }