コード例 #1
0
        void ParseColorSpawnPercentages(JSONNode data)
        {
            var dict = data.GetDictionary(COLOR_SPAWN_PERCENTAGES);

            colorSpawnPercentages.Clear();

            if (dict.Count > 0)
            {
                try
                {
                    foreach (var key in dict.Keys)
                    {
                        int amount  = (int)dict[key];
                        var colorId = LevelEditorUtils.ParseEnum <ColorId>(key.UppercaseFirst());
                        colorSpawnPercentages[colorId] = amount;
                    }
                }
                catch (Exception ex)
                {
                    colorSpawnPercentages.Clear();
                    Debug.Log("LEVEL : colorSpawnPercentages = " + JSON.Serialize(dict));
                    Debug.LogError("Failed to parse colorSpawnPercentages" + ex.Message);
                }
            }
            else
            {
                foreach (var color in ColorUtils.allColors)
                {
                    colorSpawnPercentages[color] = COLOR_CHANCE;
                }
            }
        }
コード例 #2
0
        void UpdateGameUniqueData(string gameSpecificPath)
        {
            var node = LevelEditorUtils.JSONNodeFromFileResourcesPath(gameSpecificPath);

            BoardWidth  = node.GetInt(FIELD_BOARD_WIDTH);
            BoardHeight = node.GetInt(FIELD_BOARD_HEIGHT);

            InvisibleBoardIndex = new List <int>();
            var invisible_board_index = node.GetCollection("invisible_board_index");

            foreach (var item in invisible_board_index)
            {
                InvisibleBoardIndex.Add(item.AsInt());
            }

            //关卡类型与数字段的对应关系
            LevelNumToLevelType = new SortedDictionary <int, string>();
            var dic = node.GetDictionary(FIELD_LEVELNUM_TO_TYPE);

            foreach (var item in dic)
            {
                LevelNumToLevelType.Add(item.Value.AsInt(), item.Key);
            }

            SortLevelBeforeThisNum = node.GetInt(FIELD_SORTLEVELNUM_BEFORE);

            LevelsPerFile = node.GetInt(FIELD_LEVELS_PER_FILE);

            LevelNumOrigin = node.GetInt(FIELD_LEVELS_NUM_ORIGIN);

            Layers = new List <string>();
        }
コード例 #3
0
        void ParseColorSpawningOrder(JSONNode data)
        {
            if (!data.HasKey(COLOR_SPAWNING_ORDER))
            {
                return;
            }

            var items = data.GetCollection(COLOR_SPAWNING_ORDER);

            if (items.Count > 0)
            {
                colorSpawningOrder.Clear();

                try
                {
                    foreach (var item in items)
                    {
                        ColorId colorId = LevelEditorUtils.ParseEnum <ColorId>(item.AsString().UppercaseFirst());
                        colorSpawningOrder.Add(colorId);
                    }
                }
                catch (Exception ex)
                {
                    colorSpawningOrder.Clear();
                    Debug.LogError("LEVEL : Failed to parse colorSpawningOrder" + ex.Message);
                }
            }
        }
コード例 #4
0
        void UpdateLevelSettingsData(string path)
        {
            var node = LevelEditorUtils.JSONNodeFromFileResourcesPath(path);

            if (node != null)
            {
                levelSettingConfig = new LevelSettingConfig();
                levelSettingConfig.Update(node);
            }
        }
コード例 #5
0
        public static List <string> GetGameTypes()
        {
            List <string> gameTypes = new List <string>();
            var           node      = LevelEditorUtils.JSONNodeFromFileResourcesPath(FILE_META);
            var           games     = node.GetCollection(FIELD_GAMES);

            foreach (var item in games)
            {
                gameTypes.Add(item.AsString());
            }
            return(gameTypes);
        }
