Пример #1
0
    /** Saves all game state data to permant storage. */
    public void Save()
    {
        if (!Loaded)
        {
            Trace.LogWarning("Tried to save game before game was initialized.");
            return;
        }

        DateTime startTime = DateTime.Now;

        CoM.Profile.SaveVersion   = SAVE_VERSION;
        CoM.Profile.SaveTimeStamp = DateTime.Now;

        StateStorage.SaveData("Characters", CharacterList);
        StateStorage.SaveData("Parties", PartyList);
        StateStorage.SaveData("ExploredDungeon", ExploredDungeon);
        StateStorage.SaveData("Store", Store);
        StateStorage.SaveData("GameStats", GameStats);
        StateStorage.SaveData("SpawnData", SpawnManager);
        StateStorage.SaveData("Profile", CoM.Profile);

        TimeSpan delta = (DateTime.Now - startTime);

        Trace.Log("Game saved. [" + delta.TotalMilliseconds.ToString("0.0") + "ms]");
    }
Пример #2
0
        private void testDataSerialization()
        {
            var dataObject = new TestClass();

            StateStorage.SaveData("TestClass", dataObject);

            ValidateReadWrite();
        }
Пример #3
0
Файл: CoM.cs Проект: bsimser/CoM
 /** Writes all static game data to storage with optional compression */
 public static void WriteStaticDataToStorage(bool compression = false)
 {
     StateStorage.SaveData("Dungeon", Dungeon, compression);
     StateStorage.SaveData("Guilds", Guilds, compression);
     StateStorage.SaveData("Races", Races, compression);
     StateStorage.SaveData("ItemClasses", ItemClasses, compression);
     StateStorage.SaveData("ItemTypes", ItemTypes, compression);
     StateStorage.SaveData("Items", Items, compression);
     StateStorage.SaveData("MonsterClasses", MonsterClasses, compression);
     StateStorage.SaveData("MonsterTypes", MonsterTypes, compression);
     StateStorage.SaveData("Monsters", Monsters, compression);
     StateStorage.SaveData("SpellClasses", SpellClasses, compression);
     StateStorage.SaveData("Spells", Spells, compression);
 }
Пример #4
0
        /** Writes out each object in library, reads it back in, and makes sure they are the same */
        private bool Validate <T>(DataLibrary <T> library) where T : NamedDataObject
        {
            List <string> differences = new List <string>();

            foreach (NamedDataObject item in library)
            {
                StateStorage.SaveData("validationtest", item);
                object loadedItem = StateStorage.LoadData <T>("validationtest");
                if (!Util.CompareProperites(item, loadedItem, ref differences))
                {
                    Trace.LogWarning("Validation failed on " + typeof(T) + ": " + String.Join(",", differences.ToArray()) + "]");
                    return(false);
                }
            }

            Trace.Log("Validation passed for " + typeof(T));

            return(true);
        }
Пример #5
0
    void OnToggleChanged(Toggle t, string name, PageType pt, bool isOn, GameObject child)
    {
        if (isOn)
        {
            m_CurContestRankingToggle = null;
            CustomAudio.GetInstance().PlayCustomAudio(1003);
            if (pt == PageType.ePT_Chess)
            {
                m_CurContestRankingToggle = t.gameObject;
                if (ContestGameDataDictionary.ContainsKey(t.gameObject))
                {
                    string [] ValueString = ContestGameDataDictionary[t.gameObject].Split('|');
                    if (ValueString.Length == 2)
                    {
                        long ContestID = 0;
                        long.TryParse(ValueString[0], out ContestID);
                        int PlayetNumber = 0;
                        int.TryParse(ValueString[1], out PlayetNumber);
                        CGameContestRankingTifings.GetChessRankingInstance().SetSelectContestID(ContestID);
                        CGameContestRankingTifings.GetChessRankingInstance().CreateGameRankingPlayerUIOjbect(PlayetNumber, true);
                    }
                }
                CGameContestRankingTifings.GetChessRankingInstance().ResetChessRanking();
            }
            else if (pt == PageType.ePT_Activity)
            {
                GameObject obj = t.transform.Find("ImageSpot").gameObject;
                if (obj.activeSelf)
                {
                    NeedClick--;
                    obj.SetActive(false);
                    StateStorage.SaveData(pt + ":" + name, true);
                }
            }
        }

        if (child != null)
        {
            child.SetActive(isOn);
        }
    }
Пример #6
0
    bool HandleStepInfo(uint _msgType, UMessage _ms)
    {
        m_ActionsList.Clear();
        long nVideoid = _ms.ReadLong();     //录像ID
        byte nIndex   = _ms.ReadByte();     //第几局
        byte res      = _ms.ReadByte();     //是否成功 1成功有数据 0没有

        if (res == 0)
        {
            return(false);
        }
        ushort nSize = _ms.ReaduShort();    //有多少条数据

        for (int i = 0; i < nSize; i++)
        {
            VideoAction ac    = new VideoAction();
            float       nTime = _ms.ReadSingle();    //发生时间
            ac.userId = _ms.ReadUInt();              //做这个事件的useid
            ushort nAction = _ms.ReaduShort();       //事件编号
            ac.vai = (VideoActionInfo_Enum)nAction;
            ushort nParameterNum = _ms.ReaduShort(); //有多少参数

            for (int k = 0; k < nParameterNum; k++)
            {
                int nParameter = _ms.ReadInt();     //
                ac.list.Add(nParameter);
            }
            m_ActionsList.Add(ac);
        }

        String key = nVideoid + ":" + nIndex;

        StateStorage.SaveData(key, m_ActionsList);

        StartPlay(nIndex);

        return(true);
    }
Пример #7
0
    public static void SaveSettings()
    {
        if (!IsLoaded)
        {
            Trace.LogWarning("Tried saving settings, but settings are not yet loaded.");
            return;
        }

        XElement node = new XElement("Settings");
        XElement subNode;

        subNode = new XElement("General");
        General.WriteNode(subNode);
        node.Add(subNode);

        subNode = new XElement("Advanced");
        Advanced.WriteNode(subNode);
        node.Add(subNode);

        StateStorage.SaveData("Settings", node);

        PlayerPrefs.Save();
    }
Пример #8
0
 /// <summary>
 /// 保存游戏排行榜数据
 /// </summary>
 public void SaveContestRankingData()
 {
     StateStorage.SaveData <SerializableDictionary <long, SerializableDictionary <int, CPlayerRankingInfo> > >(Key, ContestRankingDataDictionary);
 }
Пример #9
0
 /** Saves just the characters. */
 public void SaveCharacters()
 {
     StateStorage.SaveData("Characters", CharacterList);
 }