Ejemplo n.º 1
0
    private void Start()
    {
        if (!MedicalAppManager.Instance().UserDefine)
        {
            ProfileInterface.SetActive(true);
            MenuInterface.SetActive(false);
            Consigne.text = Consignes[0];

            MajModelWithInterface();
        }
        else
        {
            ProfileInterface.SetActive(false);
            MenuInterface.SetActive(true);
            Consigne.text        = Consignes[1];
            nameMenuDisplay.text = "Bonjour " + MedicalAppManager.Instance().userFirstName;

            MajModelWithProfile();
        }

        float ratio = (float)Screen.width / (float)Screen.height;

        if (ratio < (16.0f / 9.0f))
        {
            MedicalAppManager.Instance().TestRatioScale = 0.75f;
        }
        else
        {
            MedicalAppManager.Instance().TestRatioScale = 1.0f;
        }
    }
Ejemplo n.º 2
0
 public void loadQuestion()
 {
     perfect_meal.SetActive(false);
     MealManager.Instance().plateau.gameObject.SetActive(false);
     if (nextQuestion < list.questions.Count)
     {
         if (nextQuestion >= 1)
         {
             back.interactable = true;
         }
         else
         {
             back.interactable = false;
         }
         infos.text = MedicalAppManager.Instance().setUserDataInText(list.questions[nextQuestion].Text);
         smiley.gameObject.SetActive(false);
         SetChoices();
         ok.gameObject.SetActive(false);
     }
     else
     {
         //charger texte de fin
         infos.text = MealManager.Instance().EndGameMessage;
         loadMenu.SetActive(true);
         MealManager.Instance().AutoEvaluation.SetActive(false);
     }
 }
Ejemplo n.º 3
0
 private void OnMouseUp()
 {
     if (!MedicalAppManager.Instance().OnMeal)
     {
         //remettre l'ancien
         if (GameObject.Find("SliderModif") && MedicalAppManager.Instance().selectedAliment != null)
         {
             GameObject.Find("SliderModif").GetComponent <SliderModif>().CloseAndKeepOldValues();
         }
         // ajout aliment selectionne dans le manager
         MedicalAppManager.Instance().selectedAliment = gameObject;
         // zone de modification
         AtelierManager.Instance().showModification(true);
     }
     else
     {
         if (MealManager.Instance().MangerPortion != null)
         {
             // affichage manger portion
             MedicalAppManager.Instance().selectedAliment = gameObject;
             MealManager.Instance().updateInfos();
             MealManager.Instance().MangerPortion.SetActive(true);
         }
     }
 }
Ejemplo n.º 4
0
    public void SetAlimentQuantity()
    {
        int nbAliments = Mathf.CeilToInt(nbSlices / (float)al.slices);

        for (int i = transform.childCount; i > nbAliments; --i)//je détruit ceux en trop
        {
            GameObject temp = transform.GetChild(i - 1).gameObject;
            temp.transform.parent = null;
            Destroy(temp);
            //Destroy(transform.GetChild(i-1).gameObject);
        }

        while (transform.childCount < nbAliments)//j'en ajoute tant qu'il n'y en a pas assez
        {
            if (loader == null)
            {
                loader = MedicalAppManager.Instance().gameObject.GetComponent <LoadAliment>();
            }
            loader.LoadAndSetParent(al, transform);
        }

        for (int i = 0; i < transform.childCount; ++i)//tous sauf le dernier
        {
            if (i != transform.childCount - 1 || nbSlices % al.slices == 0)
            {
                transform.GetChild(i).GetComponent <BlocAliment>().nbSlices = al.slices;//al est le même aliment que celui dans les enfants
            }
            else //dernier
            {
                transform.GetChild(i).GetComponent <BlocAliment>().nbSlices = nbSlices % al.slices;
            }
        }
    }
Ejemplo n.º 5
0
    public void updateInfos()
    {
        if (!MedicalAppManager.Instance().PortionsMax)
        {
            if (MedicalAppManager.Instance().selectedAliment != null)
            {
                List <string> t = MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.types;
                string        n = MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.name;
                float         p = MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().nbSlices;

                //types
                Infos.text = "Type(s) : ";
                foreach (string type in t)
                {
                    Infos.text += type + " ";
                }
                //autres
                if (MedicalAppManager.Instance().IsSelectedDrink())
                {
                    Infos.text += "\nAliment : " + n + "\nNombre de gorgée(s) restante(s) : " + p.ToString();
                }
                else
                {
                    Infos.text += "\nAliment : " + n + "\nNombre de tranche(s) restante(s) : " + p.ToString();
                }
            }
            else
            {
                Infos.text = "Veuillez sélectionner un aliment";
            }
        }
    }
