1
00:00:00,000 --> 00:00:03,270
Welcome back, my fellow game developers.

2
00:00:03,270 --> 00:00:06,090
In this video, we've created money,

3
00:00:06,090 --> 00:00:07,920
so let's get started.

4
00:00:07,920 --> 00:00:10,140
When I run the game.

5
00:00:10,140 --> 00:00:13,050
You can see that I have 0 Bitcoins.

6
00:00:13,050 --> 00:00:14,310
If I hit the GKE,

7
00:00:14,310 --> 00:00:16,470
I have 20, 40,

8
00:00:16,470 --> 00:00:21,030
60, and then I can also remove them from my inventory.

9
00:00:21,030 --> 00:00:22,640
It's nothing very special.

10
00:00:22,635 --> 00:00:25,175
There's nothing to coolants video except for

11
00:00:25,170 --> 00:00:27,240
the really nice-looking symbol

12
00:00:27,240 --> 00:00:28,970
right here of the game manager.

13
00:00:28,965 --> 00:00:31,205
So let's not waste any more time and

14
00:00:31,200 --> 00:00:34,100
let's get to creating money.

15
00:00:34,095 --> 00:00:35,915
O k.

16
00:00:35,910 --> 00:00:37,950
So now we have enemies,

17
00:00:37,950 --> 00:00:41,490
now we have weapons, everything is set.

18
00:00:41,485 --> 00:00:43,915
It's time for sound money.

19
00:00:43,910 --> 00:00:45,530
We need to make some money.

20
00:00:45,530 --> 00:00:48,890
So and I believe in the last video,

21
00:00:48,890 --> 00:00:51,800
I told you that we are going to be creating menus.

22
00:00:51,800 --> 00:00:53,750
Sorry for that honesty.

23
00:00:53,750 --> 00:00:56,540
I don't actually remember what we have.

24
00:00:56,540 --> 00:00:59,120
I just go from one video to the next.

25
00:00:59,120 --> 00:01:01,630
Obviously all the time I know what I'm doing.

26
00:01:01,625 --> 00:01:04,225
Obviously, I know where we are heading.

27
00:01:04,220 --> 00:01:06,400
But anyways, let's continue on.

28
00:01:06,395 --> 00:01:09,205
We have the level manager and this is where we want

29
00:01:09,200 --> 00:01:12,260
to keep track of the money that we have.

30
00:01:12,260 --> 00:01:15,050
So first of all,

31
00:01:15,050 --> 00:01:17,030
we are going to create a variable in here

32
00:01:17,030 --> 00:01:19,340
which is going to be a serialized field,

33
00:01:19,340 --> 00:01:24,210
and it's going to be an end of the current coins.

34
00:01:24,214 --> 00:01:28,924
Okay, so here is where we will have our current coins.

35
00:01:28,925 --> 00:01:31,825
And now it's your job to create two methods

36
00:01:31,820 --> 00:01:34,810
to get and spent the Bitcoins.

37
00:01:34,805 --> 00:01:36,805
So you'll create two methods.

38
00:01:36,800 --> 00:01:39,550
One that adds, I should change this,

39
00:01:39,545 --> 00:01:40,675
you know what, let me check or

40
00:01:40,670 --> 00:01:42,920
no electron will change this to Bitcoin.

41
00:01:42,920 --> 00:01:44,330
So create two methods.

42
00:01:44,330 --> 00:01:45,740
One that adds bit coins,

43
00:01:45,740 --> 00:01:47,750
one that removes the Bitcoins.

44
00:01:47,750 --> 00:01:51,440
Then each should take in a parameter for the amount.

45
00:01:51,440 --> 00:01:53,300
Make sure that we never have

46
00:01:53,300 --> 00:01:56,950
negative amounts of money because that's very bad.

47
00:01:56,945 --> 00:01:59,335
So with that out of the way,

48
00:01:59,330 --> 00:02:04,510
pause the video right now and go do the challenge.

49
00:02:04,505 --> 00:02:06,415
Okay, welcome back.

50
00:02:06,410 --> 00:02:08,360
So instead of current coins,

51
00:02:08,360 --> 00:02:12,670
I'm going to call this the current bit coins.

52
00:02:12,665 --> 00:02:14,695
And if you don't like Bitcoin,

53
00:02:14,690 --> 00:02:16,880
well, you should try it out anyways.

54
00:02:16,880 --> 00:02:18,950
I'm not trying to put anything in your head.

