Esempio n. 1
0
    IEnumerator makeEnemies()
    {
        //Object bundle;
        GameObject instance;

        working = true;
        while (working)
        {
            yield return(new WaitForSeconds(SpawnCycleTime));

            //Set dificulty computation here, load spawnpattern class rather than resources.load
            //Make a difficulty pool and a list collection ordered by difficulties
            //Then roll dices to choose and that's ok !

            //TODO HERE !
            //Populate difficulty pool
            //Debug.Log("Difficulty : "+difficulty);
            //if (poppedNum < 300) {
            if (_dynamics_.transform.childCount < maxInstances)
            {
                foreach (GameObject go in spPat.getRandomPattern(difficulty))
                {
                    //Debug.Log ("\t pattern : "+go.name);
                    instance = Instantiate(go) as GameObject;

                    Vector3 randomPos = getRandomPosFromFar(spawnDistance);
                    //instance.transform.position = spawnPointList[Random.Range((int)0, (int)spawnPointList.Count)].transform.position;
                    instance.transform.position = randomPos;
                    GameObject warn = Instantiate(warning);
                    warn.GetComponent <SpriteRenderer> ().color = new Color(1.0f, 1 - (((float)spPat.getDifficultyOfPattern(go)) / ((float)spPat.getMaxDifficulty())), 0.0f);
                    warn.GetComponent <AlignWithPlayer> ().dest = instance.transform.position;

                    generate(instance);
                    Destroy(instance);
                }
            }

            //


            //bundle = Resources.Load ("Prefabs/Pattern" + Random.Range((int)1, (int)12));

            difficulty = Mathf.Min(maxDifficulty, difficulty + 1);
        }
    }