コード例 #1
0
        public void init(Settings settings)
        {
            if (tsStart == 0)
            {
                tsStart = Main.getCurrentTimestamp();
            }
            if (playerGuid == null)
            {
                playerGuid = Guid.NewGuid().ToString();
            }

            tsSessionStarts.Add(currentGameStart);
            sessionIdx = tsSessionStarts.Count - 1;

            if (currentPark == null && currentParkGuid.Length > 0)
            {
                currentPark = new ParkData();
                currentPark.setGuid(currentParkGuid);
            }
            if (!parks.ContainsKey(currentPark.guid))
            {
                parks.Add(currentPark.guid, currentPark);
            }

            currentPark.init(settings);
        }
コード例 #2
0
        public override List <string> loadByHandles()
        {
            uint currentDataVersionIdx = dataVersionIdx;

            dataVersionIdx = 0; // set to 0 to check data version from file
            List <string> msgs = base.loadByHandles();

            Debug.LogMT("data version " + dataVersionIdx);
            if (dataVersionIdx == 0)
            {
                // related to dataVersionIdx = 0 in loadByHandles
                // backup old data and keep main data valid if no newer dataVersionIdx has been loaded
                // old park guid data will be ignored in the further process automatically
                fh.backupAll(dataVersionIdx);
                fh.deleteAll();
                oldDataVersion = true;
            }
            dataVersionIdx = currentDataVersionIdx;

            List <string> parkGuidsToRemove = new List <string>();

            foreach (string parkGuid in parks.Keys)
            {
                if (currentParkOnly == false || (currentParkGuid == parkGuid))
                {
                    msgs.AddRange(parks[parkGuid].loadByHandles());
                    if (parks[parkGuid].errorOnLoad || parks[parkGuid].oldDataVersion)
                    {
                        parkGuidsToRemove.Add(parkGuid);
                    }
                    else if (parks.ContainsKey(parkGuid) && currentParkGuid == parkGuid)
                    {
                        currentPark = parks[parkGuid];
                    }
                }
            }
            if (parkGuidsToRemove.Count > 0)
            {
                foreach (string parkGuid in parkGuidsToRemove)
                {
                    parks.Remove(parkGuid);
                }
            }

            return(msgs);
        }
コード例 #3
0
ファイル: GameData.cs プロジェクト: parkitectLab/statMaster
        public void init(Settings settings)
        {
            if (tsStart == 0) tsStart = Main.getCurrentTimestamp();
            if (playerGuid == null) playerGuid = Guid.NewGuid().ToString();

            tsSessionStarts.Add(currentGameStart);
            sessionIdx = tsSessionStarts.Count - 1;

            if (currentPark == null && currentParkGuid.Length > 0)
            {
                currentPark = new ParkData();
                currentPark.setGuid(currentParkGuid);
            }
            if (!parks.ContainsKey(currentPark.guid))
                parks.Add(currentPark.guid, currentPark);

            currentPark.init(settings);
        }
コード例 #4
0
ファイル: GameData.cs プロジェクト: parkitectLab/statMaster
        public override List<string> loadByHandles()
        {
            uint currentDataVersionIdx = dataVersionIdx;
            dataVersionIdx = 0; // set to 0 to check data version from file
            List<string> msgs = base.loadByHandles();
            Debug.LogMT("data version " + dataVersionIdx);
            if (dataVersionIdx == 0)
            {
                // related to dataVersionIdx = 0 in loadByHandles
                // backup old data and keep main data valid if no newer dataVersionIdx has been loaded
                // old park guid data will be ignored in the further process automatically
                fh.backupAll(dataVersionIdx);
                fh.deleteAll();
                oldDataVersion = true;
            }
            dataVersionIdx = currentDataVersionIdx;

            List<string> parkGuidsToRemove = new List<string>();
            foreach (string parkGuid in parks.Keys)
            {
                if (currentParkOnly == false || (currentParkGuid == parkGuid))
                {
                    msgs.AddRange(parks[parkGuid].loadByHandles());
                    if (parks[parkGuid].errorOnLoad || parks[parkGuid].oldDataVersion)
                    {
                        parkGuidsToRemove.Add(parkGuid);
                    }
                    else if (parks.ContainsKey(parkGuid) && currentParkGuid == parkGuid)
                    {
                        currentPark = parks[parkGuid];
                    }
                }
            }
            if (parkGuidsToRemove.Count > 0)
            {
                foreach (string parkGuid in parkGuidsToRemove)
                {
                    parks.Remove(parkGuid);
                }
            }

            return msgs;
        }
コード例 #5
0
        protected override bool setObjByKey(string handle, string key, object obj)
        {
            bool success = base.setObjByKey(handle, key, obj);

            if (handle == "main")
            {
                switch (key)
                {
                case "playerGuid":
                    playerGuid = obj.ToString();
                    break;

                case "parkGuids":
                    List <object> parkGuids = obj as List <object>;
                    foreach (object parkGuid in parkGuids)
                    {
                        if (currentParkOnly == false || (currentParkGuid == parkGuid.ToString()))
                        {
                            ParkData nPark = new ParkData();
                            nPark.setGuid(parkGuid.ToString());
                            parks.Add(nPark.guid, nPark);

                            if (currentParkGuid == parkGuid.ToString())
                            {
                                currentPark = nPark;
                            }
                        }
                        else
                        {
                            parks.Add(parkGuid.ToString(), null);
                        }
                    }
                    break;
                }
            }
            return(success);
        }
コード例 #6
0
ファイル: GameData.cs プロジェクト: parkitectLab/statMaster
        protected override bool setObjByKey(string handle, string key, object obj)
        {
            bool success = base.setObjByKey(handle, key, obj);

            if (handle == "main")
            {
                switch (key)
                {
                    case "playerGuid":
                        playerGuid = obj.ToString();
                        break;
                    case "parkGuids":
                        List<object> parkGuids = obj as List<object>;
                        foreach (object parkGuid in parkGuids)
                        {
                            if (currentParkOnly == false || (currentParkGuid == parkGuid.ToString()))
                            {
                                ParkData nPark = new ParkData();
                                nPark.setGuid(parkGuid.ToString());
                                parks.Add(nPark.guid, nPark);

                                if (currentParkGuid == parkGuid.ToString())
                                {
                                    currentPark = nPark;
                                }
                            }
                            else
                            {
                                parks.Add(parkGuid.ToString(), null);
                            }
                        }
                        break;
                }
            }
            return success;
        }