示例#1
0
    public void BuildNewOrder()
    {
        var newOrder = GenerateNewOrder();

        if (npcOrder == null)
        {
            npcOrder = GetComponent <NpcOrder>();
            if (npcOrder.GetOrder() == null)
            {
                npcOrder.SetOrder(newOrder);
            }
        }
    }
示例#2
0
 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);
 }
示例#3
0
    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());
    }