Ejemplo n.º 6
0
    public void SetAlimentsPositions()
    {
        int nbAl            = transform.childCount;
        int nbAlimentInLine = Mathf.Min(nbAl, maxNbAlimentInLine);

        for (int i = 0; i < nbAl; ++i)
        {
            //taille
            Mesh mesh;
            if (transform.GetChild(i).GetComponent <BlocAliment>().aliment.multiMesh)
            {
                mesh = transform.GetChild(i).GetComponent <BlocAliment>().Meshs[transform.GetChild(i).GetComponent <BlocAliment>().nbSlices - 1];
            }
            else
            {
                mesh = transform.GetChild(i).GetComponent <MeshFilter>().mesh;
            }
            float scale = (GetComponent <MeshFilter>().mesh.bounds.size.x - MedicalAppManager.Instance().offset) / Mathf.Max((nbAlimentInLine * (mesh.bounds.size.x * (1 + xStep)) - mesh.bounds.size.x * xStep), Mathf.Ceil(nbAl / (float)maxNbAlimentInLine) * (mesh.bounds.size.z * (1 + zStep)) - mesh.bounds.size.z * zStep, mesh.bounds.size.y);
            transform.GetChild(i).transform.localScale = scale * Vector3.one;

            //position
            float x = ((i % nbAlimentInLine) - (nbAlimentInLine - 1) / 2.0f) * (mesh.bounds.size.x * scale * (1 + xStep));
            float z = (i / maxNbAlimentInLine - (Mathf.Ceil(nbAl / (float)maxNbAlimentInLine) - 1) / 2.0f) * (mesh.bounds.size.z * scale * (1 + zStep));

            transform.GetChild(i).transform.localPosition = new Vector3(x, 0, z);
            if (MedicalAppManager.Instance().OnMeal)
            {
                transform.GetChild(i).transform.localPosition += new Vector3(0.25f, 0, 0);
            }

            //maj
            transform.GetChild(i).GetComponent <BlocAliment>().SetAspectWithSlice();
        }
    }
Ejemplo n.º 7
0
    public GameObject Aliment2; //pour le feedback visuel lorsqu'on modifie le slider

    public void InitAliment()
    {
        if (Aliment1 != null || Aliment2 != null)
        {
            GameObject.Find("SliderAjout").GetComponent <SliderAjout>().DeleteVisualFeedBack();
        }
        if (loader == null)
        {
            loader = MedicalAppManager.Instance().gameObject.GetComponent <LoadAliment>();
        }
        Aliment1 = loader.LoadWithSliceManagement(MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment);
        Aliment2 = loader.LoadWithSliceManagement(MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment);

        Aliment1.transform.position = new Vector3(-1.5f, 3, 0);
        if (Aliment1.GetComponent <BlocAliment>().normal.z == 1)
        {
            Aliment1.transform.rotation = Quaternion.Euler(0, 90, 0);
        }
        Aliment2.transform.position = new Vector3(1.5f, 3, 0);
        if (Aliment2.GetComponent <BlocAliment>().normal.z == 1)
        {
            Aliment2.transform.rotation = Quaternion.Euler(0, 90, 0);
        }

        GetComponent <Slider>().maxValue = MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment.slices * 2;
        if (GetComponent <Slider>().value == MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment.slices)
        {
            ModificationAliment();
        }
        GetComponent <Slider>().value = MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment.slices;// en gros, la moitié du slider et l'équivalent d'un aliment plein
    }
Ejemplo n.º 8
0
 public void OnMouseDown()
 {
     if (!MedicalAppManager.Instance().OnMeal)
     {
         AtelierManager.Instance().Consigne.text = AtelierManager.Instance().Consignes[2];
         Modification(true);
     }
 }
Ejemplo n.º 9
0
    public void SetDefaultSize()
    {
        Mesh mesh = GetComponent <MeshFilter>().mesh;

        if (mesh != null && Mathf.Max(mesh.bounds.size.x, mesh.bounds.size.y, mesh.bounds.size.z) != 0)
        {
            transform.localScale = MedicalAppManager.Instance().alimentSize / Mathf.Max(mesh.bounds.size.x, mesh.bounds.size.y, mesh.bounds.size.z) * Vector3.one;
        }
    }
Ejemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     xml_questions = Resources.Load <TextAsset>(path_questions).text;
     if (MedicalAppManager.Instance().userOperation == Operation.sleeve)
     {
         loadAndSaveQuestion(sleeveQuestion);
     }
     else if (MedicalAppManager.Instance().userOperation == Operation.by_pass)
     {
         loadAndSaveQuestion(byPassQuestion);
     }
 }
Ejemplo n.º 11
0
    private void TaskOnClick()
    {
        // si bouton oui ajouter aliement au repas
        if (name == "YES")
        {
            AtelierManager.Instance().addAlimentToMeal(MedicalAppManager.Instance().selectedAliment, (int)GameObject.Find("SliderAjout").GetComponent <Slider>().value);
        }

        MedicalAppManager.Instance().selectedAliment = null;
        AtelierManager.Instance().showValidation(false);
        //Camera.main.GetComponent<MouseLook>().setCameraFree(true);
    }
Ejemplo n.º 12
0
 public void MajModelWithProfile()
 {
     if (MedicalAppManager.Instance().userGender == Gender.man)
     {
         Man.SetActive(true);
         Woman.SetActive(false);
     }
     else if (MedicalAppManager.Instance().userGender == Gender.woman)
     {
         Man.SetActive(false);
         Woman.SetActive(true);
     }
 }
Ejemplo n.º 13
0
 public void UpdatePanel()
 {
     // mise a jour du text en fonction du type d'aliement
     if (MedicalAppManager.Instance().IsSelectedDrink())
     {
         ModificationText.text = MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.name + "\n" + GetComponent <Slider>().value + " gorgée(s)";
     }
     else
     {
         ModificationText.text = MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.name + "\n" + GetComponent <Slider>().value + " tranche(s)";
     }
     UpdateSlider();
 }
Ejemplo n.º 14
0
    // ################
    // ## transfere du plateau a la scene repas
    // ################
    public void LoadMeal()
    {
        MedicalAppManager.Instance().exportablePlateau.Clear();
        foreach (GameObject it in Instance().Plateau.GetComponent <scriptPlateau>().aliments)
        {
            Plate newPlate;
            newPlate.aliment = it.GetComponent <PlateBlocAliment>().al;
            newPlate.nbSlice = it.GetComponent <PlateBlocAliment>().nbSlices;
            MedicalAppManager.Instance().exportablePlateau.Add(newPlate);
        }

        Debug.Log("Chargement Repas");
        SceneManager.LoadScene("Scenes/SceneMeal", LoadSceneMode.Single);
    }
Ejemplo n.º 15
0
 // Use this for initialization
 void Start()
 {
     //al = new Aliment();
     //al.type = "Test";
     //al.name = "pain";
     //al.portions = 4;
     //al.slices = 5;
     //al.sugary = true;
     //al.greasy = false;
     //al.cold = false;
     //al.hot = false;
     //SetAlimentQuantity();
     //SetAlimentsPositions();
     loader = MedicalAppManager.Instance().gameObject.GetComponent <LoadAliment>();
 }
Ejemplo n.º 16
0
    public void EatPortion()
    {
        if (MealManager.Instance().totalPortions <= 30)
        {
            ////gérer animation
            MealManager.Instance().SetMouthAnimation(AnimationTime);

            ////enlever une portion à la selection courante
            MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().nbSlices -= 1;
            MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().SetAlimentQuantity();
            MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().SetAlimentsPositions();
            float temp = MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.portions / (float)MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.slices;

            MealManager.Instance().totalPortions += temp;
            MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().updateAliments();

            MealManager.Instance().AddEatenAliment();

            if ((MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.greasy ||
                 MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.sugary) &&
                MedicalAppManager.Instance().userOperation == Operation.by_pass)
            {
                MealManager.Instance().SetDumpingSyndrom(true);
                MealManager.Instance().EndMeal();
            }


            ////mettre à jour meal
            //if (!_MGR_MedicalApp.instance.repas.listAliments.Exists(u => u == _MGR_MedicalApp.instance.selectedAliment.GetComponent<BlocAliment>()))
            //    _MGR_MedicalApp.instance.repas.listAliments.Add(_MGR_MedicalApp.instance.selectedAliment.GetComponent<BlocAliment>());
            //_MGR_MedicalApp.instance.repas.totalPortions += 1;

            ////si il n'y a plus rien, passer au plat suivant
            if (MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().nbSlices == 0)
            {
                MealManager.Instance().MangerPortion.SetActive(false);
                DestroyImmediate(MedicalAppManager.Instance().selectedAliment);
            }
            MealManager.Instance().updateInfos();
        }
        else
        {
            MealManager.Instance().SetDumpingSyndrom(true);
            MealManager.Instance().DumpingToggle.SetActive(true);
            MealManager.Instance().EndMeal();
            MedicalAppManager.Instance().PortionsMax = true;
        }
    }
