Ejemplo n.º 1
0
 public bool isUseful(string pn)
 {
     fi = new FileInfo(pn);
     if (!fi.Exists)
     {
         return(false);
     }
     if (!isMusicFile(pn))
     {
         return(false);
     }
     wi = new WaveInfo(pn);
     //   tools.log.Debug("文件名:" + pn + "秒数:" + wi.Second + "Channels:" + wi.Channels + "BitsPerSample:" + wi.BitsPerSample + "SamlesPerSec:" + wi.SamlesPerSec + "FormatTag:" + wi.FormatTag);
     //   tools.log.Debug("文件名:----------");
     if (!wi.WaveBool)
     {
         return(false);
     }
     isExists = true;
     if (wi.Second > usefulSecond)
     {
         return(true);
     }
     isValid = true;
     return(true);
 }
Ejemplo n.º 2
0
    private void InternalStartWave(int wave)
    {
        _currentWaveInfo = GetWaveInfo(wave);
        _currentSection  = 0;

        SpawnWaveSection(_currentWaveInfo.WaveSections[_currentSection]);
    }
Ejemplo n.º 3
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //  Starts spawning new wave enemies, as well as reinitializing the required stats for the wave.
    /// </summary>
    public void StartNewWave()
    {
        _CurrentSubwave  = 0;
        _CurrentWaveTime = 0f;
        _NextWaveTimer   = _TimeTillNextWave;

        // Add to wave count
        _CurrentWave++;
        _WaveInterval++;

        // Check if current interval is boss wave
        if (_WaveInterval == WavesPerInterval)
        {
            _BossWave = true;
        }
        else
        {
            _BossWave = false;
        }

        // Get lockdown pad reference
        _CurrentLockdownPad = GetPadForSpawning();

        // Get array of new wave enemies
        _CurrentWaveInfo = GetWave();
        InitializeWave();

        // Notification popup event
        if (WaveNotificationWidget != null)
        {
            WaveNotificationWidget.NewWaveNotification(_CurrentWaveInfo);
        }
    }
Ejemplo n.º 4
0
    void PlayTutorial()
    {
        WaveInfo waveInfo = new WaveInfo
        {
            minNumberOfBoxes     = 1,
            maxNumberOfBoxes     = 2,
            minNumberOfDecals    = 1,
            maxNumberOfDecals    = 2,
            spawnAfterSeconds    = 0.0f,
            canSpawnGarbage      = false,
            canSpawnCrossedLabel = false
        };

        StartCoroutine(Coroutines.Chain(
                           Coroutines.Wait(2.0f),
                           tutorialCanvas.DisplayText("Hello!", 3.0f),
                           Coroutines.Wait(1.0f),
                           tutorialCanvas.DisplayText("Welcome to \"Rooster Express, Inc.\" We hope that you enjoy this job as much as we enjoy having you here!", 5.5f),
                           Coroutines.Wait(1.0f),
                           tutorialCanvas.DisplayText("Your job here will consist in picking up packages from that place over there and putting them in these conveyor belts...", 5.5f),
                           Coroutines.Wait(1.0f),
                           tutorialCanvas.DisplayText("But you have to make sure they go in the right conveyor, or some clients won't receive their packages in time.", 5.5f),
                           Coroutines.Wait(1.0f),
                           Coroutines.Join(
                               tutorialCanvas.DisplayText("Look, let's try it...", 2.0f),
                               Coroutines.Wrap(() => spawner.SpawnBoxes(waveInfo))),
                           Coroutines.Wait(2.5f),
                           Coroutines.Wrap(() => CreateTutorialBoxSpawnAndDeliver(waveInfo))
                           ));
    }
Ejemplo n.º 5
0
    protected override void OnUpdate()
    {
        Entities.ForEach((DynamicBuffer <WaveBufferElementData> waveInfo) =>
        {
            spawnTimer -= Time.DeltaTime;
            if (spawnTimer < 0f)
            {
                if (currentWave > waveInfo.Length - 1)
                {
                    UnityEngine.Debug.Log("There are no more waves");
                    return;
                }

                WaveInfo wave = waveInfo[currentWave].Value;
                spawnTimer    = wave.secondsBetweenSpawns;

                for (int i = 0; i < wave.spawnAmountAtATime; i++)
                {
                    SpawnEnemy(prefabToSpawn);
                    ++numOfSpawnedEntity;
                    UnityEngine.Debug.Log($"Spawned an enemy! Wave{currentWave}. {numOfSpawnedEntity}/{wave.totalAmountToSpawn}");
                    if (numOfSpawnedEntity == wave.totalAmountToSpawn)  // move to next wave
                    {
                        UnityEngine.Debug.Log($"Wave{currentWave} clear! nextWave Starts!");
                        numOfSpawnedEntity = 0;
                        ++currentWave;
                    }
                }
            }
        });
    }
