Exemplo n.º 1
0
    public void ChangeActiveTask(DOW_Tasks_TaskButton b, int index)
    {
        if (index == -1)
        {
            return;
        }

        //if(index >= 0 && index <= highestStepReached)
        if (b.taskCompleted)
        {
            SetActiveTask(index);

            goButton.EnableButton();
            //if (currentIndex != indexBeforeChange)
            //    goButton.EnableButton();
            //else
            //    goButton.DisableButton();
        }
        else
        {
            if (b.GetSequenceIndex() == indexBeforeChange)
            {
                SetActiveTask(indexBeforeChange);
                goButton.DisableButton();
            }
            else if (b.GetSequenceIndex() == highestStepReached)
            {
                SetActiveTask(highestStepReached);
                goButton.EnableButton();
            }
        }
    }
Exemplo n.º 2
0
    public void TaskComplete(int taskIndex)
    {
        DOW_Tasks_TaskButton b = sequenceDictionary[taskIndex];
        int buttonIndex        = b.GetSequenceIndex();

        if (!b.taskCompleted)
        {
            b.taskCompleted = true;

            tasksFinished++;

            //Set the color of the right side thingy
            if (b.GetSequenceIndex() < DOW_Buttons.Count)
            {
                DOW_Buttons[b.GetSequenceIndex()].transform.Find("Image").GetComponent <UnityEngine.UI.Image>().color = new Color(0.2f, 0.44f, 0.717f, 1);
            }
        }

        //Increment the task
        if (taskIndex >= 0)// && buttonIndex < tasksButtons.Count - 1)
        {
            Debug.Log("Incerementing task from: " + buttonIndex + " to: " + (buttonIndex + 1) + "Button Count: " + tasksButtons.Count + " TASk finish count: " + tasksFinished);
            SetActiveTask(buttonIndex + 1);
        }
    }
Exemplo n.º 3
0
    // Start is called before the first frame update
    protected override void Start()
    {
        base.Start();
        sequenceDictionary = new Dictionary <int, DOW_Tasks_TaskButton>();

        if (descriptionPanel)
        {
            titleTextComponent       = descriptionPanel.transform.Find("Title").GetChild(0).GetComponent <TextMeshProUGUI>();
            descriptionTextComponent = descriptionPanel.transform.Find("Description").GetChild(0).GetComponent <TextMeshProUGUI>();
        }
        else
        {
            Debug.Log("Please feed in the description panel");
        }


        int count = 0;

        foreach (DOW_Button button in DOW_Buttons)
        {
            button.ButtonPressEvent += ButtonPressed;

            //Converting to tasks specific button
            DOW_Tasks_TaskButton tb = button as DOW_Tasks_TaskButton;
            tasksButtons.Add(tb);
            tb.SetButtonSequenceIndex(count);

            //if(tb.taskIndex != -1)
            //{
            //}
            sequenceDictionary.Add(tb.taskIndex, tb);

            count++;
        }

        goButton = transform.Find("Go").GetComponent <DOW_Button>();
        goButton.ButtonPressEvent += GoButtonClicked;

        ActivateNextButton();
        ActivatePreviousButton();

        panelActivatedEvent += CheckTasksCompletion;

        //Initially, 0th task is the active task. Get the 0th task button index from the dictionary
        SetActiveTask(sequenceDictionary[0].GetSequenceIndex());


        scrollBar.onValueChanged.AddListener((float f) => { if (f == 0)
                                                            {
                                                                TaskComplete(-1);
                                                            }
                                             });
    }