Пример #1
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();
                        }
                    }
                }
            }
        }
Пример #2
0
        public Game(string gameParamsKey, WundeeUnity.GameEntry mainMonoBehaviour)
        {
            Game.instance = this;

            this.definitions = new DataLoader();

            var gameParams = new GameParams();

            this.@params = gameParams;

            var gameParamsData = definitions.GetJsonDataFromYamlFile(DataLoader.GetContentFilePath() + "GameParams.yaml");

            ContentHelper.VerifyKey(gameParamsData, gameParamsKey, "PARAMS_READER");
            gameParams.InitializeFromData(gameParamsData[gameParamsKey]);

            this._GameEntry = mainMonoBehaviour;

            Time.gameTime = 0d;
            Time.realTime = 0d;

            Time.multiplier = gameParams.timeMultiplier;

            this.world = new World(this);
        }