コード例 #6
0
 void ParseCompanion(JSONObject companion)
 {
     if (companion.Count == 0 ||
         !companion.ContainsKey(TYPE))
     {
         companionType           = CompanionTypeId.Empty;
         companionRequiredCharge = 0;
     }
     else
     {
         companionType           = LevelEditorUtils.ParseEnum <CompanionTypeId>(companion[TYPE].AsString());
         companionRequiredCharge = (int)companion[REQUIRED_CHARGE];
     }
 }
コード例 #7
0
        void LoadLevelList()
        {
            _levelList = new LevelDataList();

            foreach (var typename in LevelEditorInfo.Instance.LevelNumToLevelType.Values)
            {
                var files = Directory.GetFiles(LevelEditorInfo.Instance.FullConfigurationFolderPath, typename + ".json");
                foreach (var filename in files)
                {
                    var node = LevelEditorUtils.JSONNodeFromFileFullPath(filename);

                    _levelList.Update(node);
                }
            }
        }
コード例 #8
0
        void UpdateGameItems(string itemsPath)
        {
            var node = LevelEditorUtils.JSONNodeFromFileResourcesPath(itemsPath);

            DicBoardItem = new Dictionary <string, BoardItem>();
            _itemSprites = new Dictionary <string, Sprite>();
            var collection = node.GetCollection("items");

            foreach (var data in collection)
            {
                BoardItem t = new BoardItem();
                t.Update(data);
                Sprite s = Resources.Load <Sprite>(WhichGame + "/Sprites/" + t.SpriteId);
                _itemSprites.Add(t.Name, s);
                DicBoardItem.Add(t.Name, t);
            }
        }
コード例 #9
0
        private void Start()
        {
            JSONNode node = LevelEditorUtils.JSONNodeFromFileResourcesPath(
                LevelEditorInfo.Instance.EditorConfigPath + LevelEditorInfo.FILE_BRUSH);

            UpdateData(node);



            foreach (var data in _list)
            {
                BrushCatView cat = Instantiate(prefabBrushCatView);
                cat.transform.SetParent(brushRoot);
                cat.transform.localScale = new Vector3(1, 1, 1);
                cat.SetData(data);
            }
        }
コード例 #10
0
        public void LoadAllInfo()
        {
            UpdateMetaInfo();

            CheckWhichGame();


            UpdateGameUniqueData(EditorConfigPath + FILE_GAME_UNIQUE);

            UpdateLevelSettingsData(EditorConfigPath + FILE_LEVEL_SETTINGS);

            UpdateGameItems(EditorConfigPath + FILE_GAME_ITEMS);

            //other game unique data
            gameConfig = new GameConfig();
            var gameConfigNode = LevelEditorUtils.JSONNodeFromFileFullPath(FullConfigurationFolderPath + FILE_GAME_CONFIG);

            gameConfig.Update(gameConfigNode);

            UpdateDefault();
        }
コード例 #11
0
        void ParseConditions(JSONObject conditions)
        {
            typeWinningConditions.Clear();
            colorWinningConditions.Clear();
            skillWinningConditions.Clear();
            var keys = conditions.Keys;

            foreach (string key in keys)
            {
                if (key == SCORE)
                {
                    minScoreWinningCondition = (int)conditions[key];
                }
                else if (key == MOVESOVER)
                {
                    movesOver = (int)conditions[key] > 0?true:false;
                }
                else
                {
                    if (LevelEditorInfo.Instance.levelSettingConfig.ObjectiveCollection.Contains(key))
                    {
                        int amount = (int)conditions[key];
                        typeWinningConditions.Add(key, amount);
                    }
                    else
                    {
                        try
                        {
                            string[] colorsStrings = key.Split(',');

                            var colorIds = new List <ColorId>();

                            foreach (string colorString in colorsStrings)
                            {
                                ColorId colorId = LevelEditorUtils.ParseEnum <ColorId>(colorString.UppercaseFirst());
                                colorIds.Add(colorId);
                            }

                            int amount = (int)conditions[key];

                            var colorWinningCondition = new ColorWinningCondition();
                            colorWinningCondition.amount = amount;
                            colorWinningCondition.colors = colorIds;

                            colorWinningConditions.Add(colorWinningCondition);
                        }
                        catch
                        {
                            try
                            {
                                CompanionTypeId skillType = LevelEditorUtils.ParseEnum <CompanionTypeId>(key);
                                int             amount    = (int)conditions[key];
                                skillWinningConditions.Add(skillType, amount);
                            }
                            catch
                            {
                                Debug.LogWarning("Could not parse winning condition for key = " + key + ", levelNum = " + levelNum);
                            }
                        }
                    }
                }
            }
        }
