예제 #1
0
    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");
            }
        }
    }
예제 #2
0
    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");
    }
예제 #3
0
    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);
        }
    }
예제 #4
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));
            }
        }
    }