Ejemplo n.º 6
0
 private void CreateTutorialBoxSpawnAndDeliver(WaveInfo waveInfo)
 {
     StartCoroutine(Coroutines.Chain(
                        _CreateTutorialBoxSpawnAndDeliver(waveInfo),
                        Coroutines.Wrap(() =>
     {
         if (!gm.playerCompletedFirstTaskSuccessful)
         {
             gm.playerCompletedFirstTask = false;
             StartCoroutine(Coroutines.Chain(
                                Coroutines.Join(
                                    Coroutines.Wait(2.0f),
                                    tutorialCanvas.DisplayText("... Ok, let's try again.", 2.0f),
                                    Coroutines.Wrap(() => spawner.SpawnBoxes(waveInfo))),
                                Coroutines.Wait(3.0f),
                                Coroutines.Wrap(() => CreateTutorialBoxSpawnAndDeliver(waveInfo))
                                ));
             return;
         }
         else
         {
             StartCoroutine(Coroutines.Chain(
                                tutorialCanvas.DisplayText("Good job!", 2.0f),
                                Coroutines.Wrap(() => CreateTutorialDifferentDisplayGarbage())
                                ));
         }
     })));
 }
Ejemplo n.º 7
0
    private WaveInfo ReadWaveData(string line)
    {
        if (string.IsNullOrEmpty(line))
        {
            return(null);
        }
        string[] _arr = line.Split(',');
        if (_arr.Length < 4)
        {
            return(null);
        }
        WaveInfo wave = new WaveInfo();

        try
        {
            wave.Time = int.Parse(_arr[0]);
            wave.ListUnitIndex.Add(int.Parse(_arr[1]));
            wave.ListLevel.Add(int.Parse(_arr[2]));
            wave.ListNumber.Add(int.Parse(_arr[3]));
        }
        catch
        {
            Debug.Log("Line not valid");
            return(null);
        }
        return(wave);
    }
Ejemplo n.º 8
0
    private IEnumerator SpawnWaveCoroutine(object[] args)
    {
        int      waveNumber = (int)args[0];
        WaveInfo waveInfo   = args[1] as WaveInfo;

        yield return(null);

        int   spawnedCount   = 0;
        int   enemiesToSpawn = Mathf.RoundToInt(waveInfo.BaseSpawnCount * Mathf.Pow(waveInfo.WaveNumberSpawnCountMultiplier, waveNumber));
        float nextSpawnTime  = Time.time;
        float spawnTimeDelta = (waveInfo.Duration * waveInfo.SpawnPeriod) / enemiesToSpawn;

        while (spawnedCount < enemiesToSpawn)
        {
            foreach (var spawner in Spawner.Instances)
            {
                spawner.Spawn(waveInfo.EnemyPrefab);
            }
            nextSpawnTime = Time.time + spawnTimeDelta;
            spawnedCount++;

            while (Time.time < nextSpawnTime)
            {
                yield return(null);
            }
        }
    }
        private IEnumerator start_wave(WaveInfo wave_info)
        {
            clear_wave();

            state = State.playing_wave;

            set_theme_color(wave_info.wave.background_color);
            string progress_title = string.Format("Level {0} {2}- Wave {1}", current_level_number, current_wave_number, wave_info.category == WaveCategory.Boss ? "- Boss " : "");

            int wave_start_idx = ++wave_start_count; // Keep track of which wave we were starting.

            timeout.stop();
            if (wave_info.wave.timeout_secs > 0)
            {
                timeout.show_timeout(wave_info.wave.timeout_secs);
            }

            yield return(display_title(progress_title, wave_info.wave.title, title_display_duration_secs));

            if (wave_start_idx != wave_start_count) // If another wave was started in-betwen, do nothing.
            {
                yield break;
            }

            current_wave = Instantiate(wave_info.wave);

            current_wave.on_finished += wave => next_wave();

            if (current_wave.timeout_secs > 0)
            {
                timeout.start(current_wave.timeout_secs);
            }
        }
