/// <summary>
    /// Shows a menu with a given text and lets the user press one of two buttons.
    /// These buttons are assigned to a certain delegated passed as parameter. Finally, this functions on the delegates are called using the aproppiate arguments passed as parameter.
    /// </summary>
    /// <param name="messageQuestion"></param>
    /// Provided text to be shown.
    /// <param name="answer"></param>
    /// delegate containing the function that will be executed once the button is pressed.
    /// <param name="acceptParams"></param>
    /// String array with the accept parameters needed to execute the method in the delegate.
    /// <param name="rejectParams"></param>
    /// String array with the reject parameters needed to execute the method in the delegate.
    public static void ShowMessageWithSelection(string messageQuestion, DelegateSelectionMenu answer, Dictionary <string, string> acceptParams, Dictionary <string, string> rejectParams)
    {
        GameObject messageWithSelection = GameObject.Find("Canvas_Selection_Message");

        if (messageWithSelection == null)
        {
            messageWithSelection      = GameObject.Instantiate(Resources.Load("Canvas_Selection_Message", typeof(GameObject))) as GameObject;
            messageWithSelection.name = "Canvas_Selection_Message";
        }

        messageWithSelection.SetActive(true);
        messageWithSelection.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = messageQuestion;

        messageWithSelection.transform.GetChild(0).GetChild(1).GetComponent <Button>().onClick.AddListener(() => answer.Invoke(acceptParams));
        messageWithSelection.transform.GetChild(0).GetChild(2).GetComponent <Button>().onClick.AddListener(() => answer.Invoke(rejectParams));
    }
Esempio n. 2
0
    /// <summary>
    /// Thread in charge of the whole proccess of training an action, it could end up in an accepted training, a rejected one or a failed one.
    /// </summary>
    /// <param name="detectionType"></param>
    /// <param name="action"></param>
    IEnumerator InitializeTraining(string detectionType, string action)
    {
        if (isTrainingComplete)
        {
            Dictionary <string, string> initialParams = new Dictionary <string, string>();
            initialParams.Add("_auth", _auth);
            initialParams.Add("detection", detectionType);
            initialParams.Add("action", action);
            initialParams.Add("status", "start");
            SendTrainMessage(initialParams);
            isTrainingDone     = false;
            isTrainingComplete = false;
            while (!isTrainingDone)
            {
                yield return(0);
            }
            DelegateSelectionMenu delegateSelection = SendTrainMessage;

            Dictionary <string, string> acceptParams = new Dictionary <string, string>();
            acceptParams.Add("_auth", _auth);
            acceptParams.Add("detection", detectionType);
            acceptParams.Add("action", action);
            acceptParams.Add("status", "accept");

            Dictionary <string, string> rejectParams = new Dictionary <string, string>();
            rejectParams.Add("_auth", _auth);
            rejectParams.Add("detection", detectionType);
            rejectParams.Add("action", action);
            rejectParams.Add("status", "reject");

            MessageQuestionSelection.ShowMessageWithSelection
            (
                "Aceptas el entrenamiento realizado de la accion " + action.ToUpper() + "?",
                delegateSelection,
                acceptParams,
                rejectParams
            );
        }
    }