Ejemplo n.º 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");
            }
        }
    }
Ejemplo n.º 2
0
 public void OnLevelWasLoaded()
 {
     Debug.Log("Loaded level, spawning " + coinCount + " coins now", this);
     tipJar = FindObjectOfType <TipJar>();
     tipJar.SpawnCoins(coinCount);
     if (levelPrefab)
     {
         Debug.Log("Starting level with prefab", levelPrefab);
         StartLevel(levelPrefab);
         levelPrefab = null;
     }
 }
Ejemplo n.º 3
0
 public void Awake()
 {
     tipJar = GameObject.FindObjectOfType <TipJar>();
 }