Ejemplo n.º 17
0
    IEnumerator MouthAnimationEnd(float time)
    {
        yield return(new WaitForSeconds(time));

        if (MedicalAppManager.Instance().userGender == Gender.woman)
        {
            AnimationWoman.SetBool("isActive", false);
        }
        else if (MedicalAppManager.Instance().userGender == Gender.man)
        {
            AnimationMan.SetBool("isActive", false);
        }
        MangerPortion.transform.GetChild(0).GetComponent <Button>().interactable = true;
        MangerPortion.transform.GetChild(1).GetComponent <Button>().interactable = true;
        EndMealActivator.GetComponent <Button>().interactable = true;
    }
Ejemplo n.º 18
0
 // ################
 // ## Validation du profil utilisateur
 // ################
 public void validateProfile()
 {
     if (userName.text != "" && userLastName.text != "")
     {
         MedicalAppManager.Instance().SetProfile(userName.text, userLastName.text, userOperation.text, userGender.text);
         nameMenuDisplay.text = "Bonjour " + userName.text;
         Consigne.text        = Consignes[1];
         ProfileInterface.SetActive(false);
         MenuInterface.SetActive(true);
         Error.text = "";
     }
     else
     {
         Error.text = "Veuillez entrer un texte valide";
     }
 }
Ejemplo n.º 19
0
    // Use this for initialization
    void Start()
    {
        MedicalAppManager.Instance().OnMeal = true;

        //afficher bon modèle
        if (MedicalAppManager.Instance().userGender == Gender.woman)
        {
            Woman.SetActive(true);
        }
        else if (MedicalAppManager.Instance().userGender == Gender.man)
        {
            Man.SetActive(true);
        }

        // tableau pour l'analyse
        EatenAliments = new List <PlateBlocAliment>();
        //aliment
        listAliments  = new List <PlateBlocAliment>();
        totalPortions = 0;

        Consigne.text = Consignes[0];

        /*
         * //pour tester
         * Aliment tempAliment = new Aliment();
         * tempAliment.name = "pain";
         * tempAliment.type = "Test";
         * tempAliment.name = "pain";
         * tempAliment.portions = 4;
         * tempAliment.slices = 5;
         * tempAliment.sugary = true;
         * tempAliment.greasy = false;
         * tempAliment.cold = false;
         * tempAliment.hot = false;
         * Plate temp = new Plate();
         * temp.nbSlice = 1;
         * temp.aliment = tempAliment;
         * MedicalAppManager.Instance().exportablePlateau.Add(temp);
         */

        updateInfos();
        //hdri
        GetComponent <LoadHDRI>().LoadTexture(MedicalAppManager.Instance().theScenario.name, MedicalAppManager.Instance().theScenario.skyboxRotation);

        loadAllAlimentsFromExport();
        MangerPortion.SetActive(false);
    }
Ejemplo n.º 20
0
    public void InitSlider()
    {
        // recuperation valeurs sliders lors de la selection d'un aliment
        float maxValue = MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().nbSlices;

        // definition des la valeurs + text en fonction du type d'aliment
        GetComponent <Slider>().maxValue = maxValue;
        GetComponent <Slider>().value    = maxValue;
        if (MedicalAppManager.Instance().IsSelectedDrink())
        {
            ModificationText.text = MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.name + "\n" + GetComponent <Slider>().value + " gorgée(s)";
        }
        else
        {
            ModificationText.text = MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.name + "\n" + GetComponent <Slider>().value + " tranche(s)";
        }
    }
Ejemplo n.º 21
0
 public void SetMouthAnimation(float time)
 {
     MangerPortion.transform.GetChild(0).GetComponent <Button>().interactable = false;
     MangerPortion.transform.GetChild(1).GetComponent <Button>().interactable = false;
     EndMealActivator.GetComponent <Button>().interactable = false;
     if (MedicalAppManager.Instance().userGender == Gender.woman)
     {
         AnimationWoman.SetBool("isActive", true);
     }
     else if (MedicalAppManager.Instance().userGender == Gender.man)
     {
         AnimationMan.SetBool("isActive", true);
     }
     StartCoroutine(MouthAnimationEnd(time));
     TimerUI.SetActive(true);
     TimerUI.transform.GetChild(0).GetComponent <TimerMastication>().initializeTimer(time);
 }
