/// <summary> /// 删除数据 /// </summary> public void DeleteData(string userId, WorldTypeEnum worldType, Vector3Int position) { string worldName = saveFileName + "_" + EnumExtension.GetEnumName(worldType); string fileName = "w_" + position.x + "_" + position.z; BaseDeleteFile(userId + "/" + worldName + "/" + fileName); }
/// <summary> /// 查询数据 /// </summary> /// <returns></returns> public ChunkSaveBean QueryData(string userId, WorldTypeEnum worldType, Vector3Int position) { string worldName = saveFileName + "_" + EnumExtension.GetEnumName(worldType); string fileName = "w_" + position.x + "_" + position.z; return(BaseLoadData(userId + "/" + worldName + "/" + fileName)); }
/// <summary> /// 更新数据 /// </summary> /// <param name="gameConfig"></param> public void UpdateData(ChunkSaveBean data) { WorldTypeEnum worldType = data.GetWorkType(); string worldName = saveFileName + "_" + EnumExtension.GetEnumName(worldType); string fileName = "w_" + data.position.x + "_" + data.position.z; FileUtil.CreateDirectory(dataStoragePath + "/" + data.userId); FileUtil.CreateDirectory(dataStoragePath + "/" + data.userId + "/" + worldName); if (data.userId != null) { BaseSaveData(data.userId + "/" + worldName + "/" + fileName, data); } }
/// <summary> /// 注册所有方块 /// </summary> public void RegisterBlock() { List <BlockTypeEnum> listBlockType = EnumExtension.GetEnumValue <BlockTypeEnum>(); for (int i = 0; i < listBlockType.Count; i++) { BlockTypeEnum blockType = listBlockType[i]; //获取方块数据 BlockInfoBean blockInfo = GetBlockInfo(blockType); string blockTypeName = EnumExtension.GetEnumName(blockType); //通过反射获取类 Block block = ReflexUtil.CreateInstance <Block>($"BlockType{blockTypeName}"); if (block == null) { block = new Block(); } block.SetData(blockType); block.blockInfo = blockInfo; arrayBlockRegister[(int)blockType] = block; } }
/// <summary> /// 设置语言 /// </summary> /// <param name="language"></param> public void SetLanguage(LanguageEnum language) { this.language = EnumExtension.GetEnumName(language); }