Ejemplo n.º 10
0
        public AudioWrapper(string audioFile)
        {
            AudioFile = audioFile;
            AudioInfo = new WaveInfo();

            LoadAudioFile();
        }
Ejemplo n.º 11
0
        /// <summary>
        ///  副本自动战斗数据
        /// </summary>
        void InitCopyCombatData()
        {
            m_dicWaveInfo.Clear();
            table.MonsterWaveDatabase wavedata = GameTableManager.Instance.GetTableItem <table.MonsterWaveDatabase>(m_nCopyId);
            if (wavedata != null)
            {
                string[] strWaves = wavedata.strWaves.Split(';');
                for (int i = 0; i < strWaves.Length; i++)
                {
                    string strWave = strWaves[i];
                    if (string.IsNullOrEmpty(strWave))
                    {
                        continue;
                    }

                    string[] strWaveSplit = strWave.Split(':');
                    if (strWaveSplit.Length == 2)
                    {
                        WaveInfo waveInfo = new WaveInfo();
                        waveInfo.nWaveid = uint.Parse(strWaveSplit[0]);

                        string[] strPoss = strWaveSplit[1].Split('_');
                        for (int k = 0; k < strPoss.Length; k++)
                        {
                            string[] strpos = strPoss[k].Split(',');
                            if (strpos.Length == 2)
                            {
                                waveInfo.m_lstPos.Add(new UnityEngine.Vector2(int.Parse(strpos[0]), -int.Parse(strpos[1])));
                            }
                        }
                        m_dicWaveInfo.Add(waveInfo.nWaveid, waveInfo);
                    }
                }
            }
        }
Ejemplo n.º 12
0
    private void LoadPrefs()
    {
        StartCoins = PlayerPrefs.GetInt("startCoins", _startCoins);
        LifesCount = PlayerPrefs.GetInt("startLifes", _lifesCount);
        WavesCount = PlayerPrefs.GetInt("wavesCount", _wavesCount);
        wavesInfo  = new List <WaveInfo>();

        for (int i = 0; i < _maxWaves; i++)
        {
            WaveInfo waveInfo = new WaveInfo();

            foreach (var value in Enum.GetValues(typeof(Unit.UnitType)))
            {
                for (int j = 0; j < unitsPrefabs.Count; j++)
                {
                    int unitsCount = PlayerPrefs.GetInt("wave" + i + value.ToString() + unitsPrefabs[j].name + "Count", 0);
                    if (unitsCount > 0)
                    {
                        waveInfo.dictionaryUnits.Add(new WaveInfo.UnitInfo((Unit.UnitType)value, unitsPrefabs[j]), unitsCount);
                    }
                }

                for (int k = 0; k < bossesPrefabs.Count; k++)
                {
                    int bossesCount = PlayerPrefs.GetInt("wave" + i + value.ToString() + bossesPrefabs[k].name + "Count", 0);
                    if (bossesCount > 0)
                    {
                        waveInfo.dictionaryBosses.Add(new WaveInfo.UnitInfo((Unit.UnitType)value, bossesPrefabs[k]), bossesCount);
                    }
                }
            }

            wavesInfo.Add(waveInfo);
        }
    }
Ejemplo n.º 13
0
    // Use this for initialization
    void Start()
    {
        _waveNumberIndex = 0;
        WaveNumber       = new List <WaveInfo>();

        var waveOne = new WaveInfo {
            SpiderCount = 24, SpiderSpeed = 1.5f, SpiderScale = 0.15f, SpiderHealth = 100
        };

        WaveNumber.Add(waveOne);

        var waveTwo = new WaveInfo {
            SpiderCount = 16, SpiderSpeed = 1.0f, SpiderScale = 0.20f, SpiderHealth = 200
        };

        WaveNumber.Add(waveTwo);

        var waveThree = new WaveInfo {
            SpiderCount = 8, SpiderSpeed = 0.5f, SpiderScale = 0.50f, SpiderHealth = 400
        };

        WaveNumber.Add(waveThree);

        var waveFour = new WaveInfo {
            SpiderCount = 1, SpiderSpeed = 0.2f, SpiderScale = 1.15f, SpiderHealth = 800
        };

        WaveNumber.Add(waveFour);

        _spiderCount = WaveNumber[_waveNumberIndex].SpiderCount;
        InvokeRepeating("Spawn", SpawnTime, SpawnTime);
    }