Ejemplo n.º 22
0
    public void SetChoices()
    {
        for (int i = 0; i < list.questions[nextQuestion].Choices.Count; ++i)
        {
            GameObject temp_button = Instantiate(button_prefab, choices_group.transform);

            //positionnement
            temp_button.GetComponent <RectTransform>().sizeDelta = new Vector2(Screen.width, temp_button.GetComponent <RectTransform>().sizeDelta.y);//TODO régler la taille en fonction du nombre de ligne
            temp_button.GetComponent <RectTransform>().position  = new Vector3(Screen.width / 2, (i + 0.5f) * temp_button.GetComponent <RectTransform>().sizeDelta.y);
            //ajout données nécessaires au bon fonctionnement
            int temp = i;
            temp_button.GetComponent <Button>().onClick.AddListener(() => userChoice(temp));

            temp_button.transform.GetChild(0).transform.GetComponent <Text>().text = MedicalAppManager.Instance().setUserDataInText(list.questions[nextQuestion].Choices[i]);

            choice_buttons.Add(temp_button);
        }
    }
Ejemplo n.º 23
0
    void Remove()
    {
        //destruction dans les listes + gestion des portions
        GameObject toDeleate = MedicalAppManager.Instance().selectedAliment;

        foreach (Transform temp in MedicalAppManager.Instance().selectedAliment.transform)//je détruit ceux en trop
        {
            temp.parent = null;
            Destroy(temp.gameObject);
        }

        AtelierManager.Instance().Plateau.GetComponent <scriptPlateau>().aliments.Remove(toDeleate);
        Destroy(toDeleate);

        //replacer les aliments dans le plateau et réafficher repas
        AtelierManager.Instance().Plateau.GetComponent <scriptPlateau>().SetAlimentsPositions();
        AtelierManager.Instance().updateInfosRepas();

        Close();
    }
Ejemplo n.º 24
0
    // ################
    // ## charger scénario et quitter interface choix scénario (à utiliser dans
    // ################
    public void loadScenarioChoice(string scenario)
    {
        for (int i = 0; i < _scenariosCollection.scenarios.Count; ++i)
        {
            if (_scenariosCollection.scenarios[i].name == scenario)
            {
                MedicalAppManager.Instance().theScenario = _scenariosCollection.scenarios[i];
            }
        }
        activateTypeButtons(true);
        Plateau.gameObject.SetActive(true);

        GetComponent <LoadHDRI>().LoadTexture(scenario, MedicalAppManager.Instance().theScenario.skyboxRotation);
        SetAliment();

        foreach (Transform child in ChoixScenariosParent.transform)
        {
            Destroy(child.gameObject);
        }
        //Camera.main.GetComponent<MouseLook>().setCameraFree(true);
    }
Ejemplo n.º 25
0
    public void loadAllAlimentsFromExport()
    {
        foreach (Plate p in MedicalAppManager.Instance().exportablePlateau)
        {
            //je rajoute un aliment
            GameObject parent = Instantiate <GameObject>(plateBlocAliment, plateau.transform);
            //GameObject temp = loader.LoadAndSetParent(al.GetComponent<BlocAliment>().aliment, parent.transform);
            parent.transform.position    = plateau.transform.position;
            parent.transform.localScale *= 0.06f;
            parent.transform.rotation    = Quaternion.AngleAxis(-90, Vector3.right);

            parent.GetComponent <PlateBlocAliment>().al       = p.aliment;
            parent.GetComponent <PlateBlocAliment>().nbSlices = p.nbSlice;
            parent.GetComponent <PlateBlocAliment>().SetAlimentQuantity();
            parent.GetComponent <PlateBlocAliment>().SetAlimentsPositions();

            //ajout dans le plateau
            plateau.GetComponent <scriptPlateau>().aliments.Add(parent);
            plateau.GetComponent <scriptPlateau>().SetAlimentsPositions();
        }
    }
