コード例 #1
0
        public void AddNewRuleset(List <RuleData> defaultRules = null)
        {
            //convert from json to object
            RulesetList rsets = JsonUtility.FromJson <RulesetList>(
                PlayerPrefs.GetString(c_RulesetsKey)
                );

            //copy default rules if not null
            if (defaultRules != null)
            {
                rsets.list.Add(new RuleDataList(defaultRules, c_NewRulesetName));
            }
            else
            {
                rsets.list.Add(new RuleDataList(c_NewRulesetName));
            }

            //save
            PlayerPrefs.SetString(c_RulesetsKey,
                                  //convert from object to json
                                  JsonUtility.ToJson(rsets)
                                  );

            PlayerPrefs.Save();
        }
コード例 #2
0
        public void ChangeCurrentRulesetName(string str)
        {//convert from json to object
            RulesetList rsets = JsonUtility.FromJson <RulesetList>(
                PlayerPrefs.GetString(c_RulesetsKey)
                );

            rsets.list[CurrentRulesetIndex].name = str;

            //save
            PlayerPrefs.SetString(c_RulesetsKey,
                                  //convert from object to json
                                  JsonUtility.ToJson(rsets)
                                  );

            PlayerPrefs.Save();
        }
コード例 #3
0
        public void SetMaxNeighbors(int ruleIndex, int newValue)
        {
            //convert from json to object
            RulesetList rsets = JsonUtility.FromJson <RulesetList>(
                PlayerPrefs.GetString(c_RulesetsKey)
                );

            rsets.list[CurrentRulesetIndex].list[ruleIndex].m_MaxNumNeighbors = newValue;

            //save
            PlayerPrefs.SetString(c_RulesetsKey,
                                  //convert from object to json
                                  JsonUtility.ToJson(rsets)
                                  );

            PlayerPrefs.Save();
        }
コード例 #4
0
        internal void DeleteRule(int ruleIndex)
        {
            //convert from json to object
            RulesetList rsets = JsonUtility.FromJson <RulesetList>(
                PlayerPrefs.GetString(c_RulesetsKey)
                );

            rsets.list[CurrentRulesetIndex].list.RemoveAt(ruleIndex);

            //save
            PlayerPrefs.SetString(c_RulesetsKey,
                                  //convert from object to json
                                  JsonUtility.ToJson(rsets)
                                  );

            PlayerPrefs.Save();
        }
コード例 #5
0
        public void AddNewRule(RuleData rd)
        {
            //convert from json to object
            RulesetList rsets = JsonUtility.FromJson <RulesetList>(
                PlayerPrefs.GetString(c_RulesetsKey)
                );

            rsets.list[CurrentRulesetIndex].list.Add(rd);

            //save
            PlayerPrefs.SetString(c_RulesetsKey,
                                  //convert from object to json
                                  JsonUtility.ToJson(rsets)
                                  );

            PlayerPrefs.Save();
        }
コード例 #6
0
        private void DeleteRuleset(int index)
        {
            Debug.Assert(index > 0 && index < NumRulesets);

            //convert json to object
            RulesetList rsets = JsonUtility.FromJson <RulesetList>(
                PlayerPrefs.GetString(c_RulesetsKey)
                );

            //delete ruleset
            rsets.list.RemoveAt(index);

            //save
            PlayerPrefs.SetString(c_RulesetsKey,
                                  //convert from object to json
                                  JsonUtility.ToJson(rsets)
                                  );

            PlayerPrefs.Save();
        }