Ejemplo n.º 14
0
    private WaveInfo GetWaveInfo(int wave)
    {
        CurrentWave = wave;

        // TODO: Replace Test wave with real algorithm
        WaveSectionObject section = new WaveSectionObject();

        section.Enemies = new EnemySpawnData[]
        {
            new EnemySpawnData(EnemyModel.EnemyCharacterType.Normal, 1, "First"),
            new EnemySpawnData(EnemyModel.EnemyCharacterType.Double, 1, "Second"),
            new EnemySpawnData(EnemyModel.EnemyCharacterType.Normal, 2, "The Number after two"),
        };

        section.TimeToFightEnemiesInSeconds = TIME_TO_FIGHT_UNTIL_ALL_EXTINCT;
        // -- End Test Wave

        WaveInfo waveInfo = new WaveInfo(wave, section);

        if (SpawnWaveEvent != null)
        {
            SpawnWaveEvent(waveInfo);
        }

        return(waveInfo);
    }
Ejemplo n.º 15
0
        public AudioWrapper(string audioFile)
        {
            AudioFile = audioFile;
            AudioInfo = new WaveInfo();

            LoadAudioFile();
        }
Ejemplo n.º 16
0
        public void Read(BinaryReader br)
        {
            // Read and validate header

            Header = new Mono.Header(br);

            if (Header.offsetWaveInfo > Header.headerSize)
            {
                throw new SoundBankException("WaveInfo is outside of header");
            }

            // Read block info headers

            var blockInfoHeaders = new WaveInfoHeader[Header.numBlocks];

            br.BaseStream.Seek(Header.offsetWaveInfo, SeekOrigin.Begin);

            for (int i = 0; i < Header.numBlocks; i++)
            {
                blockInfoHeaders[i] = new WaveInfoHeader(br);
            }

            // Read block infos
            _waveInfos = new List <WaveInfo>(Header.numBlocks);
            var position = br.BaseStream.Position;

            foreach (var biHeader in blockInfoHeaders)
            {
                br.BaseStream.Seek(position + biHeader.offset, SeekOrigin.Begin);

                var blockInfo = new WaveInfo(biHeader, br);
                _waveInfos.Add(blockInfo);
            }
        }
Ejemplo n.º 17
0
 protected override void OnModelDestroy()
 {
     base.OnModelDestroy();
     _sectionTracker.Clean();
     _sectionTracker  = null;
     _currentWaveInfo = null;
     _gameCamera      = null;
 }
Ejemplo n.º 18
0
    public WaveInfoContainer(WaveInfo waveInfo, int enemyQuantityMod)
    {
        int enemies = Random.Range(waveInfo.minAmountOfEnemies, waveInfo.maxAmountOfEnemies);

        // Add (or subtract) the given modifier to the number of enemies while keeping it clamped between the min and max
        enemies += enemyQuantityMod;
        enemies  = Mathf.Clamp(enemies, waveInfo.minAmountOfEnemies, waveInfo.maxAmountOfEnemies);
        ConstructContainer(waveInfo, enemies);
    }
Ejemplo n.º 19
0
    public static StageLogic RandomMonsters(string stageID, List <ELEMENT_TYPE> skillElement, List <ELEMENT_TYPE> monsterEle)
    {
        StageLogic stageLogic = new StageLogic();

        stageLogic._Waves = new List <WaveInfo>();

        int        randomWave  = GameRandom.GetRandomLevel(10, 60, 35) + 1;
        List <int> waves       = GetRandomValue(randomWave, 3, 3, 1);
        int        stageIdInt  = int.Parse(stageID);
        string     stageBaseID = (stageIdInt + 1000).ToString();

        for (int i = 0; i < randomWave; ++i)
        {
            WaveInfo waveInfo = new WaveInfo();
            stageLogic._Waves.Add(waveInfo);
            waveInfo.NPCs = new List <string>();

            int atkTotal     = 12;
            int randomNpcCnt = GameRandom.GetRandomLevel(10, 45, 45) + 1;
            for (int j = 0; j < randomNpcCnt; ++j)
            {
                MonsterInfo monster = new MonsterInfo();
                monster.ID = stageBaseID + i + j;
                int isBoxSkill = Random.Range(0, 10000);
                if (skillElement.Count > 0 && stageIdInt >= MAX_LEVEL * 0.1f && isBoxSkill < 3333)
                {
                    int randomEleIdx = Random.Range(0, skillElement.Count);
                    monster.Element = skillElement[randomEleIdx];
                    monster.ExSkill = GetRandomBoxSkill(stageIdInt, BattleField.ElementTypeToTrapType(monster.Element), monster.ID);
                }
                else
                {
                    int randomEleIdx = Random.Range(0, skillElement.Count + monsterEle.Count);
                    if (randomEleIdx > skillElement.Count - 1)
                    {
                        monster.Element = monsterEle[randomEleIdx - skillElement.Count];
                    }
                    else
                    {
                        monster.Element = skillElement[randomEleIdx];
                    }
                }
                monster.AttackSkill = Random.Range(1, 10).ToString();
                int atkMax = Mathf.Min(atkTotal, 10);
                monster.AttackRate = Random.Range(1, atkMax);
                atkTotal          -= monster.AttackRate;
                atkTotal           = Mathf.Max(1, atkTotal);
                monster.HpRate     = Random.Range(1, 11);

                waveInfo.NPCs.Add(monster.ID);
                RandomMonsterList.Add(monster.ID, monster);
            }
        }

        return(stageLogic);
    }
