Esempio n. 1
0
    void Start()
    {
        Text text = GetComponent <Text>();

        foreach (SubWave subWave in WaveFactory.GenerateWave(WaveNumber.waveNumber))
        {
            foreach (StatsHolder statsHolder in subWave.GetEnemies())
            {
                if (!enemyTypeToAmount.ContainsKey(statsHolder.Name))
                {
                    enemyTypeToAmount.Add(statsHolder.Name, 1);
                }
                else
                {
                    enemyTypeToAmount[statsHolder.Name]++;                    // enemyTypeToAmount[statsHolder.Name] + 1);
                }
            }
        }

        string        enemyInfoText = "";
        List <string> nameList      = new List <string>();

        foreach (KeyValuePair <string, int> entry in enemyTypeToAmount)
        {
            nameList.Add(entry.Key + ": " + entry.Value + "\n");
        }

        nameList.Sort();
        foreach (string name in nameList)
        {
            enemyInfoText += name;
        }
        text.text = enemyInfoText.ToUpper();
    }
Esempio n. 2
0
    void Start()
    {
        List <SubWave> wave = WaveFactory.GenerateWave(WaveNumber.waveNumber);

        requiredKillEnemiesInWave = 0;
        foreach (SubWave subWave in wave)
        {
            requiredKillEnemiesInWave += subWave.RequiredKillEnemyCount();
        }
        this.requireKillUnitsSpawned = 0;
        this.enemySpawner.SpawnWave(wave);
    }
Esempio n. 3
0
        private WaveChunk ProcessWaves()
        {
            if (waves.Count == 0)
            {
                return(null);
            }

            WaveAttributes attr = new WaveAttributes(sampleRate, fileDuration, -1);


            WaveChunk wave = makeWave(waves[0], attr);

            for (int i = 1; i < waves.Count; i++)
            {
                var item    = waves[i];
                var newWave = makeWave(item, attr);
                switch (item.waveOperator)
                {
                case "Add":
                    wave += newWave;
                    break;

                case "Sub":
                    wave -= newWave;
                    break;

                case "Mult Wave":
                    wave *= newWave;
                    break;

                case "Div":
                    wave /= newWave;
                    break;

                default:
                    throw new Exception("Invalid wave operation");
                }
            }

            wave.LinearVolumeNormalize();
            return(wave);

            WaveChunk makeWave(WaveItem item, WaveAttributes attr2)
            {
                attr2.TargetFrequency = item.waveFrequency;
                return(WaveFactory.MakeWave(WAVE_TYPES_MAP[item.waveType], attr2));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Get the wave data from a file path.
        /// </summary>
        /// <returns>Wave data.</returns>
        public Wave GetWave()
        {
            string wavePath = GetWavePath();

            if (wavePath == "")
            {
                return(null);
            }

            //Extension.
            string ext = Path.GetExtension(wavePath).ToLower();

            //RIFF.
            if (ext.StartsWith(".w"))
            {
                RiffWave r = new RiffWave();
                r.Load(System.IO.File.ReadAllBytes(wavePath));
                return(new Wave()
                {
                    Wav = WaveFactory.CreateWave(r, true, forceWavMaj, forceWavMin, forceWavRev)
                });
            }

            //Wave.
            else if (ext.EndsWith("wav"))
            {
                b_wav b = new b_wav();
                b.Load(System.IO.File.ReadAllBytes(wavePath));
                return(new Wave()
                {
                    Wav = b
                });
            }

            //Stream.
            else if (ext.EndsWith("stm"))
            {
                b_stm s = new b_stm();
                s.Load(System.IO.File.ReadAllBytes(wavePath));
                return(new Wave()
                {
                    Wav = WaveFactory.CreateWave(s, forceWavMaj, forceWavMin, forceWavRev)
                });
            }

            //Null.
            return(null);
        }
Esempio n. 5
0
 void Start()
 {
     this.player = GameObject.FindWithTag("Player");
     waveFactory = GameObject.FindGameObjectWithTag("WaveFactory").GetComponent <WaveFactory>();
     InvokeRepeating("Spawner", 0.0f, spawnRate);
 }
Esempio n. 6
0
        /// <summary>
        /// Import files.
        /// </summary>
        public override void WarBatchImport()
        {
            //File open check.
            if (!FileTest(null, null, false, true))
            {
                return;
            }

            //Safety.
            string path = GetFolderPath();

            if (path == "")
            {
                return;
            }

            //Sort files.
            List <string> files = Directory.EnumerateFiles(path).ToList();

            for (int i = files.Count - 1; i >= 0; i--)
            {
                if (!files[i].Contains("wav"))
                {
                    files.RemoveAt(i);
                }
            }

            //Read each file.
            foreach (string d in files)
            {
                if (Path.GetExtension(d).ToLower().Contains(".wav"))
                {
                    byte[] b = System.IO.File.ReadAllBytes(d);
                    if (b.Length > 0)
                    {
                        RiffWave r = new RiffWave();
                        r.Load(b);
                        (File as SoundWaveArchive).Add(new Wave()
                        {
                            Wav = WaveFactory.CreateWave(r, true, forceWavMaj, forceWavMin, forceWavRev)
                        });
                    }
                    else
                    {
                        (File as SoundWaveArchive).Add(null);
                    }
                }
                else
                {
                    byte[] b = System.IO.File.ReadAllBytes(d);
                    if (b.Length > 0)
                    {
                        Wave a = new Wave();
                        a.Wav = new b_wav();
                        a.Wav.Load(b);
                        (File as SoundWaveArchive).Add(a);
                    }
                    else
                    {
                        (File as SoundWaveArchive).Add(null);
                    }
                }
            }

            //Update.
            UpdateNodes();
            DoInfoStuff();
        }