All language subtitles for 24. Win The Level & Load

af Afrikaans
ak Akan
sq Albanian
am Amharic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

1 1

[MUSIC] 2

2

In this video we're going to hook it up so that when all the blocks are destroyed, 3

3

we load our next scene. 4

4

Super exciting, so let's get started. 5

5

One thing I didn't talk about fully in the previous video that I'll touch on now is 6

6

each of these blocks, you've got one, two, three, all the way down to ten blocks. 7

7

Each of these blocks contains the script block. 8

8

And on that script block we have, we're saying, we're calling the method, 9

9

CountBreakableBlock which basically just increments the number of blocks by one. 10

10

And the reason that adds up the total number of blocks is when we start 11

11

the game, every single one of these instances, these are instances of our 12

12

prefab, every instance says, do the thing that is on my script. 13

13

So count me as a block. 14

14

And then this one says, add another block. 15

15

And this one says, add another block, add another block. 16

16

So each of these are saying add another block. 17

17

And so they're doing that ten times. 18

18

That's why it's adding up in our level. 19

19

It's adding up all the breakable blocks. 20

20

Each of them have said count me, and that adds up to ten. 21

21

Okay, so just wanted to be super clear with what's going on there. 22

22

Now we're gonna jump into level.cs. 23

23

Again, we need to create ourselves our next public method. 24

24

Cuz if we look at our flow we can see that we have gone through, 25

25

we've created a level object, we're keeping track of breakable blocks, 26

26

we're adding up the blocks. 27

27

Now we need a method to signal that a block was broken, 28

28

an if statement to load the next level if the blocks is zero, and 29

29

then also to tell each block to remove itself when it's destroyed. 30

30

Remove itself from the total number of breakable blocks, and 31

31

that's what we're up to at the moment. 32

32

The first thing we'll do is create a public method, public void, and 33

33

we'll call this one block destroyed. 34

34

Block destroyed. 35

35

I have an enclosed parenthesis, I have enclosed curly braces brackets, 36

36

and then within here we want to say, 37

37

well I'm gonna basically say the opposite to what's happening up in here. 38

38

When a block is destroyed we want it to say hey, decrease the number 39

39

of breakable blocks by saying breakable blocks minus minus, and then semicolon. 40

40

Now what else do we need to do? 41

41

Well, within here as well, at the same time that a block is destroyed, 42

42

we want to say right now hey, have the number of blocks reached zero? 43

43

So put in an if statement, if, and then our parenthesis we 44

44

wanna say if the (breakableBlocks) is less than or 45

45

equal to 0, then what do we want to have happen? 46

46

Well, what we wanna have happen is to load the next level. 47

47

So we know from our ScreenLoader, so we have a ScreenLoader class. 48

48

We've already created a load next level method, so we wanna call that. 49

49

If you remember, I'll find object of thought. 50

50

And once again, I will cache this as a reference just so 51

51

that we don't have to find the object of type every single time. 52

52

And so to do that we will say SceneLoader, 53

53

capital S, SceneLoader, and then sceneloader. 54

54

So this is just a way of saying we now have a variable, 55

55

sceneloader variable that have type SceneLoader. 56

56

And again I'll just make a note in here, cached reference, so 57

57

that we know this is our cache not the thought we have, 58

58

our parameters, parameters, that we need to keep track of. 59

59

Just helping you guys see that this is the structure we have at the top of our 60

60

script, so you can get into the habit of putting things in the right place. 61

61

You don't have to write in your comments each time, 62

62

I'm just doing that to make it clear from a teaching point of view. 63

63

Okay, so we have our scene loader, now if breakableBlocks is less than, 64

64

sorry in our start method now. 65

65

I've jumped a step ahead. 66

66

What do we need to do next? 67

67

This is a question for you. 68

68

Many challenge for you. 69

69

How do we get access to our sceneloader? 70

70

How do we cache that? 71

71

Well, we say Start. 72

72

Hit Tab to autocomplete, and then we will say sceneloader = what? 73

73

Another mini challenge for you, complete that sentence. 74

74

sceneloader = FindObjectOfType. 75

75

Angle brackets, and within here we're finding capital s breaks Sceneloader. 76

76

Open and close parenthesis, semicolon. 77

77

So now we know that SceneLoader is a cash reference to the class or 78

78

the objective type SceneLoader. 79

79

Now in our if statement down here, we can say, cuz we need to access sceneloader. 80

80

What are we accessing in there? 81

81

We're accessing load next scene. 82

82

So, here's another mini challenge for you. 83

83

Let's load the next level. 84

84

Okay, you're just waiting for me to continue, 85

85

are you actually doing these mini challenges? 86

86

It's okay if you're not but this is how you really get better at these things. 87

87

If you push yourself and pause and try to figure it out on your own. 88

88

That's how this really embeds. 89

89

It's cool if you're not, but it's even better if you are. 90

90

So we'll say in here sceneloader.LoadNextScene. 91

