예제 #1
0
    override protected void InitData()
    {
        base.InitData();

        Wave wave = new Wave("1");

        wave.AddEnemy(EnemyType.ET_TRASH, 3, 5);

        waves.Add(wave);

        wave = new Wave("2");
        wave.AddEnemy(EnemyType.ET_TRASH, 5, 5);

        waves.Add(wave);

        wave = new Wave("3");
        wave.AddEnemy(EnemyType.ET_TRASH, 7, 15);

        waves.Add(wave);

        //WARNING!
        currentWave = waves[0];

        AddSpawnsToPendingEnemies(currentWave.StartWave());
        UnblockExits();
    }
예제 #2
0
    private void ChooseEnemies(Wave wave)
    {
        wave.AddEnemy("soldier", WaveSoldiers());
        int addAmount = WaveRocketeers();

        if (addAmount != 0)
        {
            wave.AddEnemy("rocketeer", addAmount);
        }
        addAmount = WaveDynamiters();
        if (addAmount != 0)
        {
            wave.AddEnemy("dynamiter", addAmount);
        }
        addAmount = WaveSuiciders();
        if (addAmount != 0)
        {
            wave.AddEnemy("suicider", addAmount);
        }
        addAmount = WaveSprayers();
        if (addAmount != 0)
        {
            wave.AddEnemy("sprayer", addAmount);
        }
        if (BossLevel())
        {
            wave.AddEnemy("boss", Math.Max(1, waveNumber / 18));
        }
    }
예제 #3
0
    void SpawnWave(Wave wave)
    {
        List <Transform> spawnPointsCopy = new List <Transform>(spawnPoints);
        int spawnPointIndex = 0;

        foreach (GameObject enemyPrefab in wave.enemiesPrefab)
        {
            spawnPointIndex = Random.Range(0, spawnPointsCopy.Count);
            Enemy enemy = SpawnEnemy(enemyPrefab, spawnPointsCopy[spawnPointIndex].position);
            wave.AddEnemy(enemy);
            spawnPointsCopy.RemoveAt(spawnPointIndex);
        }
    }
    private void SpawnBatch()
    {
        foreach (var spawnPoint in spawnPoints)
        {
            var variant = currentWave.Pick(spawnPoint);
            if (variant.HasValue)
            {
                var path = GetPathToTarget(spawnPoint);
                var obj  = pool.Get();
                obj.GetComponent <Enemy>().Configure(variant.Value, target, currentWave, path);
                obj.transform.position = grid.CellToCellCenter(grid.WorldToCell(spawnPoint.transform.position));

                currentWave.AddEnemy(obj);
            }
        }
    }
예제 #5
0
    // Use this for initialization
    void Start()
    {
        // load the wave file
        zPosition = 0;
        waveList = new List<Wave>();
        JSONNode wavesData = JSON.Parse(waveFile.text);

        // set up global buff
        globalBuff.strengthAddon = wavesData ["options"] ["buff"] ["str"].AsInt;
        globalBuff.dexterityAddon = wavesData ["options"] ["buff"] ["dex"].AsInt;
        globalBuff.intelligenceAddon = wavesData ["options"] ["buff"] ["int"].AsInt;
        globalBuff.baseHealth = wavesData ["options"] ["buff"] ["health"].AsInt;
        globalBuff.baseMana = wavesData ["options"] ["buff"] ["mana"].AsInt;

        JSONArray wavesName = wavesData ["waves"].AsArray;
        for (int i = 0; i < wavesName.Count; i++) {
            JSONNode waveData = wavesData [wavesName [i]];
            int count = waveData ["count"].AsInt;
            JSONArray enemies = waveData ["enemies"].AsArray;

            Wave w = new Wave();
            for (int j = 0; j < enemies.Count; j++) {
                JSONNode enemyData = enemies [j];

                SpawnSet spawnSet = new SpawnSet (
                                        Resources.Load<GameObject> (enemyData ["enemy"]),
                                        enemyData ["count"].AsInt,
                                        enemyData ["mustBeKilled"].AsBool,
                                        enemyData ["interval"].AsFloat);

                // look for buff
                if (enemyData ["buff"].Count > 0) {
                    JSONClass buffJson = enemyData ["buff"].AsObject;
                    Buff buff = new Buff ();
                    buff.strengthAddon = buffJson ["str"].AsInt;
                    buff.dexterityAddon = buffJson ["dex"].AsInt;
                    buff.intelligenceAddon = buffJson ["int"].AsInt;
                    buff.baseHealth = buffJson ["health"].AsInt;
                    buff.baseMana = buffJson ["mana"].AsInt;
                    buff.level = j + 1;
                    buff.AddBuff (globalBuff);
                    spawnSet.SetBuff (buff);
                }

                w.AddEnemy (spawnSet);
            }
            waveList.Add (w);
        }
        Debug.Log (waveList.Count.ToString () + " waves loaded");
    }