Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "land")
        {
            bOverLand = true;
        }
        if (collision.gameObject.tag == "piepl" && GetComponent <ControllerScript> ().Altitude <= 0.01f)
        {
            PieplBehavior piggie = collision.gameObject.GetComponent <PieplBehavior>();
            CollectPiepl(piggie.isSpecial, piggie.PigName);

            GameObject.Destroy(collision.gameObject);
        }
    }
Exemplo n.º 2
0
    public void SpawnPiepl()
    {
        if (PieplWaves.Length <= CurrentWave)
        {
            return;
        }
        //ShuffleArray<int>(PieplSpawns);
        int CurrentNumPiepl = PieplWaves[CurrentWave].NumPiepl;

        int[] randomList = MakeIntList(PieplSpawns);

        if (CurrentNumPiepl > PieplSpawns.Length)
        {
            CurrentNumPiepl = PieplSpawns.Length;
        }

        Shuffle(randomList);
        int j = 0;
        int k = 0;

        for (j = 0; j < CurrentNumPiepl; j++)
        {
            k = randomList[j];
            Transform spawnTransform = PieplSpawns[k].transform;

            string PigToSpawn   = "poorpiggy_01";
            bool   spawnSpecial = false;
            if ((Random.Range(0, CurrentWave + 10) < 3))
            {
                spawnSpecial = true;
            }
            else
            {
                int rare = Random.Range(0, 40);

                if (rare < 6)
                {
                    if (rare < 2)
                    {
                        PigToSpawn = "zombiepiggy";
                    }
                    else if (rare < 4)
                    {
                        PigToSpawn = "darkpiggy";
                    }
                    else if (rare < 6)
                    {
                        PigToSpawn = "rainbowpiggy";
                    }
                }
            }
            GameObject spawnedPigObj = (GameObject)Instantiate(Resources.Load(PigToSpawn), spawnTransform.position, spawnTransform.rotation);

            PieplBehavior piggy = spawnedPigObj.GetComponent <PieplBehavior>();

            piggy.isSpecial  = spawnSpecial;
            piggy.SpawnDelay = Random.Range(1, 65 + CurrentWave * 2);
            piggy.LifeTime   = Random.Range(35, 75 + CurrentWave * 2);

            piggy.StartForReal();
        }
    }