Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (current != null && current.isComplete())
        {
            if (!current.isWaiting() || enemycount == 0)
            {
                i++;
                current = new SpawnPattern(i, scheme);
            }
        }

        //out of time
        gc.SetLevel(i);
        if (timer <= 0 && !current.isComplete())
        {
            GameObject lastEnemy;
            //spawn the enemy
            SpawnCommand enemyInfo = current.getNext();
            if (enemyInfo.GetType() == "fixed")
            {
                lastEnemy = Instantiate(fixedenemy, enemyInfo.GetLocation(), new Quaternion()) as GameObject;
            }
            else if (enemyInfo.GetType() == "curve")
            {
                lastEnemy = Instantiate(curveenemy, enemyInfo.GetLocation(), new Quaternion()) as GameObject;
                if (enemyInfo.IsGoingLeft())
                {
                    lastEnemy.GetComponent <CurveEnemy>().SetLeft();
                }
                else
                {
                    lastEnemy.GetComponent <CurveEnemy>().SetRight();
                }
            }
            else
            {
                lastEnemy = Instantiate(enemy, enemyInfo.GetLocation(), new Quaternion()) as GameObject;
            }

            lastEnemy.GetComponent <Enemy>().SetColor(enemyInfo.GetColor());
            timer = enemyInfo.GetDelay();
            enemycount++;
        }


        //tick time down
        timer -= Time.deltaTime;
    }