업적 이미지
실행 코드
classApp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
namespace study_016
{
class App
{
Dictionary<int, AchievementData> dicAchievementDatas;
Dictionary<int, AchievementReward> dicAchievementRewards;
Dictionary<int, AchievementInfo> achievementInfo;
public App()
{
string dataJson = File.ReadAllText(dataPath);
string rewardJson = File.ReadAllText(rewardPath);
AchievementData[] arrAchievementDatas = JsonConvert.DeserializeObject<AchievementData[]>(dataJson);
AchievementReward[] arrAchievementRewards = JsonConvert.DeserializeObject<AchievementReward[]>(rewardJson);
dicAchievementDatas = new Dictionary<int, AchievementData>();
dicAchievementRewards = new Dictionary<int, AchievementReward>();
foreach (AchievementReward reward in arrAchievementRewards)
{
}
foreach (AchievementData data in arrAchievementDatas)
{
}
//foreach (KeyValuePair<int, AchievementData> arrdata in this.dicAchievementDatas)
//{
// AchievementData data = arrdata.Value;
// string format = string.Format(data.desc, data.goal);
// Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7}",
//}
//foreach (KeyValuePair<int, AchievementReward> arrReward in this.dicAchievementRewards)
//{
// AchievementReward reward = arrReward.Value;
// Console.WriteLine("{0} {1} {2} {3}",
//}
achievementInfo = new Dictionary<int, AchievementInfo>();
achievementInfo.Add(this.dicAchievementDatas[1000].id, new AchievementInfo(this.dicAchievementDatas[1000].id, 40000));
achievementInfo.Add(this.dicAchievementDatas[1001].id, new AchievementInfo(this.dicAchievementDatas[1001].id, 72456));
achievementInfo.Add(this.dicAchievementDatas[1002].id, new AchievementInfo(this.dicAchievementDatas[1002].id, 14084));
achievementInfo.Add(this.dicAchievementDatas[1003].id, new AchievementInfo(this.dicAchievementDatas[1003].id, 45));
this.PrintAchievement(1000);
this.PrintAchievement(1001);
this.PrintAchievement(1002);
this.PrintAchievement(1003);
}
public void PrintAchievement(int id)
{
AchievementData data = this.dicAchievementDatas[id];
if (sum >= 100)
{
sum = 100;
Console.WriteLine("name : {0}, desc : {1} {2}% ({3}/{4}) ", data.name, desc, sum, achievementInfo[id].count, data.goal);
}
else
{
string format = string.Format("{0:f2}%", sum);
Console.WriteLine("name : {0}, desc : {1} {2}% ({3}/{4}) ", data.name, desc, sum, achievementInfo[id].count, data.goal);
}
}
}
}
|
cs |
class AchievementData
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace study_016
{
class AchievementData
{
public int id;
public string name;
public string desc;
public int goal;
public int reward1_id;
public int reward1_amount;
public int reward2_id;
public int reward2_amount;
public AchievementData()
{
}
}
}
|
cs |
class AchievementReward
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace study_016
{
class AchievementReward
{
public int id;
public string name;
public int type;
public string icon_name;
}
}
|
cs |
class AchievementInfo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace study_016
{
class AchievementInfo
{
public int id;
public int count;
public AchievementInfo(int id, int count)
{
this.id = id;
this.count = count;
}
}
}
|
cs |
실행 창
'c# > 수업내용' 카테고리의 다른 글
2020.05.01 이차원 배열 움직이기 (0) | 2020.05.01 |
---|---|
2020.04.29 출석 보상 아이템 (0) | 2020.04.30 |
2020.04.22 json파일 역직렬화, 직렬화 Achievement (0) | 2020.04.22 |
2020.04.13 if문 사용 Starcraft (0) | 2020.04.13 |
2020.04.09 enum과 switch 사용 weapon (0) | 2020.04.09 |