Ejemplo n.º 1
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);
                }
            }
        }
Ejemplo n.º 2
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;
                }
            }
        }
Ejemplo n.º 3
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];
     }
 }
Ejemplo n.º 4
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);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
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];
            }
        }