Search Unity

"Hints" system for puzzle game.

Discussion in 'Scripting' started by mihaicatalind, Aug 18, 2017.

  1. mihaicatalind

    mihaicatalind

    Joined:
    Jan 12, 2015
    Posts:
    10
    Hi everyone!

    I have a BIG problem with my code and app and I don't know how to solve it:

    This is a puzzle game and I have 18 puzzle buttons what corespond to 27 video players(some of them are hint A and hint B) and one "Hint" button.
    I want to make the player to play hints for the player but to verify first if the one from start was completed or not.
    Example:
    I have Puzzle Button 1 and PuzzleButton2 finished. If I press HINT, it has to verify what puzzle are done and give me the correct HINT for Puzzle3.
    The tricky thing is : if I press PuzzleButton1 and PuzzleButton2 and PuzzleButton 6, the HINT Button must give me the HINT for Puzzle3 even if Puzzle6 was completed allready.

    I tried to make it run with int and boolean but no success... I struggle with this for about 3 days from now and no ideea how to solve this...

    Here is the code that I managed to make it work but now If I press puzzle 6, it will get me at HINT number 7 even if Puzzle1,2,3,4,5 are not solved...

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Video;
    5. using UnityEngine.Experimental;
    6. using UnityEngine.UI;
    7.  
    8. public class Indicii : MonoBehaviour {
    9.  
    10.  
    11.     public int laCeIndiciuAmAjus = 0 ;
    12.     public Button Buton0;
    13.     public Button Buton1;
    14.     public Button Buton2;
    15.     public Button Buton3;
    16.     public Button Buton4;
    17.     public Button Buton5;
    18.     public Button Buton6;
    19.     public Button Buton7;
    20.     public Button Buton8;
    21.     public Button Buton9;
    22.     public Button Buton10;
    23.     public Button Buton11;
    24.     public Button Buton12;
    25.     public Button Buton13;
    26.     public Button Buton14;
    27.     public Button Buton15;
    28.     public Button Buton16;
    29.     public Button Buton17;
    30.     public Button Buton18;
    31.     public Button ButonIndicii;
    32.  
    33.  
    34.  
    35.  
    36. //indiciu means HINT
    37.  
    38.     public VideoPlayer indiciu1;
    39.     public VideoPlayer indiciu2;
    40.     public VideoPlayer indiciu3;
    41.     public VideoPlayer indiciu4;
    42.     public VideoPlayer indiciu5;
    43.     public VideoPlayer indiciu6;
    44.     public VideoPlayer indiciu7;
    45.     public VideoPlayer indiciu8;
    46.     public VideoPlayer indiciu9;
    47.     public VideoPlayer indiciu10;
    48.     public VideoPlayer indiciu11;
    49.     public VideoPlayer indiciu12;
    50.     public VideoPlayer indiciu13;
    51.     public VideoPlayer indiciu14;
    52.     public VideoPlayer indiciu15;
    53.     public VideoPlayer indiciu16;
    54.     public VideoPlayer indiciu17;
    55.     public VideoPlayer indiciu18;
    56.     public VideoPlayer indiciu19;
    57.     public VideoPlayer indiciu20;
    58.     public VideoPlayer indiciu21;
    59.     public VideoPlayer indiciu22;
    60.     public VideoPlayer indiciu23;
    61.     public VideoPlayer indiciu24;
    62.     public VideoPlayer indiciu25;
    63.     public VideoPlayer indiciu26;
    64.     public VideoPlayer indiciu27;
    65.  
    66.  
    67.  
    68.  
    69.  
    70.  
    71.     public void marestenumar()
    72.     {
    73.         if (!Buton0.enabled)
    74.             {
    75. //plusunu means Plus One
    76.             plusunu ();
    77.             }
    78.  
    79.     }
    80.  
    81.     public void plusunu()
    82.     {
    83.  
    84.         laCeIndiciuAmAjus - laCeIndiciuAmAjus + 1;
    85.     }
    86.  
    87.         void Start () {
    88.  
    89.         Button btn1 = Buton1.GetComponent<Button> ();
    90.         btn1.onClick.AddListener (marestenumar);// marestenumar is  "increasenumber"
    91.         Button btn2 = Buton2.GetComponent<Button> ();
    92.         btn2.onClick.AddListener (marestenumar);
    93.         Button btn3 = Buton3.GetComponent<Button> ();
    94.         btn3.onClick.AddListener (marestenumar);
    95.         Button btn4 = Buton4.GetComponent<Button> ();
    96.         btn4.onClick.AddListener (marestenumar);
    97.         Button btn5 = Buton5.GetComponent<Button> ();
    98.         btn5.onClick.AddListener (marestenumar);
    99.         Button btn6 = Buton6.GetComponent<Button> ();
    100.         btn6.onClick.AddListener (marestenumar);
    101.         Button btn7 = Buton7.GetComponent<Button> ();
    102.         btn7.onClick.AddListener (marestenumar);
    103.         Button btn8 = Buton8.GetComponent<Button> ();
    104.         btn8.onClick.AddListener (marestenumar);
    105.         Button btn9 = Buton9.GetComponent<Button> ();
    106.         btn9.onClick.AddListener (marestenumar);
    107.         Button btn10 = Buton10.GetComponent<Button> ();
    108.         btn10.onClick.AddListener (marestenumar);
    109.         Button btn11 = Buton11.GetComponent<Button> ();
    110.         btn11.onClick.AddListener (marestenumar);
    111.         Button btn12 = Buton12.GetComponent<Button> ();
    112.         btn12.onClick.AddListener (marestenumar);
    113.         Button btn13 = Buton13.GetComponent<Button> ();
    114.         btn13.onClick.AddListener (marestenumar);
    115.         Button btn14 = Buton14.GetComponent<Button> ();
    116.         btn14.onClick.AddListener (marestenumar);
    117.         Button btn15 = Buton15.GetComponent<Button> ();
    118.         btn15.onClick.AddListener (marestenumar);
    119.         Button btn16 = Buton16.GetComponent<Button> ();
    120.         btn16.onClick.AddListener (marestenumar);
    121.         Button btn17 = Buton17.GetComponent<Button> ();
    122.         btn17.onClick.AddListener (marestenumar);
    123.         Button btn18 = Buton18.GetComponent<Button> ();
    124.         btn18.onClick.AddListener (marestenumar);
    125.  
    126.     }
    127.  
    128.  
    129. //    // Use this for initialization
    130. //
    131. //
    132.     void Start () {
    133.  
    134.         Button btn1 = Buton1.GetComponent<Button> ();
    135.         btn1.onClick.AddListener (DezactivareIndiciu1); //DezactivareIndiciu - Deactivate HINT
    136.         Button btn2 = Buton2.GetComponent<Button> ();
    137.  
    138.         btn2.onClick.AddListener(DezactivareIndiciu2);
    139.         Button btn3 = Buton3.GetComponent<Button> ();
    140.         btn3.onClick.AddListener (DezactivareIndiciu3);
    141.  
    142.         Button btn4 = Buton4.GetComponent<Button> ();
    143.         btn4.onClick.AddListener (DezactivareIndiciu4);
    144.  
    145.  
    146.         Button btn5 = Buton5.GetComponent<Button> ();
    147.         btn5.onClick.AddListener (DezactivareIndiciu5);
    148.  
    149.         Button btn6 = Buton6.GetComponent<Button> ();
    150.         btn6.onClick.AddListener (DezactivareIndiciu6);
    151.  
    152.         Button btn7 = Buton7.GetComponent<Button> ();
    153.         btn7.onClick.AddListener (DezactivareIndiciu7);
    154.  
    155.         Button btn8 = Buton8.GetComponent<Button> ();
    156.         btn8.onClick.AddListener (DezactivareIndiciu8);
    157.  
    158.         Button btn9 = Buton9.GetComponent<Button> ();
    159.         btn9.onClick.AddListener (DezactivareIndiciu9);
    160.  
    161.         Button btn10 = Buton10.GetComponent<Button> ();
    162.         btn10.onClick.AddListener (DezactivareIndiciu10);
    163.  
    164.         Button btn11 = Buton11.GetComponent<Button> ();
    165.         btn11.onClick.AddListener (DezactivareIndiciu11);
    166.  
    167.         Button btn12 = Buton12.GetComponent<Button> ();
    168.         btn12.onClick.AddListener (DezactivareIndiciu12);
    169.  
    170.         Button btn13 = Buton13.GetComponent<Button> ();
    171.         btn13.onClick.AddListener (DezactivareIndiciu13);
    172.  
    173.         Button btn14 = Buton14.GetComponent<Button> ();
    174.         btn14.onClick.AddListener (DezactivareIndiciu14);
    175.  
    176.         Button btn15 = Buton15.GetComponent<Button> ();
    177.         btn15.onClick.AddListener (DezactivareIndiciu15);
    178.  
    179.         Button btn16 = Buton16.GetComponent<Button> ();
    180.         btn16.onClick.AddListener (DezactivareIndiciu16);
    181.  
    182.         Button btn17 = Buton17.GetComponent<Button> ();
    183.         btn17.onClick.AddListener (DezactivareIndiciu17);
    184.  
    185.         Button btn18 = Buton18.GetComponent<Button> ();
    186.         btn18.onClick.AddListener (DezactivareIndiciu18);
    187.  
    188.  
    189.          
    190.  
    191.     }
    192.  
    193.     public void maresteindiciu()
    194.     {
    195.         ++laCeIndiciuAmAjus;
    196.     }
    197.  
    198.  
    199.  
    200.  
    201. //    // Update is called once per frame
    202. //
    203.     void DezactivareIndiciu1()
    204.     {
    205.         laCeIndiciuAmAjus = 3;//  laceindiciuamajuns means What is the current HINT
    206.         Debug.Log("am activat indiciu 1");
    207.  
    208.  
    209.     }
    210.     void DezactivareIndiciu2()
    211.  
    212.  
    213.     {
    214.         laCeIndiciuAmAjus = 4;
    215.  
    216.  
    217.     }
    218.     void DezactivareIndiciu3()
    219.  
    220.  
    221.     {
    222.         laCeIndiciuAmAjus = 5;
    223.  
    224.  
    225.     }
    226.     void DezactivareIndiciu4()
    227.  
    228.  
    229.     {
    230.     laCeIndiciuAmAjus = 6;
    231.  
    232.  
    233.     }
    234.     void DezactivareIndiciu5()
    235.  
    236.  
    237.     {
    238.         laCeIndiciuAmAjus = 8;
    239.  
    240.     }
    241.     void DezactivareIndiciu6()
    242.  
    243.  
    244.     {
    245.         laCeIndiciuAmAjus = 9;
    246.  
    247.     }
    248.     void DezactivareIndiciu7()
    249.  
    250.  
    251.     {
    252.         laCeIndiciuAmAjus = 11;
    253.  
    254.     }
    255.     void DezactivareIndiciu8()
    256.  
    257.  
    258.     {
    259.         laCeIndiciuAmAjus = 12;
    260.  
    261.     }
    262.     void DezactivareIndiciu9()
    263.  
    264.  
    265.     {
    266.         laCeIndiciuAmAjus = 13;
    267.  
    268.     }
    269.     void DezactivareIndiciu10()
    270.  
    271.  
    272.     {
    273.         laCeIndiciuAmAjus = 14;
    274.  
    275.     }
    276.     void DezactivareIndiciu11()
    277.  
    278.  
    279.     {
    280.         laCeIndiciuAmAjus = 16;
    281.  
    282.     }
    283.     void DezactivareIndiciu12()
    284.  
    285.  
    286.     {
    287.         laCeIndiciuAmAjus = 18;
    288.  
    289.     }
    290.     void DezactivareIndiciu13()
    291.  
    292.  
    293.     {
    294.         laCeIndiciuAmAjus = 20;
    295.  
    296.     }
    297.     void DezactivareIndiciu14()
    298.  
    299.  
    300.     {
    301.         laCeIndiciuAmAjus = 21;
    302.  
    303.     }
    304.     void DezactivareIndiciu15()
    305.  
    306.  
    307.     {
    308.         laCeIndiciuAmAjus = 22;
    309.  
    310.     }
    311.     void DezactivareIndiciu16()
    312.  
    313.  
    314.     {
    315.         laCeIndiciuAmAjus = 24;
    316.  
    317.     }
    318.     void DezactivareIndiciu17()
    319.  
    320.  
    321.     {
    322.         laCeIndiciuAmAjus = 25;
    323.  
    324.     }
    325.     void DezactivareIndiciu18()
    326.  
    327.  
    328.     {
    329.         laCeIndiciuAmAjus = 27;
    330.  
    331.     }
    332.  
    333.  
    334.  
    335.  
    336.  
    337.     void Update ()
    338.     {
    339.         if (Buton0.enabled == false)
    340.         {
    341.             laCeIndiciuAmAjus = 1;
    342.  
    343.         }
    344.         if (Buton1.enabled == false)
    345.         {
    346.             DezactivareIndiciu1 ();
    347.  
    348.         }
    349.         if (Buton2.enabled == false)
    350.         {
    351.             DezactivareIndiciu2 ();
    352.  
    353.         }
    354.         if (Buton3.enabled == false)
    355.         {
    356.             DezactivareIndiciu3 ();
    357.         }
    358.         if (Buton4.enabled == false)
    359.         {
    360.             DezactivareIndiciu4 ();
    361.         }
    362.         if (Buton5.enabled == false)
    363.         {
    364.             DezactivareIndiciu5 ();
    365.         }
    366.         if (Buton6.enabled == false)
    367.         {
    368.             DezactivareIndiciu6 ();
    369.         }
    370.         if (Buton7.enabled == false)
    371.         {
    372.             DezactivareIndiciu7 ();
    373.         }
    374.         if (Buton8.enabled == false)
    375.         {
    376.             DezactivareIndiciu8 ();
    377.         }
    378.         if (Buton9.enabled == false)
    379.         {
    380.             DezactivareIndiciu9 ();
    381.         }
    382.         if (Buton10.enabled == false)
    383.         {
    384.             DezactivareIndiciu10 ();
    385.         }
    386.         if (Buton11.enabled == false)
    387.         {
    388.             DezactivareIndiciu11 ();
    389.         }
    390.         if (Buton12.enabled == false)
    391.         {
    392.             DezactivareIndiciu12 ();
    393.         }
    394.         if (Buton13.enabled == false)
    395.         {
    396.             DezactivareIndiciu13 ();
    397.         }
    398.         if (Buton14.enabled == false)
    399.         {
    400.             DezactivareIndiciu14 ();
    401.         }
    402.         if (Buton15.enabled == false)
    403.         {
    404.             DezactivareIndiciu15 ();
    405.         }
    406.         if (Buton16.enabled == false)
    407.         {
    408.             DezactivareIndiciu16 ();
    409.         }
    410.         if (Buton17.enabled == false)
    411.         {
    412.             DezactivareIndiciu17 ();
    413.         }
    414.         if (Buton18.enabled == false)
    415.         {
    416.             DezactivareIndiciu18 ();
    417.         }
    418.     }
    419.  
    420.  
    421.  
    422.     public void Play_Indicii()
    423.     {
    424.      
    425.  
    426.         switch (laCeIndiciuAmAjus)
    427.         {
    428.         case 1:
    429.             indiciu1.Play ();
    430.             laCeIndiciuAmAjus = 2;
    431.             break;
    432.         case 2:
    433.             indiciu2.Play();
    434.             break;
    435.         case 3:
    436.             indiciu3.Play();
    437.             break;
    438.         case 4:
    439.             indiciu4.Play();
    440.             break;
    441.         case 5:
    442.             indiciu5.Play();
    443.             break;
    444.         case 6:
    445.             indiciu6.Play ();
    446.             laCeIndiciuAmAjus = 7;
    447.             break;
    448.         case 7:
    449.             indiciu7.Play();
    450.             break;
    451.         case 8:
    452.             indiciu8.Play();
    453.             break;
    454.         case 9:
    455.             indiciu9.Play ();
    456.             laCeIndiciuAmAjus = 10;
    457.             break;
    458.         case 10:
    459.             indiciu10.Play();
    460.             break;
    461.         case 11:
    462.             indiciu11.Play();
    463.             break;
    464.         case 12:
    465.             indiciu12.Play();
    466.             break;
    467.         case 13:
    468.             indiciu13.Play();
    469.             break;
    470.         case 14:
    471.             indiciu14.Play ();
    472.             laCeIndiciuAmAjus = 15;
    473.             break;
    474.         case 15:
    475.             indiciu15.Play();
    476.             break;
    477.         case 16:
    478.             indiciu16.Play ();
    479.             laCeIndiciuAmAjus = 17;
    480.             break;
    481.         case 17:
    482.             indiciu17.Play();
    483.             break;
    484.         case 18:
    485.             indiciu18.Play ();
    486.             laCeIndiciuAmAjus = 19;
    487.             break;
    488.         case 19:
    489.             indiciu19.Play();
    490.             break;
    491.         case 20:
    492.             indiciu20.Play();
    493.             break;
    494.         case 21:
    495.             indiciu21.Play();
    496.             break;
    497.         case 22:
    498.             indiciu22.Play ();
    499.             laCeIndiciuAmAjus = 23;
    500.             break;
    501.         case 23:
    502.             indiciu23.Play();
    503.             break;
    504.         case 24:
    505.             indiciu24.Play();
    506.             break;
    507.         case 25:
    508.             indiciu25.Play ();
    509.             laCeIndiciuAmAjus = 26;
    510.             break;
    511.         case 26:
    512.             indiciu26.Play();
    513.             break;
    514.         case 27:
    515.             indiciu27.Play();
    516.             break;
    517.         default:
    518.             Debug.Log ("IndiciuIncorect");
    519.             break;
    520.         }
    521.     }
    522. }
    523.  
     
    Last edited: Aug 19, 2017
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    First, create either arrays or list for your buttons and VideoPlayer

    Code (CSharp):
    1. public List<Button> hintButtons = new List<Button>();
    2.  
    3. public List<VideoPlayer> indiciu = new List<VideoPlayer>();
    Then, if you want to add the listeners in code instead of the inspector

    Code (CSharp):
    1. foreach(Button btn in hintButtons)
    2. {
    3.    btn.onClick.AddListener(marestenumar); //No need to get the component...you already have it.
    4. }
    Add an int to the top to determine what index you are at.

    Code (CSharp):
    1. private int hintIndex = 0;
    Note you have two start methods? Not sure what you are doing there...but your deactivates should take an index, a gameobject, something else.

    When you want to deactivate a button, just have a single method that takes a gameobject or the button and turn off it's gameobject. No need to have DezactivareIndiciu3 and 4 and 5...

    When you go to play a video, no matter what button I click on..This will play the next video in the array and then increment the index by 1, so the next video in the list will play. Which I think is what you wanted...

    Code (CSharp):
    1. public void Play_Indicii()
    2. {
    3.    indiciu[hintIndex].Play();
    4.    hintIndex++;
    5. }
    Just a quick type up. I didn't check for typos or such, but you can improve this code so much.

    This might not be exactly what you want. Since I'm not sure if I understand exactly. If you hit puzzlebtn6, does puzzlebtn6 turn off? Does it play puzzle6 video or puzzle3 video if puzzle1 and 2 are done?
     
    mihaicatalind likes this.
  3. mihaicatalind

    mihaicatalind

    Joined:
    Jan 12, 2015
    Posts:
    10
    Thank you very much Brathnann! This helped me to simplify the code but still can't get what I want... Maybe it was hard to explain what I want do to so I did an image to be more accurate and to understand the system.
    Here is the picture:


    Thank you for your help!!
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    Ok, I think I'm understanding a bit better.

    So you have puzzles and a hint button. The hint button always displays the first puzzle not played, however, you can play the puzzles in any order. Just when you hit the hint button, it should be the earliest level not played yet.

    Ok, there are a few ways to do this. While I would say you should have a class that maybe has a button, a video, and a bool or something, you can consider those options.

    So, instead of adding to the hintIndex each time, we'll loop through our buttons. So when a puzzle is played, you'll be able to find the first one free. You need some way to track what has been done. If you are able to replay puzzles, then this method doesn't work as well, but you could add the index to a list, keep track of the buttons on a variable, but the basic idea is you finish a level...

    Code (CSharp):
    1. for(int x = 0; x < hintButtons.Count;x++)
    2. {
    3.    if(hintButtons[x].interactable)
    4.    {
    5.        hintIndex = x;
    6.        break;
    7.    }
    8. }
    Ok, so this is just to give you an idea. You need to figure out a solution of how you're going to track what has been done. Even if it's just checking the color of the sprite or something along those lines.

    So, when you complete a level, you'll call this which will loop through your buttons. Your buttons should be in your list in order so that index 0 is level 1, etc. So as it moves through the list, it will find the first button that is still interactable. (in this example, I would make the buttons non-interactable as the player finishes a level).

    So if I finish puzzle 1 and then puzzle 3, the index would stop at 1 (puzzle 2) so when I call the hint, it displays the correct one. Then if I complete puzzle 2 it loops through and would stop at index 3 (since puzzle 1,2, and 3 are done).

    You could also check other things. Maybe you're turning off the videoplayer objects if the level is complete, then you can just loop through them instead. Maybe you are doing something else. But this is the basic concept. You just want to find the first free one and then break out of your loop.
     
    mihaicatalind likes this.
  5. mihaicatalind

    mihaicatalind

    Joined:
    Jan 12, 2015
    Posts:
    10
    Thank you @Brathnann for your help!
    I managed to do it with a rudimentary system of "if"'s :p
    I will try to improve the code on the next stage but your advice was very useful to me and made me to think about
    checking the buttons every time I push the Hint button.

    I also deleted the code that I don't really need it :)

    Here is the code as I managed to work with:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Video;
    5. using UnityEngine.Experimental;
    6. using UnityEngine.UI;
    7.  
    8. public class Indicii : MonoBehaviour {
    9.  
    10.  
    11.     public int laCeIndiciuAmAjus = 0 ;
    12.     public Button Buton0;
    13.     public Button Buton1;
    14.     public Button Buton2;
    15.     public Button Buton3;
    16.     public Button Buton4;
    17.     public Button Buton5;
    18.     public Button Buton6;
    19.     public Button Buton7;
    20.     public Button Buton8;
    21.     public Button Buton9;
    22.     public Button Buton10;
    23.     public Button Buton11;
    24.     public Button Buton12;
    25.     public Button Buton13;
    26.     public Button Buton14;
    27.     public Button Buton15;
    28.     public Button Buton16;
    29.     public Button Buton17;
    30.     public Button Buton18;
    31.  
    32.  
    33.  
    34.  
    35.  
    36.     public VideoPlayer indiciu1;
    37.     public bool trecLaIndiciul_1B;
    38.     public VideoPlayer indiciu2;
    39.     public VideoPlayer indiciu3;
    40.     public VideoPlayer indiciu4;
    41.     public VideoPlayer indiciu5;
    42.     public VideoPlayer indiciu6;
    43.     public bool trecLaIndiciul_6B;
    44.     public VideoPlayer indiciu7;
    45.     public VideoPlayer indiciu8;
    46.     public VideoPlayer indiciu9;
    47.     public bool trecLaIndiciul_9B;
    48.     public VideoPlayer indiciu10;
    49.     public VideoPlayer indiciu11;
    50.     public VideoPlayer indiciu12;
    51.     public VideoPlayer indiciu13;
    52.     public VideoPlayer indiciu14;
    53.     public bool trecLaIndiciul_14B;
    54.     public VideoPlayer indiciu15;
    55.     public VideoPlayer indiciu16;
    56.     public bool trecLaIndiciul_16B;
    57.     public VideoPlayer indiciu17;
    58.     public VideoPlayer indiciu18;
    59.     public bool trecLaIndiciul_18B;
    60.     public VideoPlayer indiciu19;
    61.     public VideoPlayer indiciu20;
    62.     public VideoPlayer indiciu21;
    63.     public VideoPlayer indiciu22;
    64.     public bool trecLaIndiciul_22B;
    65.     public VideoPlayer indiciu23;
    66.     public VideoPlayer indiciu24;
    67.     public VideoPlayer indiciu25;
    68.     public bool trecLaIndiciul_25B;
    69.     public VideoPlayer indiciu26;
    70.     public VideoPlayer indiciu27;
    71.  
    72.  
    73.  
    74.  
    75.  
    76.  
    77.  
    78.  
    79.  
    80.     public void Play_Indicii()
    81.     {
    82. ///Checking if any video is playing
    83.         if (!indiciu1.isPlaying && !indiciu2.isPlaying && !indiciu3.isPlaying && !indiciu4.isPlaying && !indiciu5.isPlaying && !indiciu6.isPlaying && !indiciu7.isPlaying && !indiciu8.isPlaying && !indiciu9.isPlaying && !indiciu10.isPlaying && !indiciu11.isPlaying && !indiciu12.isPlaying && !indiciu13.isPlaying && !indiciu14.isPlaying && !indiciu15.isPlaying && !indiciu16.isPlaying && !indiciu17.isPlaying && !indiciu18.isPlaying && !indiciu19.isPlaying && !indiciu21.isPlaying && !indiciu22.isPlaying && !indiciu23.isPlaying && !indiciu24.isPlaying && !indiciu25.isPlaying && !indiciu26.isPlaying && !indiciu27.isPlaying) {
    84.  
    85.  
    86. //Checking if the condition for the last puzzle is applicable - And make this check every time I push the button "Hint"
    87.         if (!Buton0.enabled  && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled && !Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled &&  !Buton11.enabled && !Buton12.enabled &&  !Buton13.enabled && !Buton14.enabled && !Buton15.enabled  && !Buton16.enabled && !Buton17.enabled &&  !Buton18.enabled) {
    88.                 indiciu27.Play ();
    89.                 Debug.Log ("Activez indiciu 27");
    90.                 return;
    91.             }
    92.  
    93.         else if (!Buton0.enabled && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled &&  !Buton11.enabled &&  !Buton12.enabled && !Buton13.enabled && !Buton14.enabled && !Buton15.enabled &&  !Buton16.enabled && !Buton17.enabled && trecLaIndiciul_25B == true) {
    94.             indiciu26.Play ();
    95.             Debug.Log ("Activez indiciu 25");
    96.             return;
    97.         }
    98.         else if (!Buton0.enabled && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled &&  !Buton11.enabled &&  !Buton12.enabled && !Buton13.enabled && !Buton14.enabled && !Buton15.enabled &&  !Buton16.enabled && !Buton17.enabled && trecLaIndiciul_25B == false) {
    99.             indiciu25.Play ();
    100.             Debug.Log ("Activez indiciu 25");
    101.             trecLaIndiciul_25B = true;
    102.             return;
    103.         }
    104.  
    105.         else if (!Buton0.enabled &&  !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled && !Buton6.enabled  && !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled &&  !Buton11.enabled &&  !Buton12.enabled &&  !Buton13.enabled && !Buton14.enabled && !Buton15.enabled && !Buton16.enabled) {
    106.             indiciu24.Play ();
    107.             Debug.Log ("Activez indiciu 24");
    108.             return;
    109.         }
    110.  
    111.         else if (!Buton0.enabled  && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&!Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled &&  !Buton11.enabled && !Buton12.enabled &&  !Buton13.enabled && !Buton14.enabled && !Buton15.enabled && trecLaIndiciul_22B == true) {
    112.             indiciu23.Play ();
    113.             Debug.Log ("Activez indiciu 22.b");
    114.             return;
    115.         }
    116.  
    117.         else if (!Buton0.enabled  && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&!Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled &&  !Buton11.enabled && !Buton12.enabled &&  !Buton13.enabled && !Buton14.enabled && !Buton15.enabled && trecLaIndiciul_22B == false) {
    118.             indiciu22.Play ();
    119.             Debug.Log ("Activez indiciu 22");
    120.             trecLaIndiciul_22B = true;
    121.             return;
    122.         }
    123.  
    124.         else if (!Buton0.enabled &&  !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled && !Buton6.enabled && !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled && !Buton11.enabled && !Buton12.enabled && !Buton13.enabled && !Buton14.enabled) {
    125.             indiciu21.Play ();
    126.             Debug.Log ("Activez indiciu 21");
    127.             return;
    128.         }
    129.  
    130.         else if (!Buton0.enabled &&  !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled && !Buton6.enabled && !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled && !Buton11.enabled && !Buton12.enabled && !Buton13.enabled) {
    131.             indiciu20.Play ();
    132.             Debug.Log ("Activez indiciu 20");
    133.             return;
    134.         }
    135.  
    136.         else if (!Buton0.enabled &&  !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled  && !Buton11.enabled && !Buton12.enabled && trecLaIndiciul_18B == true) {
    137.             indiciu19.Play ();
    138.             Debug.Log ("Activez indiciu 19");
    139.             return;
    140.         }
    141.  
    142.         else if (!Buton0.enabled &&  !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled && !Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled &&  !Buton11.enabled && !Buton12.enabled && trecLaIndiciul_18B == false) {
    143.             indiciu18.Play ();
    144.             Debug.Log ("Activez indiciu 18");
    145.             trecLaIndiciul_18B = true;
    146.             return;
    147.         }
    148.  
    149.         else if (!Buton0.enabled && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled && !Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled && !Buton11.enabled && trecLaIndiciul_16B == true) {
    150.             indiciu17.Play ();
    151.             Debug.Log ("Activez indiciu 17");
    152.  
    153.             return;
    154.         }
    155.  
    156.         else if (!Buton0.enabled &&  !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled && !Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled &&  !Buton11.enabled && trecLaIndiciul_16B == false) {
    157.             indiciu16.Play ();
    158.             Debug.Log ("Activez indiciu 16");
    159.             trecLaIndiciul_16B = true;
    160.             return;
    161.         }
    162.  
    163.         else if (!Buton0.enabled &&  !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled && trecLaIndiciul_14B == true) {
    164.             indiciu15.Play ();
    165.             Debug.Log ("Activez indiciu 15");
    166.             return;
    167.         }
    168.  
    169.         else if (!Buton0.enabled &&  !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled && !Buton10.enabled && trecLaIndiciul_14B == false) {
    170.             indiciu14.Play ();
    171.             Debug.Log ("Activez indiciu 14");
    172.             trecLaIndiciul_14B = true;
    173.             return;
    174.         }
    175.  
    176.         else if (!Buton0.enabled && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled && !Buton8.enabled && !Buton9.enabled) {
    177.             indiciu13.Play ();
    178.             Debug.Log ("Activez indiciu 13");
    179.             return;
    180.         }
    181.  
    182.         else if (!Buton0.enabled &&  !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled && !Buton6.enabled && !Buton7.enabled && !Buton8.enabled) {
    183.             indiciu12.Play ();
    184.             Debug.Log ("Activez indiciu 12");
    185.             return;
    186.         }
    187.  
    188.         else if (!Buton0.enabled  && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled && !Buton6.enabled &&  !Buton7.enabled) {
    189.             indiciu11.Play ();
    190.             Debug.Log ("Activez indiciu 11");
    191.             return;
    192.         }
    193.  
    194.         else if (!Buton0.enabled &&  !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled  && !Buton5.enabled && !Buton6.enabled && trecLaIndiciul_9B == true) {
    195.             indiciu10.Play ();
    196.             Debug.Log ("Activez indiciu 9.b");
    197.             return;
    198.         }
    199.         else if (!Buton0.enabled && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled  && !Buton5.enabled && !Buton6.enabled && trecLaIndiciul_9B == false) {
    200.             indiciu9.Play ();
    201.             Debug.Log ("Activez indiciu 9");
    202.             trecLaIndiciul_9B = true;
    203.             return;
    204.         }
    205.  
    206.         else if (!Buton0.enabled  && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled &&  !Buton5.enabled) {
    207.             indiciu8.Play ();
    208.             Debug.Log ("Activez indiciu 8");
    209.             return;
    210.         }
    211.         else if (!Buton0.enabled &&  !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled && trecLaIndiciul_6B == true) {
    212.             indiciu7.Play ();
    213.             Debug.Log ("Activez indiciu 7");
    214.             return;
    215.         }
    216.         else if (!Buton0.enabled  && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled && !Buton4.enabled && trecLaIndiciul_6B == false) {
    217.             indiciu6.Play ();
    218.             Debug.Log ("Activez indiciu 6");
    219.             trecLaIndiciul_6B = true;
    220.             return;
    221.         }
    222.         else if (!Buton0.enabled  && !Buton1.enabled && !Buton2.enabled && !Buton3.enabled) {
    223.             indiciu5.Play ();
    224.             Debug.Log ("Activez indiciu 5");
    225.             return;
    226.         }
    227.         else if (!Buton0.enabled  && !Buton1.enabled && !Buton2.enabled) {
    228.             indiciu4.Play ();
    229.             Debug.Log ("Activez indiciu 4");
    230.             return;
    231.         }
    232.  
    233.         else if (!Buton0.enabled  && !Buton1.enabled) {
    234.             indiciu3.Play ();
    235.             Debug.Log ("Activez indiciu 3");
    236.             return;
    237.         }
    238.  
    239.         else if (!Buton0.enabled && trecLaIndiciul_1B == true) {
    240.             indiciu2.Play ();
    241.             Debug.Log ("Activez indiciu 1B");
    242.             return;
    243.         }
    244.  
    245.         else if (!Buton0.enabled && trecLaIndiciul_1B == false) {
    246.             indiciu1.Play ();
    247.             Debug.Log ("Activez indiciu 1A");
    248.             trecLaIndiciul_1B = true;
    249.             return;
    250.         }
    251.  
    252.         }
    253.  
    254.     }
    255. }
    256.  
     
  6. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    I'm glad you figured out something, but take the time to fix that code up. It's not a good habit to get into to not learn how to use collections, loops, etc in code. It will make your life so much easier!