コード例 #12
0
        public void SaveSettingsToLevelData()
        {
            //单个数据

            _level.name                    = _levelName;
            _level.levelNum                = _levelNum;
            _level.maxMoves                = _moves;
            _level.companionType           = _companionType;
            _level.companionRequiredCharge = _companionCharge;
            _level.acsMax                  = _acsMax;
            _level.acsMin                  = _acsMin;
            _level.starThresholds          = new List <int>(_mastery);

            //supergem

            _level.superMergingEnabled = _superMergingEnabled;
            _level.preventItems        = new List <string>(_preventItems);
            //Items

            List <ColorId> colorOrderList = new List <ColorId>();

            for (int i = 0; i < 6; i++)
            {
                var item = _colorOrder.Find(x => x.amount == i);
                if (item != null)
                {
                    colorOrderList.Add(LevelEditorUtils.ParseEnum <ColorId>(item.itemType));
                }
            }
            _level.colorSpawningOrder = colorOrderList;


            foreach (var item in _itemSpawnChance)
            {
                _level.itemSpawnPercentages[item.itemType] = item.amount;
            }


            foreach (var item in _itemSpawnMin)
            {
                _level.itemSpawnMin[item.itemType] = item.amount;
            }


            foreach (var item in _itemSpawnMax)
            {
                _level.itemSpawnMax[item.itemType] = item.amount;
            }


            foreach (var item in _totalMin)
            {
                _level.itemTotalSpawnMin[item.itemType] = item.amount;
            }


            foreach (var item in _totalMax)
            {
                _level.itemTotalSpawnMax[item.itemType] = item.amount;
            }


            foreach (var item in _ensureItems)
            {
                _level.ensureItems[item.itemType] = item.amount;
            }


            List <ColorWinningCondition> colorWinningCondition = new List <ColorWinningCondition>();

            if (_combineObjective)
            {
                ColorWinningCondition condition = new ColorWinningCondition();
                condition.colors = new List <ColorId>();
                foreach (var item in _objectiveColor)
                {
                    if (item.amount != 0)
                    {
                        condition.colors.Add(LevelEditorUtils.ParseEnum <ColorId>(item.itemType));
                    }
                }
                if (condition.colors.Count != 0)
                {
                    condition.amount = _combineTotal;
                    colorWinningCondition.Add(condition);
                }
            }
            else
            {
                foreach (var item in _objectiveColor)
                {
                    if (item.amount != 0)
                    {
                        ColorWinningCondition condition = new ColorWinningCondition();
                        condition.colors = new List <ColorId>();
                        condition.colors.Add(LevelEditorUtils.ParseEnum <ColorId>(item.itemType));
                        condition.amount = item.amount;
                        colorWinningCondition.Add(condition);
                    }
                }
            }
            _level.colorWinningConditions = colorWinningCondition;

            foreach (var item in _objectives)
            {
                if (item.amount != 0)
                {
                    _level.typeWinningConditions[item.itemType] = item.amount;
                }
            }

            _level.movesOver = _moveOver;

            //boss

            _level.bossName = _bossNames[_bossIndex] == NO_BOSS_STRING ? "0" : _bossNames[_bossIndex];


            if (_spawningSetIndex < 0)
            {
                _level.spawningSetName = "";
            }
            else
            {
                _level.spawningSetName = _spawningSets[_spawningSetIndex];
            }
        }