55
00:02:18,950 --> 00:02:21,620
Let's continue on. Let's focus on the main thing.

56
00:02:21,620 --> 00:02:26,050
Now, something in here that you might want to consider.

57
00:02:26,045 --> 00:02:29,995
So it's great. We have Level Manager which takes,

58
00:02:29,990 --> 00:02:31,820
takes care of the whole level.

59
00:02:31,820 --> 00:02:33,320
But when it comes to

60
00:02:33,320 --> 00:02:35,770
the amount of money that we carry with us,

61
00:02:35,765 --> 00:02:38,785
I think it's better to have it in

62
00:02:38,780 --> 00:02:40,160
something called a game

63
00:02:40,160 --> 00:02:42,080
manager that's just for the future.

64
00:02:42,080 --> 00:02:43,780
It's no problem.

65
00:02:43,775 --> 00:02:45,655
You can create it in level manager.

66
00:02:45,650 --> 00:02:47,150
It does the functionality,

67
00:02:47,150 --> 00:02:49,580
but level manager seems like it

68
00:02:49,580 --> 00:02:52,520
just handles the current level that we're on.

69
00:02:52,520 --> 00:02:54,530
When it comes to the mind that we hold,

70
00:02:54,530 --> 00:02:57,890
it should be around the entire game.

71
00:02:57,890 --> 00:02:59,590
So as soon as you start the game,

72
00:02:59,585 --> 00:03:01,885
every single level you collect more coins,

73
00:03:01,880 --> 00:03:02,990
you go to the next level,

74
00:03:02,990 --> 00:03:04,850
you then add to that.

75
00:03:04,850 --> 00:03:08,450
So level manager is a bit of a weird one.

76
00:03:08,450 --> 00:03:11,630
I don't know, maybe we should move it to a game manager.

77
00:03:11,630 --> 00:03:14,440
You know what, let's move it to a game manager.

78
00:03:14,435 --> 00:03:16,195
I've convinced myself.

79
00:03:16,190 --> 00:03:20,240
So in here, I'm going to right-click.

80
00:03:20,240 --> 00:03:25,000
Create an empty game manager, hit Enter.

81
00:03:24,995 --> 00:03:27,045
We'll reset the position.

82
00:03:27,049 --> 00:03:30,079
And in here in the manager's going to create

83
00:03:30,080 --> 00:03:35,290
a C-sharp four script for the game manager at Enter.

84
00:03:35,285 --> 00:03:36,985
And this is exactly why

85
00:03:36,980 --> 00:03:38,780
I wanted to create a game manager just

86
00:03:38,780 --> 00:03:42,410
to show you this weird symbol for some reason,

87
00:03:42,410 --> 00:03:46,040
no other script changes except for this one.

88
00:03:46,040 --> 00:03:49,180
This one has this weird knob on it.

89
00:03:49,175 --> 00:03:50,935
I don't know Why. Don't ask me why.

90
00:03:50,930 --> 00:03:52,130
I'm still not sure.

91
00:03:52,130 --> 00:03:53,900
But anyways now the game manager

92
00:03:53,900 --> 00:03:55,460
has the game manager script.

93
00:03:55,460 --> 00:03:57,040
And as long as we're here,

94
00:03:57,035 --> 00:03:58,405
we have the level manager,

95
00:03:58,400 --> 00:03:59,740
we have the game manager,

96
00:03:59,735 --> 00:04:01,775
we also have the Audio Manager.

97
00:04:01,774 --> 00:04:03,234
There we go, the Audio Manager.

98
00:04:03,230 --> 00:04:06,110
So I'm going to right-click create an empty.

99
00:04:06,110 --> 00:04:08,770
The managers hit Enter.

100
00:04:08,765 --> 00:04:13,765
I'm going to reset its position so that the game manager,

101
00:04:13,760 --> 00:04:18,430
level manager, and the where is it?

102
00:04:18,425 --> 00:04:20,545
Audiomanager. There we go.

103
00:04:20,540 --> 00:04:23,240
So now we have a list of all the managers.

104
00:04:23,240 --> 00:04:24,770
And in the prefabs,

105
00:04:24,770 --> 00:04:28,040
let's prefab the level and the game manager.

106
00:04:28,040 --> 00:04:32,800
So do we have where is the AudioManager saved?

107
00:04:32,795 --> 00:04:36,965
I think he is in the prefabs where z.