Ejemplo n.º 20
0
 private void InitializeWaveList()
 {
     _waveInfo = new List <WaveInfoContainer>();
     for (int i = 0; i < numWaves; i++)
     {
         int      modifier = GetEnemyModifier();
         WaveInfo waveInfo = _stageInfo.waveInfos[i % numWaves];
         _waveInfo.Add(new WaveInfoContainer(waveInfo, modifier));
     }
 }
Ejemplo n.º 21
0
    IEnumerator SpawnWave()
    {
        PlayerStats.rounds++;
        WaveInfo wave = enemyType[difficulty];

        for (int i = 0; i < wave.count; i++)
        {
            SpawnEnemy(wave.enemy);
            yield return(new WaitForSeconds(1f / wave.rate));
        }
    }
Ejemplo n.º 22
0
 void Awake()
 {
     GameObject.DontDestroyOnLoad(Camera.main);
     GameObject.DontDestroyOnLoad(
         GameObject.FindGameObjectWithTag("Light"));
     waveInfo      = GetComponent <WaveInfo>();
     levelSelect   = GetComponent <LevelSelect>();
     increaseStats = GetComponent <IncreaseStats>();
     loadingScreen = GetComponent <LoadingScreen>();
     Application.LoadLevel("levelSelect");
 }
Ejemplo n.º 23
0
        /// <summary>
        /// 根据检查人id和检查诊室得出声音
        /// </summary>
        /// <param name="Patienid">检查人id</param>
        /// <param name="departID">诊室id</param>
        /// <returns></returns>
        public string   GetVoice(string Patienid, string departID)
        {
            IDictionary <string, object> dic = new Dictionary <string, object>();
            string   voice    = voicDao.GetVoice(Patienid, departID);
            WaveInfo waveinfo = new WaveInfo(voice);
            int      playnum  = 2;

            dic.Add("Voice", voice);          //语音信息
            dic.Add("Time", waveinfo.Second); //语音时长
            dic.Add("playnum", playnum);
            return(JsonConvert.SerializeObject(dic));
        }
Ejemplo n.º 24
0
    public void SpawnBoxes(int ammountOfBoxes, float timeBetweenSpawns)
    {
        WaveInfo waveInfo = new WaveInfo
        {
            minNumberOfBoxes  = ammountOfBoxes,
            maxNumberOfBoxes  = ammountOfBoxes + 1,
            minNumberOfDecals = ammountOfDecals,
            maxNumberOfDecals = ammountOfDecals + 1
        };

        StartCoroutine(SpawnBoxesDelayed(waveInfo, timeBetweenSpawns));
    }
Ejemplo n.º 25
0
        public void ExportAsPCM(int index, Stream soundBankStream, Stream outStream)
        {
            WaveInfo waveInfo = _waveInfos[index];

            int count = waveInfo.numSamplesInBytes_computed / 2048;

            DviAdpcmDecoder.AdpcmState state = new DviAdpcmDecoder.AdpcmState();

            for (int k = 0; k < count; k++)
            {
                ExportWaveBlockAsPCM(index, k, ref state, soundBankStream, outStream);
            }
        }
