示例#1
0
    public static bool CheckForFarthestLevel()
    {
        //Lot of level spawners here...
        LevelSpawner levelSpawner = GameObject.Find("LevelSpawner").GetComponent <LevelSpawner>();

        if (levelSpawner.GetLevel() > farthestLevel)
        {
            farthestLevel = levelSpawner.GetLevel();
            return(true);
        }
        return(false);
    }
    //Spawn a random piece of food
    void ActivateFood()
    {
        if (foodEaten < maxFood)
        {
            int objIndex = Random.Range(0, foodLeftToSpawn.Count);

            //Spawn food in by making it active.
            foodLeftToSpawn[objIndex].SetActive(true);

            //Make arrow point to the new piece of food
            if (levelSpawner.GetLevel() > 0 && levelSpawner.GetLevelObject().name != "EasyLevel3(Clone)")
            {
                pointer.cubeRef = foodLeftToSpawn[objIndex];
            }

            //Set it to the gate parent
            foodLeftToSpawn[objIndex].transform.parent = transform.parent;

            //Remove from list now
            foodLeftToSpawn.RemoveAt(objIndex);

            foodEaten++;
        }
        else
        {
            Destroy(gameObject);  //Destroy self when max food amount is collected
        }
    }