private void LoadFood()
    {
        string curFood;

        for (int i = 0; i < 5; i++)
        {
            curFood = SelectedFood.getInstance().GetFoodList()[i];

            try
            {
                if (curFood.Equals(""))
                {
                    continue;
                }
                // instantiate prefab
                GameObject foodObject = Instantiate(Resources.Load <GameObject>("Prefabs/" + curFood)) as GameObject;
                // setPosition & size
                foodObject.transform.localScale    = foodTr.scale;
                foodObject.transform.localPosition = foodTr.pos[i];
                foodObject.AddComponent <MouseEvent>();

                DontDestroyOnLoad(foodObject);
            }
            catch (Exception e)
            {
                Debug.Log(curFood + ":is not available");
                Debug.Log(e.Message);
            }
        }
    }
예제 #2
0
 public static SelectedFood getInstance()
 {
     if (instance == null)
     {
         instance = new SelectedFood();
     }
     return(instance);
 }
예제 #3
0
        public async Task <bool> ShowDialogFood(Food food)
        {
            taskCompletionSource = new TaskCompletionSource <bool>();
            task = taskCompletionSource.Task;
            SelectedFood alertDialog = new SelectedFood(food, Callback);
            await Application.Current.MainPage.Navigation.PushPopupAsync(alertDialog);

            return(await task);
        }
예제 #4
0
        private void Awake()
        {
            plateConfig  = gameObject.AddComponent <PlateConfig>(); //new PlateConfig();
            listview     = gameObject.AddComponent <Listview>();
            searchConfig = gameObject.AddComponent <SearchConfig>();
            changeScene  = gameObject.AddComponent <ChangeScene>();
            selectedFood = SelectedFood.getInstance();

            searchConfig.setListview(listview, searchConfig, this);
            plateConfig.PlateButtonListener(searchConfig, this);
        }
예제 #5
0
        private void CalculateServingsNutritionalValue()
        {
            if (txtServingSizeToAdd.Text != null)
            {
                if (txtServingSizeToAdd.Text != string.Empty)
                {
                    SelectedServingSize = Decimal.Parse(txtServingSizeToAdd.Text.Replace(',', '.'));
                    SelectedFood        = (Food)grdFoodDatabaseReference.SelectedItem;

                    if (SelectedFood != null)
                    {
                        this.txtCaloriesToAdd.Text = SelectedFood.CaloriesInServingSize(SelectedServingSize).ToString();
                        this.txtCarbsToAdd.Text    = SelectedFood.CarbsInServingSize(SelectedServingSize).ToString();
                        this.txtFatsToAdd.Text     = SelectedFood.FatsInServingSize(SelectedServingSize).ToString();
                        this.txtSugarToAdd.Text    = SelectedFood.SugarsInServingSize(SelectedServingSize).ToString();
                        this.txtProteinsToAdd.Text = SelectedFood.ProteinsInServingSize(SelectedServingSize).ToString();
                    }
                }
            }
        }