Exemplo n.º 1
0
        public static SceneItemData CreateSceneItemData(SceneData sd, string sceneItemId, string itemId)
        {
            SceneItemData sid = new SceneItemData {
                archiveId        = sd.ArchiveId,
                sceneId          = sd.SceneId,
                sceneItemId      = sceneItemId,
                itemId           = itemId,
                pickUp           = false,
                persistenceState = PersistenceState.New
            };

            sd.SceneItemsDatas.Add(sceneItemId, sid);
            return(sid);
        }
Exemplo n.º 2
0
        // 创建一个新的存档
        // 1. 创建新存档
        // 2. 创建玩家
        // 3. 创建场景数据
        public static Archive CreateNewArchive()
        {
            Archive archive = new Archive {
                archiveId  = Guid.NewGuid().ToString(),
                sceneId    = "FrontPolicementGate",
                createTime = DateTime.Now,
                playTime   = 0
            };

            Repository.Instance.Submit(new Command(archive.CreateCommandText(), null));
            archive.player           = Player.CreatePlayer(archive.archiveId);
            archive.currentSceneData = SceneData.CreateSceneData(archive.archiveId, archive.sceneId);
            return(archive);
        }
Exemplo n.º 3
0
        public static SceneData LoadSceneData(string archiveId, string sceneId)
        {
            SceneData sd = new SceneData {
                archiveId = archiveId, sceneId = sceneId, persistenceState = PersistenceState.New
            };

            Repository.Instance.Submit(
                new Command(sd.RetrieveCommandText(), (dataReader) => {
                if (dataReader.Read())
                {
                    sd.entry            = dataReader.GetString(0) == "1" ? true : false;
                    sd.persistenceState = PersistenceState.NoChange;
                }
            })
                );
            SceneItemData.LoadSceneItemDatas(sd);
            return(sd);
        }
Exemplo n.º 4
0
        public static void LoadSceneItemDatas(SceneData sd)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("select * from scene_item_datas where archive_id = '").Append(sd.ArchiveId).Append("' and scene_id = '").Append(sd.SceneId).Append("'");
            Repository.Instance.Submit(
                new Command(sb.ToString(), (dataReader) => {
                sd.SceneItemsDatas.Clear();
                SceneItemData sid;
                while (dataReader.Read())
                {
                    sid = new SceneItemData {
                        archiveId   = dataReader.GetString(0),
                        sceneId     = dataReader.GetString(1),
                        sceneItemId = dataReader.GetString(2),
                        itemId      = dataReader.GetString(3),
                        pickUp      = dataReader.GetString(4) == "1" ? true : false
                    };
                    sd.SceneItemsDatas.Add(sid.SceneItemId, sid);
                }
            })
                );
        }
Exemplo n.º 5
0
 // 载入存档中的玩家和场景数据
 public static void LoadArchiveData(Archive archive)
 {
     archive.player           = Player.LoadPlayer(archive.archiveId);
     archive.currentSceneData = SceneData.LoadSceneData(archive.archiveId, archive.sceneId);
 }