Ejemplo n.º 26
0
	public void SetInfoFieldsForWave(WaveInfo waveInfo, int WaveNumber) {
		if ((WaveNumber >= 0) && (WaveNumber <= WavesCount)) {
			VictimEnumID vID = WavesPattern [WaveNumber % WavesPattern.Length];

			foreach (GameObject victim in VictimPrefabs) {
				VictimController vCon = victim.GetComponent<VictimController> ();
				if (vCon.VictimID == vID) {
					waveInfo.SetFields (vCon.VictimSprite.sprite, GetVictimsHp(WaveNumber), GetVictimsPrize(WaveNumber), WaveNumber);
					break;
				}
			}
		}
	}
Ejemplo n.º 27
0
        private void MoveToWavePos()
        {
            if (m_ActiveCtrl != null)
            {
                if (m_RoleAction == RoleAction.MOVETOWAWEPOINT)
                {
                    return;
                }

                WaveInfo waveinfo = null;
                if (m_dicWaveInfo.TryGetValue(m_nLaskKillWave, out waveinfo))
                {
                    if (waveinfo.m_lstPos.Count > m_nLaskMovePosIndex)
                    {
                        // OnPause(false);

                        //SetTimer(COPYCOMBAT_TIMEID, COPYCOMBAT_TIME_INTERVAL);

                        EntityMoveEndCallBack callback = new EntityMoveEndCallBack();
                        callback.callback = OnMoveToTargetPos;
                        ControllerSystem.m_ClientGlobal.MainPlayer.SetCallback(callback);

                        int index = (int)m_nLaskMovePosIndex;
                        UnityEngine.Vector2 pos = new UnityEngine.Vector3(waveinfo.m_lstPos[index].x, waveinfo.m_lstPos[index].y);
                        bool canMove            = m_ActiveCtrl.MoveToTarget(new UnityEngine.Vector3(pos.x, 0, pos.y), pos);

                        while (!canMove && index < waveinfo.m_lstPos.Count)
                        {
                            pos = new UnityEngine.Vector2(waveinfo.m_lstPos[index].x, waveinfo.m_lstPos[index].y);
                            m_nLaskMovePosIndex = (uint)index;

                            canMove = m_ActiveCtrl.MoveToTarget(new UnityEngine.Vector3(pos.x, 0, pos.y), pos);
                            index++;
                        }
                        if (canMove)
                        {
                            ChangeRoleAction(RoleAction.MOVETOWAWEPOINT);
                        }
                        else
                        {
                            ChangeRoleAction(RoleAction.NONE);
                        }
                        //注意要用我们的log
                        // string msg = string.Format("副本 移动 {2}wave{0} posIndex{1}  pos {3}", m_nLaskKillWave, m_nLaskMovePosIndex, canMove, pos);
                        // UnityEngine.Debug.Log(msg);
                        // AddTips(msg);
                    }
                }
            }
        }
    public WaveInfo Clone()
    {
        WaveInfo returnee = new WaveInfo();

        returnee.defaultOrderTargetTag = this.defaultOrderTargetTag;

        returnee.m_enemiesOnWave = new WaveEnemyType[this.m_enemiesOnWave.Length];
        for (int i = 0; i < this.m_enemiesOnWave.Length; ++i)
        {
            returnee.m_enemiesOnWave[i] = this.m_enemiesOnWave[i].Clone();
        }

        return(returnee);
    }
Ejemplo n.º 29
0
    private void PrepareWave(int id, WaveInfo waveInfo)
    {
        Wave wave = new Wave();

        wave.units = new List <GameObject>();

        if (dontLoadPrefs)
        {
            foreach (WaveInfo.Dict dict in waveInfo.dictUnits)
            {
                for (int i = 0; i < dict.count; i++)
                {
                    wave.units.Add(Instantiate(dict.unitInfo.unitPrefab));
                }
            }

            foreach (WaveInfo.Dict dict in waveInfo.dictBosses)
            {
                for (int i = 0; i < dict.count; i++)
                {
                    wave.units.Add(Instantiate(dict.unitInfo.unitPrefab));
                }
            }

            goto Adding;
        }

        foreach (KeyValuePair <WaveInfo.UnitInfo, int> keyPair in waveInfo.dictionaryUnits)
        {
            for (int i = 0; i < keyPair.Value; i++)
            {
                GameObject newUnit = Instantiate(keyPair.Key.unitPrefab);
                newUnit.SetActive(false);
                wave.units.Add(newUnit);
            }
        }

        foreach (KeyValuePair <WaveInfo.UnitInfo, int> keyPair in waveInfo.dictionaryBosses)
        {
            for (int i = 0; i < keyPair.Value; i++)
            {
                GameObject newUnit = Instantiate(keyPair.Key.unitPrefab);
                newUnit.SetActive(false);
                wave.units.Add(newUnit);
            }
        }

Adding:
        _wavesList.Add(wave);
    }
