コード例 #1
0
    private bool turnAround;       // Flag for when to turn around.

    // Use this for initialization
    void Start()
    {
        turnAround = false;
        settings   = new WaveSettings(settings); // Create a copy to ensure we don't overwrite the scriptable object

        if (enemyTemplates != null && enemyTemplates.Length > 0)
        {
            // Spawn all enemies
            enemies = new GameObject[settings.columnAmount, settings.rowAmount];

            for (int i = 0; i < settings.columnAmount; i++)
            {
                for (int j = 0; j < settings.rowAmount; j++)
                {
                    int chosenTemplate = (int)Mathf.Min((j + 1f) / settings.rowAmount * enemyTemplates.Length, enemyTemplates.Length - 1);                                                                                                  // Picks a template based on the row.
                    enemies[i, j] = Instantiate(enemyTemplates[chosenTemplate], new Vector3(transform.position.x + i * settings.horizontalOffset, transform.position.y + j * settings.verticalOffset, 0f), Quaternion.identity, transform); // Spawn in each enemy type depending on row.
                    enemiesLeft++;

                    // Assign location to each enemy
                    enemies[i, j].GetComponent <Invader>().col = i;
                    enemies[i, j].GetComponent <Invader>().row = j;
                }
            }

            // Start firing coroutine
            StartCoroutine(FireLoop());
        }
        else
        {
            Debug.Log("Could not spawn enemies. Make sure there is at least one enemy template defined.");
        }
    }
コード例 #2
0
    //---------------------------------------------------------------------//
    //------------------------ INITIALIZE NEW WAVE ------------------------//
    //---------------------------------------------------------------------//
    #region Initialize New Wave
    public void InitializeWave(WaveSettings newWaveSettings)
    {
        resetVariables();
        _curWaveSettings = newWaveSettings;

        if (!_curWaveSettings.backup)
        {
            backupSend = true;
        }
        StartCoroutine(SpawnInitialFlock());

        if (_curWaveSettings.backup)
        {
            for (int i = 0; i < _curWaveSettings.backupSpawnFlock.Length; i++)
            {
                StartCoroutine(SC_KoaSpawn.Instance.GoTargetPos(SC_PhaseManager.Instance.curWaveIndex, 1, i, _curWaveSettings.backupSpawnPosition[i], 350, 3.5f));
            }
        }
        else if (SC_PhaseManager.Instance.curWaveIndex + 1 < SC_PhaseManager.Instance.waves.Length)
        {
            WaveSettings nextWave = SC_PhaseManager.Instance.waves[SC_PhaseManager.Instance.curWaveIndex + 1];
            for (int i = 0; i < nextWave.initialSpawnFlock.Length; i++)
            {
                StartCoroutine(SC_KoaSpawn.Instance.GoTargetPos(SC_PhaseManager.Instance.curWaveIndex + 1, 0, i, nextWave.initialSpawnPosition[i], 350, 3.5f));
            }
        }
    }
コード例 #3
0
ファイル: SimForm.cs プロジェクト: COMHTVM/wavesim
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Engine.Stop();
            WaveSettings set = Engine.Settings;

            DialogResult res = openFileDialog.ShowDialog();

            if (res != System.Windows.Forms.DialogResult.Cancel)
            {
                bool result = set.LoadFromFile(openFileDialog.FileName);

                if (!result)
                {
                    MessageBox.Show("An error occured whilst loading the file!", "Load");
                    Engine.Start();
                    return;
                }

                //Resize windows
                int deltaWidth  = this.Width - pb_image.Width;
                int deltaHeight = this.Height - pb_image.Height;

                Size windowS = new Size(set.Width * _resDiv + deltaWidth, set.Height * _resDiv + deltaHeight);
                this.Size = windowS;

                Engine.Settings = set;
                MessageBox.Show("File loaded successfully!", "Load");
                Engine.Start();
            }
        }
