示例#1
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;
            }
        }
    }
示例#2
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
    }
示例#3
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>();
 }