Ejemplo n.º 30
0
    private IEnumerator _CreateTutorialBoxSpawnAndDeliver(WaveInfo waveInfo)
    {
        return(Coroutines.Chain(

                   Coroutines.IfCondition(

                       x => !gm.playerGrabbedFirstBox,

                       Coroutines.Chain(
                           tutorialCanvas.DisplayCommand("Pick up that box to continue [LeftMouseClick or the \"A\" button]."),
                           Coroutines.WaitFor(x => gm.playerGrabbedFirstBox),
                           Coroutines.Join(
                               tutorialCanvas.HideCommand(),
                               tutorialCanvas.DisplayText("Good job!", 3.0f)))),

                   Coroutines.IfCondition(

                       x => !gm.playerInspectedFirstBox,

                       Coroutines.Chain(
                           tutorialCanvas.DisplayText("As you know, out city is distributed in districts. Each one of these conveyors...", 4.0f),
                           tutorialCanvas.DisplayText("... delivers to a specific district. The district info can be found in the package labels.", 5.0f),
                           tutorialCanvas.DisplayText("Now please, pay attention to the box.", 2.0f),
                           tutorialCanvas.DisplayCommand(
                               "Inspect the box to continue [RightMouseClick or the \"B\" button]."),

                           Coroutines.WaitFor(x => gm.playerInspectedFirstBox || gm.playerCompletedFirstTask),
                           Coroutines.IfCondition(
                               x => !gm.playerCompletedFirstTask,

                               Coroutines.Join(
                                   Coroutines.Chain(
                                       tutorialCanvas.HideCommand(),
                                       tutorialCanvas.DisplayCommand("Zoom in / out [MouseScrollWheel or the Left/right triggers].")),

                                   Coroutines.Chain(
                                       tutorialCanvas.DisplayText("Good job!", 2.0f),
                                       tutorialCanvas.DisplayText("But be careful, because sometimes the packages are redirected and have to go through another district.", 5.0f)))))),

                   Coroutines.IfCondition(

                       x => !gm.playerCompletedFirstTask,

                       Coroutines.Chain(
                           Coroutines.Wait(0.5f),
                           tutorialCanvas.DisplayCommand("Drop it in the correct conveyor"),
                           Coroutines.WaitFor(x => gm.playerCompletedFirstTask),
                           tutorialCanvas.HideCommand()))));
    }
        private WaveInfo pick_a_wave_in(IList <Wave> wave_bag, WaveCategory wave_category = WaveCategory.Wave)
        {
            if (wave_bag == null || wave_bag.Count == 0)
            {
                Debug.LogWarningFormat("No ennemies in enemy wave bag: {0}", wave_bag);
                return(null);
            }
            var      random_idx  = Random.Range(0, wave_bag.Count);
            var      picked_wave = wave_bag[random_idx];
            WaveInfo result      = new WaveInfo();

            result.wave     = picked_wave;
            result.category = wave_category;
            return(result);
        }
Ejemplo n.º 32
0
        //protected virtual void OnDisable()
        //{
        //    var json = JsonUtility.ToJson(_spawner, true);
        //    Debug.Log(json);
        //    if (File.Exists(Path)) File.Delete(Path);
        //    File.Create(Path).Dispose();
        //    var stream = File.CreateText(Path);
        //    stream.Write(json);
        //    stream.Close();
        //}

        #endregion

        #region Private methods

        private IEnumerator StartSpawning()
        {
            UpdateTextInfo();
            _waveInfoIndex  = 0;
            _curentWaveInfo = _spawner.GetWaveInfoByIndex(WaveInfoIndex);
            while (true)
            {
                yield return(StartCoroutine(StartWave()));

                WaveInfoIndex++;
                _curentWaveInfo = _spawner.GetWaveInfoByIndex(WaveInfoIndex);
                UpdateTextInfo();
                yield return(new WaitForSeconds(_curentWaveInfo.Delay));
            }
        }
Ejemplo n.º 33
0
 public WaveEventArgs(WaveInfo info, int number)
     : base()
 {
     this.Info = info;
     this.Number = number;
 }