Exemplo n.º 1
0
    void Init()
    {
        forbiddenAreas = GameObject.FindGameObjectsWithTag("forbiddenArea").ToList();
        deadAreas      = GameObject.FindGameObjectsWithTag("deadArea").ToList();

        totalEnemies      = Ultilities.TotalEnemiesInLevel();
        wildEnemyDuration = ConstData.EnemyWaveTimes[ConstData.EnemyWaveTimes.Count - 1] / (totalEnemies * 0.1f);
        //		Debug.Log("totalEnemies " + totalEnemies);
        SubscribeEvents();

        if (GameData.Instance.LevelType == LevelType.RushLevel)
        {
            mode = (PlayModes)(IOHelper.GetStageInfoByStageId(GameData.Instance.CurrentLevel).type);
            switch (mode)
            {
            case PlayModes.Normal:
                UIBattleSceneLogic.Instance.WaveChange();
                StartCoroutine(WaveGenerator());
                StartCoroutine(GenerateWildEnemy());
                StartCoroutine(GenerateWeaponEnemy());
                StartCoroutine(GenerateGoldEnemy());
                StartCoroutine(RemoveEnemyInDeadArea());
                StartCoroutine(PopupTargetDescription(strNormalPlaymode));
                break;

            case PlayModes.OnlyBoss:

                string     bossids   = IOHelper.GetStageInfoByStageId(GameData.Instance.CurrentLevel).boss_id;
                string[]   ids       = bossids.Split(';');
                int        id        = int.Parse(ids[0]);
                GameObject player    = (GameObject)GameObject.FindGameObjectWithTag("Player");
                Vector3    playerPos = player.transform.position;
                GenerateEnemy(playerPos, (EnemyType)id);
                GameData.Instance.CurrentWave = ConstData.MaxWaves;
                UIBattleSceneLogic.Instance.WaveChange();
                //				StartCoroutine(GenerateWildEnemy());
                StartCoroutine(GenerateWeaponEnemy());
                StartCoroutine(GenerateGoldEnemy());
                StartCoroutine(RemoveEnemyInDeadArea());
                StartCoroutine(PopupTargetDescription(strOnlyBossPlaymode));
                break;

            case PlayModes.Bosses:
                StartCoroutine(WaveGenerator());
                StartCoroutine(GenerateWildEnemy());
                StartCoroutine(GenerateWeaponEnemy());
                StartCoroutine(GenerateGoldEnemy());
                StartCoroutine(RemoveEnemyInDeadArea());
                StartCoroutine(PopupTargetDescription(strBossesPlayMode));
                break;

            case PlayModes.TimeLimited:
                StartCoroutine(WaveGenerator());
                StartCoroutine(GenerateWildEnemy());
                StartCoroutine(GenerateWeaponEnemy());
                StartCoroutine(GenerateGoldEnemy());
                StartCoroutine(RemoveEnemyInDeadArea());
                StartCoroutine(DoCountDown(300));
                StartCoroutine(PopupTargetDescription(strTimeLimitedPlayMode));
                break;
            }
        }
        else
        {
            UIBattleSceneLogic.Instance.WaveChange();
            StartCoroutine(WaveGenerator());
            StartCoroutine(GenerateWildEnemy());
            StartCoroutine(GenerateWeaponEnemy());
            StartCoroutine(GenerateGoldEnemy());
            StartCoroutine(RemoveEnemyInDeadArea());
        }

        GameObject target;

        if (SettingManager.Instance.CurrentAvatar == 1)
        {
            target = nan;
        }
        else
        {
            target = nv;
        }

        Physics.IgnoreLayerCollision(gameObject.layer, target.layer, true);
    }