108
00:04:36,965 --> 00:04:39,665
Okay, so AudioManager, his Albany himself,

109
00:04:39,665 --> 00:04:46,505
folder managers, AudioManager, level manager,

110
00:04:46,504 --> 00:04:48,124
and the game manager.

111
00:04:48,125 --> 00:04:49,825
Okay, with that out of the way,

112
00:04:49,820 --> 00:04:52,160
let's open up the script again.

113
00:04:52,160 --> 00:04:53,930
Whereas the level manager,

114
00:04:53,930 --> 00:04:56,090
we are going to take the Bitcoins from

115
00:04:56,090 --> 00:04:59,520
here and move them to the game manager.

116
00:04:59,830 --> 00:05:02,540
And then we are going to go ahead

117
00:05:02,540 --> 00:05:04,330
and create two methods in here.

118
00:05:04,325 --> 00:05:05,605
I'll keep the start and update.

119
00:05:05,600 --> 00:05:08,200
I have a feeling that we might use them later on.

120
00:05:08,195 --> 00:05:10,105
So in here, first of all,

121
00:05:10,100 --> 00:05:12,320
the public void, obviously

122
00:05:12,320 --> 00:05:14,980
it has to be public because we are going to be.

123
00:05:14,975 --> 00:05:16,975
Calling it from different scripts.

124
00:05:16,970 --> 00:05:21,790
So public void get bitcoins.

125
00:05:21,785 --> 00:05:26,705
And in here the amount to get.

126
00:05:26,705 --> 00:05:31,085
So we open up the brackets or squiggly lines or whatever.

127
00:05:31,085 --> 00:05:37,885
And the current Bitcoins plus equals the amount to get.

128
00:05:37,880 --> 00:05:40,430
And if you want, we can set it to 21 million,

129
00:05:40,430 --> 00:05:42,050
but let's keep it as infinite.

130
00:05:42,050 --> 00:05:44,110
We can get as many as we want.

131
00:05:44,105 --> 00:05:47,995
And then we are going to create the public void,

132
00:05:47,990 --> 00:05:53,890
spend coins, bitcoins.

133
00:05:53,885 --> 00:05:57,665
And this one is going to be

134
00:05:57,660 --> 00:06:04,440
an integer of amount to spend.

135
00:06:04,435 --> 00:06:06,915
And in here we are going to get

136
00:06:06,910 --> 00:06:09,160
the current coins, excuse me,

137
00:06:09,160 --> 00:06:12,160
get the current coins removed from them,

138
00:06:12,160 --> 00:06:14,180
the amount to spend.

139
00:06:14,184 --> 00:06:16,454
And finally, we are going to check if

140
00:06:16,450 --> 00:06:22,680
the current coins are less than or equal to 0,

141
00:06:22,675 --> 00:06:24,855
than the current coins will be.

142
00:06:24,850 --> 00:06:29,580
Current coins will be set to 0. Save that.

143
00:06:29,575 --> 00:06:32,535
And now let's just create a small Peston near.

144
00:06:32,530 --> 00:06:39,830
So if input and put dot,

145
00:06:39,825 --> 00:06:43,495
get the down key,

146
00:06:43,490 --> 00:06:48,520
coat gene G, so keycode.

147
00:06:48,515 --> 00:06:51,715
So I mean get, if, GET,

148
00:06:51,710 --> 00:06:57,760
then get bitcoins and let's say we get 25 or 20.

149
00:06:57,755 --> 00:07:01,625
Then if the same in here.

150
00:07:01,625 --> 00:07:03,415
But instead of a G,

151
00:07:03,410 --> 00:07:05,970
we use the H,

152
00:07:06,370 --> 00:07:11,820
H spend, but coins.

153
00:07:11,824 --> 00:07:13,344
And how many do we spend?

154
00:07:13,340 --> 00:07:15,910
Let's say 10.

155
00:07:15,905 --> 00:07:18,745
So we get 20, We spent ten.

156
00:07:18,740 --> 00:07:21,620
And finally, let's create a debug.

157
00:07:21,620 --> 00:07:26,940
Oh, we forgot this debug.

158
00:07:29,350 --> 00:07:37,760
I have current Bitcoins

159
00:07:37,760 --> 00:07:42,020
plus equals bitcoins.

160
00:07:42,020 --> 00:07:44,840
And obviously we'll be setting all of this in the UI,

161
00:07:44,840 --> 00:07:46,430
but for now we save,