コード例 #4
0
    //---------------------------------------------------------------------//

    //---------------------------------------------------------------------//
    //------------------------ BACKUP MANAGEMENT --------------------------//
    //---------------------------------------------------------------------//
    #region Backup Management

    IEnumerator SpawnBackupFlock()
    {
        for (int i = 0; i < _curWaveSettings.backupSpawnFlock.Length; i++)
        {
            SpawnNewFlock(_curWaveSettings.backupSpawnFlock[i], i, true);

            StartCoroutine(SC_KoaSpawn.Instance.SpawnCoro(SC_PhaseManager.Instance.curWaveIndex, 1, i, _curWaveSettings.backupSpawnPosition[i]));

            yield return(new WaitForSeconds(_curWaveSettings.timeBetweenSpawnBackup));
        }

        WaveSettings nextWave = null;

        if (SC_PhaseManager.Instance.curWaveIndex + 1 <= SC_PhaseManager.Instance.waves.Length)
        {
            nextWave = SC_PhaseManager.Instance.waves[SC_PhaseManager.Instance.curWaveIndex + 1];
        }


        if (nextWave != null)
        {
            for (int i = 0; i < nextWave.initialSpawnFlock.Length; i++)
            {
                StartCoroutine(SC_KoaSpawn.Instance.GoTargetPos(SC_PhaseManager.Instance.curWaveIndex + 1, 0, i, nextWave.initialSpawnPosition[i], 200, 3.5f));
            }
        }
    }
コード例 #5
0
 public void StartNextWave()
 {
     _currentWaveCount++;
     _waveSettings = LevelSettings.Waves[_currentWaveCount];
     GameState     = GameStateEnum.Wave;
     StartCoroutine(EnemySpawnEnumerator());
 }
コード例 #6
0
    private void SetUpWaveSettings()
    {
        currentWave      = waves[waveNumber];
        currentEnemyList = waveOfEnemies[waveNumber];

        waveDuration      = currentWave.Duration;
        startTime         = currentWave.StartSpawnTime;
        waveTime          = waveDuration + startTime;
        timeBetweenSpawns = currentWave.TimeBetweenSpawns;
    }
コード例 #7
0
    // Constructor for copying data.
    public WaveSettings(WaveSettings settingsToCopy)
    {
        speedModifier = settingsToCopy.speedModifier;
        fireInterval  = settingsToCopy.fireInterval;

        columnAmount     = settingsToCopy.columnAmount;
        rowAmount        = settingsToCopy.rowAmount;
        horizontalOffset = settingsToCopy.horizontalOffset;
        verticalOffset   = settingsToCopy.horizontalOffset;
    }
コード例 #8
0
ファイル: SimForm.cs プロジェクト: COMHTVM/wavesim
        private void editSimulationParametersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WaveSettings set = Engine.Settings;

            SimSettingsForm ssf = new SimSettingsForm();

            ssf.Settings = set;
            ssf.ShowDialog();

            if (ssf.Settings != null)
            {
                Engine.Settings = ssf.Settings;
            }
        }
コード例 #9
0
    public void InitNewPhase(PhaseSettings newPhaseSettings)
    {
        int nbMaxFlock = 0;
        int nbSpawn    = 8;
        int nbWaves    = newPhaseSettings.waves.Length;

        GameObject container = Instantiate(containerPrefab);

        for (int i = 0; i < nbWaves; i++)
        {
            int nbFlock = newPhaseSettings.waves[i].initialSpawnFlock.Length;
            if (nbFlock < newPhaseSettings.waves[i].backupSpawnFlock.Length)
            {
                nbFlock = newPhaseSettings.waves[i].backupSpawnFlock.Length;
            }


            if (nbFlock > nbMaxFlock)
            {
                nbMaxFlock = nbFlock;
            }
        }

        koaTab2 = new GameObject[nbWaves, 2, nbMaxFlock, nbSpawn];

        for (int i = 0; i < nbWaves; i++)
        {
            WaveSettings curWave = newPhaseSettings.waves[i];

            for (int j = 0; j < curWave.initialSpawnFlock.Length; j++)
            {
                GameObject curKoa;
                koaTab2[i, 0, j, curWave.initialSpawnPosition[j]] = Instantiate(koaPrefab);
                curKoa = koaTab2[i, 0, j, curWave.initialSpawnPosition[j]];
                DisplaceKoaOnSpawn(curKoa, curWave.initialSpawnPosition[j]);
                StartCoroutine(GoTargetPos(i, 0, j, curWave.initialSpawnPosition[j], 700, 8f));
                curKoa.transform.SetParent(container.transform);
            }
            for (int k = 0; k < curWave.backupSpawnFlock.Length; k++)
            {
                GameObject curKoa;
                koaTab2[i, 1, k, curWave.backupSpawnPosition[k]] = Instantiate(koaPrefab);
                curKoa = koaTab2[i, 1, k, curWave.backupSpawnPosition[k]];
                DisplaceKoaOnSpawn(curKoa, curWave.backupSpawnPosition[k]);
                StartCoroutine(GoTargetPos(i, 1, k, curWave.backupSpawnPosition[k], 700, 8f));
                curKoa.transform.SetParent(container.transform);
            }
        }
        KoaCountMaster();
    }
