Beispiel #1
0
 // Use this for initialization
 void Start()
 {
     cr     = GetComponent <CanvasRenderer> ();
     cc     = (ChoiceController)FindObjectOfType(typeof(ChoiceController));
     t      = GetComponent <Text> ();
     t.text = "Age: " + cc.age;
 }
Beispiel #2
0
 // Start is called before the first frame update
 void Start()
 {
     model = FindObjectOfType <ChoiceController>();
     if (model != null)
     {
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        model = FindObjectOfType <ChoiceController>();
        //Debug.Log("model : " + model);
        if (model != null)
        {
            Debug.Log("number of element in objets : " + model.Objets.Count);
            foreach (Objets element in model.Objets)
            {
                GameObject objet = new GameObject();
                objet      = (GameObject)Instantiate(prefab_object, this.transform);
                objet.name = element.Nom;

                Toggle temp_toggle = objet.GetComponentInChildren <Toggle>();
                temp_toggle.name  = element.Nom;
                temp_toggle.group = this.GetComponent <ToggleGroup>();
                temp_toggle.isOn  = element.Modification;
                Image temp_background = (Image)temp_toggle.GetComponentInChildren <Image>();
                Image temp_selected   = (Image)temp_toggle.graphic;

                Debug.Log("image path : " + element.Image + "_unselected");
                Sprite temp_sprite = Resources.Load <Sprite>(element.Image + "_unselected");
                Debug.Log("image is null ? : " + temp_sprite == null);
                Debug.Log("image background is null ? : " + temp_background.sprite == null);
                Debug.Log(element.Image + "_unselected");
                temp_background.sprite = temp_sprite;
                //Resources.Load<Sprite>(element.Image + "_unselected");
                temp_selected.sprite = Resources.Load <Sprite>(element.Image + "_selected");
                temp_toggle.onValueChanged.AddListener(delegate {
                    ToggleValueChanged(temp_toggle);
                });
            }
        }
    }
    //Add a button to the list of buttons in the question
    //@param choiceButtonTemplate template of the button to implement, the other buttons will be like this template
    //@param choice this object contains the choice information
    //@param index numer of choice in the list
    public static ChoiceController AddChoiceButton(GameObject panel, Choice choice, int index, int panelMode)
    {
        Button button = null;

        if (panelMode == 1)
        {
            Button choiceButtonTemplate = panel.transform.Find("Choice Buttons/Choice Button").GetComponent <Button>();
            int    buttonSpacing        = -44;
            button = Instantiate(choiceButtonTemplate);

            //Button settings
            button.transform.SetParent(choiceButtonTemplate.transform.parent);
            button.transform.localScale    = Vector3.one;
            button.transform.localPosition = new Vector3(0, index * buttonSpacing, 0);
            button.name = "Choice " + (index + 1);
            button.gameObject.SetActive(true);
        }
        else if (panelMode == 2 || panelMode == 3)
        {
            button = panel.transform.Find("Choice Buttons/Choice " + (index + 1)).GetComponent <Button>();
            button.gameObject.SetActive(true);
        }

        //Get ChoiceController
        ChoiceController choiceController = button.GetComponent <ChoiceController>();

        choiceController.choice = choice;
        button.GetComponentInChildren <TextMeshProUGUI>().text = choice.text;
        return(choiceController);
    }
Beispiel #5
0
    // Start is called before the first frame update
    void Start()
    {
        model = FindObjectOfType <ChoiceController>();
        //Debug.Log("model : " + model);
        if (model != null)
        {
            foreach (Objets obj in model.Objets)
            {
                if (obj.Modification == true)
                {
                    //Debug.Log("model forme : " + model.Forme);
                    foreach (Item element in model.Forme)
                    {
                        GameObject objet = (GameObject)Instantiate(prefab_object, this.transform);
                        objet.name = element.Nom;
                        //Debug.Log("element name : " + element.Nom);
                        Toggle temp_toggle = objet.GetComponentInChildren <Toggle>();
                        temp_toggle.name = element.Nom;
                        if (obj.FormeActive.Contains(element.ID))
                        {
                            //Debug.Log("toggle is on");
                            temp_toggle.isOn = true;
                        }
                        else if (obj.FormeInactive.Contains(element.ID))
                        {
                            //Debug.Log("toggle is off");
                            temp_toggle.isOn = false;
                        }
                        Text temp_texte = temp_toggle.GetComponentInChildren <Text>();
                        temp_texte.text = element.Nom;

                        foreach (int temp_formeActive in obj.FormeActive)
                        {
                            //Debug.Log("forme active : " + temp_formeActive + " ; element ID : " + element.ID);
                            if (temp_formeActive == element.ID)
                            {
                                //Debug.Log("toggle is on");
                                temp_toggle.isOn = true;
                                break;
                            }
                            else
                            {
                                //Debug.Log("toggle is off");
                                temp_toggle.isOn = false;
                            }
                        }
                        Image temp_background = (Image)temp_toggle.GetComponentInChildren <Image>();
                        Image temp_selected   = (Image)temp_toggle.graphic;

                        temp_background.sprite = Resources.Load <Sprite>(element.Image + "");
                        temp_selected.sprite   = Resources.Load <Sprite>(element.Image + "");
                        temp_selected.color    = Color.grey;
                        temp_toggle.onValueChanged.AddListener(delegate {
                            ToggleValueChanged(temp_toggle);
                        });
                    }
                }
            }
        }
    }
 public void CloseChoiceIfExists()
 {
     if (ChoiceController != null)
     {
         ChoiceController.Destroy();
         ChoiceController = null;
     }
 }
Beispiel #7
0
 private void Initialize()
 {
     questionText.text = question.text;
     for (int jndex = 0; jndex < question.choices.Length; jndex++)
     {
         ChoiceController c = ChoiceController.AddChoicebutton(choiceButton, question.choices[jndex], jndex);
         choiceControllers.Add(c);
     }
     choiceButton.gameObject.SetActive(false);
 }
 public void LeaveChoices()
 {
     PopStateStack();
     AddWait(new Wait(0.5f, WaitTypes.WaitForTime, delegate
     {
         ChoiceController.Destroy();
         ChoiceController = null;
     }));
     ExecuteActions();
 }
Beispiel #9
0
    private void Initialize()
    {
        questionText.text = question.questionText;
        for (int index = 0; index < question.choices.Count; index++)
        {
            ChoiceController c = ChoiceController.AddChoiceButton(choiceButton, question.choices[index], index);
            choiceControllers.Add(c);
        }

        choiceButton.gameObject.SetActive(false);
    }
 public void DisplayChoices(List <string> options, int count)
 {
     if (ChoiceController != null)
     {
         ChoiceController.Destroy();
         ChoiceController = null;
     }
     PushStateStack(ChoiceHandleInput, GameState.ChoiceScreen);
     ChoiceController = new ChoiceController();
     ChoiceController.Create(options, count);
 }
Beispiel #11
0
    // Use this for initialization
    void Start()
    {
        ChoiceController cc = (ChoiceController)FindObjectOfType(typeof(ChoiceController));

        bool isRich = cc.choseCivic;

        string    startPosName = isRich ? "StartingPositionRich" : "StartingPositionPoor";
        Transform startPos     = GameObject.FindGameObjectsWithTag(startPosName)[0].transform;

        transform.position = startPos.position;
    }
 // Start is called before the first frame update
 void Start()
 {
     model = FindObjectOfType <ChoiceController>();
     //Debug.Log("model : " + model);
     if (model != null)
     {
         Question temp_question = model.Questions.Find(r => r.Modification == true);
         Text     temp_text     = this.GetComponent <Text>();
         temp_text.text = temp_question.Description;
     }
 }
    private void Initialize()
    {
        questionText.SetText(question.GetText());

        for (int index = 0; index < question.GetChoiceLength(); index++)
        {
            ChoiceController c = ChoiceController.AddChoiceButton(choiceButton, question.GetChoice(index), index);
            choiceControllers.Add(c);
        }

        choiceButton.gameObject.SetActive(false);
    }
    private void Intialize()
    {
        choiceText.text = choices.text;

        for (int index = 0; index < choices.choicetext.Length; index++)
        {
            ChoiceController c = ChoiceController.AddChoiceButton(choiceButton, choices.choicetext[index], index);
            choiceControllers.Add(c);
        }

        choiceButton.gameObject.SetActive(true);
    }
    public static ChoiceController AddChoiceButton(Button choiceButtonPrefab, Choices choice, int index)
    {
        Button button = Instantiate(choiceButtonPrefab);

        button.transform.SetParent(choiceButtonPrefab.transform.parent);
        button.name = choice.choiceText;
        button.gameObject.SetActive(true);

        ChoiceController choiceController = button.GetComponent <ChoiceController>();

        choiceController.choice = choice;
        return(choiceController);
    }
Beispiel #16
0
 private void Initialize()
 {
     //текст из скриптаблОбжект Question передается в окно UI текст
     questionText.text = question.text;
     //пробегаемся по всем choices из скриптаблОбжект Question
     for (int index = 0; index < question.choices.Length; index++)
     {
         //добавляем кнопки в соответствии с индексом choice из скриптаблОбжект Question в список
         ChoiceController c = ChoiceController.AddChoiceButton(choiceButton, question.choices[index], index);
         choiceControllers.Add(c);
     }
     //образец кнопки(префаб) диактивируем
     choiceButton.gameObject.SetActive(false);
 }
Beispiel #17
0
    // Start is called before the first frame update
    void Start()
    {
        model = FindObjectOfType <ChoiceController>();

        Text temp = this.GetComponent <Text>();

        foreach (Objets element in model.Objets)
        {
            if (element.Modification)
            {
                temp.text = element.Nom;
            }
        }
    }
Beispiel #18
0
    // Start is called before the first frame update
    void Start()
    {
        model = FindObjectOfType <ChoiceController>();

        if (model != null)
        {
            temp_question = model.Questions.Find(r => r.Modification == true);
            Text temp_text = this.GetComponentInChildren <Text>();
            if (temp_question.Reponse != null && temp_question.Reponse != "")
            {
                temp_text.text = temp_question.Reponse;
            }
        }
    }
Beispiel #19
0
    private void Start()
    {
        model = FindObjectOfType <ChoiceController>();
        Button button = this.GetComponent <Button>();

        button.interactable = false;
        foreach (Objets element in model.Objets)
        {
            //Debug.Log("element modification : " + element.Modification + " ; name  : " + element.Nom);
            if (element.Modification)
            {
                button.interactable = true;
            }
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        model = FindObjectOfType <ChoiceController>();

        Image temp = this.GetComponent <Image>();

        foreach (Objets element in model.Objets)
        {
            //Debug.Log("element modification : " + element.Modification + " ; name  : " + element.Nom);
            if (element.Modification)
            {
                temp.sprite = Resources.Load <Sprite>(element.Image + "_unselected");
            }
        }
    }
Beispiel #21
0
    public static ChoiceController AddChoicebutton(Button choiceButtonTemplate, Choice choice, int index)
    {
        int    buttonSpacing = -44;
        Button button        = Instantiate(choiceButtonTemplate);

        button.transform.localScale    = Vector3.one;
        button.transform.localPosition = new Vector3(0, index * buttonSpacing, 0);
        button.name = "Choice " + (index + 1);
        button.gameObject.SetActive(true);

        ChoiceController choiceController = button.GetComponent <ChoiceController>();

        choiceController.choice = choice;
        return(choiceController);
    }
Beispiel #22
0
 // Use this for initialization
 void Start()
 {
     cc = (ChoiceController)FindObjectOfType(typeof(ChoiceController));
     if (cc.choseCivic)
     {
         player.transform.position = civicWaypoint.position;
         player.transform.parent   = civicWaypoint;
         player.transform.rotation = civicWaypoint.rotation;
         sportsCarSound.volume     = 8;
     }
     else
     {
         coupeRadio.volume = 0;
         driverAvatar.SetActive(false);
     }
 }
    // Use this for initialization
    void Start()
    {
        text = gameObject.GetComponent <Text>();
        ChoiceController cc = (ChoiceController)FindObjectOfType(typeof(ChoiceController));

        int age      = cc.age;
        int wealth   = (cc.choseCivic ? 3000000 : 100000) + (cc.chosePlanner ? 2000000 : 100000);
        int earnings = wealth / 10;

        text.text = string.Format(
            "You retired at age {0} with {1:C0} invested.\n\nAt a rate of 10%, this will earn you {2:C0} per year.",
            age,
            wealth,
            earnings
            );
    }
Beispiel #24
0
    // Use this for initialization
    void Start()
    {
        ChoiceController cc = (ChoiceController)FindObjectOfType(typeof(ChoiceController));

        bool       isRich         = cc.choseCivic;
        Vector3    targetPosition = transform.position;
        Quaternion targetRotation = transform.rotation;

        if (!isRich)
        {
            targetPosition.x = -121.29f;
            targetRotation.y = 83.9f;
        }

        transform.position = targetPosition;
        transform.rotation = targetRotation;
    }
    // Start is called before the first frame update
    void Awake()
    {
        if (controller == null)
        {
            DontDestroyOnLoad(gameObject);
            controller = this;
        }
        else if (controller != this)
        {
            Destroy(gameObject);
        }

        Profils    = new Profils();
        Historique = new List <Historique>();
        Objets     = new List <Objets>();
        AssociationJustifications        = new List <Association_justification>();
        JustificationLienMateriel        = new List <JustificationMateriel>();
        CoherenceMaterielTechniqueOutils = new List <CoherenceMaterielTechniqueOutils>();



        Forme                 = new List <Item>();
        TailleObjet           = new List <Taille>();
        JustificationMateriel = new List <Item>();
        Outils                = new List <Item>();
        Technique             = new List <Item>();
        SousMateriaux         = new List <Item>();
        Materiaux             = new List <Materiaux>();
        Questions             = new List <Question>();

        load_CoherenceMateriel();
        load_JustificationMateriel();

        load_Profils();
        load_Objets();
        load_taille();
        load_Item(FORME_FILENAME, Forme);
        load_Item(JUSTIFICATION_FILENAME, JustificationMateriel);
        load_Item(OUTILS_FILENAME, Outils);
        load_Item(TECHNIQUE_FILENAME, Technique);
        load_Materiaux();

        load_currentState();
    }
    //Set the initial values of question
    private void Initialize()
    {
        if (rigthToLeft)
        {
            questionText.alignment         = TextAlignmentOptions.TopRight;
            questionText.isRightToLeftText = true;
        }

        questionText.text = question.text;

        questionStarted = true;

        for (int index = 0; index < question.choices.Length; index++)
        {
            ChoiceController c = ChoiceController.AddChoiceButton(actualPanel, question.choices[index], index, panelToUse);
            choiceControllers.Add(c);
        }

        // choiceButton.gameObject.SetActive(false);
    }
Beispiel #27
0
    public void InitializeUI(GameObject UIPrefab, GameObject UIButton, TMP_FontAsset fontAsset, float characterPerSecond, float buttonSpacing)
    {
        choiceController = GetComponent <ChoiceController>();
        GameObject ui = Instantiate(UIPrefab);

        DialogueBox         = ui.transform.GetChild(0).GetChild(0).GetComponent <Canvas>();
        ChoiceBox           = ui.transform.GetChild(1).GetChild(0).GetComponent <Canvas>();
        DialogueBox.enabled = false;
        ChoiceBox.enabled   = false;
        choiceController.InitializeChoice(ChoiceBox, UIButton, buttonSpacing);

        DialogueText   = DialogueBox.transform.GetChild(0).GetChild(0).GetComponent <TextMeshProUGUI>();
        Speaker        = DialogueBox.transform.GetChild(0).GetChild(1).GetComponent <TextMeshProUGUI>();
        characterSpeed = new WaitForSecondsRealtime(1 / characterPerSecond);
        defaultFont    = DialogueText.font;
        if (fontAsset != null)
        {
            defaultFont = fontAsset;
        }
        skip = false;
    }
    private void Initialize()
    {
        choiceButton.gameObject.SetActive(false);
        for (int i = 0; i < question.choices.Length; i++)
        {
            ChoiceController c = ChoiceController.AddChoiceButton(choiceButton, question.choices[i], i);

            if (i > 0)
            {
                Navigation nav = c.button.navigation;
                nav.selectOnUp      = choiceControllers[i - 1].button;
                c.button.navigation = nav;

                nav = choiceControllers[i - 1].button.navigation;
                nav.selectOnDown = c.button;
                choiceControllers[i - 1].button.navigation = nav;
            }

            choiceControllers.Add(c);
        }
        gameObject.SetActive(true);
    }
    // Start is called before the first frame update
    void Start()
    {
        model = FindObjectOfType <ChoiceController>();
        //Debug.Log("model : " + model);
        if (model != null)
        {
            foreach (Objets obj in model.Objets)
            {
                if (obj.Modification == true)
                {
                    //Debug.Log("model forme : " + model.Forme);
                    foreach (Item justification in model.JustificationMateriel)
                    {
                        GameObject objet = (GameObject)Instantiate(prefab_object, this.transform);
                        objet.name = justification.Nom;
                        //Debug.Log("element name : " + element.Nom);
                        Toggle temp_toggle = objet.GetComponentInChildren <Toggle>();
                        temp_toggle.name = justification.Nom;

                        temp_toggle.isOn = false;

                        Text temp_texte = temp_toggle.GetComponentInChildren <Text>();
                        temp_texte.text = justification.Nom;


                        Image temp_background = (Image)temp_toggle.GetComponentInChildren <Image>();
                        Image temp_selected   = (Image)temp_toggle.graphic;

                        temp_background.sprite = Resources.Load <Sprite>(justification.Image + "");
                        temp_selected.sprite   = Resources.Load <Sprite>(justification.Image + "");
                        temp_selected.color    = Color.grey;
                        temp_toggle.onValueChanged.AddListener(delegate {
                            ToggleValueChanged(temp_toggle);
                        });
                    }
                }
            }
        }
    }
Beispiel #30
0
    /// <summary>
    /// создание кнопок в зависимости от кол-ва Choice в ScriptableObjecte Question
    /// </summary>
    /// <param name="choiceButtonTemplate"></param>
    /// <param name="choice"></param>
    /// <param name="index"></param>
    /// <returns></returns>
    public static ChoiceController AddChoiceButton(Button choiceButtonTemplate, Choice choice, int index)
    {
        //расстояние между кнопками
        int buttonSpacing = -44;
        //создаем кнопку
        Button button = Instantiate(choiceButtonTemplate);

        //создаем родительскую папку (контейнер)
        button.transform.SetParent(choiceButtonTemplate.transform.parent);
        //задаем размер кнопки
        button.transform.localScale = Vector3.one;
        //задаем положение кнопки (каждая создается ниже предыдущей кнопки в зависимости от значения Index)
        button.transform.localPosition = new Vector3(0, index * buttonSpacing, 0);
        //присваем имя объекту (первая кнопка будет названа Choice 1)
        button.name = "Choice" + (index + 1);
        //делаем активным на сцене (так как объект Question  и его потомки установлены "не активными")
        button.gameObject.SetActive(true);
        //получаем у кнопки компонент <ChoiceController>
        ChoiceController choiceController = button.GetComponent <ChoiceController>();

        //кнопка выбора будет иметь возможность делать выбор среди сохраннеых вариантов
        choiceController.choice = choice;
        return(choiceController);
    }