public void PlaceAnOrder(MainDish dish, Option newOption, int nAmount) { string optionType = null; List <Option> lstOption = new List <Option> (); if (newOption != null) { if (option_ != null) { lstOption.Add(option_); } lstOption.Add(newOption); optionType = newOption.getOptionType(); } List <OrderedDish> lstTemp; if (true == dicOrder_.TryGetValue(dish.getIndex(), out lstTemp)) { if (DAKGOGI.DishesManager.Instance.IfOptionsAreExistByIndex(DAKGOGI.NDakgogiManager.Instance.GetCurrentDishIndex())) { if (nSelectedOrderIndex_ > 0) { foreach (OrderedDish op in lstTemp) { if (op.getOrderIndex() == nSelectedOrderIndex_) { op.RemoveAllOptions(); foreach (Option newop in lstOption) { op.AddOption(newop); } } } } else { lstTemp.Add(new DAKGOGI.OrderedDish(++nOrderIndex_, dish, lstOption, optionType, nAmount)); } dicOrder_[dish.getIndex()] = lstTemp; } else { foreach (OrderedDish order in lstTemp) { order.AddUpAmount(nAmount); } } } else { List <OrderedDish> newList = new List <OrderedDish>(); newList.Add(new DAKGOGI.OrderedDish(++nOrderIndex_, dish, lstOption, optionType, nAmount)); dicOrder_.Add(dish.getIndex(), newList); } option_ = null; /*Debug.Log ("........... For Debugging start................"); * * // for debugging * foreach (KeyValuePair<int, List<OrderedDish>> order in dicOrder_) * { * Debug.Log ("DishIndex : " + order.Key); * * foreach(DAKGOGI.OrderedDish orderedDish in order.Value) * orderedDish.Output(); * }*/ }
public bool SerializeFromData() { if (dicDishesByCategory_ != null) { return(true); } // Dishes dicDishesByCategory_ = new SortedDictionary <string, List <MainDish> > (); dicDishesByIndex_ = new SortedDictionary <int, MainDish> (); if (null == dicDishesByCategory_ || null == dicDishesByIndex_) { return(false); } for (int i = 0; i < nProductCount; i++) { MainDish newDish = new MainDish(); { int index; double price; System.Int32.TryParse(aryDishData[i, 0], out index); System.Double.TryParse(aryDishData[i, 8], out price); newDish.OnInit(index, aryDishData[i, 1], aryDishData[i, 2], aryDishData[i, 3], aryDishData[i, 4], aryDishData[i, 5], aryDishData[i, 6], aryDishData[i, 7], price); } List <MainDish> lstTemp; if (true == dicDishesByCategory_.TryGetValue(aryDishData[i, 6], out lstTemp)) { lstTemp.Add(newDish); } else { List <MainDish> newList = new List <MainDish>(); newList.Add(newDish); dicDishesByCategory_.Add(aryDishData[i, 6], newList); } dicDishesByIndex_.Add(newDish.getIndex(), newDish); } // Option Information dicOptionInformation_ = new SortedDictionary <string, List <Option> > (); for (int i = 0; i < nCountOptionInformation; i++) { Option newFood = new Option(); { int index = 0; double price; System.Int32.TryParse(aryOptionInformation [i, 0], out index); System.Double.TryParse(aryOptionInformation[i, 6], out price); newFood.OnInit(index, aryOptionInformation [i, 3], aryOptionInformation [i, 4], aryOptionInformation [i, 5], price); newFood.setOptionType(aryOptionInformation[i, 2]); } List <Option> lstTemp; if (true == dicOptionInformation_.TryGetValue(aryOptionInformation [i, 1], out lstTemp)) { lstTemp.Add((Option)newFood); } else { List <Option> newList = new List <Option>(); newList.Add((Option)newFood); dicOptionInformation_.Add(aryOptionInformation [i, 1], newList); } } // Options dicOptions_ = new SortedDictionary <int, List <string> > (); for (int i = 0; i < nCountMenuOption; i++) { int j = 0, nIndex = 0; System.Int32.TryParse(aryMenuNOption [i, j], out nIndex); List <string> lstTemp; if (true == dicOptions_.TryGetValue(nIndex, out lstTemp)) { lstTemp.Add(aryMenuNOption [i, j + 1]); } else { List <string> newList = new List <string>(); newList.Add(aryMenuNOption [i, j + 1]); dicOptions_.Add(nIndex, newList); } } // Localization string [] languages = new string[4]; dicLocalization_ = new SortedDictionary <string, SortedDictionary <string, string> >(); for (int i = 0; i < 3; i++) { for (int j = 1; j < 4; j++) { if ("Language" == aryLocalization[i, 0]) { languages[j] = aryLocalization[i, j]; // to get language's index SortedDictionary <string, string> newLanguage = new SortedDictionary <string, string>(); dicLocalization_.Add(aryLocalization[i, j], newLanguage); } else { SortedDictionary <string, string> dicTemp; if (true == dicLocalization_.TryGetValue(languages[j], out dicTemp)) { string key = aryLocalization[i, 0]; string value = aryLocalization[i, j]; dicTemp.Add(key, value); } } } } Debug.Log("Loading Data... count :" + dicDishesByCategory_.Count); return(true); }