public static IEnumerator Destroy_Menus(GameManager.customer customer, GameObject parent) { for (int i = 0; i < parent.transform.childCount; i++) { Destroy(parent.transform.GetChild(i).gameObject); } if (GameObject.Find("BeverageField").transform.childCount > 0) { Destroy(GameObject.Find("BeverageField").transform.GetChild(0).gameObject); } if (GameObject.Find("SideMenuField1").transform.childCount > 0) { Destroy(GameObject.Find("SideMenuField1").transform.GetChild(0).gameObject); } if (GameObject.Find("SideMenuField2").transform.childCount > 0) { Destroy(GameObject.Find("SideMenuField2").transform.GetChild(0).gameObject); } Stack.instance.stack.Clear(); Stack.instance.sideMenu.Clear(); Destroy(Stack.instance.beverage); yield return(new WaitForSecondsRealtime(1.0f)); if (customer != null) { Destroy(customer.obj); } }
void SpawnSpecialCustomer(GameManager.customer customer) { CustomerType.Special type = GetRandomEnumSpecialCustomerType(); if (StatManager.instance.date.GetData() >= 9 && StatManager.instance.date.GetData() <= 15) { if (type == CustomerType.Special.drunkType || type == CustomerType.Special.celebType) { SpawnSpecialCustomer(customer); return; } } switch (type) { case CustomerType.Special.vegeType: customer.obj = Instantiate(vege); break; case CustomerType.Special.meatonlyType: customer.obj = Instantiate(meatonly); break; case CustomerType.Special.nobreadType: customer.obj = Instantiate(nobread); break; case CustomerType.Special.breadonlyType: customer.obj = Instantiate(breadonly); break; case CustomerType.Special.chickenonlyType: customer.obj = Instantiate(chickenonly); break; case CustomerType.Special.bigmacType: customer.obj = Instantiate(bigmac); break; case CustomerType.Special.celebType: customer.obj = Instantiate(celeb); break; case CustomerType.Special.beggarType: customer.obj = Instantiate(beggar); break; case CustomerType.Special.groupType: customer.obj = Instantiate(group); break; case CustomerType.Special.drunkType: customer.obj = Instantiate(drunk); break; } }
void SpawnNormalCustomer(GameManager.customer customer) { CustomerType.Normal type = GetRandomEnumNormalCustomerType(); if (StatManager.instance.date.GetData() >= 9 && StatManager.instance.date.GetData() <= 15) { if (type == CustomerType.Normal.normalType5 || type == CustomerType.Normal.normalType9) { SpawnNormalCustomer(customer); return; } } switch (type) { case CustomerType.Normal.normalType1: customer.obj = Instantiate(normal1); break; case CustomerType.Normal.normalType2: customer.obj = Instantiate(normal2); break; case CustomerType.Normal.normalType3: customer.obj = Instantiate(normal3); break; case CustomerType.Normal.normalType4: customer.obj = Instantiate(normal4); break; case CustomerType.Normal.normalType5: customer.obj = Instantiate(normal5); break; case CustomerType.Normal.normalType6: customer.obj = Instantiate(normal6); break; case CustomerType.Normal.normalType7: customer.obj = Instantiate(normal7); break; case CustomerType.Normal.normalType8: customer.obj = Instantiate(normal8); break; case CustomerType.Normal.normalType9: customer.obj = Instantiate(normal9); break; case CustomerType.Normal.normalType10: customer.obj = Instantiate(normal10); break; } }
void SellMethod(GameManager.customer customer) { if (customer.me == null || customer.me.orderState != CustomerParent.OrderState.yet) // 손님이 없는 상태에서 누르는 경우, { return; } CheckSideMenus(customer); if (customer.me.orderState == CustomerParent.OrderState.wrong) { Debug.Log("!"); } if (customer.me.orderState != CustomerParent.OrderState.wrong) { CheckMainMenus(customer); } if (customer.me.groupStack != 0) //단체 손님인 경우 { StartCoroutine(Destroy_Menus(null, GameObject.Find("IngredientStack"))); if (customer.me.orderState != CustomerParent.OrderState.wrong) { effect.effectSounds[13].source.Play(); customer.me.orderState = CustomerParent.OrderState.yet; return; } } if (customer.me.orderState == CustomerParent.OrderState.yet) // 주문을 받았기에 틀린 경우가 아니면 아직 yet이기에 proper로 전환 { customer.me.orderState = CustomerParent.OrderState.proper; } if (customer.me.orderState == CustomerParent.OrderState.proper) { effect.effectSounds[6].source.Play(); customer.me.textbox.text = customer.me.thankMsg; if (StatManager.instance.date.GetData() >= 12) { StatManager.instance.StatPlus(StatManager.instance.money, (int)(customer.me.payment * 0.8f)); } else { StatManager.instance.StatPlus(StatManager.instance.money, customer.me.payment); } StatManager.instance.StatPlus(StatManager.instance.popular, customer.me.plusPopular); } else { effect.effectSounds[5].source.Play(); customer.me.textbox.text = customer.me.wrongMsg; StatManager.instance.StatPlus(StatManager.instance.popular, -customer.me.minPopular); } if (StatManager.instance.popular.GetData() > 100) { StatManager.instance.popular.SetData(100); } StartCoroutine(Destroy_Menus(customer, GameObject.Find("IngredientStack"))); }
void CheckSideMenus(GameManager.customer customer) { if (customer.me.orderState != CustomerParent.OrderState.wrong) { CheckBeverage(customer); } if (customer.me.orderState != CustomerParent.OrderState.wrong) { CheckSideMenu(customer); } }
void CheckSideMenu(GameManager.customer customer) { GameObject sideParent1 = GameObject.Find("SideMenuField1"); GameObject sideParent2 = GameObject.Find("SideMenuField2"); if (customer.me.sideMenu1 == "") // 주문이 없는 경우. { if (sideParent1.transform.childCount > 0) // 주문이 없는데 주는 경우. { customer.me.orderState = CustomerParent.OrderState.wrong; } } else { if (sideParent1.transform.childCount == 0 || !sideParent1.transform.GetChild(0).name.Contains(customer.me.sideMenu1)) // 사이드 메뉴 1번이 틀린 경우. { customer.me.orderState = CustomerParent.OrderState.wrong; } if (customer.me.sideMenu2 == "") // 사이드 주문이 1개인 경우. { if (sideParent2.transform.childCount > 0) // 사이드 주문이 1개인데, 두개를 주는 경우. { customer.me.orderState = CustomerParent.OrderState.wrong; } } else // 사이드 주문이 2개인 경우 { if (sideParent2.transform.childCount == 0) // 사이드 주문이 2개인데 한개를 주는 경우. { customer.me.orderState = CustomerParent.OrderState.wrong; } else if (!sideParent2.transform.GetChild(0).name.Contains(customer.me.sideMenu2)) // 사이드 주문 2번을 틀린 경우. { customer.me.orderState = CustomerParent.OrderState.wrong; } } if (customer.me.sideMenu1 != "" && customer.me.sideMenu2 != "" && sideParent2.transform.childCount == 0 && sideParent1.transform.childCount == 0) { if (sideParent1.transform.GetChild(0).name.Contains(customer.me.sideMenu2) && sideParent2.transform.GetChild(0).name.Contains(customer.me.sideMenu1)) { customer.me.orderState = CustomerParent.OrderState.yet; } } } }
void CheckBeverage(GameManager.customer customer) { GameObject beverageParent = GameObject.Find("BeverageField"); if (customer.me.beverage == "") // 주문이 없는데 주는 경우 { if (beverageParent.transform.childCount > 0) { customer.me.orderState = CustomerParent.OrderState.wrong; } } else // 주문이 있는 경우 { if (beverageParent.transform.childCount == 0 || // 주문은 있는데, 안 주는 경우 !beverageParent.transform.GetChild(0).name.Contains(customer.me.beverage)) // 주문과 다른 음료를 주는 경우. { customer.me.orderState = CustomerParent.OrderState.wrong; } } }
// 손님 생성 메소드 public void Spawn_Customer(GameManager.customer customer, GameObject line) { if (customer.obj == null) { customer.timer += Time.deltaTime; if (customer.timer >= customer.spawnTime) { ResultManager.instance.metCustomer++; CustomerType.HeadType headType = GetRandomEnumHeadCutomerType(); switch (headType) { case CustomerType.HeadType.normal: { SpawnNormalCustomer(customer); break; } case CustomerType.HeadType.special: { SpawnSpecialCustomer(customer); break; } } //지우지 말아주세요 //customer.obj = Instantiate(drunk); customer.obj.transform.SetParent(line.transform); customer.obj.transform.localPosition = new Vector2(0, -55); if (customer.obj.name.Contains("Normal3")) { customer.obj.transform.localPosition = new Vector2(0, -83); } customer.timer = 0; EffectManager.instance.effectSounds[12].source.Play(); } } }
void CheckMainMenus(GameManager.customer customer) { GameObject parent = GameObject.Find("IngredientStack"); if (parent.transform.childCount == 0) { customer.me.orderState = CustomerParent.OrderState.wrong; } switch (customer.me.type) { case ("BreadOnly"): { for (int i = 0; i < parent.transform.childCount; i++) { if (!(parent.transform.GetChild(i).name.Contains("Flat") || parent.transform.GetChild(i).name.Contains("HoneyOat") || parent.transform.GetChild(i).name.Contains("Oregano") || parent.transform.GetChild(i).name.Contains("Sesame") || parent.transform.GetChild(i).name.Contains("White") || parent.transform.GetChild(i).name.Contains("Wit"))) { customer.me.orderState = CustomerParent.OrderState.wrong; } } break; } case ("Group"): { if (parent.transform.childCount != customer.me.order.Length) { customer.me.orderState = CustomerParent.OrderState.wrong; } else { for (int i = 0; i < customer.me.order.Length; i++) { if (!parent.transform.GetChild(i).name.Contains(customer.me.order[i])) { customer.me.orderState = CustomerParent.OrderState.wrong; break; } if (i == customer.me.order.Length - 1) { customer.me.groupStack--; } } } break; } default: { if (parent.transform.childCount != customer.me.order.Length) { customer.me.orderState = CustomerParent.OrderState.wrong; } else { for (int i = 0; i < customer.me.order.Length; i++) { if (!parent.transform.GetChild(i).name.Contains(customer.me.order[i])) { customer.me.orderState = CustomerParent.OrderState.wrong; } } } break; } } }