コード例 #1
0
        public LevelTree(int nodeType, int id, int difficulty, int depth = -1, LevelParams levelParams = null, string name = null, string desc = null, string fixedRewardDescription = null)
        {
            levelData = null;

            Unlocked = false;

            LevelReward = new DropInfo();

            this.LevelNodeType = nodeType;
            this.Id            = id;
            this.Depth         = depth;
            this.Difficulty    = difficulty;
            this.LevelParams   = levelParams;
            this.Name          = name;
            this.Description   = desc;

            if (fixedRewardDescription != null)
            {
                hardcodedRewardDesc = fixedRewardDescription;
            }
            else
            {
                hardcodedRewardDesc = null;
            }
        }
コード例 #2
0
        private MapType GetNextLevelType(int level, ref int mapLevel, LevelParams param)
        {
            MapType nextLevel = MapType.SixRegions;

            switch (level)
            {
            case 1:
                param.mapLevel = 1;
                nextLevel      = MapType.BossRush;
                break;

            case 2:
                param.mapLevel = 1;
                param.variant  = Random.Range(1, 3);
                nextLevel      = MapType.FourRegion;
                break;

            case 3:
                param.mapLevel = 1;
                param.variant  = Random.Range(1, 3);
                nextLevel      = MapType.FindBoss;
                break;
            }

            return(nextLevel);
        }
コード例 #3
0
        public void GenerateAndOpenLevel(LevelTree levelNode)
        {
            LevelParams param = levelNode.LevelParams;

            // map hasnt been generated yet
            if (!maps.ContainsKey(new Cords(levelNode.Id, 0)))
            {
                MapHolder newMap = new MapHolder(this, levelNode.Name, new Cords(levelNode.Id, 0), param.levelType, width, height, param, levelNode.LevelReward);

                newMap.CreateMap();
                maps.Add(new Cords(levelNode.Id, 0), newMap);

                levelNode.levelData = newMap.levelData;
            }

            foreach (LevelTree n in mapTree.GetAllNodes())
            {
                n.CurrentlyActive = false;
            }

            levelNode.CurrentlyActive = true;
            levelNode.Unlocked        = true;

            SetActiveLevel(levelNode.Id, 0, false);
        }
コード例 #4
0
        public LevelTree CreateRandomExtraNodeLevel(int id, int depth)
        {
            LevelParams param      = new LevelParams(MapType.GenericMonster);        //TODO new types
            int         difficulty = LevelTree.DIFF_MEDIUM;

            if (worldLevel == 1)             // medium or easy levels
            {
                int rnd = Random.Range(0, 100);
                if (rnd < 50)
                {
                    difficulty = LevelTree.DIFF_EASY;
                }
            }
            else             // also hard levels possible - TODO
            {
                int rnd = Random.Range(0, 100);
                if (rnd < 50)
                {
                    difficulty = LevelTree.DIFF_EASY;
                }
                else if (rnd < 80)
                {
                    difficulty = LevelTree.DIFF_HARD;
                }
            }

            param.difficulty = difficulty;

            LevelTree newNode = new LevelTree(LevelTree.LEVEL_EXTRA, id, difficulty, depth, param, "Extra Level " + id, "This level is filled with random monsters.");

            switch (difficulty)
            {
            case 1:
                //newNode.AddLevelRewardRandom(66, ItemType.STAT_UPGRADE, 1, 1);
                newNode.AddLevelReward(typeof(DnaItem), 100, 3, 100);
                newNode.AddLevelReward(typeof(XpItem), 100, 4, 100);
                break;

            case 2:
                //newNode.AddLevelRewardRandom(100, ItemType.STAT_UPGRADE, 1, 1);
                newNode.AddLevelReward(typeof(DnaItem), 100, 3, 100);
                newNode.AddLevelReward(typeof(XpItem), 100, 4, 100);
                break;

            case 3:
                //newNode.AddLevelRewardRandom(100, ItemType.STAT_UPGRADE, 1, 1);
                //newNode.AddLevelRewardRandom(100, ItemType.CLASSIC_UPGRADE, 1, 1);
                newNode.AddLevelReward(typeof(DnaItem), 100, 3, 250);
                newNode.AddLevelReward(typeof(XpItem), 100, 4, 250);
                break;
            }

            return(newNode);
        }
