コード例 #1
0
        void AppendGlobalInitData()
        {
            foreach (InitData dat in globalStartData)
            {
                if (!string.IsNullOrEmpty(dat.name))
                {
                    //check if data exists in user first
                    string key = string.Format(GlobalDataFormat, dat.name);

                    StateValue s = dat.stateValue;
                    s.Apply(UserData.main, key);
                    if (s.type != Type.Invalid)
                    {
                        if (mGlobalStates.ContainsKey(dat.name))
                        {
                            mGlobalStates[dat.name] = s;
                        }
                        else
                        {
                            mGlobalStates.Add(dat.name, s);
                        }

                        if (onValueChange != null)
                        {
                            onValueChange(true, dat.name, s);
                        }
                    }
                }
            }
        }
コード例 #2
0
        void AppendInitData()
        {
            InitData[] dats;
            if (mStartData.TryGetValue(mScene, out dats))
            {
                foreach (InitData dat in dats)
                {
                    if (!string.IsNullOrEmpty(dat.name))
                    {
                        //check if data exists in user first
                        string key = string.Format(DataFormat, mScene, dat.name);

                        StateValue s = dat.stateValue;
                        s.Apply(UserData.main, key);
                        if (s.type != Type.Invalid)
                        {
                            if (mStates.ContainsKey(dat.name))
                            {
                                mStates[dat.name] = s;
                            }
                            else
                            {
                                mStates.Add(dat.name, s);
                            }

                            if (onValueChange != null)
                            {
                                onValueChange(false, dat.name, s);
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        void OnUserDataAction(UserData ud, UserData.Action act)
        {
            switch (act)
            {
            case UserData.Action.Load:
                //update global states
                if (mGlobalStates != null && mGlobalStates.Count > 0)
                {
                    string[] keys = new string[mGlobalStates.Count];
                    mGlobalStates.Keys.CopyTo(keys, 0);

                    foreach (string key in keys)
                    {
                        StateValue val = mGlobalStates[key];
                        val.Apply(ud, string.Format(GlobalDataFormat, key));
                        mGlobalStates[key] = val;
                    }
                }

                //update states
                if (mStates != null && mStates.Count > 0 && !string.IsNullOrEmpty(mScene))
                {
                    string[] keys = new string[mStates.Count];
                    mStates.Keys.CopyTo(keys, 0);

                    foreach (string key in keys)
                    {
                        StateValue val = mStates[key];
                        val.Apply(ud, string.Format(DataFormat, mScene, key));
                        mStates[key] = val;
                    }
                }
                break;
            }
        }