Use UGS on WPF, Console C# Project
UGS는 WPF 혹은 C#으로 만들어진 Console Application 에서도 사용 가능합니다. 이 기능을 제공하는 이유는, C#으로 만든 게임의 서버에서 클라이언트측 데이터를 검사하는데에 사용하거나, 게임 자체가 서버에서 시뮬레이션 될 수 있기 때문입니다. 먼저, 사용하려면 UGS를 임포트한 후, HamsterGoogleSpreadSheet.dll을 찾아 자신만의 C# 프로젝트에 Reference Add 하십시오.

Use Example Code

임포트를 했다면 아래 코드를 참고하여
1
using Hamster.ZG;
2
using Hamster.ZG.IO.FileReader;
3
using Hamster.ZG.IO.FileWriter;
4
using UGS.Protocol.v2.Req;
5
using System;
6
using System.IO;
7
8
namespace ConsoleApp1
9
{
10
class Program
11
{
12
static void Main(string[] args)
13
{
14
// Login
15
GoogleSheet.Initialize("https://script.google.com/macros/s/AKfycbxpqlYM5SfX0pL2RHzgiT_cFykKFLkcr_PgzU1KKnVx2Aa6YNN3/exec", "123123");
16
17
18
19
// Code Generate And Copy To Folder
20
GoogleSheet.Generate("1BXya0YQq980kbNBN_-hQAvmBrNkHFIoqXJkQTXIsXHQ",
21
() => {
22
System.IO.DirectoryInfo di1 = new System.IO.DirectoryInfo("TableScript");
23
System.IO.DirectoryInfo di2 = new System.IO.DirectoryInfo("CachedJson");
24
25
DirectoryCopy(di1.FullName, "../../../TableScript", true);
26
DirectoryCopy(di2.FullName, "../../../CachedJson", true);
27
});
28
29
30
GoogleSheet.LoadAllData();
31
foreach (var value in UnitData.Balance.BalanceList)
32
Console.WriteLine(quot;{value.id} {value.jump} {value.name} {value.speed}");
33
34
}
35
36
37
38
39
private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
40
{
41
// Get the subdirectories for the specified directory.
42
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
43
44
if (!dir.Exists)
45
{
46
throw new DirectoryNotFoundException(
47
"Source directory does not exist or could not be found: "
48
+ sourceDirName);
49
}
50
51
DirectoryInfo[] dirs = dir.GetDirectories();
52
53
// If the destination directory doesn't exist, create it.
54
Directory.CreateDirectory(destDirName);
55
56
// Get the files in the directory and copy them to the new location.
57
FileInfo[] files = dir.GetFiles();
58
foreach (FileInfo file in files)
59
{
60
string tempPath = Path.Combine(destDirName, file.Name);
61
file.CopyTo(tempPath, true);
62
}
63
64
// If copying subdirectories, copy them and their contents to new location.
65
if (copySubDirs)
66
{
67
foreach (DirectoryInfo subdir in dirs)
68
{
69
string tempPath = Path.Combine(destDirName, subdir.Name);
70
DirectoryCopy(subdir.FullName, tempPath, copySubDirs);
71
}
72
}
73
}
74
75
}
76
}
77
Copied!
Copy link