162
00:07:46,430 --> 00:07:49,880
we go into our game.

163
00:07:49,880 --> 00:07:51,410
I think everything is good.

164
00:07:51,410 --> 00:07:53,560
So we set everything up.

165
00:07:53,555 --> 00:07:56,665
The current coins are always going to start at 0.

166
00:07:56,660 --> 00:07:58,880
So we start the game. There we go.

167
00:07:58,880 --> 00:08:00,140
I have 0 Bitcoins,

168
00:08:00,140 --> 00:08:01,660
so I'm going to get,

169
00:08:01,655 --> 00:08:03,745
get, get, get, there you go.

170
00:08:03,740 --> 00:08:06,080
And then I'm going to spend, spend, spend, spend,

171
00:08:06,080 --> 00:08:07,340
spends, but spend, spend,

172
00:08:07,340 --> 00:08:08,980
and as you can see,

173
00:08:08,975 --> 00:08:11,965
we cannot go less than 10 Whenever I

174
00:08:11,960 --> 00:08:14,930
tried to spend 10 because I only have 10.

175
00:08:14,930 --> 00:08:16,820
And this is something that we will need to

176
00:08:16,820 --> 00:08:19,280
keep in mind if it's less than or equal,

177
00:08:19,280 --> 00:08:22,660
if we set it to less than or equal than 0.

178
00:08:22,655 --> 00:08:24,745
Actually, I think that's a good idea.

179
00:08:24,740 --> 00:08:26,720
So now we can actually spend what we

180
00:08:26,720 --> 00:08:28,630
have problem in here,

181
00:08:28,625 --> 00:08:30,805
Is that, okay, Sorry.

182
00:08:30,800 --> 00:08:34,330
This is how we said the less than or equal.

183
00:08:34,325 --> 00:08:36,925
So there is something that we will need to keep in

184
00:08:36,920 --> 00:08:39,320
mind and that whenever we are spending,

185
00:08:39,320 --> 00:08:41,840
we actually need to have these coins with us.

186
00:08:41,840 --> 00:08:43,640
But this is something I believe will be

187
00:08:43,640 --> 00:08:46,960
handled later on by the Sharp script.

188
00:08:46,955 --> 00:08:48,685
So in here, let's see,

189
00:08:48,680 --> 00:08:50,630
I spend, spend, spend, spend.

190
00:08:50,630 --> 00:08:52,730
Okay, that's still not working.

191
00:08:52,730 --> 00:08:53,930
Hey, welcome back.

192
00:08:53,930 --> 00:08:57,740
So it was totally something very simple.

193
00:08:57,740 --> 00:08:59,810
When we have the collapse right here,

194
00:08:59,810 --> 00:09:01,430
you can see that we start off at 0,

195
00:09:01,430 --> 00:09:02,900
20, 40, and et cetera.

196
00:09:02,900 --> 00:09:05,140
But when I start spending,

197
00:09:05,135 --> 00:09:08,305
when I get to 0, it's already here so it doesn't show up.

198
00:09:08,300 --> 00:09:09,680
And the messages I can

199
00:09:09,680 --> 00:09:11,480
show you if we remove the collapse.

200
00:09:11,480 --> 00:09:15,530
So every single line is not maximize on play, please.

201
00:09:15,530 --> 00:09:17,120
If I click in here,

202
00:09:17,120 --> 00:09:19,490
so now you can see that when I hit the gigi,

203
00:09:19,490 --> 00:09:22,310
gigi, 120, sell, sell,

204
00:09:22,310 --> 00:09:23,510
sell, sell, sell, sell.

205
00:09:23,510 --> 00:09:25,280
There we go. Everything is working.

206
00:09:25,280 --> 00:09:28,120
So it wasn't because of the less than or equal,

207
00:09:28,115 --> 00:09:30,985
it was actually our inability to see it.

208
00:09:30,980 --> 00:09:32,560
So I hope you enjoy it.

209
00:09:32,555 --> 00:09:34,105
Make sure to commit your changes.

210
00:09:34,100 --> 00:09:35,300
And I'll see you in

211
00:09:35,300 --> 00:09:38,500
the next video where we will be actually picking

212
00:09:38,495 --> 00:09:40,465
up the bitcoins and not just adding

213
00:09:40,460 --> 00:09:42,940
them using magic keys on the keyboard.

214
00:09:42,935 --> 00:09:44,885
So see you then.

