public void LoadCard(DishCard c) { if (c == null) { return; } card = c; title.text = c.title; int noArtDiff = art.transform.childCount - c.ingredients.Count; if (noArtDiff > 0) { for (int count = 0; count < noArtDiff; count++) { Destroy(art.transform.GetChild(art.transform.childCount - count - 1).gameObject); } } else if (noArtDiff < 0) { for (int count = 0; count > noArtDiff; count--) { GameObject obj = Instantiate(new GameObject(), art.transform); obj.name = "Ingredient"; obj.AddComponent <Image>(); } } for (int idx = 0; idx < c.ingredients.Count; idx++) { art.transform.GetChild(idx).GetComponent <Image>().sprite = c.ingredients[idx].sprite; } score.text = c.score.ToString(); }
private void DishCards_MouseLeave(object sender, System.EventArgs e) { System.Windows.Forms.Label lbl = (System.Windows.Forms.Label)sender; DishCard dc = (DishCard)lbl.Parent.Parent; dc.DishNameBGColor = Color.FromArgb(0, 92, 50, 50); dc.DishPriceBGColor = Color.FromArgb(93, 108, 179); }
private void DishCards_MouseHover(object sender, System.EventArgs e) { System.Windows.Forms.Label lbl = (System.Windows.Forms.Label)sender; DishCard dc = (DishCard)lbl.Parent.Parent; dc.HoverBackColor = Color.FromArgb(200, 100, 100, 100); dc.DishNameBGColor = Color.BurlyWood; dc.DishPriceBGColor = Color.BurlyWood; }
private void DishCards_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { System.Windows.Forms.Label lbl = (System.Windows.Forms.Label)sender; DishCard dc = (DishCard)lbl.Parent.Parent; dc.DishNameBGColor = Color.FromArgb(0, 92, 10, 50); dc.DishPriceBGColor = Color.FromArgb(93, 108, 179); if (dc.isgq == 1) { dc.DishName = currDishName; dc.ForeColor = Color.Black; } }
private void DishCards_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { System.Windows.Forms.Label lbl = (System.Windows.Forms.Label)sender; DishCard dc = (DishCard)lbl.Parent.Parent; dc.DishNameBGColor = System.Drawing.Color.FromArgb(230, 20, 100); dc.DishPriceBGColor = System.Drawing.Color.FromArgb(230, 20, 100); if (dc.isgq == 1) { currDishName = dc.DishName; dc.DishName = "此菜已沽清..."; } }
private void GenerateDishDeck() { dishDeck = new List <DishCard>(); string path = "Cards/Dish/Food"; // load cards for (int count = 1; count < 16; count++) { string realPath = path + count.ToString(); if (count < 11) { for (int i = 0; i < 3; i++) { dishDeck.Add(Resources.Load(realPath) as DishCard); } } else if (count < 15) { for (int i = 0; i < 2; i++) { dishDeck.Add(Resources.Load(realPath) as DishCard); } } else { dishDeck.Add(Resources.Load(realPath) as DishCard); } } // shuffle cards for (int i = 0; i < dishDeck.Count; i++) { DishCard temp = dishDeck[i]; int randomIndex = Random.Range(i, dishDeck.Count); dishDeck[i] = dishDeck[randomIndex]; dishDeck[randomIndex] = temp; } //set index to 0 dishIdx = 0; }
IEnumerator CookingPhase() { Debug.Log("Cooking Phase"); assignDishButton(true); yield return(new WaitForSeconds(1)); // cook or skip DishCard selected = null; yield return(StartCoroutine(WaitForChoosingDish(value => selected = value))); Debug.Log(selected); assignDishButton(false); if (selected != null) { yield return(StartCoroutine(WaitForCooking(selected))); } overlayDish.SetActive(false); phase = "EndTurn"; }
private void DishCards_Click(object sender, System.EventArgs e) { try { timer1.Enabled = false; int mo_count = 0; Label lbl = (Label)sender; DishCard dc = (DishCard)lbl.Parent.Parent; if (!dc.DishName.Equals("")) { string pos = ""; string mydishname = dc.DishName; if (mydishname.Split(']').Length > 1) { mydishname = dc.DishName.Split(']')[1].Trim(); } int orderId; //if (new OrdersManage().ExistsMenuInDgv(dc.DishId, this.tableOrders.Id, out orderId)) //{ // OrdersEntity orderDish = new SqlServerDbMapper<OrdersEntity>().GetSingleObj(new OrdersEntity { Id = orderId }); // new OrdersManage().ChangeAmount(0, "++", orderDish); // timer1.Enabled = true; // return; // //new OrdersManage().ChangeAmount(amount, psType, this.m_selectOrderDish); // //return; //} if (dc.dispType.Equals("")) { if (dc.isgq == 1) { return; } if (this.dgvOrderDish.SelectedRows.Count > 0) { //selectedOrderdish = (DataRow)dgvOrderDish.SelectedRows[0].Tag; //OrdersEntity orderDish = new OrdersEntity(); //m_selectOrderDish = new OrdersManage().GetOrdersEntitiyById(Convert.ToInt32(selectedOrderdish["Id"])); //if ((DataRow)dgvOrderDish.SelectedRows[0].Tag != null) //{ // if (dc.DishId == m_selectOrderDish.Menu_Id) // { // this.ChangeAmount(0, "++"); // timer1.Enabled = true; // return; // } //} } OrdersCls orderdish = new OrdersCls(); orderdish.MenuName = mydishname; orderdish.Amount = 1; orderdish.Menu_Id = dc.DishId; orderdish.Price = Convert.ToSingle(dc.Price.Split('/')[0]); orderdish.Status = 0; // "即上"; orderdish.TableOrders_Id = this.tableOrders.Table_Id; orderdish.UnitName = Convert.ToString(dc.Price.Split('/')[1]); //this.AddNewDish(orderdish, 0); //this.updateOrdersPages(); //mo_count = new PriceManage().GetDishPriceCountByMenuId(dc.DishId); //SetCCOrderDishInfo(); } } } catch (Exception ex) { MessageBox2.Show(ex.ToString()); } }
IEnumerator WaitForCooking(DishCard dishCard) { assignIngredientButton(true, player - 1); List <IngredientCard> needed = new List <IngredientCard>(dishCard.ingredients); List <int> used = new List <int>(); while (needed.Count > 0) { int idx = -1; if (Input.GetKeyDown(KeyCode.Q)) { idx = 0; } else if (Input.GetKeyDown(KeyCode.W)) { idx = 1; } else if (Input.GetKeyDown(KeyCode.E)) { idx = 2; } else if (Input.GetKeyDown(KeyCode.R)) { idx = 3; } else if (Input.GetKeyDown(KeyCode.T)) { idx = 4; } else if (Input.GetKeyDown(KeyCode.Y)) { idx = 5; } else if (Input.GetKeyDown(KeyCode.U)) { idx = 6; } else if (Input.GetKeyDown(KeyCode.I)) { idx = 7; } else if (Input.GetKeyDown(KeyCode.O)) { idx = 8; } else if (Input.GetKeyDown(KeyCode.P)) { idx = 9; } if (Input.GetKeyDown(KeyCode.Space)) { used = new List <int>(); break; } if (idx > -1 && idx < AllIngCard[player - 1].Count) { IngredientCard pop = needed.Find(x => x.title == AllIngCard[player - 1][idx].title); if (pop != null) { if (!used.Contains(idx)) { used.Add(idx); needed.Remove(pop); IngredientCardViz Viz = AllIngTransform[0].GetChild(idx).GetComponent <IngredientCardViz>(); Viz.setSelected(true); UpdateIngCard(0, player - 1); } } } yield return(null); } if (needed.Count == 0) { used.Sort(); int bonus = 0; int shift = 0; foreach (int idx in used) { if (AllIngCard[player - 1][idx - shift].bonus) { bonus++; } AllIngCard[player - 1].RemoveAt(idx - shift); shift++; } UpdateIngCard(0, player - 1); //update score scores[player - 1] += dishCard.score + bonus; //Check end game int _player = 0; foreach (int score in scores) { Debug.Log(score); _player++; if (score >= WINSCORE) { Debug.Log(_player.ToString() + "Win"); winner = _player; yield return(StartCoroutine(GameEnd())); break; } } AllDishCard.Remove(dishCard); UpdateDishCard(); } assignIngredientButton(false, player - 1); }