コード例 #5
0
        public LevelTree CreateRandomMainNodeLevel(int id, int depth, bool addShop, int difficulty)
        {
            LevelParams param = new LevelParams(MapType.GenericMonster);

            param.difficulty = difficulty;

            /*if (addShop) // already added to the first level
             * {
             *      param.shop = new ShopData();
             *      param.shop.GenerateRandomShopItems(worldLevel, 2);
             * }*/

            LevelTree newNode = new LevelTree(LevelTree.LEVEL_MAIN, id, difficulty, depth, param, "Level " + id, "This level is filled with random monsters.");

            switch (difficulty)
            {
            case 1:
                //newNode.AddLevelRewardRandom(100, ItemType.STAT_UPGRADE, 1, 1);

                newNode.AddLevelReward(typeof(DnaItem), 100, 3, 100);
                newNode.AddLevelReward(typeof(XpItem), 100, 4, 100);
                break;

            case 2:
                //newNode.AddLevelRewardRandom(100, ItemType.STAT_UPGRADE, 1, 1);

                newNode.AddLevelReward(typeof(DnaItem), 100, 3, 100);
                newNode.AddLevelReward(typeof(XpItem), 100, 4, 100);
                break;

            case 3:
                //newNode.AddLevelRewardRandom(100, ItemType.STAT_UPGRADE, 1, 1);

                newNode.AddLevelReward(typeof(DnaItem), 100, 3, 250);
                newNode.AddLevelReward(typeof(XpItem), 100, 4, 250);
                break;
            }

            return(newNode);
        }
