Exemplo n.º 1
0
    List <string> GetSolutionOrder()
    {
        List <string> solutionOrder = new List <string>(new string[] { "©", "★", "☆", "⊛", "ټ", "Җ", "Ω", "Ѭ", "Ѽ" });
        SerialNumber  sn            = SceneManager.Instance.Bomb.Serial;

        //Serial number starts with number
        if (sn && !char.IsLetter(sn.GetSerialString()[0]))
        {
            return(new List <string>(new string[] { "Җ", "Ѽ", "★", "©", "⊛", "ټ", "Ω", "Ѭ", "☆" }));
        }

        foreach (KeypadButton button in buttons)
        {
            if (button.GetText() == "Ѭ")
            {
                return(new List <string>(new string[] { "Ѭ", "Җ", "©", "Ѽ", "★", "☆", "Ω", "⊛", "ټ" }));
            }
        }

        foreach (KeypadButton button in buttons)
        {
            if (button.GetText() == "Җ")
            {
                return(new List <string>(new string[] { "Ѽ", "★", "Ω", "ټ", "☆", "Ѭ", "Җ", "©", "⊛" }));
            }
        }

        return(solutionOrder);
    }
Exemplo n.º 2
0
    //Based on the state of the bomb, calculate the correct wire index to cut
    protected int GetSolutionIndex()
    {
        int wireCount     = wires.Length;
        int solutionIndex = -1;

        SerialNumber sn = SceneManager.Instance.Bomb.Serial;

        String solution = String.Format("{0} wires, ", wireCount);

        switch (wireCount)
        {
        case 3:
        {
            if (sn != null && !sn.IsLastDigitEven())
            {
                solution     += "serial number is odd, cut 2nd wire. ";
                solutionIndex = 1;
            }
            else if (GetColourCount(WireColour.Yellow) > 0)
            {
                solution     += "at least one yellow wire, cut last yellow wire. ";
                solutionIndex = GetLastIndexOfColour(WireColour.Yellow);
            }
            else
            {
                solution     += "no other rules apply, cut 1st wire. ";
                solutionIndex = 0;
            }
        }
        break;

        case 4:
        case 5:
        {
            if (GetColourCount(WireColour.Black) == 1)
            {
                solution     += "exactly one black wire, cut it. ";
                solutionIndex = GetFirstIndexOfColour(WireColour.Black);
            }
            else if (sn != null && char.IsDigit(sn.GetSerialString()[0]))
            {
                solution     += "serial number starts with a digit, cut 2nd wire. ";
                solutionIndex = 1;
            }
            else if (wires[0].getColour() == WireColour.Yellow ||
                     wires[0].getColour() == WireColour.Blue)
            {
                solution     += "last wire is yellow or blue, cut 3rd wire. ";
                solutionIndex = 2;
            }
            else
            {
                solution     += "no other rules apply, cut 4th wire. ";
                solutionIndex = 3;
            }
        }
        break;

        case 6:
        {
            if (sn != null && !sn.IsLastDigitEven() && GetColourCount(WireColour.Red) > 0)
            {
                solution     += "serial number is odd and there is at least one red wire, cut 1st wire. ";
                solutionIndex = 0;
            }
            else if (GetColourCount(WireColour.Black) > GetColourCount(WireColour.Yellow))
            {
                solution     += "there are more black wires than yellow wires, cut 2nd wire. ";
                solutionIndex = 1;
            }
            else if (GetColourCount(WireColour.Black) == GetColourCount(WireColour.Blue))
            {
                solution     += "there are as many black wires as blue wires, cut 3rd wire. ";
                solutionIndex = 2;
            }
            else
            {
                solution     += "no other rules apply, cut 4th wire. ";
                solutionIndex = 3;
            }
        }
        break;
        }

        solution += "solutionIndex is " + solutionIndex;

        Debug.Log(solution);
        return(solutionIndex);
    }