예제 #1
0
        public override void ParseDefinition(string definitionKey, JsonData jsonData)
        {
            this.definitionKey = definitionKey;

            var keys = jsonData.Keys;

            this.name         = ContentHelper.ParseString(jsonData, D.NAME, definitionKey);
            this.memberName   = ContentHelper.ParseString(jsonData, "member", definitionKey);
            this.rivalFaction = ContentHelper.ParseString(jsonData, "rivalFaction", definitionKey);


            this.startingReputation = ContentHelper.ParseInt(jsonData, D.STARTING_REPUTATION, 50);
        }
예제 #2
0
        public void InitializeFromData(JsonData gameParamData)
        {
            var constantsData = gameParamData[P.CONSTANTS];
            var constantKeys  = constantsData.Keys;

            startingPawns = ContentHelper.ParseInt(gameParamData, P.STARTING_PAWNS, 9001);
            startingGold  = ContentHelper.ParseInt(gameParamData, P.STARTING_GOLD, 9001);


            foreach (var constantKey in constantKeys)
            {
                constants[constantKey] = ContentHelper.ParseDouble(constantsData, constantKey, 0d);
            }

            timeMultiplier = ContentHelper.ParseDouble(gameParamData, P.TIME_MULTIPLIER, this.timeMultiplier);

            if (gameParamData.Keys.Contains(P.NEED_PARAMS))
            {
                var needParamData = gameParamData[P.NEED_PARAMS];

                if (needParamData.Keys.Contains(P.NEEDS))
                {
                    var needsData = needParamData[P.NEEDS];

                    if (needsData.IsArray)
                    {
                        var count = needsData.Count;
                        needParams.needs = new string[count];

                        for (int i = 0; i < count; i++)
                        {
                            needParams.needs[i] = needsData[i].ToString();
                        }
                    }
                }
            }
        }