Ejemplo n.º 26
0
    public void loadQuestion(string next)
    {
        if (next == "End")//je quitte le questionnaire pour retourner au menu
        {
            LoadAtelier();
        }
        else
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xml_questions);
            //Je récupère la question ou l'info
            XmlNode question = xmlDoc.SelectSingleNode("/Questions/Question[@name='" + next + "']");

            //Je m'occupe des boutons
            Questionnaire questionnaire = this.GetComponent <Questionnaire>();
            if (saveQuestion.Count >= 2)
            {
                questionnaire.back.interactable = true;
            }
            else
            {
                questionnaire.back.interactable = false;
            }
            questionnaire.ClearChoices();
            foreach (XmlNode choice in question.SelectSingleNode("Choices"))
            {
                questionnaire.choice_text.Add(MedicalAppManager.Instance().setUserDataInText(choice.InnerXml));
                questionnaire.choice.Add(choice.Attributes["name"].Value);
            }
            questionnaire.SetChoices();
            //texte
            questionnaire.text.text = MedicalAppManager.Instance().setUserDataInText(question.SelectSingleNode("Text").InnerXml);
            //démo éventuelle
            if (question.Attributes["type"].Value == "Demo")
            {
                Debug.Log(question.SelectSingleNode("Demo").InnerXml);
                questionnaire.AddDemo(question.SelectSingleNode("Demo").InnerXml);
            }
        }
    }
Ejemplo n.º 27
0
    public void AddEatenAliment()
    {
        bool             alreadyAdd = false;
        string           testName   = MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.name;
        PlateBlocAliment temp;

        foreach (PlateBlocAliment al in EatenAliments)
        {
            if (al.al.name == testName)
            {
                alreadyAdd   = true;
                al.nbSlices += 1;
            }
        }
        if (!alreadyAdd)
        {
            temp          = new PlateBlocAliment();
            temp.al       = MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al;
            temp.nbSlices = 1;
            EatenAliments.Add(temp);
        }
    }
Ejemplo n.º 28
0
    public void ModificationAliment()
    {
        int value = (int)gameObject.GetComponent <Slider>().value;
        //_MGR_MedicalApp.instance.selectedAliment.GetComponent<BlocAliment>().nbSlices = value;
        //_MGR_MedicalApp.instance.updateInfosRepas();
        GameObject Txt = gameObject.transform.parent.transform.GetChild(1).gameObject;

        Txt.GetComponent <Text>().text = MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment.name + "\n" + value.ToString() + " tranche(s)";

        // modification du texte en fonction du type d'aliement
        if (MedicalAppManager.Instance().IsSelectedDrink())
        {
            Txt.GetComponent <Text>().text = MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment.name + "\n" + value.ToString() + " gorgée(s)";
        }
        else
        {
            Txt.GetComponent <Text>().text = MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment.name + "\n" + value.ToString() + " tranche(s)";
        }

        //feedback visuel
        if (value <= MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment.slices)
        {
            Aliment1.GetComponent <BlocAliment>().nbSlices = value;
            Aliment2.GetComponent <BlocAliment>().nbSlices = 0;
        }
        else
        {
            Aliment1.GetComponent <BlocAliment>().nbSlices = MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment.slices;
            Aliment2.GetComponent <BlocAliment>().nbSlices = value - MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment.slices;
        }
        Aliment1.GetComponent <BlocAliment>().SetAspectWithSlice();
        Aliment2.GetComponent <BlocAliment>().SetAspectWithSlice();
        if (Aliment1.GetComponent <BlocAliment>().aliment.multiMesh)
        {
            Aliment1.GetComponent <BlocAliment>().SetDefaultSize();
            Aliment2.GetComponent <BlocAliment>().SetDefaultSize();
        }
    }
Ejemplo n.º 29
0
 public bool IsSelectedDrink()
 {
     if (MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>() != null)
     {
         foreach (string type in MedicalAppManager.Instance().selectedAliment.GetComponent <PlateBlocAliment>().al.types)
         {
             if (type == "boisson")
             {
                 return(true);
             }
         }
     }
     else if (MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>() != null)
     {
         foreach (string type in MedicalAppManager.Instance().selectedAliment.GetComponent <BlocAliment>().aliment.types)
         {
             if (type == "boisson")
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 30
0
 private void OnMouseUp()
 {
     // ajout aliment selectionne dans le manager
     MedicalAppManager.Instance().selectedAliment = gameObject;
     if (OnPlate)
     {
         // zone de modification
         AtelierManager.Instance().showModification(true);
     }
     else if (OnMeal)
     {
         if (MealManager.Instance().MangerPortion != null)
         {
             // affichage manger portion
             MealManager.Instance().MangerPortion.SetActive(true);
         }
     }
     else if (OnAtelier)
     {
         // zone de validation
         AtelierManager.Instance().showValidation(true);
         //Camera.main.GetComponent<MouseLook>().setCameraFree(false);
     }
 }