Exemple #1
0
        /// <summary>
        /// Generates a new Level with the current LevelNo in GameManager.
        /// The Level can be builded by the LevelBuilder.
        /// </summary>
        /// <param name="difficulty">the level difficulty</param>
        /// <returns>The generated level</returns>
        public Level GenerateNextLevel(int difficulty)
        {
            int levelNo = GameManager.GetInstance().LevelNo;

            GameManager.GetInstance().LevelNo++;
            levelNo++;

            /*
             * // Try to obtain the jungle sections.
             * List<GameObject> _sectionArray = GetJungleSections();
             * if(_sectionArray.Count == 0)
             * {   // No jungle sections present -- simply fetch some random sections
             *  // (two for now).
             *  _sectionArray = GetRandomSections(2);
             * }
             */
            List <GameObject> sectionArray = GetFixedSections(3);

            Level newLevel     = new Level(difficulty, levelNo);
            int   sectionCount = sectionArray.Count;

            for (int i = 0; i < sectionCount; i++)
            {
                //// int rand = UnityEngine.Random.Range(0, _sectionPrefabs.Count - 1);
                Section newSection = new Section(sectionArray[i]);
                newSection.SectionNumber = i + 1;
                int x = ((levelNo - 1) * sectionCount) + i + 1;

                List <GameObject> mobs = Datasheet.Mobs();

                int monsterCount = (int)(((3 * x) + Math.Sin(1.5 * x) + 7) * Math.Sqrt(GameManager.GetInstance().GetAllTeams()[0].GetHeroTeamMembers().Count));
                for (int m = 0; m < monsterCount; m++)
                {
                    //// TODO: produce inbalance, so that easy mobs are more often, then hard mobs
                    int random = UnityEngine.Random.Range(0, mobs.Count);
                    newSection.AddMob(mobs[random].GetComponent <Mob>());
                }

                List <GameObject> mercenaries = Datasheet.Mercenaries();

                for (int m = 0; m < MercenaryCount; m++)
                {
                    // TODO: produce inbalance, so that easy mercs are more often, then hard mercs
                    int random = UnityEngine.Random.Range(0, mercenaries.Count);
                    newSection.AddMercenary(mercenaries[random].GetComponent <Mercenary>());
                }

                newLevel.AddSection(newSection);
            }

            return(newLevel);
        }