コード例 #10
0
        public GameSpawningWave(ObjectPool enemyPool, GameStateData stateData, WaveSettings waveSettings)
        {
            this.stateData    = stateData;
            this.waveSettings = waveSettings;
            enemyFactory      = new EnemyFactory(waveSettings.Seed, enemyPool, waveSettings.ConversionRates);
            archetypes        = new GameObject[waveSettings.WaveCount];

            var parent = new GameObject("WaveArchetypes").transform;

            for (int i = 0; i < waveSettings.WaveCount; i++)
            {
                archetypes[i]      = enemyFactory.CreateEnemy(waveSettings.EnemyPower[i]);
                archetypes[i].name = $"Wave {i}";
                archetypes[i].transform.SetParent(parent);
            }
        }
コード例 #11
0
ファイル: SimForm.cs プロジェクト: COMHTVM/wavesim
        private void Form1_Load(object sender, EventArgs e)
        {
            Engine = new WaveEngine();
            Engine.OnNewSimulationFrame += new WaveEngine.NewSimulationFrameHandler(Engine_OnNewSimulationFrame);
            Engine.Init(pb_image.Width / _resDiv, pb_image.Height / _resDiv);

            dcv = new DynamicColorVisualizer();

            tsCbMouseAction.SelectedIndex   = 0;
            tsCbMouseValue.SelectedIndex    = 9;
            tsCbSimResolution.SelectedIndex = 3;

            if (_fileToLoad != "")
            {
                WaveSettings set = Engine.Settings;

                bool result = set.LoadFromFile(_fileToLoad);

                if (!result)
                {
                    MessageBox.Show("An error occured whilst loading the file!", "Load");
                    return;
                }

                //Resize window
                int deltaWidth  = this.Width - pb_image.Width;
                int deltaHeight = this.Height - pb_image.Height;

                Size windowS = new Size(set.Width * _resDiv + deltaWidth, set.Height * _resDiv + deltaHeight);
                this.Size = windowS;

                Engine.Settings = set;
                //MessageBox.Show("File loaded successfully!", "Load");
            }

            String PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            saveFileDialog.InitialDirectory = PersonalFolder + "\\WaveSim";
            openFileDialog.InitialDirectory = PersonalFolder + "\\WaveSim";

            Engine.Start();
        }
コード例 #12
0
ファイル: SimForm.cs プロジェクト: COMHTVM/wavesim
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Engine.Stop();
            WaveSettings set = Engine.Settings;

            DialogResult res = saveFileDialog.ShowDialog();

            if (res != System.Windows.Forms.DialogResult.Cancel)
            {
                bool result = set.SaveToFile(saveFileDialog.FileName);
                if (result)
                {
                    MessageBox.Show("File successfully saved!", "Save");
                }
                else
                {
                    MessageBox.Show("Error whilst saving the file!", "Save");
                }
            }

            Engine.Start();
        }
コード例 #13
0
 public void Spawn(WaveSettings wave)
 {
 }
コード例 #14
0
ファイル: Wave.cs プロジェクト: kakawaGG/TowerDefence
 public void Initialize(WaveSettings waveSettings, EnemyPath path, float increasedStatsPercent)
 {
     _waveSettings          = waveSettings;
     _path                  = path;
     _increasedStatsPercent = increasedStatsPercent;
 }
コード例 #15
0
    /* --------------------------------------------------------------------- */

    #region Internal Methods

    #endregion

    /* --------------------------------------------------------------------- */

    #region Protected Methods

    public override void ApplySettings(WaveSettings settings)
    {
        InitialWaveSettings waveSettings = settings as InitialWaveSettings;
    }
コード例 #16
0
    /* --------------------------------------------------------------------- */

    #region Internal Methods

    #endregion

    /* --------------------------------------------------------------------- */

    #region Protected Methods

    public abstract void ApplySettings(WaveSettings settings);
コード例 #17
0
ファイル: SimSettingsForm.cs プロジェクト: COMHTVM/wavesim
 private void b_cancel_Click(object sender, EventArgs e)
 {
     Settings = null;
     this.Close();
 }