public void DeleteOneFood(int tempId) { OutFoodPerCell cell = null; if (m_dicFoodCells.TryGetValue(tempId, out cell)) { m_dicFoodCells.Remove(tempId); GameObject.Destroy(cell.gameObject); } }
private void ChangeOneFood(object[] args) { if (args.Length < 3) { return; } string name = (string)args[0]; string price = (string)args[1]; bool good = (bool)args[2]; string strState = good ? "好吃" : "不好吃"; int tempId = (int)args[3]; foreach (var item in m_dicFoodCells) { if (item.Key != tempId) { continue; } OutFoodPerCell cell = item.Value; cell.Refresh(name, price, good); } }
private void AddOneFood(object[] args) { if (args.Length < 2) { return; } string name = (string)args[0]; string price = (string)args[1]; bool good = (bool)args[2]; string strState = good ? "好吃" : "不好吃"; //直接clone一个cell出来 GameObject go = Instantiate(m_outFoodPerCell, m_outFoodPerCellParent.transform); go.SetActive(true); OutFoodPerCell cell = go.GetComponent <OutFoodPerCell>(); if (cell != null) { cell.Init(m_tempId, name, price, good, this); m_dicFoodCells.Add(m_tempId, cell); m_tempId++; } }
public void Init(OutFood data) { m_foodData = data; m_isChange = true; m_btnComfirmAdd.SetActive(!m_isChange); m_btnComfirmChange.SetActive(m_isChange); //初始化界面 m_inputAdress.text = data.V_Adress; m_inputEvaluate.text = data.V_Evaluate; m_inputLine.text = data.V_Line; m_inputStar.text = data.V_Star + ""; m_inputStoreName.text = data.V_StoreName; m_imageName = data.V_Iamge; int yearIndex = 0; for (int i = 0; i < m_Years.Count; i++) { string year = data.V_Date.Year.ToString(); if (m_Years[i] == year) { yearIndex = i; break; } } m_dropdownYear.value = yearIndex; m_dropdownMonth.value = data.V_Date.Month - 1; //菜单 string[] goodFoods = data.V_GoodFoodName.Split(';'); string[] badFoods = data.V_BadFoodName.Split(';'); for (int i = 0; i < goodFoods.Length; i++) { if (string.IsNullOrEmpty(goodFoods[i])) { continue; } string[] foodStr = goodFoods[i].Split('-'); GameObject go = Instantiate(m_outFoodPerCell, m_outFoodPerCellParent.transform); go.SetActive(true); OutFoodPerCell cell = go.GetComponent <OutFoodPerCell>(); if (cell != null) { cell.Init(m_tempId, foodStr[0], foodStr[1], true, this); m_dicFoodCells.Add(m_tempId, cell); m_tempId++; } } for (int i = 0; i < badFoods.Length; i++) { if (string.IsNullOrEmpty(badFoods[i])) { continue; } string[] foodStr = badFoods[i].Split('-'); GameObject go = Instantiate(m_outFoodPerCell, m_outFoodPerCellParent.transform); go.SetActive(true); OutFoodPerCell cell = go.GetComponent <OutFoodPerCell>(); if (cell != null) { cell.Init(m_tempId, foodStr[0], foodStr[1], false, this); m_dicFoodCells.Add(m_tempId, cell); m_tempId++; } } //图片 string[] imagename = m_imageName.Split(';'); for (int i = 0; i < imagename.Length; i++) { if (string.IsNullOrEmpty(imagename[i])) { continue; } GameObject go = Instantiate(m_imgCell, m_imgCellParent.transform); go.SetActive(true); ImageCell cell = go.GetComponent <ImageCell>(); if (cell != null) { cell.SetImage(imagename[i], this); if (!m_dicImgCells.ContainsKey(imagename[i])) { m_dicImgCells.Add(imagename[i], cell); } } } }
public void OnComfirmClick() { //检查参数 string adress = m_inputAdress.text; if (string.IsNullOrEmpty(adress)) { UnityHelper.OpenAtlerWin("地址不能为空"); return; } string storeName = m_inputStoreName.text; if (string.IsNullOrEmpty(adress)) { UnityHelper.OpenAtlerWin("店名不能为空"); return; } string line = m_inputLine.text; string evaluate = m_inputEvaluate.text; float star = 0; float.TryParse(m_inputStar.text, out star); string year = m_Years[m_dropdownYear.value]; string month = m_dropdownMonth.options[m_dropdownMonth.value].text; string goodFood = ""; string badFood = ""; foreach (var item in m_dicFoodCells) { OutFoodPerCell cell = item.Value; if (cell.Good) { goodFood += cell.FoodName + "-"; goodFood += cell.Price + ";"; } else { badFood += cell.FoodName + "-"; badFood += cell.Price + ";"; } } if (!string.IsNullOrEmpty(goodFood)) { goodFood = goodFood.TrimEnd(';'); } if (!string.IsNullOrEmpty(badFood)) { badFood = badFood.TrimEnd(';'); } string imgName = m_imageName; if (m_isChange) { UnityHelper.OpenAtlerWin("确定修改?", () => { OutFoodMgr.GetInstance().Model.UpdateFoodData(m_foodData.V_Key, adress, storeName, goodFood, badFood, evaluate, year + "-" + month, star, line, imgName); //关闭添加菜单界面 CloseUIForm(GetWinType()); EventMgr.GetInstance().NotifireEvent(EventName.Event_RefreshOutFoodData, m_foodData.V_Key); }); } else { UnityHelper.OpenAtlerWin("确定添加?", () => { OutFoodMgr.GetInstance().Model.AddOutFood(adress, storeName, goodFood, badFood, evaluate, year + "-" + month, star, line, imgName); //关闭添加菜单界面 CloseUIForm(GetWinType()); }); } }