-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameData.swift
170 lines (120 loc) · 5.4 KB
/
GameData.swift
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//
// GameData.swift
// Jack The Giant
//
// Created by Marc Llopart Riera on 1/8/17.
// Copyright © 2017 The Fox Game Studio. All rights reserved.
//
import Foundation
class GameData : NSObject, NSCoding {
struct Keys {
static let EasyDiffcultyScore = "EasyDiffcultyScore";
static let MediumDiffcultyScore = "MediumDiffcultyScore";
static let HardDiffcultyScore = "HardDiffcultyScore";
static let EasyDiffcultyCoinScore = "EasyDiffcultyCoinScore";
static let MediumDiffcultyCoinScore = "MediumDiffcultyCoinScore";
static let HardDiffcultyCoinScore = "HardDiffcultyCoinScore";
static let EasyDiffculty = "EasyDiffculty";
static let MediumDiffculty = "MediumDiffculty";
static let HardDiffculty = "HardDiffculty";
static let Music = "Music";
}
private var easyDifficultyScore = Int32();
private var mediumDifficultyScore = Int32();
private var hardDifficultyScore = Int32();
private var easyDifficultyCoinScore = Int32();
private var mediumDifficultyCoinScore = Int32();
private var hardDifficultyCoinScore = Int32();
private var easyDifficulty = false;
private var mediumDifficulty = false;
private var hardDifficulty = false;
private var isMusicOn = false;
override init() {}
required init?(coder aDecoder: NSCoder) {
super.init();
self.easyDifficultyScore = aDecoder.decodeCInt(forKey: "EasyDiffcultyScore");
self.mediumDifficultyScore = aDecoder.decodeCInt(forKey: "MediumDiffcultyScore");
self.hardDifficultyScore = aDecoder.decodeCInt(forKey: "HardDiffcultyScore");
self.easyDifficultyCoinScore = aDecoder.decodeCInt(forKey: "EasyDiffcultyCoinScore");
self.mediumDifficultyCoinScore = aDecoder.decodeCInt(forKey: "MediumDiffcultyCoinScore");
self.hardDifficultyCoinScore = aDecoder.decodeCInt(forKey: "HardDiffcultyCoinScore");
self.easyDifficulty = aDecoder.decodeBool(forKey: "EasyDiffculty");
self.mediumDifficulty = aDecoder.decodeBool(forKey: "MediumDiffculty");
self.hardDifficulty = aDecoder.decodeBool(forKey: "HardDiffculty");
self.isMusicOn = aDecoder.decodeBool(forKey: "Music");
}
func encode(with aCoder: NSCoder) {
aCoder.encodeCInt(self.easyDifficultyScore, forKey: Keys.EasyDiffcultyScore);
aCoder.encodeCInt(self.mediumDifficultyScore, forKey: Keys.MediumDiffcultyScore);
aCoder.encodeCInt(self.hardDifficultyScore, forKey: Keys.HardDiffcultyScore);
aCoder.encodeCInt(self.easyDifficultyCoinScore, forKey: Keys.EasyDiffcultyCoinScore);
aCoder.encodeCInt(self.mediumDifficultyCoinScore, forKey: Keys.MediumDiffcultyCoinScore);
aCoder.encodeCInt(self.hardDifficultyCoinScore, forKey: Keys.HardDiffcultyCoinScore);
aCoder.encode(easyDifficulty, forKey: Keys.EasyDiffculty);
aCoder.encode(mediumDifficulty, forKey: Keys.MediumDiffculty);
aCoder.encode(hardDifficulty, forKey: Keys.HardDiffculty);
aCoder.encode(isMusicOn, forKey: Keys.Music);
}
//setters
func setEasyDifficultyScore(easyDifficultyScore: Int32) {
self.easyDifficultyScore = easyDifficultyScore;
}
func setMediumDifficultyScore(mediumDifficultyScore: Int32) {
self.mediumDifficultyScore = mediumDifficultyScore;
}
func setHardDifficultyScore(hardDifficultyScore: Int32) {
self.hardDifficultyScore = hardDifficultyScore;
}
func setEasyDifficultyCoinScore(easyDifficultyCoinScore: Int32) {
self.easyDifficultyCoinScore = easyDifficultyCoinScore;
}
func setMediumDifficultyCoinScore(mediumDifficultyCoinScore: Int32) {
self.mediumDifficultyCoinScore = mediumDifficultyCoinScore;
}
func setHardDifficultyCoinScore(hardDifficultyCoinScore: Int32) {
self.hardDifficultyCoinScore = hardDifficultyCoinScore;
}
func setEasyDifficulty (easyDifficulty : Bool) {
self.easyDifficulty = easyDifficulty;
}
func setMediumDifficulty (mediumDifficulty : Bool) {
self.mediumDifficulty = mediumDifficulty;
}
func setHardDifficulty (hardDifficulty : Bool) {
self.hardDifficulty = hardDifficulty;
}
func setIsMusicOn (isMusicOn : Bool) {
self.isMusicOn = isMusicOn;
}
//geters
func getEasyDifficultyScore() -> Int32 {
return self.easyDifficultyScore
}
func getMediumDifficultyScore() -> Int32 {
return self.mediumDifficultyScore
}
func getHardDifficultyScore() -> Int32 {
return self.hardDifficultyScore
}
func getEasyDifficultyScoreCoins() -> Int32 {
return self.easyDifficultyCoinScore
}
func getMediumDifficultyScoreCoins() -> Int32 {
return self.mediumDifficultyCoinScore
}
func getHardDifficultyScoreCoins() -> Int32 {
return self.hardDifficultyCoinScore
}
func getEasyDifficulty() -> Bool {
return self.easyDifficulty
}
func getMediumDifficulty() -> Bool {
return self.mediumDifficulty
}
func getHardDifficulty() -> Bool {
return self.hardDifficulty
}
func getIsMusicOn() -> Bool {
return self.isMusicOn
}
}