public IEnumerator AutoFulfillOrder(NpcOrder npc) { yield return(new WaitForSeconds(secondsToWait)); CompletedBurger completedBurger = (CompletedBurger)Instantiate(completedBurgerPrefab, npc.trayPosition.position, Quaternion.identity); npc.ReceiveCompletedBurger(completedBurger); }
public override IEnumerator NpcServed(NpcOrder npc, CompletedBurger burger) { Debug.Log("Npc was served, sending this one away then spawning a new wave"); currentNpc.GetComponent <NpcEnterStyle>().StopMovement(); yield return(ScoreBurger(npc, burger)); yield return(npc.GetComponent <NpcExitStyle>().NpcExit()); Debug.Log("Npc exited, spawning a new wave"); StartCoroutine("SpawnWave"); }
public override IEnumerator NpcServed(NpcOrder npc, CompletedBurger burger) { Debug.Log("Npc was served, sending this one away"); float accuracy = LevelManager.Instance.burgerScorer.CalcAccuracyScore(npc.GetOrder(), burger.ingredients); if (accuracy < 99) { Debug.Log("Accuracy was bad, making angry face: " + accuracy, burger); if (npc.transform.FindChild("angryFace")) { // If this NPC was already angry, end the level EndLevel(); } else { GameObject angryFace = (GameObject)Instantiate(angryFacePrefab, npc.transform); angryFace.transform.localPosition = new Vector3(0, 1f, 0); angryFace.name = "angryFace"; npc.acceptingOrders = true; } Destroy(burger.gameObject); } else { Debug.Log("Customer satisfied"); Transform clock = npc.transform.FindChild("clock"); if (clock != null) { Destroy(clock.gameObject); } Destroy(burger); npc.GetComponent <NpcEnterStyle>().StopMovement(); yield return(npc.GetComponent <NpcExitStyle>().NpcExit()); currentNpcs--; TipJar tipJar = GameObject.FindObjectOfType <TipJar>(); if (currentNpcs <= 0) { float maxCoins = LevelManager.Instance.settings.difficultyLevel; // maxCoins += npcCount * 0.1f; maxCoins *= maxCoins; maxCoins *= 0.25f; maxCoins /= 3; maxCoins = Mathf.Max(0.25f, maxCoins); if (tipJar != null) { tipJar.SpawnCoins(Random.Range(0, maxCoins) + 0.25f); } Debug.Log("Finished giving tip, spawning next wave"); StartCoroutine("SpawnWave"); } } }
public void BuildNewOrder() { var newOrder = GenerateNewOrder(); if (npcOrder == null) { npcOrder = GetComponent <NpcOrder>(); if (npcOrder.GetOrder() == null) { npcOrder.SetOrder(newOrder); } } }
public override IEnumerator SpawnWave() { waveCount--; if (waveCount < 0) { EndLevel(); } else { currentNpc = (NpcOrder)Instantiate(npcPrefab, LevelManager.Instance.startPosition.position, LevelManager.Instance.startPosition.rotation); yield return(currentNpc.GetComponent <NpcEnterStyle>().NpcEnter()); LevelManager.Instance.orderRules.GenerateOrder(currentNpc); } }
public override void GenerateOrder(NpcOrder npc) { orderComplexity = LevelManager.Instance.orderRules.CalculateCurrentOrderComplexity(); string[] newOrder = new string[orderComplexity + 2]; newOrder[0] = "bottom_bun"; newOrder[newOrder.Length - 1] = "top_bun"; for (int i = 1; i <= orderComplexity; i++) { newOrder[i] = ingredientsAllowed[UnityEngine.Random.Range(0, ingredientsAllowed.Length)]; } for (int i = 0; i < newOrder.Length; i++) { Debug.Log("Generated order: " + newOrder[i], npc); } npc.SetOrder(newOrder); }
private IEnumerator ScoreBurger(NpcOrder npc, CompletedBurger burger) { GameObject tray = burger.container; Transform trayPosition = npc.trayPosition; yield return(MoveUtil.MoveOverSeconds(tray, trayPosition.localPosition, 1f)); HappinessScoreDisplay scorer = Instantiate <HappinessScoreDisplay>(npc.scorePrefab); scorer.transform.SetParent(npc.transform); scorer.transform.localPosition = npc.scorePosition.localPosition; scorer.transform.localEulerAngles = npc.scorePosition.localEulerAngles; if (scorer != null) { yield return(scorer.ScoreOrder(npc.GetDesiredIngredients(), burger, npc.GetTimeSinceOrderStarted())); } Destroy(scorer); }
public override IEnumerator SpawnWave() { npcCount = LevelManager.Instance.settings.customerCount; LevelManager.Instance.orderRules.GenerateOrder(specialOrder); waveCount--; if (waveCount < 0) { Debug.Log("Last wave passed, ending level"); EndLevel(); } else { currentNpcs = npcCount; for (int i = 0; i < npcCount; i++) { NpcOrder currentNpc = (NpcOrder)Instantiate(npcPrefab, LevelManager.Instance.startPosition.position, LevelManager.Instance.startPosition.rotation); currentNpc.GetComponent <NpcEnterStyle>().StartCoroutine("NpcEnter"); currentNpc.SetOrder(specialOrder.GetOrder()); yield return(new WaitForSeconds(LevelManager.Instance.settings.difficultyLevel)); } } }
public override void GenerateOrder(NpcOrder npc) { List <string> newOrder = new List <string>(); string[] combinations = null; int difficultyLevel = LevelManager.Instance.settings.difficultyLevel; // Get the set of possible burger definitions for the current difficulty level while (difficultyLevel > 0 && (combinations == null || combinations.Length == 0)) { difficultyLevel--; if (difficultyLevel < difficultyLevelCombinations.Length) { combinations = difficultyLevelCombinations[difficultyLevel]; } } // If we had bad input (missing/empty burger definition) just use the default if (combinations == null) { combinations = defaultCombinations; } // Pick a random burger definition from the current difficulty level list string[] orderCombo = combinations[Random.Range(0, combinations.Length)].Split(','); for (int i = 0; i < orderCombo.Length; i++) { int ingredientTypeIdx = int.Parse(orderCombo[i]); // Get a random ingredient list for the current burger definition component string[] ingredientOptions = ingredientTypes[ingredientTypeIdx].Split(':'); // Add a random entry from the ingredient list newOrder.AddRange(ingredientOptions[Random.Range(0, ingredientOptions.Length)].Split(',')); } for (int i = 0; i < newOrder.Count; i++) { Debug.Log("Generated order: " + newOrder[i], npc); } npc.SetOrder(newOrder.ToArray()); }
public override void GenerateOrder(NpcOrder npc) { base.GenerateOrder(npc); StartCoroutine("AutoFulfillOrder", npc); }
public abstract void GenerateOrder(NpcOrder npc);
public abstract IEnumerator NpcServed(NpcOrder npcOrder, CompletedBurger completedBurger);