Example #1
0
    public void CheckStageOver()
    {
        int foodCount = FoodList.Count;

        eatenFoodCount = 0;

        foreach (var child in FoodList)
        {
            if (child.IsEaten)
            {
                eatenFoodCount++;
            }
        }

        if (!isFruitCreated && eatenFoodCount > foodCount * 0.5f)
        {
            Vector3 createPosition = CurrentStage.GetFruitCreatePosition();
            Fruit   fruit          = Instantiate(prefFruit, createPosition, Quaternion.identity).GetComponent <Fruit>();
            fruit.Init(fruitIndex);
            isFruitCreated = true;
        }

        if (eatenFoodCount == foodCount)
        {
            SetGameState(EState.StageOver);
        }
    }