Пример #1
0
    public static List <Wave> LoadWaveset(string name)
    {
        string path = Game.WAVESET_SAVE_DIRECTORY + name + WAVESET_FILE_EXTENSION;

        string[] content = ModuleAssemblyLoader.GetContents(path);

        List <Wave> locWaves = new List <Wave> ();

        Wave cw = null;

        Wave.Subwave cs = null;
        Wave.Enemy   ce = null;

        for (int i = 0; i < content.Length; i++)
        {
            string c = content [i];

            // Find wave
            if (c.Length > 4)
            {
                if (c.Substring(0, 5) == "\twave")
                {
                    cw = new Wave();
                    locWaves.Add(cw);
                }
            }

            // Find and read subwave
            if (c.Length > 5)
            {
                if (c.Substring(0, 6) == "\t\tsptm")
                {
                    cs           = new Wave.Subwave();
                    cs.spawnTime = float.Parse(c.Substring(7));
                    cw.subwaves.Add(cs);
                }
            }

            // Find and read enemy
            if (c.Length > 6)
            {
                if (c.Substring(0, 7) == "\t\t\tenmy")
                {
                    ce       = new Wave.Enemy();
                    ce.enemy = EnemyManager.cur.GetEnemyFromName(c.Substring(8));
                }

                if (c.Substring(0, 7) == "\t\t\tamnt")
                {
                    ce.spawnAmount = int.Parse(c.Substring(8));
                    cs.enemies.Add(ce);
                }
            }
        }

        return(locWaves);
    }
Пример #2
0
    void AddFinalBoss()
    {
        // What the f**k is this shit?
        Wave.Enemy e = new Wave.Enemy();
        e.enemy       = endBoss;
        e.spawnAmount = 1;
        Wave.Subwave s = new Wave.Subwave();
        s.enemies.Add(e);
        s.spawnTime = 1f;
        Wave w = new Wave();

        w.subwaves.Add(s);
        waves.Add(w);
    }
Пример #3
0
    void CreateEnemy(int index)
    {
        if (waveStarted)
        {
            Wave.Enemy enemy = currentSubwave.enemies[index];
            GameObject e     = pooledEnemies[enemy][0];

            if (e)
            {
                e.SetActive(true);

                Enemy ene = e.GetComponent <Enemy> ();
                ene.active = true;
                e.tag      = ene.type.ToString();

                ene.spawnPoint         = GetSpawnPosition(ene);
                ene.transform.position = ene.spawnPoint.worldPosition;

                ene.path = ene.spawnPoint.path;
            }

            pooledEnemies[enemy].RemoveAt(0);
            spawnIndex[index]++;

            if (spawnIndex[index] < currentSubwave.enemies[index].spawnAmount * amountModifier)
            {
                Invoke("Spawn" + index.ToString(), currentSubwave.spawnTime / ((float)currentSubwave.enemies[index].spawnAmount * amountModifier));
            }
            else
            {
                endedIndex++;
                if (endedIndex == spawnIndex.Length)
                {
                    ContinueWave(false);
                }
            }
        }
        else
        {
            EndWave(false);
        }
    }