// Use this for initialization void Start() { provider = GlobalContentProvider.Instance; foodManager = provider.GetCurrentFoodManager(); canvas = this.gameObject; detail = canvas.transform.Find("ScrollView_5/ScrollRect/Content"); backBtn = canvas.transform.Find("Title/BackBtn").GetComponent <Button>(); backBtn.onClick.AddListener(OnBackClick); // Set up the Editor before calling into the realtime database. FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://armenu-2220c.firebaseio.com/"); //set the layout content DishContent _content = new DishContent( foodManager.GetFoodName(), foodManager.GetFoodImage(), 0f, foodManager.GetFoodDescription(), null, foodManager.GetFoodPrice(), 1, "", comments ); setContent(_content); }
//set content of the detail screen public void setContent(DishContent _content) { content = _content; //Set content GameObject menuinfo = GameObject.Find("MenuDetail"); Transform Content = menuinfo.transform.Find("ScrollView_5/ScrollRect/Content"); Content.localPosition = new Vector3(Content.localPosition.x, 0, Content.localPosition.z); menuinfo.transform.Find("Title/Text").GetComponent <Text>().text = content.dishname; if (content.image == null) { Content.Find("Image").GetComponent <Image>().color = Color.black; } else { Content.Find("Image").GetComponent <Image>().sprite = content.image; } Content.Find("Rating").GetComponent <Rating>().setValue((float)content.score / 5); Content.Find("Description").GetComponent <Text>().text = content.description; //Options content setOptions(optionprefab, Content.gameObject); Content.Find("Price").GetComponent <Text>().text = "$" + content.price.ToString(); Content.Find("Amount").Find("Placeholder").GetComponent <Text>().text = content.amount.ToString(); Content.Find("Total").GetComponent <Text>().text = "$" + (content.price * content.amount).ToString(); Content.Find("AdditionalInfo").GetComponent <InputField>().text = content.additionalinfo; //call database to get comments InvokeDatabase(); //setComments(commentprefab, Content.gameObject); }
// Use this for initialization void Start() { viewinfo = false; menuinfo = null; MenuItems = new List <GameObject>(); Content = GameObject.Find("/Menulist/Background/ScrollView_1/ScrollRect/Content"); dishDetail = GameObject.Find("/Menulist/MenuDetail/ScrollView_5/ScrollRect/Content"); reviewCanvas = GameObject.Find("ReviewCanvas"); orderHistoryCanvas = GameObject.Find("OrderList"); offset = ((RectTransform)menuPrefab.transform).rect.height * 0.03f; menuHeight = ((RectTransform)menuPrefab.transform).rect.height * 0.65f + offset; //wl(MenuItems[0].transform.localScale.x.ToString()); // Set up the Editor before calling into the realtime database. FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://armenu-2220c.firebaseio.com/"); //add dishes from GlobalContentProvider to the MenuItem list provider = GlobalContentProvider.Instance; Content.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, menuHeight * provider.foods.Length + 10); for (int i = 0; i < provider.foods.Length; ++i) { //init options (variants) for each dish List <string> options = new List <string>(); for (int j = 0; j < provider.foods[i].variants.Length; ++j) { options.Add(provider.foods[i].variants[j].variantName); } //init comments for each dish, init defaul value for demo List <Tuple <string, string> > comments = new List <Tuple <string, string> >(); //invoke database to get the rating score and add menuitem once the async task is finished DishContent temp = new DishContent( provider.foods[i].foodName, provider.foods[i].foodImage, 0, provider.foods[i].description, options, provider.foods[i].price, 1, "", comments); InvokeDatabase(temp); // addMenuItem(new DishContent( // provider.foods[i].foodName, // provider.foods[i].foodImage, // 0, // provider.foods[i].description, // options, // (float)provider.foods[i].price, // 1, // "", // comments)); } }
//listener on end editing of quantity input field public void onQuantityChanged(DishContent content) { if (quantityInput.text == null || quantityInput.text == "") { menuinfoTransform.Find("Total").GetComponent <Text>().text = "$" + content.price.ToString(); } else { menuinfoTransform.Find("Total").GetComponent <Text>().text = "$" + (Convert.ToInt64(quantityInput.text) * content.price).ToString(); } }
public void init(DishContent _content) { content = _content; foodKey = GlobalContentProvider.GetMealKey(content.dishname); commentsRef = FirebaseDatabase.DefaultInstance .GetReference("Meal/" + foodKey + "/Comments"); // Get the reference for rating ratingRef = FirebaseDatabase.DefaultInstance .GetReference("Meal/" + foodKey + "/Rating"); }
public void setContent(DishContent _content) { content = _content; //Set content detail.localPosition = new Vector3(detail.localPosition.x, 0, detail.localPosition.z); canvas.transform.Find("Title/Text").GetComponent <Text>().text = content.dishname; detail.Find("Price").GetComponent <Text>().text = content.price.ToString() + "$"; quantityInput.text = content.amount.ToString(); detail.Find("Total").GetComponent <Text>().text = (content.price * content.amount).ToString() + "$"; detail.Find("AdditionalInfo").GetComponent <InputField>().text = content.additionalinfo; }
public void ViewMenuItem() { //set content for MenuDetail DishContent content = GetMenuItemContent(); menuinfo = GameObject.Find("MenuDetail"); menuinfo.GetComponent <MenuDetailControl>().setContent(content); //Move MenuDetail posx = menuinfo.transform.position.x; nextx = Screen.width / 2; v = -vx; viewinfo = true; }
public void ViewMenuItem(DishContent content) { //set content for MenuDetail menuinfo = GameObject.Find("MenuDetail"); menuinfo.GetComponent <MenuDetailControl>().setContent(content); //Move MenuDetail posx = menuinfo.transform.position.x; nextx = Screen.width / 2; v = -vx; viewinfo = true; //referencing quantity and requirements input fields to set blank when users viewMenuList() Transform menuinfoTransform = menuinfo.transform.Find("ScrollView_5/ScrollRect/Content"); quantityInput = menuinfoTransform.Find("Amount").GetComponent <InputField>(); requirementsInput = menuinfoTransform.Find("AdditionalInfo").GetComponent <InputField>(); }
// void InvokeDatabase(Rating _rating, string key, DishContent content) { // double temp = 0; // Debug.Log(key + "!!!!!!!"); // FirebaseDatabase.DefaultInstance // .GetReference("Meal/" + key + "/AveRating/Rate") // .GetValueAsync().ContinueWith(task => { // if (task.IsFaulted) { // //handle error // } // else if (task.IsCompleted) { // DataSnapshot rating = task.Result; // temp = (double) rating.Value; // // _rating.scorevalue = (float) temp; // // _rating.setValue(_rating.scorevalue); // // content.score = _rating.scorevalue; // } // }); // } void InvokeDatabase(DishContent content) { FirebaseDatabase.DefaultInstance .GetReference("Meal/" + GlobalContentProvider.GetMealKey(content.dishname) + "/AveRating/Rate") .GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { //handle error } else if (task.IsCompleted) { DataSnapshot rating = task.Result; double temp = (double)rating.Value; content.score = (float)temp; addMenuItem(content); } }); }
// Use this for initialization void Start() { provider = GlobalContentProvider.Instance; foodManager = provider.GetCurrentFoodManager(); canvas = this.gameObject; detail = canvas.transform.Find("ScrollView_5/ScrollRect/Content"); //quantityInput = GameObject.Find ("Amount").GetComponent<InputField> (); quantityInput = detail.Find("Amount").GetComponent <InputField>(); quantityInput.onEndEdit.AddListener(delegate { onQuantityChanged(); }); //requirementsInput = GameObject.Find ("RequirementsInput").GetComponent<InputField> (); requirementsInput = detail.Find("AdditionalInfo").GetComponent <InputField>(); //get toast toast = detail.Find("Toast").GetComponent <Toast>(); //get back btn backBtn = canvas.transform.Find("Title/BackBtn").GetComponent <Button>(); backBtn.onClick.AddListener(OnBackClick); //get confirm dialog confirmDialog = transform.Find("ConfirmDialog").GetComponent <ConfirmDialog>(); // Set up the Editor before calling into the realtime database. FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://armenu-2220c.firebaseio.com/"); // Get the root reference location of the database. rootRef = FirebaseDatabase.DefaultInstance.RootReference; //set the layout content DishContent _content = new DishContent( foodManager.GetFoodName() + " (" + foodManager.GetSelectedVarName() + ")", null, 0f, null, null, foodManager.GetFoodPrice(), 1, "", null ); setContent(_content); }
private void addMenuItem(DishContent _content) { //Intantiate object GameObject menuitem = (GameObject)GameObject.Instantiate(menuPrefab); //set position menuitem.transform.SetParent(Content.transform); menuitem.transform.localScale = new Vector3(0.65f, 0.65f, 1); if (MenuItems.Count != 0) { wl("set local position"); menuitem.transform.localPosition = new Vector3(MenuItems[MenuItems.Count - 1].transform.localPosition.x, MenuItems[MenuItems.Count - 1].transform.localPosition.y - menuHeight, 0); } else { menuitem.transform.localPosition = new Vector3(401.015f, -menuHeight / 2, 0); } //set content if (_content.image != null) { menuitem.transform.Find("Image").GetComponent <Image>().color = Color.white; menuitem.transform.Find("Image").GetComponent <Image>().sprite = _content.image; } menuitem.transform.Find("Dishname").GetComponent <Text>().text = _content.dishname; menuitem.transform.Find("Info").GetComponent <Text>().text = _content.description + "\nPrice: $" + _content.price; menuitem.transform.Find("Rating").gameObject.transform.Find("Score").GetComponent <Slider>().maxValue = 5; menuitem.transform.Find("Rating").GetComponent <Rating>().scorevalue = (float)_content.score; // InvokeDatabase(menuitem.transform.Find("Rating").GetComponent<Rating>(), // GlobalContentProvider.GetMealKey(_content.dishname), _content); menuitem.transform.Find("Order").GetComponent <Button>().onClick.AddListener(() => ViewMenuItem(_content)); menuitem.transform.Find("Share").GetComponent <Button>().onClick.AddListener(() => onClickShare(_content, reviewCanvas)); menuitem.transform.Find("ItemClick").GetComponent <Button>().onClick.AddListener(() => ViewMenuItem(_content)); //add to MenuItems list MenuItems.Add(menuitem); }
void setContent(DishContent _content) { content = _content; //Set content detail.localPosition = new Vector3(detail.localPosition.x, 0, detail.localPosition.z); canvas.transform.Find("Title/Text").GetComponent <Text>().text = content.dishname; if (content.image == null) { detail.Find("Image").GetComponent <Image>().color = Color.black; } else { detail.Find("Image").GetComponent <Image>().sprite = content.image; } detail.Find("Rating").GetComponent <Rating>().setValue(content.score); detail.Find("Description").GetComponent <Text>().text = content.description; detail.Find("Price").GetComponent <Text>().text = content.price.ToString() + "$"; InvokeDatabase(); }
public void onClickShare(DishContent content, GameObject canvas) { //share canvas.SetActive(true); canvas.GetComponent <ReviewControlMenuList>().init(content); }