91

Open and closed brackets and semi-colon. 92

92

So now we've created our, when a block is destroyed, we want to yell hey, 93

93

block is destroyed. 94

94

We decrease the number of blocks by one that are breakable, and 95

95

then we say if it's reached 0, then load the next scene. 96

96

I'm gonna save that hop over into block, and 97

97

this is where I'll give you your proper full on challenge. 98

98

That was our last level. 99

99

It's our last lecturer. 100

100

That's what I'm after. 101

101

Update Block.cs. 102

102

So here is the challenge. 103

103

Call our method for decreasing the number of blocks when a block is destroyed. 104

104

Update Block.cs, and ensure that you have your build settings correct. 105

105

We haven't done that yet for this scene. 106

106

You might have done it but I haven't done it yet. 107

107

And to test and rejoice that it works. 108

108

And another little hint for 109

109

you, you might wanna decrease the number of blocks in your scene to one just so you 110

110

don't have to get rid of all of the blocks you can text it a little bit more quickly. 111

111

Okay, so as your challenge jump in and get started. 112

112

Okay, so within Block.cs, we need to find our OnCollisionEnter, 113

113

this is where things are getting destroyed. 114

114

Underneath Destroy, we want to give an update in here that says, 115

115

well not an update, but we wanna call our method in here. 116

116

I'm thinking that it's updating the situation but it's not the update method. 117

117

We're saying level, we've already created ourselves a cash reference to the level. 118

118

So level., and what do we have in here? 119

119

It's gonna be BlockDestroyed );. 120

120

So we're saying access the level class that we're doing and lock is destroyed. 121

121

Pretty straightforward. 122

122

Now I'm gonna do one more step while I'm in here which is just to factor this out 123

123

to clean it up. 124

124

This is a refactor, it's not critical. 125

125

Things will still work without it, but this is just for readability. 126

126

Not to do too many things under this OnCollisionEnter. 127

127

So I'm gonna highlight my three lines here, right-click. 128

128

Slightly different on the Mac, you'll see. 129

129

Quick Fix and then Extract Method. 130

130

On a PC, Quick Actions and Refactorings, and then Extract Method. 131

131

We'll call this method DestroyBlock, and then hit Enter. 132

132

So basically, Whenever we collide with the block, then we want to destroy the block. 133

133

Okay, I'll call DestroyBlock or, yeah, that's good for now. 134

134

It'll change a little bit later on, but for now, this is what we've got, so 135

135

this is the best thing to call it. 136

136

Save that, jump over into our game. 137

137

Now, I mentioned about Build Settings, Edit. 138

138

Sorry, File > Build Settings. 139

139

And one thing you'll notice with our Build Settings is that we don't have any level 140

140

two sitting there. 141

141

So I'll just click Add Open Scenes, cuz level two is open at the moment. 142

142

Now I'm gonna cheat a little bit and drag this above level one so that when we win 143

143

level two it'll take us to level one, just to make it easy for testing purposes. 144

144

And as I mentioned before I'm gonna select all of my blocks except for one. 145

145

Delete those, click Play, we should see if I click on level, 146

146

we should see that there are one breakable blocks, yes there are, 147

147

click back in my game window, [SOUND] and then plonk, and Game Over. 148

148

Didn't work, okay, what have we not done in here? 149

149

We're looking for in our level, we didn't go through this quite in enough detail. 150

150

We have SceneLoader, I've forgotten that we don't have SceneLoader in our scene at 151

151

the moment, do we? 152

152

That was an assumption that I made was incorrect, so on level I'm going to drag 153

153

in SceneLoader, so drag SceneLoader as a component on level now. 154

154

When we're saying fine object of type, here it is right here sceneloaded.cs 155

155

is another way of saying it's the SceneLoader class, 156

156

and it's in our scene because we have it sitting right here on level. 157

157

Make sure on level we can click Apply, so it applies all these back to the prefab, 158

158

so when we drop in level and future levels, it knows what's going on. 159

159

So just a reminder, why I was doing that is we're looking for 160

160

FindObjectOfType SceneLoader, but 161

161

we didn't actually have any SceneLoaders in our scene just yet, and now we do. 162

162

So save everything up, click on Play, look to see if there's any errors. 163

163

I don't know how long that errors been there but it's now gone. 164

164

So there is no error, fantastic. 165

165

And we click and it should, plonk, load into the other scene. 166

166

That's great, very excited to see that. 167

167

So excellent work, we now have a fully functioning game. 168

168

You can add a couple of these blocks back if you want. 169

169

I'm just gonna add one more, so we've got two sets. 170

170

It looks a little bit more like a game. 171

171

And so when we complete this scene, it will load the next scene. 172

172

That area has reappeared down the bottom of the screen but 173

173

that should go away when we click Play. 174

174

We can now play fully through a full game loop where the player can start, 175

175

win, lose, and restart the game. 176

176

So great work, and I'll see you in the next lecture.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.