コード例 #6
0
        private void GenerateWorldLevels()
        {
            int         id    = 0;
            LevelParams param = new LevelParams(MapType.LevelOne);

            param.worldLevel = worldLevel;

            if (GameSession.testMode)
            {
                param.levelType = MapType.PresentationLevel;
                mapTree         = new LevelTree(LevelTree.LEVEL_MAIN, id++, LevelTree.DIFF_MEDIUM, 0, param, "Start level", "Unknown");
            }
            else if (GameSession.arenaMode)
            {
                param.levelType = MapType.Arena;
                mapTree         = new LevelTree(LevelTree.LEVEL_MAIN, id++, LevelTree.DIFF_MEDIUM, 0, param, "Start level", "Unknown");
            }
            else
            {
                if (worldLevel > 0)
                {
                    param.levelType = MapType.GenericMonster;

                    param.shop = new ShopData();
                    param.shop.GenerateRandomShopItems(worldLevel, 2);

                    //param.levelType = MapType.FinalBoss;
                    mapTree = new LevelTree(LevelTree.LEVEL_MAIN, id++, LevelTree.DIFF_MEDIUM, 0, param, "Start level", "This level is filled with random monsters.");
                }
                else
                {
                    param.levelType = MapType.LevelOne;
                    //param.levelType = MapType.Test;
                    mapTree = new LevelTree(LevelTree.LEVEL_MAIN, id++, LevelTree.DIFF_EASY, 0, param, "First Tutorial", "Unknown");
                }
            }


            //mapTree.AddLevelReward(typeof(Heal));
            mapTree.AddLevelReward(typeof(DnaItem), 100, 3, 100);
            mapTree.AddLevelReward(typeof(XpItem), 100, 4, 100);

            mapTree.Unlocked = true;

            int levelsCount   = 15;
            int mainLineCount = 4;
            int minGenericLevelsCount;
            int minSpecialLevelsCount;

            switch (worldLevel)
            {
            case 1:
                levelsCount   = 7;
                mainLineCount = 4;
                break;

            case 2:
                levelsCount   = Random.Range(10, 12);
                mainLineCount = 4;
                break;

            case 3:
                levelsCount   = Random.Range(10, 12);
                mainLineCount = 4;
                break;

            case 4:
                levelsCount   = Random.Range(14, 16);
                mainLineCount = 5;
                break;

            default:
                levelsCount   = 15;
                mainLineCount = 5;
                break;
            }

            int maxSpecialLevelsCount = Mathf.CeilToInt((levelsCount - mainLineCount) / 4);

            if (maxSpecialLevelsCount <= 0)
            {
                maxSpecialLevelsCount = 1;
            }

            // one level is already created
            levelsCount--;
            mainLineCount--;

            int counter = levelsCount;

            if (worldLevel > 0)             // main line for all worlds
            {
                int shopLevel = Random.Range(0, mainLineCount - 1);

                // main line - all medium
                for (int i = 0; i < mainLineCount; i++)
                {
                    LevelTree newNode = null;
                    param            = new LevelParams(MapType.LevelOne);
                    param.worldLevel = worldLevel;

                    // grand boss is the last level
                    if (i + 1 == mainLineCount)
                    {
                        param.levelType  = MapType.FinalBoss;
                        param.mapLevel   = worldLevel;
                        param.worldLevel = worldLevel;
                        newNode          = new LevelTree(LevelTree.LEVEL_MAIN, id++, LevelTree.DIFF_MEDIUM, i + 1, param, "Main" + id, "The final boss.");
                    }
                    else
                    {
                        newNode = CreateRandomMainNodeLevel(id++, i + 1, shopLevel == i, LevelTree.DIFF_MEDIUM);
                    }

                    if (newNode == null)
                    {
                        continue;
                    }

                    mapTree.GetLastMainNode().AddChild(newNode);

                    if (i + 1 == mainLineCount)
                    {
                        newNode.IsLastNode = true;
                    }

                    counter--;
                }
            }
            else             // main line for tutorial world
            {
                // main line - tutorial levels - all easy
                for (int i = 0; i < mainLineCount; i++)
                {
                    LevelTree newNode = null;
                    param            = new LevelParams(MapType.LevelOne);
                    param.worldLevel = worldLevel;

                    switch (i)
                    {
                    case 0:
                        param.levelType = MapType.LevelTwo;
                        newNode         = new LevelTree(LevelTree.LEVEL_MAIN, id++, LevelTree.DIFF_EASY, i + 1, param, "Second Tutorial", "Unknown");
                        break;

                    case 1:
                        param.levelType = MapType.LevelThree;
                        newNode         = new LevelTree(LevelTree.LEVEL_MAIN, id++, LevelTree.DIFF_EASY, i + 1, param, "Third Tutorial", "Unknown");
                        break;

                    case 2:
                        param.levelType = MapType.LevelFour;
                        newNode         = new LevelTree(LevelTree.LEVEL_MAIN, id++, LevelTree.DIFF_EASY, i + 1, param, "Fourth Tutorial", "Unknown");
                        break;

                    case 3:
                        param.levelType = MapType.LevelFive;
                        newNode         = new LevelTree(LevelTree.LEVEL_MAIN, id++, LevelTree.DIFF_EASY, i + 1, param, "Last Tutorial", "Unknown");
                        break;
                    }

                    if (newNode == null)
                    {
                        continue;                                      // shouldnt happen
                    }
                    mapTree.GetLastMainNode().AddChild(newNode);

                    if (i + 1 == mainLineCount)
                    {
                        newNode.IsLastNode = true;
                    }

                    counter--;
                }
            }

            if (worldLevel > 0)
            {
                for (int i = 0; i < counter; i++)
                {
                    LevelTree mainNode = mapTree.GetRandomMainNode();
                    LevelTree nextNode = CreateRandomExtraNodeLevel(id++, mainNode.Depth);
                    mainNode.AddChild(nextNode);
                }

                for (int i = 0; i < maxSpecialLevelsCount; i++)
                {
                    LevelTree mainNode = mapTree.GetRandomSpecialNode();
                    LevelTree nextNode = CreateRandomExtraNodeLevel(id++, mainNode.Depth);
                    mainNode.AddChild(nextNode);
                }
            }

            Debug.Log(mapTree.PrintInfo());
        }