public override void GenerateWaveCount(ProceduralLevel level)
        {
            float minWaveCount = m_MinimumWaveCount.Evaluate(level.Difficulty);
            float maxWaveCount = m_MaximumWaveCount.Evaluate(level.Difficulty);

            level.WaveCount = (int)Math.Round(Random.Range(minWaveCount, maxWaveCount));
        }
        public override void GenerateEnemyLevel(ProceduralLevel level, int playerLevel)
        {
            float minEnemyLevel = m_MinimumAdditionalEnemiesLevel.Evaluate(level.Difficulty);
            float maxEnemyLevel = m_MaximumAdditionalEnemiesLevel.Evaluate(level.Difficulty);

            level.EnemyLevel = playerLevel + (int)Math.Round(Random.Range(minEnemyLevel, maxEnemyLevel));
        }
        public override void GenerateWaveDelay(ProceduralLevel level)
        {
            float minWaveDelay = m_MinimumWaveDelay.Evaluate(level.Difficulty);
            float maxWaveDelay = m_MaximumWaveDelay.Evaluate(level.Difficulty);

            level.Width  = 40f;
            level.Height = 40f;

            level.TimeBetweenWaves = (int)Math.Round(Random.Range(minWaveDelay, maxWaveDelay));
        }
        public override void GenerateTags(ProceduralLevel level)
        {
            List <TagSpawnWeight> tags = new List <TagSpawnWeight>();

            foreach (TagSpawnWeight tsw in m_TagSpawnWeights)
            {
                if (tsw.RequiredDifficulty > level.Difficulty)
                {
                    continue;
                }
                tags.Add(tsw);
            }
            int weight = 0;

            for (int i = 0; i < tags.Count; i++)
            {
                weight += tags[i].Weight;
            }
            float minTagCount = m_MinimumTagCount.Evaluate(level.Difficulty);
            float maxTagCount = m_MaximumTagCount.Evaluate(level.Difficulty);

            int tagCount = (int)Math.Round(Random.Range(minTagCount, maxTagCount));

            TagList tagList = new TagList();

            for (int i = 0; i < tagCount; i++)
            {
                if (tags.Count == 0)
                {
                    break;
                }
                int roll     = (int)(Random.Range(0, weight));
                int tagIndex = 0;
                while (roll > tags[tagIndex].Weight)
                {
                    roll -= tags[tagIndex].Weight;
                    tagIndex++;
                }
                TagIdentifier tagIdentifier = tags[tagIndex].TagIdentifier;
                tagList.Add(tagIdentifier.Object);
                weight -= tags[tagIndex].Weight;
                tags.RemoveAt(tagIndex);
            }
            if (tagList.Count == 0)
            {
                tagList.Add(m_DefaultTag.Object);
            }
            level.TagList = tagList;
        }
        public override void GenerateAttributes(ProceduralLevel level)
        {
            //check if attribute from tag or random
            float minAttributeCount = m_MinimumAttributeCount.Evaluate(level.Difficulty);
            float maxAttributeCount = m_MaximumAttributeCount.Evaluate(level.Difficulty);

            int attributeCount = (int)Math.Round(Random.Range(minAttributeCount, maxAttributeCount));

            List <ValueMod> attributes = new List <ValueMod>();

            for (int i = 0; i < attributeCount; i++)
            {
                float  roll         = Random.Range(0.0f, 1.0f);
                Mod[]  rollableMods = null;
                string tag          = "";
                if (roll <= m_ChanceToPickAttributeFromTag)
                {
                    if (level.TagList.Count > 0)
                    {
                        int tagRoll = Random.Range(0, level.TagList.Count);
                        rollableMods = ModifierManager.GetModifiersForDomainAndTag(2, level.TagList[tagRoll].Identifier);
                        tag          = level.TagList[tagRoll].Identifier;
                    }
                    if (rollableMods == null || rollableMods.Length == 0)
                    {
                        rollableMods = ModifierManager.GetModifiersForDomain(2);
                        tag          = m_DefaultTag.Identifier;
                    }
                }
                else
                {
                    rollableMods = ModifierManager.GetModifiersForDomain(2);
                    tag          = m_DefaultTag.Identifier;
                }

                if (rollableMods == null)
                {
                    continue;
                }
                ValueMod valueMod = ModUtils.Roll(rollableMods.ToArray(), tag);
                if (valueMod == null)
                {
                    continue;
                }
                attributes.Add(valueMod);
            }

            level.Attributes = attributes.ToArray();
        }
        public override void GenerateName(ProceduralLevel level)
        {
            int roll = Random.Range(0, m_LevelNames.Length);

            level.LevelName.LocalizedIdentifier = m_LevelNames[roll];

            if (m_LevelPrefixes.Length > 0) //&& Random.Range(0,1.0f) >= 0.5f)
            {
                roll = Random.Range(0, m_LevelPrefixes.Length);
                level.LevelPrefix.LocalizedIdentifier = m_LevelPrefixes[roll];
            }
            //if (m_LevelSuffixes.Length > 0 && Random.Range(0, 1.0f) >= 0.5f)
            //{
            //    roll = Random.Range(0, m_LevelSuffixes.Length);
            //    level.LevelSuffix.LocalizedIdentifier = m_LevelSuffixes[roll];
            //}
        }
        public override void GeneratePossibleEnemies(ProceduralLevel level)
        {
            float maxEnemyDifficulty = m_MaximumEnemyDifficulty.Evaluate(level.Difficulty);

            Enemy[]      enemies         = ObjectsManager.GetAllObjects <Enemy>();
            List <Enemy> possibleEnemies = new List <Enemy>();

            foreach (Enemy enemy in enemies)
            {
                if (!enemy.IsSpawnable)
                {
                    continue;
                }
                if (enemy.Difficulty > maxEnemyDifficulty)
                {
                    continue;
                }
                possibleEnemies.Add(enemy);
            }
            if (possibleEnemies.Count == 0)
            {
                return;
            }

            possibleEnemies.Sort((a, b) => { return(a.Difficulty < b.Difficulty ? 1 : -1); });

            List <Enemy> selectedEnemies       = new List <Enemy>();
            float        chanceForSelection    = 0.8f;
            float        reductionPerSelection = 0.75f;

            foreach (Enemy enemy in possibleEnemies)
            {
                if (Random.Range(0.0f, 1.0f) <= chanceForSelection)
                {
                    selectedEnemies.Add(enemy);
                    chanceForSelection *= reductionPerSelection;
                }
            }

            if (selectedEnemies.Count == 0)
            {
                selectedEnemies.Add(possibleEnemies[0]);
            }

            level.PossibleEnemies = selectedEnemies.ToArray();
        }
 public abstract void Init(ProceduralLevel level);
 public override void Init(ProceduralLevel level)
 {
     level.Display = m_LevelDisplay;
 }
 public override void GenerateSpawnCredits(ProceduralLevel level)
 {
     level.MinimumSpawnCredits = (int)m_MinimumSpawnCredits.Evaluate(level.Difficulty);
     level.MaximumSpawnCredits = (int)m_MaximumSpawnCredits.Evaluate(level.Difficulty);
 }
 public abstract void GenerateWaveDelay(ProceduralLevel level);
 public abstract void GenerateWaveCount(ProceduralLevel level);
 public abstract void GenerateTags(ProceduralLevel level);
 public abstract void GenerateAttributes(ProceduralLevel level);
 public abstract void GenerateName(ProceduralLevel level);
 public abstract void GenerateSpawnCredits(ProceduralLevel level);
 public abstract void GenerateEnemyLevel(ProceduralLevel level, int playerLevel);
 public abstract void GeneratePossibleEnemies(ProceduralLevel level);