public void AddLevelsToQueue(EnvironmentType _type, float _maxTotalWidth)
        {
            Assert.AreNotEqual(EnvironmentType.MAX, _type, "Not a valid environemnt");
            DifficultyRange difficultyRange = m_availableDifficulties[_type];
            float           num             = 0f;

            foreach (mg_jr_Level activeLevel in m_activeLevels)
            {
                num += activeLevel.LevelDefinition.Size.x;
            }
            int num2 = 0;

            while (num <= _maxTotalWidth)
            {
                mg_jr_Level current = AddRandomLevelToQueue(_type, difficultyRange.RandomDifficulty());
                num += current.LevelDefinition.Size.x;
                num2++;
            }
            mg_jr_Level value = m_activeLevels.Last.Value;

            m_activeLevels.RemoveLast();
            if (value != null)
            {
                value.DestroyLevel();
            }
            num2--;
            Debug.Log("_maxTotalWidth" + _maxTotalWidth);
            Debug.Log("loaded turbo levels =" + num2);
        }
        private mg_jr_Level LoadLevelAfterExisting(mg_jr_LevelDefinition _pattern)
        {
            _pattern.UseDeffinition();
            GameObject  gameObject   = new GameObject(string.Concat("mg_jr_Level_", _pattern.EnvironmentType, "_", _pattern.Difficulty));
            mg_jr_Level mg_jr_Level2 = gameObject.AddComponent <mg_jr_Level>();

            mg_jr_Level2.LevelDefinition = _pattern;
            EnvironmentVariant variant = m_environmentManager.CurrentEnvironment.Variant;

            foreach (mg_jr_LevelDefinition.ObjectSpawnDefinition objectSpawnDefinition in _pattern.ObjectSpawnDefinitions)
            {
                GameObject pooledResource = m_resources.GetPooledResource(objectSpawnDefinition.XmlResourceName, variant);
                pooledResource.transform.parent   = gameObject.transform;
                pooledResource.transform.position = objectSpawnDefinition.PositionInLevel;
                pooledResource.name = pooledResource.name + "_" + objectSpawnDefinition.Name;
            }
            Vector3 position;

            if (m_activeLevels.Count == 0)
            {
                float num = _pattern.Size.y * 0.5f - Camera.main.orthographicSize;
                position = new Vector3(Camera.main.RightEdgeInWorld(), Camera.main.TopEdgeInWorld() + num, 0f);
            }
            else
            {
                mg_jr_Level value = m_activeLevels.Last.Value;
                position = value.TopRightCornerInWorld();
            }
            gameObject.transform.position = position;
            gameObject.transform.parent   = base.transform;
            m_activeLevels.AddLast(mg_jr_Level2);
            return(mg_jr_Level2);
        }
 public void RemoveAllLevels()
 {
     while (m_activeLevels.First != null)
     {
         mg_jr_Level value = m_activeLevels.First.Value;
         m_activeLevels.RemoveFirst();
         if (value != null)
         {
             value.DestroyLevel();
         }
     }
 }
 private void RemoveExpiredLevels()
 {
     while (m_activeLevels.First != null && m_activeLevels.First.Value.IsSafelyOffLeftOfScreen())
     {
         mg_jr_Level value = m_activeLevels.First.Value;
         m_activeLevels.RemoveFirst();
         if (value != null)
         {
             value.DestroyLevel();
         }
     }
 }
 public void RemoveNonVisibleLevels()
 {
     while (m_activeLevels.Last != null && !m_activeLevels.Last.Value.IsOnScreen())
     {
         mg_jr_Level value = m_activeLevels.Last.Value;
         m_activeLevels.RemoveLast();
         if (value != null)
         {
             value.DestroyLevel();
         }
     }
 }
示例#6
0
            public override void EnterState()
            {
                mg_jr_TurboAnnounce pooledResourceByComponent = base.Logic.m_minigame.Resources.GetPooledResourceByComponent <mg_jr_TurboAnnounce>(mg_jr_ResourceList.PREFAB_TURBO_ANNOUNCE);

                pooledResourceByComponent.Announce(TurboAnnounceDone);
                base.Logic.ScrollingSpeed.EnableTurboSpeed(_enable: true);
                base.Logic.m_levelManager.RemoveNonVisibleLevels();
                base.Logic.m_levelManager.AddXtoQueue(EnvironmentType.TURBO, base.Logic.m_gameBalance.TurboLevelsPerTurboRun);
                float num = base.Logic.m_levelManager.EndPositionXofQueue - base.Logic.Player.transform.position.x;
                float timeToSpendInTurbo = num / base.Logic.m_gameBalance.MaxSpeed;

                base.Logic.Player.TurboDevice.UpdateTurboBurnTime(timeToSpendInTurbo);
                m_lastLevelInCurrentTurboSequence = base.Logic.m_levelManager.LastLevelInQueue;
                Assert.NotNull(m_lastLevelInCurrentTurboSequence, "No levels in queue");
                Assert.AreEqual(EnvironmentType.TURBO, m_lastLevelInCurrentTurboSequence.LevelDefinition.EnvironmentType, "Level isn't turbo");
                base.Logic.m_levelManager.AddEmptyLevelToQueue(base.Logic.m_gameBalance.EmptySpaceAfterTurbo);
                base.Logic.m_minigame.MusicManager.SelectTrack(mg_jr_Sound.TURBO_MODE.ClipName());
                base.Logic.m_minigame.PlaySFX(mg_jr_Sound.PLAYER_JETPACK_TURBO_START.ClipName());
                base.Logic.m_minigame.PlaySFX(mg_jr_Sound.PLAYER_TURBO_MODE_LOOP.ClipName());
                base.Logic.m_minigame.GoalManager.AddToProgress(mg_jr_Goal.GoalType.USE_TURBO, 1f);
            }
示例#7
0
 public GameLogicStateTurboMode(mg_jr_GameLogic _logic, mg_jr_Level _lastLevelInCurrentTurboSequence)
     : base(_logic)
 {
     Assert.NotNull(_lastLevelInCurrentTurboSequence, "Turbomode running without a valid end level");
     m_lastLevelInCurrentTurboSequence = _lastLevelInCurrentTurboSequence;
 }