Create your own 2D Mastermind game with the use of the Unity Engine. | Octo Man | Skillshare

Create your own 2D Mastermind game with the use of the Unity Engine.

Octo Man, Let's make your dream game a reality!!

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
39 Lessons (5h 18m)
    • 1. #0 Intro

      1:39
    • 2. #1 Unity Setup

      3:56
    • 3. #2 Pearl Basic Setup

      5:39
    • 4. #3 Drag Pearls

      9:36
    • 5. #4 Create Playfield

      13:44
    • 6. #5 Playfield Update

      4:27
    • 7. #6 Drop Pearls

      11:06
    • 8. #7 More Pearls

      5:33
    • 9. #8 Solution Box Setup

      5:05
    • 10. #9 Create Riddle 1

      7:11
    • 11. #10 Create Riddle 2

      8:42
    • 12. #11 Adding Pearls & Pearl Fix

      4:25
    • 13. #12 Creating Protector

      3:26
    • 14. #13 Dragging Box Variables

      6:19
    • 15. #14 Hint Box & CheckButton

      6:39
    • 16. #15 Set Ids

      9:12
    • 17. #16 Check Button

      4:21
    • 18. #17 Black Check 1

      12:23
    • 19. #18 Show Black Pearls

      5:14
    • 20. #19 White Check

      12:09
    • 21. #20 GameManager 1

      16:32
    • 22. #21 Game Manager 2

      11:28
    • 23. #22 Win & Lose Conditions

      5:22
    • 24. #23 Win & Lose Protector

      5:42
    • 25. #24 Show & Hide Solution Box

      14:39
    • 26. #25 Show SolutionBox by Code

      8:50
    • 27. #26 Win Lose Panel Setup

      9:47
    • 28. #27 Coding the WinPanel

      11:34
    • 29. #28 Show Win Panel

      8:49
    • 30. #29 Play Timer

      11:59
    • 31. #30 Win Panel Buttons

      5:25
    • 32. #31 Calculating Score

      10:13
    • 33. #32 Menu & Navigation

      13:31
    • 34. #33 Creating a harder mode

      17:28
    • 35. #34 Impossible Mode

      7:04
    • 36. #35 Cleaning up

      5:01
    • 37. #36 Menu Buttons

      4:49
    • 38. #37 Update HideImage

      3:40
    • 39. #38 Conclusion

      5:27

About This Class

0b10b6c2

In this Unity course you will learn how to create you own Mastermind Game in Unity Engine. You will learn how to write your own Scripts in C#.

About the Game

If you never heard about Mastermind, it is a combination puzzle game, where the player have to find a random "code" picked by the computer. They have 10 turns to find out the correct combination. They get hints with black and white pearls which showing up.

Black Pearl mean, correct pearl on correct position.
White Peal means, correct pearl on wrong positon.

But they don't know which is meant, so they have to find out that on their own as well.

Graphics

  • will not be covered to much

  • are available in the course to have material to work with

  • Design is totally up to you, you can even use your own Graphics

Unity

  • you will learn about the Inspector

  • how the Canvas System works

  • how to set up GameObjects

  • how to create Prefabs and what they are

C# (Monodevelop)

  • you'll learn about private and public Variables

  • you'll learn about List's and Array's

  • you'll learn about for-loops and nested for-loops

  • you'll learn how to create your own functions and neccesary arguments

  • you'll learn about Interfaces for Drag and Drop 2D Objects

  • you'll learn about if-conditionsĀ  and expressions

Conclusion

In the end of this course you will have a fully functional Mastermind Game in 2D which you can (after you have created nice Menus, Buttons, and maybe additional content) upload to any Gaming Website, Google Playstore, Apple Store or even Windows Store or Steam.

Let's make your dream game a reality!!

Level: Beginner
Video Course Length: ~5.5 hoursĀ 
Unity Version required: 4.6+

Transcripts

1. #0 Intro: welcome to the Mastermind course for unity or in unity. In this course, you will learn how to create your own master mind game with different game modes we're talking about. Or actually, you will learn how to use buttons for interactions We're gonna go and a low, different scenes between those button tabs. We're going to create riddles based on input. And also, as you can see, we're learning how to drag in thes particular pearls. I am into the corresponding slopes. We activating Andy of activating buttons on run time. Meanwhile, we are good doing some decent requests to them. We're giving the player clues where and how the correct answer might be. Meanwhile, playing as well as later on when we're losing or winning, giving out a yes solution screen, I would say where the player can see how long it took for him and also how much turn see made years off or has used as well as how long he was playing the complete game. So, as you can see, we're talking about time, we're also animating so that the solution books is going to be shown here, and we give them the possibility to try again or even go back to the menu as well s where? Completely coordinating score based on that. So I hope to see you joining this course, and I hope you're going to learn a lot from its. 2. #1 Unity Setup: Hello, ladies and gentlemen, boys and girls. Welcome to the mastermind. Yeah, Unity course, this one is going to be here as a simple one. So I aim for beginners and also probably some intermediates which want to know a bit more about four loops in the race and lists and stuff like that. So we're going to touch all of this as well as we won't going to touch the canvas system of unity, which is presented a sense you 94.6 and over. But what? I'm going to use his unity. Version two k 18.2 11 f one. Ashleigh. It doesn't really matter how old your version is. You. Even the newest unity to Kane 19 shouldn't be any problem. Was creating this course as well as creating the game mastermind wiz it since. Well, there is some design decision we have to do before I want you to go to your game view, and I want to make sure that the consul at first is always visible. So when we start coding light on, you want to make sure that you always see the consul. What's going to happen when we debug problems? and stuff like that. The consul is the one we want to see at any time. Also, I like to see the scene view and the game, but at the same time as well. So when they are sticking next to each other like it is, usually you cannot see what's happening in the sea. Meanwhile, you're in the game and vice versa. So that's why I dragged my game view down below. Over here. Open up a bit and the consul does not need to be that big. But this is just something I like to work with. If you want to have your hierarchy penalties the left, of course, feel free to use it. Just make sure you see always two game you the scene view and the consul view. Ah, same for the Project one. It isn't necessarily too big, but you want to see that all the folders and stuff like that, all the structures razor organized, that important for such tutorials as well as well as for the future. When you're working with companies, you want to make sure that you are always as organized as possible. So when you have set it up, this one. You also have to decide what's the view size off my game later on. So what's the resolution? Is it going to be in 16 by 10? 16 by nine? Or do you want to have this import remote? Then you might want to switch to nine by 16 and 10 by 16. If that is not available for you, you can always add your own. So you press on this little plus over here and you can say this a fixed resolution or an aspect ratio. So you go for aspect ratio, and then you type in 16 by our 10 by 16 for example, you can also see what is going to look about over here, and then it will add when you press OK, the 10 by 16 and saying for nine by six and you want to add nine by 16 off course refused to do so. The girls are labeled, there's one. If you don't labeled, it will automatically have this catching over here or actually something like this. When you labeled like ultra y 29 21 by war by nine again. That's how you get these resolutions or this aspect rations for your screen, You at all. One other note here is it doesn't matter if you're working in this release three D set up on YouTube. He said I basically everything is going to be the same. Nothing fancy at all. We just make need to make sure that the camera system is working. Since stat is when we're working in two D, one of the most impressive ones. And actually, for this tutorial, it is even needed because we're using some specific dragon drop possibility for all the pearls when we are starting with Ah, yeah, creating all that content. So, speaking off all the set up, I guess that is everything. What you need to know for the moment, just for setting up the scene and stuff like this and, yeah, let's go to the next part. 3. #2 Pearl Basic Setup: welcome back to part two and the last video we talked about setting everything up. So you feel comfortable was working and with everything you like and police off girls, we want to make sure again to see console game you and see me at the same time. So what I want to do is before I start setting up anything I want to choose my resolution. And in this case, I pick 10 by 16. Since I get is a resident affordable, it's not that slim to from the left to the right, we have enough space toe work within when we're making use off the camera and off course off the can was later on. So dance what? I want you to ensure to set him as well. So if you like to make use off my pearl so the acid I provide, then I Yeah, I can tell you. We gonna set up the pearl now, So the pole is basically an image or a set off images, where which we are later on, able to dreck around and put into stir the slots off the master mind game. So what do you want to do? Is you want to add for us import the package or just a P and G. I'm not sure what I'm going to share with you. So I go to my assets Wilder in the project view of a young creatine you folder. And I call those one textures. You can also name this one stride, so whatever you please and like as long as you know what it iss. So I put the pills p NZ into this taxes folder. Once again, if this is a prefab or actually it's set up, I already put provided as a unity package free, free to directly use it. If I don't would just use the P and G. I guess one of thes will be inside. Or probably both. Okay, so we have this pearls here and we want to issue that we switch them to spry to Dean you I and set them in the spread Moto be multiple since multiple objects are going to be presented or in this case, graphics are presented on this little view that apply the changes and wondering once it's done. It changed its transparency as well as we're able to go into this pride editor and this bright editor contains three graphics. Just a white Yeah, Circle one, which is like going to be our slot and this one is going to be the effect Go sitting on our pearl Now we go to slides and said, There's one toe automatic pivot center and then we slice it. What will happen when we do so when we click on one of these pills, this little squares will appear. This are going to be our Yeah, let's say sprites later on. So we have this one, this one and this one. This one does not have anything. So it's not present. Don't forget to apply the changes in the top right corner over here. And then we're good to go. You can even go he and rename those if you like to. But well, you don't have to. What we now have is a three of these Bryants. Once again, we can select them all separate Lee one after the other and we can make use of him. What I want you to do is you go to you, I Then you go to canvass or you go to image when we're creating an image it will always have the size off 100 by 100. It will we be positioned anywhere in the scene next to or on the Candace. And this image later on is going to be our pearl. And also, yes, you can see it is related to the cameras. That means that we can only see the image when it is a child off the canvas. When we know dreck out the image here, you can see it is just not visible. So images or image components are only visible inside the canvas system, and that's what we're gonna make use off. So the next thing is, we want to have the specifics blind for our pearl, and this is going to be just that round circle. What we also can do us, we can preserve the aspect ratio. That means when we scale something around over here, the aspect ratio of that would always be the same size. You don't have to do it, but you can. We can also bring this around. We can switch to two D mode off a here next to the sea Indio, so we can actually put this into any position we like. So when we keep on the size for the moment, we can also add another child image to this particular image, like so. And I want to add this glass image now onto the pearl image. So on to the second image I renamed this now glass, and the first image is going to be just our pearl, depending on what the pearl color later on is going to be the girl, as does never change, what does it mean now is we can tow like the pole itself. Do not touch the glass. But we can once again keep on selecting and drinking this around because glasses child off the pill and we now can tint the pearl toe orange. And as you can see, the glass of fact is going to lay over, and the pearl itself is only colored by a simple color overlay on the image component. And that's what makes the effect or illusion off a three D classy pearl. And we can do this was every other pill we like to. But before we going to do that, we have to set up. There were other things as well, but for now our pearl is done 4. #3 Drag Pearls: nets and the drag ability on this pill at first we need to understand is that this is only working in the camera system, this version off code I'm going to present or actually teach you so. But before we can do that, we need to make sure that we have one specific type off year. Let's say a component onto our pill. We can add this by hand, and later on we're gonna create pre fabs from this particular pearl or when we miss something and or whatever is going to happen when we deep the lead something. We can also add a specific component by coat and to start coding. I want to create at first and you folder Kohler's one scripts Double clicking the scripts Will the right click creating you see shop script, and this is going to be my drag to D script. It can be like you can name it, however you want. You can also named just dragging or drag around or whatever you want. I name it direct to D because it's short, and it remembers me that this is only working in a to D space or in a Candace I would say you could also laid on command things out. So open this director de script all up in one of developed visual studio, that museum in a bit so I can see stuff better. So this is our drank script? Nothing fancy at all. We don't need starting updates a adjusted Distract us. We don't need those so we can easily get rid of them. I want to add It's a specific type off handler and those handlers are using a name space cold using unity engine don't event systems. So we're going to use events to drag around images or these pearl objects. How can we do that at first? There are specific types off functions already provided by unity, which we can make use off. But we can. Before we can do that, we need to add some more things here. So the 1st 1 we want to add is an I Begin Drac Hendra. Once you start typing this and you can see it, you have done everything right because the event system has already added If you don't see this, you have to read your ad the event system first. So we want to make sure that we use I begin Drac handler the same one or would also want to do is an eye drac handler because you want to drag around things And then there's one other one we want to use is an I end drank Hendler. So these three handlers are important for dragging around if you don't know, or if you can't remember or whatever. If you like to do your life a bit easier, you can write, collect those hand the names, go to re factor and then you say implement interface So these are interfaces and you will get this warning. And if you get this warning nothing as bad and nothing is wrong with that, you can just say use re factoring on this solution. Then you're gonna see this little yellow line in year which say's where to implement this interface using the arrows Ah, Iraqis up and down. You can easily implement them by, you know, going up and down so you get automatically created a region. So this will be just unimplemented meditation. I begin handler, or I begin Drac handler. But it can also delete those regions If you don't like them, what you also want to delete this. This Roman uses the not implementation exception because you don't need this. So what we keep a left on? It's a public void on begin drag point. It pointed event data with the name event data. That's what we're gonna use for all these other two's as well. So the point of event data is the data. When our Mao's is doing or starting to drag around and this is automatically created, we just need to push the position some things here and there. Same for the I drink and lower right click re factor Implement interface going up and down with the arrow keys on your keyboard. You can implement this on the wherever the line is. There might be some space in there, so you probably want to get rid of it. Also, once against thrown news system, stuff can be done or can be deleted. Same for the other interface. Just go down or positioned wherever you like, as long it is inside the class. Also, once again, we don't want to throw any exceptions here, so everything is fine s against. See, those re functions are automatically provided by unity and we can make use of them. So what do we do? Is that at first want to understand or we want to see what's going to happen. For example, we can debunk that instantly so it can say debug dot log and an open girls apprentices who can say beginning, dragged or dragging so we can easily check this one out. What I want you to add also is in square brackets on top is we want to add a required component on to wherever we direct this. Yet the script on and this required component needs to have being or needs to be off type off and the parentheses once again can this group and this cameras group is in saying the importance. I gotta tell you why in just a second. So when we now go back into our into our unity, the proposal compiler will dob will go through, probably has some problems in here is there are some. Go back and check what's going to be wrong. What I now do is I dragged my director de script onto my pearl not onto the collapse onto the pearl and what it is doing it. It also automatically creates this canvas group. That is where the required component comes from. Or is for What we can do is we can says this Want to interact? Herbal? Yes. Oh, no. We can block rank cast? Yes. Oh, no. We can set its elf if we want to. Just all of that by this canvas group. But actually it doesn't really matter when I know press plane And I tried to drag around this pearl you're gonna see in the consul beginning drag this beginning Drank comes from the debug dot logline here. So we know this beginning drag is working 100% like so. When we not want to do is we want to position on drag our whatever we try to drank to our mouse. And how can we do that? We just say transform those positions Always change the pearls position to be the mouth position, But since we're not using the mouse but the event data the one we are getting here from the point of event data, we gonna get this request Don't position so we now can drag around the pearl. Let's try that out. Let the compiler run. If anything, wrong, of course. Go back and fix it. But if everything is working fine and you are in the game view, you should be able to drag around this pearl to wherever you would like to, just because off these some small kind or a small amounts of coat. Now what we want to do is we want to remember the old position so we can't snap it back to where it came from. And that's super important later, Honest will. Also, we just create a vector two or vectors re basically doesn't really matter because we only use Accent's Add Vari Ables and I just named this one old paused or old position so the old position is going to be stored whenever we're starting to drag on begin drag. How do we do this? We just say all position equals transform the position so we just store that in old position. And now, when we are ending our drag, we want to have this one snapping back to its original position. So we say, transformed. The position is equal toe old position, and that's pretty much it. There's one thing we need to take care off, but before we do anything we want to save, so you can always press Control s for quick safe. Go back to unity and once the compiler is done, you can press play and tests around so you can drag it to anywhere. Right now, we're beginning. Drag. When I let go, it automatically snaps back to its original position. Asic unsee. And that's what we need later on. And there's one more thing we need for the drug ability. Over here is we need to set the rate casting because other underlying objects need to know that we are sending a recast throw this object, and this object itself is going to block the ray cast whenever we take it. But let's keep that for one of the next tutorials, like when we're snapping stuff to the slots. But we've all we can do that we, of course, need to create those. So that's going to be in the next video, I guess 5. #4 Create Playfield: welcome back to the course in this part. We're going to create some slots where we can actually put in pills and give them the possibility to be dragged in. So but before we do that, we need to change the canvas a bit, at least just a small bit as second. See when you select the canvas that is the canvas scaler, and usually you have problems when skating things around. The scaler is in the wrong scam mode. What you want to do is later on. Also, it is important when you have different screen resolutions. You want to make sure that you select scale with Sweet'n size. What you can see. Our big, huge pill is now smaller than usual because it is now not the constant picture size. It's now scale with scaling with the screen size. So depending on the size of the screen, the pill will be bigger or smaller now. So when we do like this, just like scaling it up usually and the good thing is that the size of 100 pixels now is going to fit better into what we want to create. Eight. So let's create a play field or let's say some first, some panels to or images to see how we want to organize the game. So this is the design decision. Once again, you can do it however you like. And please, however, it matches your style of the game and so on and so forth. Once again, it doesn't really matter. Visit studios reading, see game scene. You can change your camera even to to demote if you like, but we don't have to take care of that. What I want to create in this canvas also like the cameras, right, collect you. I at first we can make use off several different things we can make use directly of panels or images or whatever your police and light. Later on, we're gonna make use one button, but for now, we just don't. So let's create an image genetic and see a 100 size or width, and the height of 100 by 100 is going to stay the same. And that's good. So we can actually Pele's things around and see how we want to rearrange or range our user interface or the player interface, whatever you call it. So what we can do is we can stretch things around, make sure you are in this little mode of a year the ranked to a mode and you are into demote of the here next to the scene dio panelled as does little button for two D. So you get this little nice knobs and everything is good to go in the scene view if you don't see enough. Of course, you can always go in scale things down like here and just probably goes that you're fitting your game view. Okay, So what you want toe? Understand that this is going to be the box light on where the solution is hidden. Meaning when, ah, we're gonna create a pattern by four or five or six pearls, whatever we want to. And we want to hide them here behind some I don't know, some box or something with question marks on it. Whatever. Then we want to make sure that these little things are matching in our little pills. So what you can do is for now, for example, you can just direct this pill on he and see what's the size. As you can also see, it is now under the image and this is not important for the moment. But later on, it's going to be. And as it can see, my my image here is now a bit bigger. Like in height is 116. When we put it like 120 we put our 100 by 100 image off the pearl on it are gonna drag it under three, Concede better and I dragged directly here. You're gonna see we're gonna have some small space over here. And even if we would duplicate the several times, we can easily figure out how many off these pills are going to fit in. Also, we're gonna make use of slot instead of just a pill. So they might be a bit bigger than, like wide and 10 in, for example. Okay, that's just what we are after. The next one is we want to have slots where we can actually drag in our polls. And that's our complete playfield. So under this image was is going to be maybe our solution box keep on going and rename things otherwise you probably don't understand, like don't want you were supposed to dio you can duplicate this. Or you can create just a new empty image directly in the canvas as a child off the cameras . So like this and we can drag it around like so that we probably keep some space to the top . If you like to. You don't have to also make use of the snapping solutions over here. And later on, we're gonna see how many space or how much space we're gonna need for our pearl pool meaning under this image and under this image. So this is going to be our playfield where we drank in our pearls. Probably we later on, we were resize it ability. And there it depends on what we need in like once again, I now duplicate the solution panel and bring this over here to the bottom line. As you can see, it's raza small so we don't get like, two lines of pearl under the Playfield. So what I want to do is I want to increase the size to maybe being the double size off whatever it has been before, like 1 20 going to be maybe a to 40 in height. So there's going to be my pope will probably later on. And so that means that I need to fix my game view over here a bit more. Ah, here to whatever it has to be or can be. Okay, so inside this box in the center, we can now put in our pearl slots. And how can we do that? It's rather simple. We can make use first off a spacing game object, which is going to do all the spacing for us. And inside of that, we're gonna put some squares or like the solution books, and we feel in those vertical e and speaking off, vertical is this is going to be a vertical layout group. We're gonna make use off. So let's rename this image. And this can be our play back ground. For example, there will be some other pile. Yeah, but child objects on this play background once again. So what we do is we go to create empty, select the play background once again and say, create empty. There's going to be different to another empty game object, because this is making use of direct transform instead of the normal trends for just keep that in mind. So the next step is we take this game, objects we rename it is going to be our space. Or so it's going to take care of that. Everything is in space and we'll space it for us. And what we want to do is you want to go to this little anchor preset. Hold on old and shift, and then select uniforms stretch in the bottom right corner, as a concede will automatically uniformly stretch around inside the play background. What does it mean is when we know move this, The spacer will move with it because it's uniformly stretching with this yet played background in this place or in the spacer. We want to create a holder, objects or, like one line off something which is holding all our game off this hour slots later on. But before we want to do that, we gonna ah, house. Can I can we do that? We create this one at first as an image in, well, not like in the play background, so I can 10th. It's a bit so we can see this better and make this one just dark. You can make it red, green, blue, whatever you like, and please once again, we can make use off the height off 1 20 if we'd like to. What? We keep it as 100 make use off the scale later on. So the pills probably are not 100 by one hundreds, but maybe 80 by 80. So that also means we can also even keep that on 100 by 100. So it all depends on how much space we laid on half to fit it into the complete play background or Playfield. So what we're gonna do is we re size does want to probably that and in the spacer, I want to create a vertical later layout group. And this vertical air group once again is taking care off different things is going to control the Wyss and the height, but is not taking care off the height Child force expend. So what we now do is we take our image. I gonna rename this, want to be hold on. And now I drag this one into the spaces like this. Now it's going to be invisible. And that's not cool, right? Why is that going to be invisible? Because its height is set to be zero. And how can we change that? Of course, we need to go into the holder at first, and we need to add a layout element, and this layout element needs to be set by us. Once again. Our minimum height should be at least 100 because we want to have that. As you can see, the layout element is overriding the vertical loyal group element over here. That's goods on what we also want to set is the flexible height to be on a but not at one. So it's not stretching over the complete thing. We want to set up 1 to 0, but we want to make sure that is enabled. Why do we want to do that? Because when something is changing, this is also going to change with it. For example, when we do it like this, the holder is going to follow up. If we change it like that, the follower, the following stuff or actually it's going to stay the same size, it would be one. It will automatically go up and down and reduces and increases its size on its own. That's bad. Okay, so finally we have the holder and the holder also has a child object. A game object we gonna keep on creating a grit in it. So at first it's going to be just an empty one. So we create an anti game object onto the holder, and once again, this is going to be another space which is lying over the complete size. So what we're gonna do is we sent this one to be uniformly stretch as well. There's going to be our slot spacer or something. Or you can also name is one space that actually it doesn't really matter. And on that we're gonna add a grid layout group this time. So the grid layer group is take care of that. All the cells, whatever we're putting as a child in it, having the same size, the same spacing and, of course, the same. Yes, set up. How can we do that week at for us? Go to the cell size. I change this 12 probably 80. As I said before an 80 over here as well if we want to use 90 or whatever off course we're able to do so now, what we need is we need something to put into almost Lord spacer to set it up correctly. And how can we do that? Actually, we go to our canvas itself and create a new you are image. Yes, we need a lot of images over here, but it's easy to set up so true. Just trust. May I got 1/10 is red so I can see this one better. There's going to be my slot once again. The color is just now for identifying it. When we know would put this into our slot spaces, see what's going to happen. So we take our slot into the slot spacer. As you can see, it is automatically snapping into this and re sizing itself to the size of 80 by 80. That's what the Grid Layer group is going to do. Was it now, Once we had done was dad. We can't set up the complete spacing stuff. So when we duplicates the slope by holding down control de selecting at first, it gonna adds more and more to the left. I guess 80 is a bit small. I maybe want to change this 1 to 90 and 90 years Well, so we fill up a bit more space. Now we want to have some spacing on X and Zad, or X and Y in this case. So maybe you want to put some small spacing in between those images. Maybe a two by two. And I want to have a padding from top left corner like five pixels from the left, five pixels from the top, as you can see. No, ever raise a goods and nicely set it up. Think no one. We had prayed a drag around the playback, the playback ground. It will automatically go and put this one into a grid. This is good, but at the same time, we can keep on and maybe reducing our complete playfield to just four. So meaning we can, for example, get rid off. This particular slot we also can do is of course, we can put in this right like the poles to over here, and we get rid off the color red and make it just gray or whatever you please. Unlike so the other ones can be deleted, for example, and with duplicate this like three times. So we have a slot. What's next? Well, it's easy. We can now easily duplicate Holder because we have to space over here. We can put the spacing off, maybe two or three in between those holders as well. And when we now duplicate the holder, we can fill the complete vertical layer group as well, whereas a simple right, and that's what we can later on, make use off. 6. #5 Playfield Update: in the last part, we were creating all the holder and slots we lay their own one to drank our pulls into We're gonna do the dragon below Tear a bit light on beforehand. I want to make sure that everything fits as it has to be. For example, if you're creating a game was just four pills you want to the polite to analyze. Of course, you want to make sure that the solution box is not as big as it airs because, well, as you can see, it probably is distracting. Also, we have more space to the lower area so it can fit in more pills into this. So what you want to go is you want to change the high eat to 100 again. Since that the holder objects are also in height 100 now we can take the pearl and make this one maybe 80 by 80. As you can see now, the glasses not fitting. So we need to do the same on the glass as well. Now we have the possibility to check this one out once again, drag it around, but not class. Take the complete pearl and see if it did, how it would look. And since the pill is on the very top, like over the play background, we are unable to see it over here. But when we drag it down, it's going to be over it. Now we want to see how this would look and probably 80 could be a bit too small, so we might want to increase the size a bit later on. But from the moment I am Arezzo happy with the result, once again we can also reduce the site of slots and so on and so forth. Answer for several possibilities. But what I want to make sure is that the pills once again are fitting the solution books in the solution books. There will be also these pills lots late on as well as I want to have more space for the complete leg. Grab a play background. So I keep it or ask. They dragged a bit up so I can increase the size to the very lower side over here, but not inside the spaces. Make sure you take the ballet background. We can now fit in another holder inside this yeah, vertical layout group. So same here. The height needs maximum of 200 instead of 240. So we get even more space back in total. We should have now, besides off nine fields to play around with, we can even increase the size to be 10 by decreasing this height off this pill pool. Like for example, we can take almost a full size and take the pill pool like this so we can even add one more into this. But we need to make sure that the height is at least 100 off the civil copied solution box . I gonna rename this now to pull pull. So that is where our polls are lying in two. Later on. We're gonna direct them out from into this slots. So once again, the play background is a bit too small that here once again, we can't fit in another hole over here. If we like Teoh like this fit in or Ashley try to fit the size off the holder bit more. So you probably want to take care off the background. Maybe you want to take the black of the background to be black or red or grey, Whatever you please in like So you have some? Yeah, some nice rose visible inside of that as well. Also, as you can see, we still have the three D background. You probably want to get rid off you so it can easily go to the main camera switch from skybox to solid color and maybe give it a darkish grey tint, a black tint or whatever you can even go was blue or anything you preferred. Like you can later on, even put in, Yeah, background images or whatever you like in police. And that's pretty much everything. Now for this slots, we gonna late on the create on protectors to overlay those. But for now, we're good to go with that. And we can also already create some tools, some other pills to drag around here and there. They're once again later on. These pills are going to be in here, like in also in a grid layer group, and then we are able to direct them to the corresponding slots. But before we do all of that, I want to make sure that we create the drop ability onto the slots 7. #6 Drop Pearls: welcome back to mastermind Unity tutorial course in this point, and we want to talk about the drag ability off all the slots. But before we can do that, we want to simplify our work because we don't want to goto all holders, all slots pacers and click onto all the slots when we want to do is we want to get rid of all the holders we already have created Nothing fancy. Does that make sure we only have four slots like this so we can easily select them? And later on, when we duplicate the holder again, we're gonna have a setups completely correctly set it up at once. So what we want to do is we want to create a new script where we are able to catch the pearl in runtime, so meaning when we're dropping the pearl, we want to drag it over here, as you maybe remember, is that we have putting this one back onto web. It is coming from other good reason for this, but what we want to do is we're going to at first simplify everything we can also take away . There's a drop ability to see if everything is fitting so far, and then we easily go and change something inside the code, no matter what. So what we now do is we create a new siege of script because one drop to D. So we know once again it is only related to the objects in a side, the canvas system. So this drop two D needs to sit on every slot. So what we can do is again I actually select all the four slots in the hierarchy panel and then drag the drop to de onto it. So it's easily sitting on that. We're gonna have to do some. That's a coding first, and then we're gonna need to set them up a bit. That means we need to go back into the inspector and set one number personal lot easily by that, so DoubleClick could drop to D and then, of course, opened this one up in mono, developed. Once it's open, we can get rid of starting update since we don't need that's. But as you probably remember, we made use off using a unity engine don't event systems. This is what we need to do here as well, since we need to really really receive the point of event data. And so that means we need to implement one interface. And this interface once again is called I dropped Handler. Since we want to drop something here and when something drops on this particular game object, we want to react to it once again, right? Click re factor Implement interface at this position will do the work for us so we don't have to type out everything. If you want to talk about everything. As you can see, it is public point on drop point event data event data. When we want to drop things, we have several possibilities. The 1st 1 is we can snap the pointed whatever. We actually the drag stuff directly to the position where it come from. And to understand this one, we're gonna test this out first. That means also we need to disable something from the drag to D at the end to drag so not snapping back to its original position. So when we need to do is at first we need to make sure that we talked to the event data were coming in. Then we say pointed drag Is this one over here? the object that is receiving on drag so pointed, drank, don't. And now we're gonna say transformed, don't position. And we now position this object of the pearl we are currently dragging on too, the transform position off the slot So we can't say transform. Don't position off the slots of the current one where the drop is on. This is only working when in drag to D on end drag we're not doing transformed the positional position. I commend us out, but with two slash is so we can test this one out because we're going to make use of this in just a second as well. So what we're gonna have now is when we press play and you can always try all things. Of course, when we press play now and I'm gonna increase a bit my viewing so you can't see it better. So I gonna take this pill and when I let go, it must not go back to its original position. But when I dragged this onto a slot which contains this drag to the script, it should drop on it. But what you can also see it is not working, and I gonna explain you why? The point is we are shooting from our mouse array through this object. And since the all red casts are blocked by this object by this pearl, we're dragging around. We are unable to reach the slot, which is sitting under the pill. Meanwhile, we're dragging it around. And what does it mean is actually we need to make sure that we make this one drag a ble, and this is only working when we a disabling block, great cast. And that's what our can This group is four, we already added in one of the last videos. So what we're gonna do is one begin drag in drag to D. We get the component off time. Canvas groups always like get component open closes the trying of brackets Candace grope and open close Prentice's behind And then we can talk to block right casts and we want not to block any red casts when we holding or dragging this one around. So we disabled and said to be false when we let go that we want to make sure, like on drag, we want to make sure that we gonna off course go back to true because we want to react to our mouse input. So we say block rate cast off the cameras. Group component to be true in on end drag. Don't forget to safe once again. Quick safe is going to be control s so keep that in mind. It can be useful and makes you faster, actually. And once the compiler is completely done and you don't have any errors off course, this opposition is not being used at the moment of girls. No problem. Was that so in north this warning because we commanded it out. Now, when we're dragging this around, as you can see everything as usual. But when we now go on to a slot and hit it like just on the corner, it automatically snaps into the position off the slot. And that's what we want. We want to make sure that we are able to say yes, drag this directly into the slot. Ignore the consul for the moment that we get rid off the debug lines later on. And that's what we wanted. We now maggot, make sure that we're dragging it and dropping it and snapping tools, a slot position, and it looks resin eyes when you try that, and that's cool, but it's not what we want. What we want is we want to create a new poll in the Raisa in the purple later on, or we want to instance she ate a poor pearl. We already have create added, like we can crew actually instantly ate the pearl we're currently dragging. And, yeah, make sure that we create a copy off this directly inside the slot. It will automatically snap, and then we can keep on reading the data onto the drop script, and that's what we want to do now. So we go back to our drop two D script and instead off putting the pointed drag transplant of position over here, we want to make sure that we create a new game object. So what we can do is I commend out the event system over here so we don't snap it. If you like to keep it. Of course, snap around. You know, this is just for snapping onto position off the drag. Yeah, game object, actually. But what we want to do is we want to create a new ball when you pearl. So we say game objects New pearl and we say is equal toe. And now we want to instance she ate and an open close Prentice's What do we want to instance? She ate. Of course we want to create or instance she ate event data thought point a drag once again point to drank the game object we're currently dragging. Don't game objects, comma. Don't want to set this one that the parents should be the slot. So we say transform comma. And then we put this one into the world Space off this object to be true So the scale is correct. Once we have done that, we can light their own position the ball to, you know, to the slot directly, since we just make it want child off the current transform. But we not position it. So we say you pull, don't transform. The position is equal to transform the position. That's it's one thing later on needs to be done, but that's what we're gonna do in another video. So when I now drag my pearl around and we don't have any arrows, of course, Well, let's hope we can clear the console. Nothing fancy, no problems at all and what we now do is we instance she ate a new pearl onto position. But before I test is out, I want to make sure that I re enable the transfer position to be old position in the two D slot so we can see that's working 1%. So we press play. Oh, I press play. And once done, I gonna drag my pearl to any slot. As you can see, there's a drank slot or the direct pull is going to be backwards. And this one here became instance. Yeah, I did now onto this position, and we cannot drag around that that's good and same here. We can now fill in all force lawns with these pills, and the cool thing is, we can't even overwrite them. The point is, there will be always a clone inside or an extra clone inside the slot. We can also get rid of it if we like to, but actually it's not necessary. But that's how it can actually also override whatever it's currently insight. The slots don't forget to safe the scene since we have done a lot over here already, so it's control as to say the scene or created you seen. If you don't use unity to care 18 something new older, it's going to be created into the sample. Seen? I'm not sure what since when? But in 45 this is not representative. We have to create your own. See, whenever you Chris press control s you have to just give it a scene name. Put it into your scene's folder and you're good to go. 8. #7 More Pearls: since we are no able to drag around or pearl and instant it you pills to whatever we have created over a year from whatever we're dragging around, we want to understand or keep or create a system which is understanding what's kind of pearl we were dragging around or dragging at all. So what I want you to create it for us is a prefab folder. So I call is one just three fab and inside we're gonna put all the possible pearls you want to make sure or use off. You can even once again create your own shapes on stuff like that. You're gonna also create, use or make use off the one I provide over here. So how can we do that? This one is going to be an orange pearl. So what we're gonna dio here first is we rename this orange pearl and I direct this complete thing that's complete. Set up into my pre fabs folder. No one can ask Lee 10th this one to be a black pearl. If I liked Teoh, I rename. It's a black tool. Don't forget to hit Enter And now I drink this one into my prefects will then have a black one. I can do the same for any color I like. I can create a yellow pearl and directors want into the heart. Yeah, into the Prefect solar. I can create a red pill once again. We name it and to drag it in my pre vessel them you can create as many as you like. I guess I'm gonna create Laurent six. So we have something toe work with. So this is going to be maybe a purple, purple pearl and, of course, a drink this one into my panel of a year and another green one, maybe Like, this may be a bit more grassy. I don't know, Andi. I rember named this one to be green curl. And of course, the directors want into my pre fabs hold up. Then I delete this one in here, or I can keep it for, you know, testing stuff around. You can once again create as much as you like, but actually this one is not related chasing but its own prefab. So when we know two changes to the pre fabs, we can actually do anything well, like inside the pre fabs and everything inside, the scene is automatically updated as well. What? I want you to go to it to the dreck, to D functional script and under the over the vector or position the victory opposition, I want you to create an integer. It's going to be a public interview, just a straight number off type. And so it's just a 123456789 and so on. It's of force. These numbers is like a lady or important, and I call this one pill I d this pearl I d needs to be set inside the prefab. This is important. So when we go to our Black Pearl, for example, and the compiler is done running and we are in the previous holder, you can see there's now the pearl ID's part over here. What you now do as you give everything every pill a unique I d want is reform finds acceptance on that start was black. One green, too, or in three poeple for rat five and yellow pearl six. You can even create your own ideas. It is important that any pearl, no matter what kind of shape it is going to be like a star or whatever everything needs to have a unique i. D. This is important because as a wise, this system is not able to see or understand what kindof Pearl relayed on drag into our slots. And since we're reading those ideas later on from the slots but not from the pearls is a super important that these are all unique. So the system understands that and updates accordingly. So and that baby, but basically everything we need to understand now for all the complete system running late on because those numbers getting crunched down, you know, until or actually compared with our solution box when we're starting to create the solution books, you will probably even know more. Understand more why we're using this unique i DS. Because the solution box does not know this is this type of game objective. This is this type of pearl or it is orange, blue, red. No, The only thing the solution books later on nose is, let's say, and an array or a list off numbers from the left to the right. So what's in the first slot? Which number are It's number 10 7 Okay, now we can so actually compare this number seven. Was this number seven? It was That is matching off course. We're gonna have a match, but all of that matching stuff is going to be come important light on. So I hope you understand. This was thes ideas. And in the next part, we're creating a dragon Books gripped, I guess. Which is providing end off course holding. All the ideas were dragging in. We're going to read the data, and then we can actually later on compare the data and give our yeah, all the players some kind of hint box like those black and white, purple or girls over here to the next. Once again, this is also designed decision. We're gonna take all yeah, care off later on, but that's it for now. 9. #8 Solution Box Setup: Welcome back to the course in this part. We want to start eight. The solution box in the solution box is going to be for my opinion, this one is going to be the one in the upper area over here. We already started to to create the solution box with just that image. What? We want to do it. We want to create some slots like this one we have created in the handler or in the holder object over here. We also want to have some over there. Also, what you want to do is you want to prepare or actually let a sister or let's create a system which is taking care off, picking pearls and creating the riddle for us like the one which is going to be the solution. The people which are playing our game are able or hopefully I able to figure out later on. So we want to create a riddle by code. But before we can do that, so once again, we need some components onto our solution box. So what's the solution box selected? We can actually put in any images as we already have done in the handler for example, as we already or no, not the handle about the holder. So what? We can do it. You can basically do the same as we do in the holder. We just don't need the layout element since it's not going to change. But what we're gonna do is we create a grid layer group or even a horizontal air group basically bows out the same. But I guess late, Gridley, a group. It's easier to set up for us because we can also deter mined the cell size, and then we put in some slots. So we're gonna do the same for the solution box over here. So what we're gonna do is we create an empty we make sure that it is already or actually when we hold on old and shift at the same time, we set this 12 uniforms stretch, so it will be fitting over here, and we can rename this one to be our space that once again, again, this is just a space object. It's this empty, which is just on doing the group lay out for us. So we add a great layer group and we can do the same as we have done in the holder. So, for example, the sale size and he is going to be 90 by 90. We want to have the padding from the top left corner by five and five, and we probably want to excellent spacing in between, like a two by two. And that's pretty much it. What we have done in the other one in the holder object for that. So, as you can see when we go to the slot space that we have basically the same set up. So top left, five cell size of 90 spacing off two by two. And the rest is nothing what we have touched so far. Same for this spacer. We're gonna have once again done a left five top five. It's like the distance between or from the top left corner and or five pixels, and then the cell size is going to be 90. So what we're gonna do is we now create one off these slots. We can simply create an image, for example, directly in the space of like so you. I image. And as you can see, we're automating a slap in the top left corner. And when it is snapping there. We just need to drag it a bit. So it is actually coming back where it has to bay. We can also give it once again a color if you look like to, just to see if everything is fine and the distances are correct. This well or once again, we can instantly go on pick. I was slot over here. You can tint this into any color, maybe something bluish so or whatever. So it's look a bit different. But since there will be pearls on it, you Onley see most of the time just the surrounding year, Etch. So I keep it as white as it is. Once again, I can also intend to the solution books itself light on. So what I now do is I rename this 12 slot as well. And then I just duplicated four or Indus case three times. So I have four slots in our grid layout like that, and I can see it's looking the same way as it is done below. So once again for the solution box, we can give it another tent. We can even put in any graphics. It would like Teoh we can give it a red blue greenish tend whatever we like and police just to see or show the player hate. This is, by the way, the solution. So once again, this is all design decisions you have to make on your own. I cannot help you. Was that once again, you can put in like any background images. You can make it a wooden. Ah, wouldn't look whatever you please. And like this can also be done once again by Sprite. So you just have to put in. And since you already know how to handle sprites, that shouldn't be that hard. Right? Okay, so now we have the solution box. We have a spacer in. It was a grid layout group, and we have five slots. What we now need to do is we need to create a script which is handling everything inside the solution box and creating a riddle for us. A riddle like picking four pearls for us to put into these slots on game start or whenever we press a specific button, for example. But that's what we're going to create in the next video 10. #9 Create Riddle 1: welcome back to the course in this part. We want to create the riddle inside the solution box. What does it mean is actually we want to pick random polls from a list or or an array and put them into the corresponding slots in the solution books, as well as storing the data off the I DS into another kind of list which you can actually request at any time to check against that list. What we need to do it for us is we need to create a new see chap script and we can crew name it, maybe riddle maker, or create riddle or whatever you please like or create Riddle to de once again. As long as you understand and know what you're doing and what these scripts are going to be four even light on when you're working for a company and stuff, then everything is going to be good to go. So naming convention is always helpful and and actually yeah needed. So once more no developed or visions duty has been opened. We can actually starts to create things. First thing I don't need update so I can get rid of it. Also you can get a rid off all the command lines. If you need to want Teoh, it's up to you. So first, as I already explained, we need an analyst or in array off game objects off all pearls possible for our games. So the our system, which is creating the riddle for us, automatically is able to pick from it. So we create a new public list, off type game object. Then we give it a name Pearl list, for example, and this is going to be equal to, and now we need to initialize dead. This so we say new list off the game object open close parentheses and closed the line was a semi column, so we need to initialize the new list every time we create one. You can do this resident you directly in the very able, or you can do it here in start message so you can say playlist equals new list of type game object. But since it presently doesn't matter where we do it or basically we want to have that let's be initialized before we even start the game. It is better to do it over here. Now we need to define how many pearls can be picked. We can do this public or private. Actually, it doesn't really matter. Later on, you can also change that kind of coat, so we create a even number or a just a number off. How many slots are there going to be? So if we play with four pearls, we can initialize that by saying, OK, this is going to be a pearl amount off maximum of four. So we have forced lots, which where we want to populate was pearls. This number is important. We can also put this directly later on into, but it's easier to take this particular number because when we change this one toe five, for example, or six, we can easily just change that number over here in public. Or once again, we do this private again also do this directly inside this script, so that's up to us for the moment. The next one is we need another list of objects, which is actually holding all the pig objects. So the Pearl list is the list from where all the pearls are getting dragged from. You can always command things out if you need on winter. This is once again how many slots we gonna have or how many pills were picking automatically by our system we're creating. Now we create another list. This needs to be proud, actually. Doesn't need to be, you know, private, but also doesn't need to be public. So I can keep this one private and then see shop. You don't necessarily have to type out private like that. You can just keep that private away. So you always know. Okay, if there's no public, then this is going to be always a private variable or private list. Whatever. So once again, same here, we gonna store game objects, which are going to be the picked pearls. I would put them into our I call it riddle list. So this is going to be the riddle with all the year corresponding. Yeah, pearls in it. And we initialized that once again. So he said, You list off type game, object, globe, open, close parentheses, and close the line with the summer column. Now we need all the parent objects or the slots parented to the holder object, and we, in this case, we also need another list. So there are two possibilities for this one as well. We can make a public so we direct them or on our own, inside this list for this force lots. So it is not directly related to the holder, but, of course, to the solution box where our slots are going to the end. So for now, I just keep it public so we can direct things in it. It's another type off list containing gain objects later on, and this is going to be our slot list. So all the slots will lend into that. We initialize that wears once again new list type of game object often go sprint disease and close the line was a semi colon. When we know, save and go back to unity, we already don't have anything related to the create riddle today. So what we go as we go to the solution box at first, and in here we don't have anything but the canvas ran round the image component and of course, the child object, which is going to be the space that was all the four slots related to it on the solution box. Directly, we gonna direct to create riddle to D Now you can see we have all the four or the pearl list and the slot list, and we can basically drag all the pill pre fabs into this pill list. Let's do it. Let's go toe prefect, select them all. But now you can see when we select something the inspector window changes so we cannot do this this way. But when you select the solution books and go this to this little lock symbol over here, we can look the current selection. Now take all the pre fabs and direct them into the pearl list. It doesn't matter in which to, um, order these polls are going to be inside as long as they are inside. That's it. So now you can get rid off the lock symbol again and you're back to the yet to the point. Same for the slot list. Once again, this is the size of zero at the moment. And since these are our child objects off the slot list, we can go and once again locked the solution box, select all the four slots and basically direct them in here. And that means the order is going to be from the left to the right. If you have created it like idea, Where is the horizontal layout group or the Grid Layer group, which we did here in the space of so we have also the order completely correct over here. 11. #10 Create Riddle 2: So what we create now is our own function, which is taking care off picking or that that means it is going to be a create is ah riddle function, for example. And here we just loops rule or the pills and add them to the riddle list and then automatically set them to be parented to the slots wherever their core sport corresponding to there might be one thing where we have Teoh reorganize things in this Lord list. All give the slot list some ideas, but actually let's take care of that, probably later on if we really need it. So what we do is we create a four loop in here for love is nothing else and repeatable loop by an I which is the letter where we're starting at. And this letter is basically just nothing else hasn't done an integer was a name we can name this whatever we want. Usually you take you or make use of I and J by looping through things were starting at zero . And while I a smaller than whatever the Mount is and in this case this amount is going to be this max morning here is going to be the pearl amount we increments I. That means there's four Loop is going to look four times through itself by starting at zero and ending at number three because I is requesting a smaller amount of pole inside of that . So that's what a full loop is doing. It is repeatedly for a specific amount in this case, four times looping through whatever we're doing or requesting in here. What? We want to do this four times. We want to create a random number. So we say int num number is stands for number and we're gonna pick a random number. So we say random good range and an organ Close practices will pick a number between zero and the maximum amount off pearls on our list. So pearl list don't count. Remember, this Pearl list has all the pearls inside, and if there are currently six inside, then of course, this is going to be number six. And since random that range is taking care off that the last numbers ignored it, only taking 0 to 5. This is important because a raise and list start with zero at the integer and not at one. So the element zero is going to be the first curl, and the last one is going to be number five. In this case when there are six pills inside. Keep that in mind. We don't need for those curly braces here, So at first we create a random number. Next one is we take this particular pick number and put a pearl from the list into the riddle list with that number we have chosen randomly. By the way, this is only working when we are allowing the same poll over and over. So we're going to start with that. And later on, we, for example, can say we don't want to have double pack picked pearls for our riddle. That is another option we can add on later. So what we do is to our riddle list we add so originalist dot ad we add the following game object. The following game object is picked by our pearl list and in square brackets. This is going to be the index were looping store or going to which we have picked randomly , which is in this case, the number over here. We put this in here as an indicator and we take this and brings us or at this to the riddle list to the first slot in the realist at number zero, the next one. What we want to do us. Since we creator or actually at this to the list, you also need to instance she ate this particular game object and perent ID to our slot. So we created new game object. So game object, Pearl or we can all the name it. New poll doesn't really matter. And what we want to do is, we want to say is equal to and that we want toe instance. She ate that's particular pick Pearl. So we say pelt list in square brackets numb. So we take this particular and insensate that is going to be anywhere in the scene. Now we want to position or X. In this case, it won't not position that we want to parent it. So we say slot list in square brackets, I. So we now take the first slot. So, in this case, slot number zero from our slot list and put this as a parent or a child object inside the slot list dot I. That's why the direction off the slaughter is important, so it's going to be from the left to the right, so you have to do it in order. Actually, it doesn't really matter. But you know, it is important that you understand how these things are acting with each other. Next one is we want to set this one to the transform off that because otherwise we just have a game object and we need to parent things to transforms and not to game objects. And then we say, Force force in this case is not related to the rotation court. Ernie in it is related to the to the local scale off the game object. Since we're working in two D and here we need to take care of that world space or local space. Very able affords for you doesn't work. Try out. True. That means you respect the world space off the slot. In this case. Now we want to position the pearl. So is a pulled or transformed. Our position is going to be equal toe there. We now position it to the pole, transforms parent in this case, slot idol, transform dot position. So in this case, I can also say pearl dot transform dot parent. So to the parent object, off pills transform. In this case, it's going to be the corresponding slot and its position, so dot position. Once again, you can also say slot list. I don't transformed opposition. Basically, it should be the same, but it's easier to take the pill directly because we have the possibility to do so. And now we want to disable the possibility to drag pulls around since we're taking from these a drinkable pearls. So we say pearl dot Now we get the component, which is sitting on it off type of drac to D we created before Hands on. Then we say enabled is equal or we forgot the open close parentheses behind it. Don't forget, those things are important. Tone abled is going to be equal to force, so we disable the drag ability off this created pill. In start. We just want to make sure that we call this function. So create riddle to do is not the correct one, because that's the name of the script. Create the riddle. Looking close parentheses and close the line was a semi colon. If everything is correct now, as against it. We don't use the parent years. So for now I may be a comment this one out. And for now, we just create a riddle by looping through all of their doing that stuff. 44 times since we said we have a proposal amount of four times, we place the pick pearls from the Poehler's into the riddle list so we can later on read from it. Whatever is inside, we can read the ideas off the slot or in this case, not of just off the slope, but also off the pill I d sitting on this riddle list and then we can Yeah, we actually parent in position, this one to the yet to the slot list that's tested out. At first, we want to make sure that we don't have any typing a rose or something, or no references or whatever. Now again, See, I got rid of that not transform over here. So we have our Pearl list, the poll amount of four and our slot list where all slots are in, and when I know press play and everything works. We should have four pills randomly picked from the Pearl list. We can repeat that, so we can't ask a check against it. As you can see, it's always picking random numbers or random pills, and sometimes, like now it can also happen that there are double picks, and that's going to be our riddle maker for this particular game. 12. #11 Adding Pearls & Pearl Fix: Now we have created the solution books, and actually, it creates the riddle for us. Now, we want to make sure that we have all pills in the scene. So we go to our little drag box down below and put in all the pills. We can actually drag into it. Yeah, once again, several possibilities to do so we can take the pool pool and make a great player group into it and drag all that pills as child objects to the purple. So since currently this green pill is not part off the pill pool, it is should be easy to set up. So we go to Pearl pool at a grid layout group. You can also pick a horizontal. Our group. I gonna pick a size off 80 by 80. I want to have once again a snapping or at distance between those from maybe 10 into 10 to the top left or from the top left corner, maybe the same size once again. You might want to changes in just a second. That may be a spacing off two or five in between. Those when we had done was Dad, We can't actually take the green pull and drag it into it will automatically snap to its possession based on the settings we have done and that we can also take the other ones. We can just take them all and bring them directly into the pearl pool. If you don't like the spacing in between those and as I see, there are two green pills now or I changed the color off. That seems to be the biggest issue. Years is this one is actually a purple one, and this one should be a red one, and this one should be in a yellow one. Then everything should be good to go. And since I have done the changes in here, I need to apply the changes to those chains pre fabs pretty quick, so I don't have any weird doubles it all. So the yellow pool has an idea of 654 purple three and so on. Everything is good to go right now. And once again, if you don't like the spacing and here between the poles, you can even go and say you want to have more like a five by five space in between those and as you can see there's enough space to put even more pulls into it. So it's going to become harder for the players later on to put in these poles. So we cannot test it out if we are able to put in all the slots into our game how my sizes have been changed here in height, off all the pearls as well. So probably are gonna fix them like this directly inside pre fabs and see what's going on. Okay, so their alignment is not in the center anymore. So I need to re sent to those pills as well as you can see currently there, anchored to the bottom left. So I need to make sure that I put this into the center over here. I don't know when why that has happened. So if that is happening to you, police fix it by just going to the anchor preset and center these things once again. So also, the pill direct list of a here is going to be organized completely correct. As you can see now, you are able to get them over here. You get these ideas and stuff also, when you go into these slots, you can see they are poor, entered correctly. It's a purple one. It's centered. And the drug ability should be. Or the direct director de scripts would be disabled, went ever needed or whenever it has to be, Uh, yeah, disabled. I'm not 1% you. If you want to disable that, maybe we just disabled some possibility to actually make use off this drug ability by protecting it with the bull. But that's another story later on, since currently we cannot drag around it. But the ideas are still Yeah, are still there. So we can probably late on return directly still from the object list. So what I wanted to test, of course, is that I'm able to put in all these pills, however, and wherever I like to go on, take a yellow one. You can also pick a green one and so on. And so force. Currently, we don't have any riddle check, but that's what we're gonna take care off in one off the next videos anyways. 13. #12 Creating Protector: welcome back to the course. In the last part, we were putting in ALS the pills and fixing some buck, as you have seen, was repositioning or actually re anchoring the pearls. And there, yeah, course morning pre fabs in this part. I want to create a little protector object which we can allay over so we can actually make sure that the corresponding slots are looking like dull. So are actually the ones are highlighted. We are able to drag pulls in, and all the other slots related to this will have a protector like overlaying but maybe semi transparent so we can burn, even disable there to block rate casts. How can we do that? We can go to our holder, since we currently still have one off these holders over here and just create another image over it. Site Like you, I image and this one once again can be set to uniforms. Stretch So old shift and select this and I go to the color and maybe reduce the l for a just a bit. Well, at least for the moment, once again, you can put in any graphic you like as an overlay, like whatever so you can show the players some design stuff, whatever. But what I want to do is like when this image I also renames us to be protector. When this image is going to be active, we don't we are unable to drag on pills. That's what I want to show you pretty quick first. So we currently have our solution box, and when I try to take a pill now here and drag it onto the slot, it is impossible. But when this protector is gone, I'm able to direct those in. That's what I want this to protect it to be. Once again, you can even create this one semi transparent or put any image over it, or I don't know. It's up to you how you want to design that. You can't even really whether the l for just a bit more. But you want to make sure that the player can see the difference. So he's not wondering. Why can't I put in any PERL into this particular slot? So that's what we want, and that's what we need to set active, an inactive laid on by the corresponding our slots, a rule we are currently in. So for now we have that. So we need Teoh. Make sure that we get our holder now getting active. That means we want to create a dragging or a dragging box. For example, Script, which sits on the holder object, which has the related slots into it, as well as reads all the pearls coming in and storing the complete correct data into the dragging box. Later on, we're gonna take this dragging books, activate the hints. Was that as well as activating a button where we are able to check the riddle and it's Yeah , it's solution, basically. So that's what we want to do in the next video. So we're starting to create this little dragging books script. We can also name it differently. Hold the box, for example. Whatever or Riddle box, It actually doesn't really matter. But that's what we're going to do in the next videos. So see you soon 14. #13 Dragging Box Variables: as promised and welcome back to the course as promised. We gonna start to create the holder now, meaning the holder script or, ah, dragging box script. We can once again name it s would like to So we go to our scripts all the right click create you see subscript and put in dragging box script once again. I have no better name for this at the moment and we need to make sure that we put this onto our holder object. This is crucial or important. Make that sure that the compiler has created two X script completely. So we can direct this one directly on the hour holder object later on, when we duplicate the holder, we always take the dragging box things as well as all the related slot stuff directly, Wizard. So we don't need to set up 10 different ones, so we just do it once. That's why we why we always only work was one set of things. And later on weekend, everything will be automatically set up for us. So we just do that once. We don't really need a prefect for that. But if you like to create one, of course refused to do so. OK, so let's open up the dragging box script in in model, developed or visual studio. And let's start to create things or write things. When the solution has been loaded, I get rid of update. Since we don't need those, this dragging box once again is going to be a bit more code heavy. But that's small functions. We go need to put in, yeah, different information to it. So it for us we want to have a connection to the protector we created in the last video. So public game object protector. And since this is going to be a child object off the holder, we'd never lose the connection to this particular protector. That's why it has to be a child off the holder object. Then we want to create a bull in which is setting this particular line later on, active or even in actor so public, the bull bull is just true or false or returning just will fall. So keep that in mind is active. When we don't put anything in here, everything is going to be zero or falls or empty, so just keep that in mind us well and then we're gonna have a probably an i d later on. I'm not true about the i d but for the moment, we just keep it s ISS and we need a check button. We're gonna create this in just a moment as well, or probably in one of the next videos against rez A zone since the check button him is needed for us to check the stuff so it is off type of button. But as against C button is not represented. So we can actually what we have to put in the using unity engine dot you I name space. This is important. Otherwise, button years not going toe work, and this is going to be on check button. Then it's going to turn blow because once again, it is related to the unity you I name space. Otherwise, once again, this does not turn into Blue Bud Rhett so and then we want to store or the pill I ds we gonna have in this particular handler or in this dragging box script. So we create an int array. An array always gets created with those square records. We can once again also use a list doesn't really matter. And I call this in i ds So I ds is equal to And now I innocently analyze that already as an int array and put in a number off four into it. So this is going to be the array lengths. So we can It's not already determined how long's is going to be. This is only public because I want to see you if that is working or not. So later on, you can put this one private or just commend or just put in an extra field like height. Um, yet this one inside the inspector and so on. So force next one is we want to have a connection to our solution Boxed over, you know, create riddle to D script. So we say public, create riddle to D and just call it maybe riddle. So we can always go and percent things to the riddle script and far and vice versa. Then we also have since we want to create hints later on, I gonna do a command, your hints. We want to have a hint books. So we say public game object. We don't have created this one yet, but we can already code that stuff in inbox where Ashley is. There are these small Paige's that's more you know, white and black packs or wide and read. It depends on the game style, but we're gonna use white and black if you like to. You can take any other colors, basically. So with these winds are going to tell later on. Okay, we have that pearl into the solution books, but it is on the wrong position. But the player never knows what's there Going to be. The correct one is what's going to be the wrong one. So he has to figure that out and related to that in books. Also, there comes toe. Other game objects of the first game of death is going to be our black hint pill. We're gonna create those as well later on, as well as another one game object white hint pill. So we create those later on and put them into the box into the hint box, okay, and that's pretty much everything we want to do over here and for now. So we have a set up all the very able towards the dragging books and what we now want to do is we want Teoh quickly create the hit box and thes two pearls before we can go forward. Don't forget to check back everything and safe everything. Make sure the compiler is running correctly and here is done. You can always check if the Dragon box script was already Yeah, working correctly. And if there are no typos and no red arrows in the Consul, make sure everything is fine. Don't forget to safe often also they scenes and see you in the next video. 15. #14 Hint Box & CheckButton: let's create the hint box. The hint box is always sitting next to the holder in the same rule and is always related to it. So what we can do is we can create a new U I image as a pair as a child off the holder. So when we laid on direct that holder or crib public eight thistle that this image like the protector, is always next to it. Now, another design decision for you has to come off course is like, Where do you place it and how do you want that to look? There are 100 different possibilities. Once again, this one can be. You can. You know, Tim, this one again, in any color you like. You can make a dark all the same color, whatever. And what we need to have is a grid layout group again. Inside of that image, I gonna call this now hint box And inside that grid layer group, they're going to be our hint pills within a maximum off four. That means we can once again to put them all into a square over here next to it, or we can put them all in one line, though there are several possibilities again what we also need to have as we need pearls, which are fitting inside these. So how can we create those? Actually, we create another image again that is going to center over here. You can also see this year I want to make them reds a small so maybe 40 by 40 pixels. So when I now put this one or directors one up a bit so we can see it better, I want to make sure that they are fitting inside this little box of a here with some spacing. So we have four in told later on inside that and since Dad is going to be 100 by 100 was a five by five per five a distance in between, maybe some spacing in the center. We want to make sure that we have enough space and the's are not too big. At least so And this image like this is going to be my black hint pearl image. And the cool thing is, once again, we just need to put in our, you know, Pearl Circle we set This one will preserve aspect ratio and another one over here is going to be just another image which also has the same size off 40 by 40 and s pride is going to be the glass sprite. And, of course, a sense that we want to have a black in pearl. We gonna take this one to be black, so we do the same. But now it is going to be super small. I put this one off course into my pary fat folder. So drag this one in and make sure it has a different name. Same for the white one. So we just choose the open, put this one back toe white. So and we rename it to be white in pill. Don't forget to hit, enter and directors one into the pre fabs folder. If that is happening for you, actually, it shouldn't because it is because of my dropbox. So just ignore that ever message. It just should not affect you. Okay, so once again, there's going to be the glass. You can always rename those some images if you like to, or that part's over here so you don't get light on distracted and saying here should be gladly or named glass and then we're good to go. Also, his can see this one is going to be affected by this. So in the hint box, we're gonna put our group layout grope with cell size off a 40 by 40. We put we start with the five left and five top once again over here and maybe a spacing in between those by five and five. I don't know. We need to test it out. And we can basically put in a weight white pill into the hint box and we can duplicate this street times. As you can see, it fits raza Good to maybe the spacing in between can be bigger. Like maybe a spacing off 10 inside the hit box. Let's see. Well, yeah, looks fine. So this is going to be the hint book so the player can later on analyze. Okay, When there are four white pearls inside of that, that means all of them are correct. But all are in on the core on the wrong spot or in the wrong slot inside the holder. Okay, so this is going to be now done for our hit box as well, or hint box as well as our pearls. What we can do with that hint books. We can already make sure that we at this into the corresponding slot over here into the Dragging Books script. There we go, as well as saying for the protector which we have created beforehand, we can put this in here as well. The next one we need to do or need to create is the check button that's rather simples were . Also, we're gonna do this pretty quick here as well. Make sure it is once again part or child off the holder. So we go you I button, we can put this button like next to of this one over here. We can make a big or small we can make it green if we like to like that and the tax element inside of this is going to be check. But as you can see, it's not even visible. So what we do is we put in best fit on. We make a superstar black color over here and probably change it. Toby Bold. So in game, you, when we need on maximize on plight that we should see it rare is a nicely so we can't we should be able to read it completely correct on actually pretty good. If you don't like the distance to the border off course, you can reduce the Langs or actually the position off the text field over here. So it's not too much squeezed to the sites, and then you have your bottom once again, another design decision. How the button should look. You can make a great green, blue whatever. You can even squeeze it together. Put the sea in the center, take it away a bit, and so on. It's a force. All of that stuff is up to you once again. So what we want to achieve with that button once everything is filled up in the dragging books later on, we're gonna talk about that and then one of the next videos. We want to have this one activated so we can get the hint and the check running against the solution. But all of that once again, is happening in one off the next videos 16. #15 Set Ids: Welcome back to the course in this chapter or in this part We are going Teoh, finalize hopefully the complete dragging box so we can actually read the data from that And maybe already put some hints within the hint box, or at least activate the tech button when all the force lots Ah, full. So how do we do that? At first, we want to make sure that on our holder everything here, which we created already is already dragged in. So currently we don't have the tech button in it. So I want to make sure that I renamed the check button first. So I know light on what it IHS or what it is for. Select the holder and drank the check button into the check button slot over here, which is of type button, Of course. Then you can see we don't have the riddle connected to it. So we can basically once again take the lock symbol, look our selection, go to the solution box and direct the solution box inside the riddle. Since the solution box contains the creator, it'll two D function or yet script. The next thing we want to fill in is the Black Pearl or hinted pill and the white and pearls, and we put that inside of that as well. Whiting Pill and the lack pin him pill on. I'm gonna do a quick check if they are center t as well, but it looks good. So basically, ever seen is set it up correctly. So we have filled in everything we need for our holder objects so we can actually yet start and do things with all these stuff. So the 1st 1 I what I want to do is at start, I want to disable the button or the buttons functionality. Since we don't want to have the player pushing the button of all time and getting nothing in return, we want to say only when there are at least four pills inside those slots. Then we want the player to be able to press that button. So how can we do that off course In start, we say tech button don't interact. Herbal, which is going to be the one intractable, is going to be the one which is activating and deactivating it by not making it invisible. And that's cool. And that's needed. Actually, the next thing we want to create is a connection from our all our slots to its parent, its holder object. Since the holder once again has the dragging broke box script over here, what we're gonna do is we goto our drop two D script and open this one. I've been mono develop or visual studio. And once we are dropping those things, we want to make sure that we put the corresponding ideas for or the I d from this poll in the Pearl idealist. I'm gonna explain in a moment why and how this is going to interact with each other. So first we create a new dragging box Dragged box, for example again, Name it. Whatever, once again, what we like. So this is going to be the holder which has the dragging box script on. We need to put this in on hand or we pick the parent off the parent object. This can also be done like one start automatically if we like to, but Ashley is not necessary since we just do that four times. And it's not that hard to do. I guess So What we're gonna do is when we are dragging that we instantly eight a new one, and we transform the new created pearl toe the slot position. After that, we want to set the Pearl I d. Inside the drag box like entire side of that. So we want to fill this particular pill array before we can do even that. We need to function, which is doing that for us by sending the corresponding data like, what is this current slot? Where is it coming from? What is coming from and what's the i d. Sitting on it? How can we do that at first? We create in your function pretty quick and dragging box. So we say Void. In this case, it's going to be a public void, since we need excess from outside from another script from the dragging script from the dropping script. Actually, so we say, Set, I d open close parentheses and now it is important than we at first put in the slot I d. So or the number off the slot we're currently dropping the pearl in, and then an int i d for the pearl. We can also say pull I D and SS Point. So these are two arguments we need to fill in here. Then what we want to do is we talk to the pill I d array and put the corresponding I d and the corresponding slot inside that pearl I d How do we do that? Once again, we say pearl, I ds open close square brackets put in the slot were actually filling in with that and then we say, is equal to ideas that we put in the correct number from that particular I d. Then we want to check if we already are able toe, activate the check button. So every time we put in something, we want to check it. We can do two things. The first thing is just doing an if statement like if an l So if ah no, Pearle has zero or actually no idea. And here is going to be number zero. Then we set this one to be true. Otherwise, like Els, we're gonna put this into falls. But we can also use it a bit or created a bit different, meaning we can set the check button dot interact, herbal By and out comes the statement and it is important that it is in parentheses. What we want to do is we want to check first if Pearl I ds, which just array dot contains in number zero. What you know can see is contained is not part often array, not directly, because it needs to make sure that it is using a different name. Space, when you have written is correct, is it was a big C and contains, like this you can right click and resolve that problem because it is using the system that link name space were pressing on, that it will be automatically added Over here, you can type it in on your own as well, meaning Now we can make use off. This contains functionality. So it returns. As you can see if there is no zero at this point, if there is a zero, we gonna have a false. But we can also negate that. If there's not zero any me anymore in the pill ideas, then we can set this one to be equal to true. So it's a question mark tro. Then there comes a colon false once again explaining that if our poll idealist or in this case array does not contain in number zero and I d off zero because it starts at zero on all four numbers. Then we sent the enter the check buttons interact ability to beat. So otherwise, we set it to force once again. I can tell that Type this out to make it more understandable. Pretty quick s an if statement so we can't say if open close parentheses. If the pill contains zero. Can a copy if it contains zero? Then we can say check button, don't interact. Herbal equals false. Then we need to do Els since we also have the other one and then we need to say the same, but vice versa. So check button does dot interact herbal or is equal to Trow. There's going to be working the same way. But as you can see, it's way more lines of code we have to type out. But actually you can do the same. So both versions work. This one was the complete if statements you don't have to type it if you don't like it. But this one is just one line of code with all of their checks and you don't have any even l stuff here you can just use this expression as I've rode it down here. So I hope you understand that, if not, feel free to ask about it. Okay, so that's what we're going to dough. So we put in a pill, I d into the slot. We sent the slot and the i d within their particular functionality in just a second. And then we check if we can actually inside the button, to be interactive all to be true, so the player can click on that. 17. #16 Check Button: back to our drop two D since now we have the functionality we gonna need. So with I again drag box dot set ideas of the current or the version or the yet the script we just created. And in open close parentheses we need to put in now the two arguments that in slot and the end i d. Once again, those are the same as we put it in here or we request here, we need to request the slaughter and an I d. And in another script where we talk to it, we gonna see that as an infant. So we need to put these informations now directly into the script while talking to it. And where do we get this? At first, we need to have a slot I d and I gonna create this one inside the drops grouped as well. So I say PLA public in slot I d. We can also automate that. But we can also set all of these public by hand because it's just 0 to 3, then the next one is we want to take the event delta dot point a drag because we need the idea right on it's no point i d but point to drag dot and I want to get the component from the object we're currently dragging around, which is going to be one of thes poll. So we're gonna take a drag to D, which is not dropped 30 but drag to D and organize Rantisi's. Then we say dot and here he should have a pearl I d because every pearl is has his own i d . Except you made a mistake when these are matching and we're gonna have all the slot I ds we can activate now the drank box check button. Don't forget to save all those two scripts that corrupted E and the dragging box script. And now we go back to unity and set the things up pretty quick. So it for us, as you will see in just a second these twos on four slots over here will have an integer and I d. And this one is once a compiler has done running. You can see now we have a drag box. We can now select all these four slots and direct the holder into that so I can see now the drinking box is going to be an all four slots. Now we start at the very left. This is going to be slot I D. Zero. A 2nd 1 over here is slot I d one. This is important. This one is going to be a slot i d two and the last one is going to be slowed idee straight . It needs to start at zero because it makes things easier and later on to compare inside the array. Otherwise, we need to negate the number incoming. When we started 1234 and four, we need to negate that number always by one. When we compare or ask, they put this into the array because once again, an array always starts at number zero as its element. Same for lists. So keep that in mind. So 0123 All of them have their holder dragging books Over here. I get written off the protector. We can light onto this in another script, and I want to show you that everything works and I want to check that out as well. So, as you can see, this button is now not a direct herbal. We cannot click on it But when we now drag in four pills, it's always checking. Can we check that? But nor press that button I can even put in like on the other ones can overlay. But when I put the last one of a year, as you can see automatically, this check button becomes active because none off these slots has a zero in its not so it's important that no Pearl has a zero in its corresponding Yeah, I d slot can press the check button and, of course, do later on the Tech against whatever the solutions are and get the Hayden's from it. And that's pretty much it for now. And in the next one, we gonna update the hit books. 18. #17 Black Check 1: welcome back to the course in this part. We want to check which off the drank in pearls are correct. So what we want to do is I want to fill in the hit box automate or the hint box automatically was black pearls whenever we have a match and that's what we're gonna create right now. So it is important that you understand that when we are green Oh, having riddles and we are creating riddles. We have our riddle list over here where we have to compare the things against. So the best thing is, since we have a connected from the dragging box to the riddle itself, we can actually create the check for the solution directly in the create riddle to D scripts. What we're gonna do is recreate it first, a public script off type void. Since we don't return anything well, basically, and we can name this one sank riddle or Tink solution, and what we need to put in is, at first an end array with all containing all I ds or just your ideas. And of course, who is doing the request since we need to pass back data to whoever was requesting that in this case it is our dragging books. And I call this just sender so laid on since descend er is containing the hint box and where we are also having the black principle and the white in pill related. Teoh, we gonna have to talk back to it like into the dragon box. That's when we sent the data. The result off our check back to birth dragging box. That's what we need to know who is going to sent this request. So let's do that first. Before we can start. I want to explain how we gonna check that? At first we have to lines off. That's a places where we put our Inter just into. I'm gonna try to explain it with an image or, as it was a set off images first. So you maybe understand this. As you can see, I'm just a ning skate so I can show you. We create a row off into just an array of inter just at first and put all of them or, like, set all of them to be minus one at the start. Off this check, Same four places to And what? When what and that's what we're going to do it first. And then when we find a match off when this point is hitting or actually when our slot is returning true, Yes, this first slot has, like, the correct color into it. Then we said this one and this one to be one same for the other ones we're gonna go to through some examples later on as well. So that's what we do. At first we create those two arrays and put in miners once into it, as well as two other variables. And then we do the check. So first we create once again an end array that is going to be called maybe places or parts or holder. It doesn't really matter. We can name it place or place, says one. Whatever places one less equal, Dona we let's say create aid or initialized. That already was the correct size, the court size going to before and in all those curly braces we gonna put in minus one comma minus one comma minus one comma, minus one comma. So that's what we're gonna do was places one end places to once again these blazes are going to be used for indicating if there is a black pearl already inside and light on also request that on the negative direction So was that two places. Once again, these two places are nothing else than the image I showed you. It's like this one. Just an array of inter just sent to B minus one on places one and places to What would not want to do is we want to define two more Inter. Jess, The 1st 1 is how many except matches do we have. So we say except matches. And we've set this 1 to 0. It is important that we sent this 1 to 0. Since we are creating this one just temporarily into the tank riddle over here. Same for the other one is going to be checked. Half matches. Maybe we don't need half matches later on, but we can actually indicate that and off course sent this particular number back to the Czech, wrote to the dragon box to say Okay, we need this amount off white pills in this amount off black pearls. Now we do the black check black check. You can comment out things however you like and police you can do as I do, or you can keep it as is. It is important that we do the black check at the very first. Otherwise, the system might not work the way we said. Oh, yeah, we expect so we create at first of four loop. When you type four and double tab on your keyboard, you're going to create this one automatically. And what we want to do is the maximum is going to be set to before. Since we only have four checks over here And since we only go from as number zero to number three in this gaze that need to be smaller than four. So when I or until I is smaller than four, then we repeat this for loop, as we have done already. What do we check now? At first, we gonna us get some info is from the center, and we get the end ideas list. What we now check is a great in. If statement on what we do is we take this incoming I ds and we take it's I. So we take I as an indicator into the square brackets, so we take the first i d on slow on I d number zero and we checked that against I will riddle list inscribe rickets I saw on the same position. Then we say, Don't get component says we want to read the component onto that game objects because we want to request drag to D, which is sitting on the pearl again, which is related or inside that little list. And then we say, Don't pill I d. So we want to read the pill I d if these two ideas now are 100% Lee matching. So they are in the same slot, I hear and I there in this case from the id's interview array, we're gonna pass in compared with the riddle list we have created on start like here, we re Since these are game objects, we request once again the component director de and the inside standing tall i d What we want to know know is when we have a 100% match over here than we want toe increment except matches. Then we say, except matches plus plus, So we increase that except matches by one. What we now also can do is since we already know how many already except matching. When we are checking the riddle, we can also sent this in pills. Now, since we know that and we have the exact matches, we need them laid on for the game manager or actually for the wind condition tack we gonna implement in just a second. I keep one line of the essence. We want to create another function of the day as well. What I want to update now is places one on position. I saw the currently loops rule and want to update this 1 to 1. So it's not going to be minus one anymore. Wherever we have an exact match, I want to do the same on places to as well. So what does it mean is late on, when we check for White, We can De Croo. Actually, we can get rid off the ones we have already and only check. The other ones are gonna explain this in a moment. Why and how already as well. Finally, when we have, like, four mentors. So if exact matches is equal to four, then we win, right? So we can actually say here needs to be Anyhow, our wind condition we're going to keep it as is since currently were not completely done. And what we also want to do is we want to return at this point since there will be the white check light on return means we just leave the complete their complete function over here. Don't forget to safe and let's go back to the dragging books in dragging books, we are checking when we're pressing the button. So pressing sank button, we want to do the request And how can we do that? We can say public it needs to Republic, since it's sitting on our check button over here. Public warrant, tank solution, attack whatever sank, so loosen almost parentheses. And now to check against that, we can residence simply do a request to the riddle. Since you already have created the function completely. So what we're gonna say is riddle don't. And now we have, like the check riddle function we need to pass, and now, and into the array off idea. In this case, it is going to be our pearl I ds and don't can say comma and then we need to set the sender and the center is going to be this, and once we had done was that we want to set the tech button. Toby not interact herbal anymore, so we don't care. We avoid double clicking. That's always say, interactive ALS Equal toe falls. Don't forget to save and, yeah, let's check it out. There's one more thing you need to consider is this junk button here needs to have an on click event with that function in it. So we were pretty press on this little plus drag in the holder object. Go to dragging box script and choose check solution. Tech Solution once again is the function we have, Crew added in dragging books to start the riddle check over here. So we request that by sending all the poll ideas from the dragging box and checking if there are any matches. So let's test this one all product quick so I can put this one in here. We can drink in any pills we like to we can. They don't also debunk that, and now we can do the check. We don't get anything in return, since we don't know we don't have any D buck lines. But what the buzzing does is it's now checking against it. It's not giving us any feedback, since we haven't put it any feedback part parts in here and it is deactivating the button. Check afterwards that arrest is going to become yeah, more useful and more understandable, hopefully in the next video. 19. #18 Show Black Pearls: Welcome back to the course. In this point, we want to prepare the hint boxes of Yeah, Black Pearl and Wipe Rolince 10. She ation to the corresponding him box. And of course we want to make sure that when we're checking that, we get a court solution written on here based on the stuff we have written in the last video. So what we need to do, is it. First, we need to go to our dragging box function or script, and I put a public void, create hint, box or hint script, and we put in any integer, and I call this one just maybe hint. So this hint is nothing else than a number at one or two. You can also take any other numbers you like, and what we compare now is if the hint is equal to two, then we want to make sure that we, for example, instance she ate a black pearl. Instance she ate open closed parentheses, lack pearl or black hint pearl comma than the transform parent, which is going to be the hint box dot transform comma falls. So in this part, we create a black pearl for a correct part, we're going to say the same or request already check the same if there is another input. For example, if hint is equal to one, we want to instance she ate a white pool. So we say instant, she ate open. Does Brenda sees white hint Pearl comma into the transform Hint bookstore transform with its world space or local space to be false. So we create a white hidden skull in the course bonding Yeah, in the corresponding slot or into the corresponding hint box. What we now need to do is we need to fill this data by the created riddle request. Inside this empty line we have left in the last video. So what we need to do is we go back to the sender and say sender dot creating box and put in a number two as an argument. Sell pretty simple, right, and we can do the same later on for the white one as well. So we say sender dot created open close parentheses and put in number two. That means it will automatically when we sent this one back to the sender. That's why we have that over here. We can request that or actually let the year let the system create a hint for us automatically by that line of code, talking back to the corresponding dragging books function or dragging box script related to the corresponding line. Let's test it out as we can in just a second. Hopefully see, is this solution boxes like that? So what? We have a red one here and maybe an orange one here and the other ones are maybe different ones. And we do check now. You can see it is instantly creating us our Hinz. Those hints are looking rather wrong. So after you fix them in just a second. As you can see, these glasses are too big, but that the pills itself Are you high enough? Big enough. That means to off our heads or our checks over here are correct. We can do the same check once again when we have, like, two or four or three Whatever. For example, we drank in all the four correct pills and hear all off. These should be black. Oh, there are not because I have done the wrong one over here. So as you can see, the black pearls are now correctly shown inside that. So once again, I try four hits or a four match over here so long, everything would be correct. And you can see or these polls are black. Now, once again, I go now and check Ward Mired. What? The problem is off the Blackpool. And let's see if our holder is holding the correct pills. Yeah, and the Black Pole is actually the wrong pull. I need to take the black hint. Pull over here, so that's should fix the problem. Now instantly. Site, Try again. Put in some of wrong one, even one correct one if we like to, just to check it out. And, bam! Everything is working as it's supposed to be. And the black pills are sewing up correctly, and the next one we gonna check against the white pills and I gonna explain you what we do with those little places 20. #19 White Check: Welcome back to the course in the last port. We were creating all the black pearls and black hints basically and checking for any bucks or stuff like that. And in this port, I want to go and start to creating or checking for the white pills. The white pearls are basically the same on razor. Well, not resident fluent, but we need to make sure that we do this check a bit different. First off, we need to go to create Riddle today. And as you can see over here, we have all black check. We'll also do is we currently fill in places with once where we have except matches and the other was ones are going to stay at mine is one I want again go back over here to my illustrator or escape in this case. And so he wanted is looking at the moment. So when we have some, except matters like, for example, here and here, both places are going to be ones. Same here. Why do we need that? Because we need to understand that we are not able to check these anymore because they are correct already. So we can actually get rid of these numbers which have which are matching one already and can just get rid of them on. We only checked the minus one us over here, no matter how many minus ones and ones are going to be insight. If there are all minors ones, of course, everything will be checked against it each other, but in a different way. What we currently do is we could check p one against p two. Like for this to this. This to this. This to this and this to this we always go in this direction. But when they are one us inside, we cannot check that against that because we already have done that. So we need to take care of that. We don't do this check twice, but what we need to do is we need to check this against that and this against that. And this is going to look somehow like this. So we check them crosswise. And if there are, like three open, we gonna take this one, which is not which is already minus one, and we not take against this. But we take against that and against that, so to see if one off these anyhow are matching. So we get this white pearls and even if none off these from this point to this Myers one or this minus one are even matching when they are not related are directly related to each other than they are not creating any poll. That's cool. So how can we do that now by coat? What we're gonna do is of course, we check it for us if we have four, except matches and we would have a win condition and will return. So meaning we are stopping the check riddle and go directly to the wind to the wind condition. But we also want to have a white check, since this might not even become true and does not return. So it does not end our check riddle function over here. So we do the white check after that. First we gonna create nested for loops once again, type and four and tap twice. We know that the size off own places is four. We have now only make use off the letter. I at first if we'll use a letter I here and this is an encapsulated for look. We can use the eye letter here as well. You can't even name those things. But actually it does not need it. Same one I a type and four again and double tab again and create a nested for loops and nested. Fallen means I gonna put a for loop inside the for loop. Otherwise, our system will not just not work in this case, This letter here is going to be j So this needs to be a giant. This needs to be j. This needs to be J. You can also name K M l. Whatever number or letter you want. So these are now nested into each other. What's going to happen? The 1st 4 loop is no going and using letter I with the number zero. And then it goes four times through that. First I until it reaches. You know this number way before this is going to be incremental. Toe one one. Status completed. This number is going to change toe one and will become changed or checked against day from 0 to 4 once again. Also your sorcery in this case. How do we do that? And how do we used places now? Since places is containing all our solutions. We have checked already. How can we do that? At first we need to have some if statements. As I said before in the image, we don't want to check this one against this one. These two have been checked in the first phase already where we have checked actually those against each other. So we want to avoid that. This number and this number are matching. How can we do that? We want to say If I is not equal to J, only then do whatever is coming afterwards. Then we use a special operator. It's called an end operator with those two ensigns for me and is like shift into number six on the keyboard and we want to do another check. We want to make sure that places one in square brackets. I is not equal to one. What does that mean? We don't want to use a slot which has been already checked and marked as a black pearl. We don't want that or actually any match. So we want to avoid that. These places number ones are going to be used so they gonna get ignored. And only those with the miners one are going to be taken and we need to do to do the same with the places to So we say, another end operator and often those parentheses places to in square brackets J so places to it once again, it's the second line is also not equal to one. We want to avoid checking any off these matches. So when we're looking to through eyes and Jay's, we're gonna take places one and want to make sure that we don't use any already checked numbers and already actually matches. Same for here. We don't want to have matches in the J line once. These are true. We want toe check the I D in card or so the incoming I d. How we do we do that in a statement. If I ds in square brackets, I so when we have a match and I is a negative number and is not the same as why, as you can see here, this is one of the ideas into the red were passing in, then we want to check that it gains the riddle list. So we checked against red list in square brackets and in this time we not take I but J because Jay is the one and places to We actually want to go across wards like whereas it like So we want to take this one and check it against this one. But it is only working when these are not the same. That's what we what? We avoid it. So it's taking this one and take it against that one. And later on, it's doing the same over here again. So in the second for a loop, when it is coming with, I is going to be at this number, like a number three or elementary in this array. Then we're gonna check against J, which is going to be represented by the peat to in this case or places to is going to check against the other negative wonder number, which is not the same as the number I indicator. So that's what we're gonna do here. And we take that and bring this into or match against the riddle list Number day. So the like the cross over as much as needed. There were gonna, of course, get its component, which is sitting in the riddle list, which is of type game object which contains drank two D open close parentheses. Don't Pearl, I d. Because you want to check? Of course. The incoming I d against the Pearl i d. And if we have a match So if that is equal equal in that destro we found a white pearl. That means ah, half match so we can say half matches is increased by one. Then we can send back the sender. Don't create him and pass in number one for white pool and we update places places one in square brackets. I is equal to one and places day or places to J is also equal one because you found a match or we have a match. No. And when we also need to do is when we found a match. We need to break out off the complete for loop. So we say break. It is important that we break that. Otherwise it's not working correctly. And later on, I gonna do a small command here. We need Teoh, Actually update the tries Update Rice. We're gonna talk about that later. No matter what. Don't forget to save the script. Don't forget to save the dragging script. If you have changed anything and that's test it out. So once the compilers done running press play, see if there are no arrows in the consul. Hopefully they're not. That's good. And as you can see, we can now try out this solution. At first I want to have to black pearls in here now a hint box. So I put in to correct ones. And then I take this one and put this like in scrawl us so it would represent a white one. And the next one is going to be a non existing ones, though it will not return anything. And so we would have in the end to black ones one white and one empty. There you go. And you can repeat that step by testing it out the world time. Now we can also yet just say we only have one green over here. This is a resident trusting because now we have two greens. But how many do we check against each other? Well, actually, just won the 1st 1 which were having actually matching so we would have won wide one. Now two white ones because of the black one is like this May be to non matching. So in the end we would have to white pills inside off or hint box. And that's what we needed and want it on. That's how masterminds, you know, Ah, hint boxes are actually working in the next parts. We gonna create more and more holders off course so we can fill the complete playfield and we start like, on the very bottom here and try to, you know, play our way up there. Also, we want toe hide later on the solution box so the player cannot seat or actually, we put something over it and we may be one toe in the very, very end. Put some stats around here like how many turns? Did you need it? How long does it take for you at two take turns, or how long does one complete rounded or took in sewn into force? But all of that is once again, stuff for the next couple off videos 21. #20 GameManager 1: welcome back to the course in this part. We, of course, want to activate and deactivate corresponding, let's say, protectors, which are protecting the input possibility for the player as well as having a let's say, solution, which is automatically updating those and giving as enough possibilities, for example, to reached the goal off sold ing that. So I want to create some kind of game manager, which is actually managing how many tries we have for what the timing is about and all the other stuff which you can probably think of, like giving the players some points, giving them some possibilities. I don't know. You can create stuff on your own later on as well to make this one even more nice. So I create an empty game. Object was the game and called us on gay manager. Also, I go to my scripts for the and creating new script called Gay Manager. If you are working in ah 22 K 18 plus, you have a correct naming, of course. Then this one will turn into some kind of ah will have on Aiken over here, as you can see, like this little here gear. So just keep that in mind and don't be afraid of it. It's nothing fancy. It's just something. Ah, Unity said. Oh, yes, said, It's going to be nice to have that little Aiken there. I guess I don't think that there is any other solution or anything to it. We opened this one. I've been model, developed off the just studio and, of course, stir to coat some stuff around here. At first we want to understand, and we want to know how many times the player is able to play rounds. How many rounds do we get? We can say a fixed number. We can automate things by reading or the hint. Oh, actually, not the hint boxes about the holder objects inside the Playfield area so we can count them as a child or yeah s child objects. But we can also drank them in by hand, according to let's say, the game moat. There are 100 possible it easier again, and you can decide how you want that. But since we need to just the connection to the dragging boxes later on to the dragging box of scripts because we want to activate and deactivate the predictor game object with this related to the dragging box, We gonna create a new list, for example, Honore off type drinking box. So we type or pass in all the dragging box scripts directly inside of that bus just by dragging the game objects and unity of once again is doing this stuff for us. So this is going to be our try list or something I don't know is equal to you. List off time, dragging books open close parentheses. Enclose the line was a semicolon. Once again, we initialize that list already here. We can also do this. That start basically doesn't really matter. But for me, I like to do it directly here in top. I just It's just my own opinion now when we are starting the game, we want to make sure that we take from that try list the first Aikin What the first item. Or we can also say we want to go backwards. This is also working, but looking through it might be a bit. It will be a bit different. So we get go into one director in just one direction. What we want to do is we want to set all its protectors in all these dragon boxes to be related to do, if that is the correct current turn. And for the Coric turn, we can use some kind off integer index, which is, actually, yeah, accounting for us. What's the current turn? So maybe we say current turn is equal to zero. That's where we start. We start at zero because try list is also starting at their or elements. The Russo. We can instantly use that number to indicate in which dragging box script we want to activate or in deactivate the protect the game object. Once again, it start. We can activate, like all of them at the same time, just by looping through them and simply call function we're creating right now. I am in the directing box now, and I want to create a new public set Active function said active mean that we want to set active the protector as well as a bowling for Well, actually, we don't need the bullying, I guess for like, this one here, but maybe we're gonna make use of it light on. We will see that we gonna put in a one argument which is setting this one to be true or false. And I just named this bowling active. What we now can do is of course, and you to say that this one is going to be off type voyage, since it doesn't return anything. And what we're gonna do is we sent is active. Even if we don't use that at the moment is equal to. And now we put in the same expression as well have done with the ah, check button is interact herbal thing like we gonna use some kind of expression like this, meaning at first we gonna do whatever we want to set. Then here comes to condition in the once again in the same area. What we want to do is we want to tank. If active is equal to truth, then we want to say question Mark trill. That won't of course, a set. This is active to be equal to true. Otherwise, Colon, we're going to say it's going to be false. So is active in this case is going to be true or false, depending on what incoming Over here. Same for the protector, the protector. It we're gonna set this one active by the condition we won't have in this case. It's the reason Want to set this vice versa. However, the current activity or is active in this case is going to be so we sent is active to be true. Meaning we gonna do the negative stuff off is active. So we check this against active. We can also take active directly. And here. So one of the activists, True. We're gonna not set this one to the active. We we have so many possibilities to do so once again, we can ignore is active in here and do with a complete request. According Teoh, This one here as well. So meaning we might not even take this one over here. Actually, it doesn't really matter. So we can just set this one, Toby, whatever it's coming into and negate, that s We do this over here once again. It doesn't really matter. You would just want to understand what we're going to do here. It's currently it is. Two lines of code can be reduced to online of gold. Actually, it once again doesn't really matter for me now and for you to student as well. As long as you understand what we're doing here at all. We just activate the protector or deactivated protector according to whatever is coming in and making use off a local bowling, which is which is public at the moment, which we don't need to be public. Same for the pill ideas. We don't need to have some public anymore, but we clean all of that stuff later on anyways for you. So it's actually a bit easier toe. Understand? Hopefully, we don't need update in the game and the Justin's. We know one Teoh check. What's the current turn? And what's the correct protector going to be active at the very start, meaning we need to drag in order dragging boxes later on, or once again call them or get them on start. We can have. Actually, we have a lot of possibilities to do so over there so and when. When this is going, Teoh, change the numbers later on. Of course, doing this automatically on start is going to be the better solution at the at that point, however, when we now want to do that active and inactive, setting the want, of course, do this. When we were starting to game. So meaning we want at first take this indicator and set this number. Whatever the indicator for this number is and said this one to be inactive. So the protector off the 1st 1 inside our trialist, so I don't Linda's update tries. Maybe we don't put any arguments since we have every argument of the here for the current turn. So what we can say is trialist and scrap briquettes current turn dot And now we should have the sad active over here and we said active, or actually activate this one, Toby, not active. So this we want this protector to be inactive. Want to set this 12 false. So once again, there is a double line over there. But actually, for me, it doesn't really matter. So And in start, we want to set up their tries. Of course. So we only said the one the current want to be not active. Okay, keep safe. That and what we can now do is we go to our player backgrounds into our space where all our holders are insight. He has one off our holder. What we can now do is we can duplicate this like three times or four times. Whatever well we know want to do is in our game. Manager. We want to understand another trialist. Which one of these are going to be the ones over here once again, Maybe we gonna do this automatically and reverse the list on start. Maybe it's easier for us to understand. And also, when we only test this with three lines, it will automatically take the correct number and get it. Maybe we're going to do that. Yeah, that's to it. So we say public game object. That's a spacer. So the spacer I gonna make it command here is going to be the object or the holder space, huh? It's going to be the parent, actually. So what we want to get is all its child components, which are containing a dragging box script and get its component. And, of course, put this into this particular list. How can we do that? Is a point. Get dragging box, Childs. And what we want to do is we want to get all this one and add this into Ah, the trial is so we can say trialist will usually trialist dot ed range. Now what we want to do is we want to add arrange off things we're gonna find in the spacer . So we say spacer, don't transform daunts. I guess there's a get child count is not any more active. Okay, so that's a get child. And and here we have an index and we can basically take all the child's at the same time and put them here as an indicator to add to the list. But the point is, we don't or ask you We cannot do it directly like that, since we have need to have an indicator or a for loop, which already knows how many child objects are going to be inside of that. So what we can do is we can create a dragging box array first. What we're gonna do is we call it all Children. It's going to be all the tired of egg ejects, and we sent this one to be equal to spacer. Don't get components in Children like this and then often close parentheses. We can't put in anything will like but beforehand we need to have the type, I mean, which is of type of dragging box. Of course, everything which has a dragon box as a za component. Inside of that, we at this in tow all Children in this temple rally created array. When we no need to do is we loops through all of them and add them to the trialist or we do this directly as I already did here. And so we can say trialist don't add range. And basically we can say all Children. If that doesn't work, we're gonna change that because sometimes strange things are going to happen. If that is not working. We looked through. It was the for each loop or four loop and at them, one by one to the trialist. And then what we can do is when it is done and working, we can rotate around like reverse the list. So we're not starting at the at the top, about at the bottom, off the whole the list. Let's see how the compiler is telling us. Any problems probably end. Of course, we need to start that stuff later on. So as you can see, there's a space of game object. What we need to do is in and start before we update the tryst. We want to say we wanted to start, gets dragging type box or box child's that's it. So we say that and when we know want to do is in the game energy we want to put in the space of which holds all the whole the ordinance. So we take the spacer, drank it in here. So every child and here will be loops looked through and everywhere where finds dragging box script will be added automatically. So let's see if that is working and if it is functioning as it has to. So as you can see this one over here, the 1st 1 has its protector to be not available. So what we can do with that now is we can once again take them, make them off line, just keep the one over here and activate the protector. So what we now do is we now can once again duplicate the holder like four times or three times just to see if the system we were creating is correct. And if it's not, we can just reverse it on Change it. So I paused the game just to see what's going on and checking back the game manager and As you can see, it starts here at the holders first spot and puts all hold the objects which are containing dragging box to the trialist. That's good, since now we can determine how many you know how many possibilities the player have. And maybe you can decrease and increase these numbers on however we want and like, and we can even start to create those from top to bottom and change them accordingly. Somehow, updating the tries is not really working or not really activating, um, the correct protector. Or actually, maybe this is not correct of you. Maybe we need to set this one to be true. So let's try this out. Maybe we just forgot something. I guess that's going to be the reason. And number zero should be now drinkable, as you can see when we set this one to true, the first row of a Here is where we now can drag in some pools like so, and then we can check against it and can see what's going on the next step. What we want to do is we want to de facto or de activate the or No, activate this protector once again so we cannot dreck around things if I mean, even that is not working. But let's assume we want to have the protective here so we can still see through it. But we are not able to drag in anything here anymore because, as you can see, this is just giving us a wrong numbers of wrong things to check against. That's what we want to avoid. So we put in the protector over it, and this one cannot be overridden later on. But that, once again, is part of the next video. So, yeah, that's basically how we want to go and activate and deactivate all the things into the child holders. 22. #21 Game Manager 2: Welcome back to the course in this part. I want to go and change the order off the list. When we are adding all these, we want to flip the stuff inside the trialist. So we're not starting at the very top of, but at the very bottom, so trialist reverse it. There we go. So we want to reverse the list completely. And after that we can do an update that tries. And what will happen now is it will automatically start at the bottom. And now we go and work up to the top from our current year. Playfield. Actually, let's see. As you can see now, the bottom one is the 1st 1 active, meaning we started the very bottom we can fill and fields and we can do the tank that's good. Also still or the tanking. It's working. But what we want to do now is we're going to once again activate this protector and or deactivate the next one. So we want to increase the Tri Index or the index. We are kind of the current index or the current try. We want to increments this toe one as long as it is not going to overflow and then once again, make sure that we are able to check against here until we find the complete correct solution. And that's what we want to do. Now we reversed the list and we start our car at our current turn at zero. Whenever we are updating our tries, we need to check at what is the current turn. What's the maximum amount? We can actually do its turn update, and that's what we want to do. We can actually take this one already on activate or in this case, deactivate. Whatever is the last one we wanted to activate. But also, at the other hand, we want not toe overflow the length of the complete list or the complete count in this case because of this are using counts and not lengths. Okay, so how can we do that? I guess there are 100 possibilities once again as well, so to protect overflow. And also we want to talk to a specific function which is doing the work for us and updating everything accordingly. Based on how many turns we have actually left. We can also do that. That's also a good idea. We can make a max turn over here is equal to I'm gonna put this one as a public one so we can see that in the Inspector or it could be a private and we serialize that basically it's both the same. We don't set this one to anything, but meanwhile, we are adding things to it. We can count it or we can set this one after we're star are done with getting all the dragging child's over here. After reversing it, for example, we can set marks. Turn is equal to trialist Don't count. So what we can now do is we can take Max turn or maximum turns and see how many we gonna have left. So if this is not matching that we have more turns left and we can take the current turn and deactivate the last turn as well as activate the current turn. Let's try that out. I want to see this running inside the inspector. So when we hit play, I gonna not maximize of play. Now I know this number needs to before the maximum turn number and as you can see, maximum turn is automatically set to before and we have an indicator. And now we can check against this indicator on which one of these slots minus one, can be activated. So what does it mean? A total is when this current turn is said to be number three. Max Stern is still four. We need to negate Max, turn by minus one. So we're not matching or we are at maximum matching current turn at number straight. So we cannot increase current turn anymore on. We cannot update the tries according to that. So how do we do that when we are done checking our riddle over here? We want to update the trysts in the create riddle to D, and we want to talk to the game manager. We want to create a public function over here. So we say public Voight update tries. Well, we already have update rise, so probably want to set trysts or something like that. So this is once again to coming as an input from the create Riddle one. And it is only coming when the riddle has more tries to do because we have not returned at the exact matches. At first, we can set current turn plus plus this will automatically increase it. And now we can think if current turn is smaller than Max, turn minus one. We should be able tow update the tries. That means we can keep on the number. Max, turn, Toby, whatever or the current earn whatever it ISS. And we can say we want to update tries. So we call the same function over here and make the next box active. And also we can set the last the last one Toby not active, for example, Meaning we talk once again to the current turn strike list protector and sent this one to be not active. So they said this one active to be false. We can also do everything over here like so and what we want to do is we want to take current turn miners one and said this one, Toby fall. So we deactivate the last one. Since you already are a one step a buffet that's tested out, we need to update this one also in the game manager, of course. Otherwise, of course, there is nothing responding to it. So and how do we do that? Because we don't have any excess to the game image of. From here we have several possibilities. We can make the game image of pretty quick static, which is the easiest one, or we're gonna create a public. The game ended a slot over here and drank in the game. Injure or we look for it through the scene. There's several possibilities. Once again, I want to do it. Ah, my way! So my way is going to be. I set this pump this game manager to be public static, So it's going to be an always existing, always accessible game manager, and I give it a name. I just name it instance. What is necessary to do it is we need to create a function called Void. Awake was a big A, its unity provided, and it is related to mourn of behavior. And in here, we say instance, is equal to this. That means this is the only a game manager instance we can a actually talk to. If they're two of them, there's, Ah, some kind off a singleton design pattern. But we don't care of that because we only have one game in the scene, will hopefully, and if not, you need to go back and or ask that we need to implement a yet once again, a single design pattern. But at the moment, it's just not necessary. So we avoid this with Dad Static instance, we can always, from any point in the game, talk to it as long as it is in the scene or related in a scene so we can say gay men. Adulthood instance. So we tell to this particular instance and then we can call the function, said tries. And basically, that's it will be going to dio here when we have done one riddle check, don't forget to save and also safe seen from time to time. Since we have probably done some changes or you have done so far, we're gonna update our first try. I gonna put in something no matter of it is the wrong or right, and I do a check when I do this check. As you can see, it automatically activates the protector off these numbers here. I cannot detract in anything else, and I cannot ruin my old solution and I cannot ruin my result of the year. But I can now drag in more into the next upcoming slots. I can check again and I can see Oh, no, not too bad. I have, like, three correct or even not doesn't really matter for us, and we can to do the same over here. But as you also can see, Number four is not going to become actively evaded, meaning we might want to get rid off the game in a just minus one or max two on minus one over here as well. So meaning if this one is smaller than that one. So if current owner is smaller than Max turn, everything is good to go because maximum turn is not equal to current turn, and it now should be working the way it should. Also, if that is not the case, we're gonna have lost the game so we can drop a line over here. We try that out debug dot log. You can also print a message. You have lost the game because you have used all possible tries, and that's where the loss or losing condition should be. Don't forget to enter. Sideline, of course, was a semi colon, and that's tested out once again. I kept that at a small amount, and I can even get rid off even more off this holders to make it a bit simpler or easier to see And to save some time. Of course, I get rid of one more. Hold over here. The coursing now is since we have created the amount off a here dynamically, we're gonna have the possibility to easily check things against each other. So we put this over here last Jack, and now we put our final solution over here and we should not have any overflow as well as no arrow message. And we get the You lost the game because they've used or ports of tries. And that's how we can't do our losing condition later on, like showing something unhygienic. Some resume or retry buttons give some points, score and anything else. But once again, this can be part off one off the next videos 23. #22 Win & Lose Conditions: now, since we have created a losing conditional. Basically, we were coming to the point where we are able to lose a game because we have used any tries and so on. It's a force. Then we also need a losing or winning condition. I mean, so what we can create here is a void. Lose condition that's for later use is so in this case when we are debugging that line over here, we can also call lose condition. And we can put this D back line directly in Lewis condition and also do several other things like once again unhygienic specific buttons or gameplay things, whatever, or just restart the complete game instantly whatever and gives the player some option, maybe a to pull year toe work around and come from that low lose condition to anywhere else or, like just a restart button appears like a restart the game. Do we want to have another try something that in overlay in image, whatever you please and like can be done into the losing condition. And yeah, you can also even do a share. Share this screen thing and so on its force. But on the other hand, We also want to have a Voight win condition. We want to see when we have one we want to see Oh, yeah, we're goods. We have done that con Yes, we have one that we give the players some reward. Maybe is something like, Oh, you Thanks for playing. And so its fourth police re try harder one. And maybe we're gonna implement harder game for him later on this world And this one condition once again can now be Call it also from here when we have, like, four exact matches since we're not going to the loose condition because when we have all exact matches once again, don't forget we return at this point, meaning we branch out of the complete. You have function at this particular area over here and do not do any white checks and do not set any tries. Well, we shouldn't. What we also want to do is since we want to talk to it from outside with setters want to be a public win condition where just once again, part off the game manager where we can later on once again show score. How long does that the player needed to solve the riddle. How many turns that took and so on. It's a force. And we know this because current turn is already over there and we can read it directly like all the steps. Ah, the time we can add a time. It's on the force. How do we do this? And wind condition now is so once again, we talked with the game in a jar dot instance don't. And now we call win condition and everything inside the wind conditions will be performed and then it will be returned over here and we lose or go around outside off the check Riddle. What we also probably want to do is we want to deactivate the currents turn. Yeah, protector once again, just in case. Maybe. What? We want to deactivate everything inside. Well, although that depends on what you want the players to do and so on and so forth. So and there will be no weird sings. Oh, yeah, yeah. Going to work or going to happen. You won. You are amazing. That's what you can put in on the screen of it lying to and so on. It's a force, but actually, we don't know are currently I don't know what we can put inside Once again, it can be time. It can be how many turns and so on and so forth. So we can actually also design a new screen or with a new scene. Or we can just do an overlay or just give the player like, restart game. He has your score, something like that, and also later on connected to maybe a some database. Whatever. It's all up to you. Once the compilers done, I want to check if we are able to win the game. So at first I want Teoh. Just do some randomness here so I can see everything works still and we're not running into anything strange. So as you can see gonna zoom in a bit to make it bigger. So now I want to do like, Okay, I'm a pro. I know the solution right now is that it's going to be a yellow one. That's going to be a black one. What I want to avoid is that the next button, or actually this protector line is not getting activated. As you can see, we want we are amazing. This debug line pops up. We have all those black ones over here. But what? We also want to avoid. This, of course, that we are unable to drag stuff and here and do that strange behavior. We don't want that. We want to avoid this. So the players are basically not able to do one off these mistakes, like a going over because it is already done. We can avoid that, for example, by hiding or the pills in the pool pool under another protector like whatever. Or we just a do a full screen overlay with the score, a restart button in the center and so on and so force. But all of that stuff can and will be done in one off the next videos. 24. #23 Win & Lose Protector: Now let's take care off that the last protect that we were playing Even if we are or no matter if we are losing a winning, we want to set the Yeah, the current protector where we're currently playing into. We want to set that want to be active once again. So we are unable to drag in pills into the corresponding yet current tone slot. We already have done such a turn in when we're checking the game manager, meaning we are updating the trysts. But what we do is we say trialist current and minus one. So the last one we have did or have done, we're setting this one to be false in news condition and even in wind condition, we want to make sure that we are using the same mass it, but only on the current turn. So we're not able to drag in any pills. Basically, you can you just copy this line of code of the here and put this may be under over the D back line over here, but what you need to do is you need to deactivate or actually get rid off the minus one. So not the last one is getting sad, active to be falls, but the current one. So don't forget to safe, said Bows, to be false and we should be able to own win or on Liu's. We should be able to not a drag in and to any new pills, for example, when I have, like, two lines of possible pills over here and I now drank in one or actually in this case, four of them pretty quickly. So 1234 no matter which one, there we go into the last line of a here, which is the one we're just giving us that lose condition when we're wrong. Then we get an argument out of range, which is interesting. So what? We need to do it. Since we are still increasing current turn at this particular point, we should cap current turn at whatever it ISS, which is in this case, the lose condition. So same here. We can basically do also current own minus one and try that out once again, since argument out of range exception means that we are outside off the size off. The current race were unable to take the next turn or the country is since it is getting her neighborhood at this point or increased at this point, we are unable to do that, so we increase still the current turn. We could also once again protect this different, so let's try this out. First I try again, just a setting these one up, this time with the miners. One active. And that means it will automatically deactivate this next role if we are winning or even losing, because we're taking care off current turn minus what? And as you can see, it gets deactivated. But at the same time, the problem was once again the size off that and the current tries it now is higher or the same as maximum tries. When you go to this little box over here next to the loch Simple, that's a debug mode. When you go into it, you can see that current turn is like great out because it's a private, very able. We can still see that it is said to be, too. And that's where the current possible problems with the current problem is coming from, since there is no turn number two inside the trialist, so we need to make sure that since this is element zero, this is element one, and we wanted to try to disable an emitter, which is currently currently the current index. So that's what we need to negate that once again by minus one, but by one so we are still going to minus one is going to be element one of with this able in this particular kite case, Element one. Instead off element To don't forget, to go back from the normal to from the department is normal mode, so you don't get distracted by where strange things and everything is no working to protect the possibility. Even if we're winning to earn able that possibility, let's try if Whoa, that's a rather rare one. Let's try out when we are instantly winning now was like four purple ones. You can see there's an argument out of range exception as well, since currently our current turn began a naval debug once again. Our current on a zero and zero is going to be this element, but current turn in this particular case would be at the current term. So what does that mean is in wind condition? We're taking the current two instance, we don't increment this by one, which we're doing over here and set tries in win condition. We do it like so that we're not taking care off that and not setting minus one over here. So we're taking the current index or the current turn index. That's right, that I don't forget to safe, often like the scene Enterp screws were here. When you have done changes, once again, we try that out. There was wrong one. So let me make this one correct. I drink them all in, make a check and at this point, at this point, we're unable to check anymore and were unable to dragon anything else to ruin, for example, by four ruining our wind condition and getting any hole full de into the next line of coat . 25. #24 Show & Hide Solution Box: Welcome back to the course in this part. I want to hide with some kind of other image, the solution box and, of course, unhygienic When we're, for example, winning or even losing the game. I already created a little image over here, which is just brown with some question marks on it. And it has in total six question marks. Why there are six are gonna explain, probably laid on or maybe in between. But for now, I just yeah, imported this one and I set the texture type now once again to spread to D and sent this one to multiple. Since I want to make use off multiple images later on from that, I don't need any packaging tank or anything else. But what I want to do is I want to open up this ride editor. As you can see, this one, he has already said it up so I can delete it. So at the moment and it is a multiple one, we are able, I am able to create my own size off image, meaning I can create, for example, three question marks and roll four question marks and roll even six or even two. What can be what can happen later on when we have, for example, creating an easy mode, maybe a more normal motor heart and a very hard mode. For example, we can for create, like, three question marks images and put them later on into a play field over the solution box. Also, we can do this for four five when five is going to be a hard mode, and six is going to be the very hard mode. So the people which are playing on a game or your game in this case might be able, ah to plate with six pearls and total. So they need to find a solution in the rez a short amount of time by just yeah, taking care off six different ones. For the moment, I just need four. So I try to figure the best way over here. I created this one, was 100 by 100 our squares and placed in one of your question mark by any time. And then I copied in pacing off course clammed thes graphics to each other. So this is in total of 600 pixels long, and somewhere here should be the centre between those two question mark pieces. If it's not, I can always go in and change that. So this is my hiding image over here. Gonna rename. It's 1 to 4, since this is going to be four pieces long and later on. When I picked that, even if I see the graphics, I'm able to make use of it. Then I applied the changes. Of course, once again, I can select anywhere and create another one with just three, for example like that. And I would just name this 13 in this case once again, I can keep continue on doing that for the number five of a life, too. I really I don't have to at the moment, but as you can see, it's rather simple to do so we can actually already prepare everything if we like to say for number sex over here. So it's going to be the full length in total later on. So nothing fence It was that. And of course, I applied the changes to the pre fatso or, in this case, to the graphic wasp, right, So we have, in total from one graphic. I want to see four different sprites with different length sex lose described editor When I opened this on up here, you can see I'm gonna have the graphics down below again. So like them and say Okay, this is 345 and six and total If the graphics are ressa Ah, here, badly seen in here doesn't really matter. We don't care about that. So what I want to do is I still like my solution box and of course, go to you. I image. And of course, I want to make sure that this one is going to be stretched over the complete sir. Face beholding down old and then just a select uniforms stretch. You can also keep on holding down shift. But this is only as you can see. Shift is also setting the pivot to the center, but at the moment it is pivoted to the center. Anyways, next one instance, I have Justin Emitter can name this one hide image or something, or high resolution image. You can once again name stuff as you like and police. But since this is your part of the solution box that we actually should know what it is about. I go to the source image selected and select the longer piece with four question marks in it. And as you can see, it is or automatically matching to it because of the stretching all over the surface, since the image type mode is going to be single or simple in this case, So what we now want to do is we want to hide and unhygienic that one on game starts. So basically on game start, it should be not. It should be there as it is currently. So when later on start a new game, we probably just want Teoh reload the scene and everything is set up and good to go. But when we are actually done was the game and we're losing or winning. No matter want, we want to show the player what is behind this books. We have several possibilities to do that we can slide this out of the way like just, you know, moving it with some kind of animation like sliding this one open and close. We can also do the other direction if we like Teoh like slight this From here to here we can also go Ah, been down. So we just I can drag it out over here. We can drag it down if you like you. So it's got going to hide under the playfield. It actually does not really matter how we do that. We can even just slide is one open, like, you know, halfway. So we can actually see part off the solution. But I guess a full solution gonna be okay. We can also instantly earn able and disabled this on. So when the game is done, we can just open this one. We can also over time, reduce the Alfa off the image and then make it one. Yeah, hide itself over a specific amount of time. Once again, there are so many puts possibilities for us, too. Unhygienic. The solution behind it s so we probably stick to animation because, Well, why not? So for animation itself, we just need to know how this animations are going to be where they're going toe idol and how the mechanism system is going toe work and off course how to create our own animation, no matter which direction you are choosing here. So what can we do with that later on? By the way, you can also use that for using hints or giving them some tip like for, for example, sliding this one just one pull open if the player needs something like a one hint or so. So ah, he's going Teoh, maybe investing kind of life or something, especially when it comes to later on maybe six pills where you have a game is going to be very hard for the player to you get to the solution. But that's once again another part, not part of that particular video. No. So what I want to do is, since we have to create several different animations or at least two would say, because one idol animation, where just that thing is going to stay where it is and an open or in this case, closed, no matter which way. Ah, yeah, animation. So I create a new full, that cold animation, so all our animations will be in here. So what we're going to do is to go toe window animation on just go to animation on this probably will go appear on this window, and what we need to do is we need to create a new animation for this hide image. So and since we don't have anything accessible over here, we need to create a new one. So basically an empty clip. So when we create this, we can go to our animation swirled over here. I will just call this one open hide or Haider. Then I say safe. And now we can add properties. Those at properties can be like transforms. So we're gonna pick the transform and maybe want to take the anchor position of it here. So we set the plus when we know go to the record button. We can define length or a duration time, Like, for example, it currently is like said toe one second. So in one second, we, for example, want to slide things around. As you can see, this little white bar in here is going to be our time. So on which frame we're currently at, you can also see over here. So frame 76 or 70 27 I mean, and that frame 60 which would mean if the one second we gonna open up the complete solution box, for example, we can now take our yes light over here. And a direct this one to the right. So it's a sliding open when we know play the animation back wards or just press play it all you can see that this one is like is easing in and easing out to its Yeah, whatever we are requesting. So we request to open this one to the right in the amount off one second. If you want to measure the if it is too long or too short became press the play moat or the play button in here and we see how fast this one is going to open or appear. And if it doesn't match for you Oh, is too fast or too slow. You can use them. I was wheel, take the last frames or the keys and bring them to maybe two seconds so you can actually create a slower animation over here. So in two seconds now, this one will slide away, and then at the end, it should just stop. And doing that stop is going to be just another frame animation or just we gonna put in some argument here to stop the animation. But for us, I guess it's the best way to just keep that or yeah, in actually create a new frame, which is just one frame. With one specific position. We're gonna have the possibility to copy that positions of your like to the right and to the left from these two positions we can put in a new animation in this case. So I disable the record button right now, Go and select this and create a new animation clip on We can say open idol or open. I'll idol Haider. We're gonna say that when we are clicking here and taking the open idol. Haider, we can put this to the corresponding sport where we want to have. So we are on frame zero over here. We want to make sure that we take the same animation or the same position off where we have bean at the last rain off the open Haider animation so we can go here. Copy that numbers go to the other one and in here. When will press that we are able to select this first number over here and then we need the right position from the wreck, transform on the other one and gonna copy this anchor position from the last time here as well so copy. And then we go back to the open Idol Haider, and once again, click this button over here the record button, and then we're good to go, and this one is going to be on the court position. We don't need to size Delta so we can actually remove the properties from that. Since we only make use of the anchor position and the X and A Y over there and nothing else So this one can play around but actually doesn't really move. Same for the other side. So, like a closed idol, Haider, we're gonna trade another clip just in case. So it's ah, closed Idol Haider and what we want to he cavers. Basically, we want to keep this particular point over here. So what we can do is we can select the record, but and just slightly drag this one around, but actually set these went back to zero. So we gonna get this key frame, but we don't have to take care of anything. Els don't forget to disable this and remove the properties for the other key we had actually not making use of. We're just making use of the anchor position and we can close that. And as you can see, an animator is automatically added to our hide image. So what we can do is we can now set this animator image high to control up. So as you can see, there's already when you're double clicking that particular Haida any major component, you can see that the closed Idol Haider would be the first animation we're gonna see. So we set this as a lie, a default state. And from this we want to have a transition to the open Haider and then a transition from the open. Haider making a transition transition to the open Heidel Idol Haider. Meaning this transition over here needs to have a next time. So it's going Teoh. Ah, actually, we need to trigger this later on was the trigger. And when this triggers running, then it's going to play the complete idol. Haider Oh, are open Haider in this case and same here. This one has an extra time and is going to go over day. What does it mean is when this when we know press play and we, of course, don't mix in my son play, Let me put it back we can. Or we should see that this over here is trying to open our basic and see. And now it is going to stay there and then it's opening completely up. So when we have this one completely, or actually select the ill image, we should also see what's going to happen over here. So the blue bar is filling up. Then here, the blue bars filling up. And then the open idol Haida will stay where days. That's what we want to make use off. But what we want to do is with this one, does not have any exit time. But when this has no exit time, once again we need a trigger, a bull or anything to trigger this particular transition. So in layers or in this case, maybe in para meters, we're gonna add up and you trigger and we call this one open just was a small Oh, you can name it whatever you want. And in the conditions tab on the first transition when you selected, you can set one this condition to be open. So when we trigger open, then this trigger will automatically play open Haider. Until then, this one is going to do the idol. So it's just staying at this position. No, I triggered that by clicking on this little radio button, and as you can see, it's opening up and transition into this. So finally, we just need to trigger this animation on the hide image, and this one is rather simple as well. But we continue was that in the next video? 26. #25 Show SolutionBox by Code: In the last video, we were creating the complete animations for our Hiding Solution box image. We already created the animation, which is actually playing automatically when we're setting this one or this particular trigger open to or on the height image. Animator component. Well, we know want to do is we want to trigger this one by code when foreign simple, we're winning or losing so the player can compare his own solution with the rial solution on game end. We have several possibilities to do so we can make this so that we are connecting the hide image directly to the solution box where the create little two D scriptures on or we make sure that we're using this one endgame Energia. But in this case, we need to connection to the create riddle anyways, so it's probably easier to do this directly in the creator of the two D script. So that's what we're going to open up a first and model develop over just studio when we're checking the riddle, we want to make sure that we trigger this particular animation, so we need a connection to the animator component, which is sitting on the high image or Haider image. So best way over here might be to I commend this one pretty quick out. So it's going to be on the height solution box. We need two components over here. The first is going to be an animator. So we gonna take animator and I just call it Annam. One start, we're going to implore you actually create this as well as we need. The connection to the hide images were as well. So just as an eight game object So we can trigger the animation or in this case, the animator component from it. Or at least get the component directly, so intricate, easily as well. So there's going to be a public one so public, and it's off type, game, object and, like always, one hide image so you can create your own commands over here, as well as creating headers and stuff later on, just to make your life easier and setting up things later on as well. So what you want to do in this particular case is in start, we want to grab the animator from the hide image. So what does it mean is in the editor itself? So in the create riddle to D script, we need to have the connection that rose to the height image. So I direct the hide image directly. He and the duly created hide image game objects lot when we know have that Once again, the animated component directly sits on it. We don't need to do anything but talking to it later on. Since the correct controller is already implemented to that now one start, we need to send the animate up. So animator is equal to and now we need to talk to hide image at first. So we se get component. And then in the trying of briquettes we gonna say, Animator, this one was a big A open, close friend To seize and close the line was the son I call on now when we are done with the playing of the game or taking the riddle for whatever it is and we don't have any turns left in this particular case Ah, for winning. It is easy since we can actually get, um, get at the animation directly here on wind condition so we can say and don't. And now we can actually set a trigger and this particular trigger has a name. So in open close parentheses, we need to say set trigger open and it will actually play the animation. Where's the set? Trick open. And that's pretty much everything we need to do for the wind condition. The downside on the loose condition is probably not possible directly in here. So we need to talk to the from the game in it, uh, back since we don't know if we have any turns left or we request the turns we have left from the game manager, so home anyway have left. And according to that, we are going to send the animation or in this case, the trigger up. What does it mean? As we can, for example, request this one as a bowling directly from the game manager, since we have already s static instance off the game injured and we just need to function, which is taking care of that or actually giving us a feedback. So what we can create is a public pool and this bull should return the turns so or tries we have left. So I can't say tries left. And if they are tries left, we want to return something as tour falls So and in here we need to return when the trialist or in this particular case, current on a Mac Stern are not equal. Then we have turns left. That means as long as current turn. So if current turn is smaller, then Max turn. We can return a true like that. We can also put this one into an expression as we already have done before. So we can try that as well or do this as well. So we can also return a fall since this function currently only returns true. So what we can say US return and then we can at first put the whatever we want to return based on the of statements. So we say return current, turn smaller Maxtor. Then we say question mark. Then we say True colon fourth. So in this case, we just go around the complete different l stuff over years we already have learned before we can put this all in one small expression. Let's check out if the compiler has any problems with our new function over here. And if it doesn't, we can continue and just do the request, meaning we can in Crete to the riddle end when we are actually setting the trysts over here . And there are notarized left, which is going to be the one with Would you update this one? We can set the animation trigger later on, no matter what. How can we do that? We can always do that when we are setting up the trysts, and but we have to do this afterwards. Since the ah gay manager is actually already increasing current turned. First, we can also do the other way. But this white ways actually easier. So we can say is gay men. Aja Daut instance of the instance of the game in a job tries left. So that is returning true, then we don't want to do that. So we want to say if not tries left. So if it is the returning of force, then we want to say Annam dot set trigger and AH Inc imprint to seize open. Let's test it out. When the compilers done running and everything is completed, we want to a template test everything. So we give a false try first because you want to lose and we don't know the solution yet. So we are done. Everything is bad. We know. Okay to are at the wrong position, but there are actually OK is. But as you can see, we now get the solution box open because we have lost the game according to our year line of code or D back line over here. And when we would restart the game now and we try to win this game, Of course, we can't see it pretty quick. And before we are actually pressing on the check button where I unable this one once again . So I never the height image again. And now I do the check. And this one say, is how you want your amazing And this one is also sliding open and keeps on the open Idol handler. If you would know, restart the game, everything would be as we just have Bean set it up at this point 27. #26 Win Lose Panel Setup: welcome back to the course in this part. I want to create a panel which is sitting or later on laying over the complete yeah game field. Whenever we're winning or losing the game, we can make use of our current canvas and just put in any image panel or anything else to completely overlay. It's a complete playfield, no matter how so, how big it is. Also, we want tohave all. I want to add some text yields, which is telling you how you win or hey, you lose as well as filling in later on data into these particular text fields and Teoh like how many turns you have used? How long did you yet took to play one round? Whatever. And all of these I'm onto this panel as well as a retry button and probably some back to menu button or something like that. So let's get into a canvas and create a new image or Penhall or whatever you like from this You I penalty. I gonna make use of an image again since images for me. I like them. Ah, easier and better, And I can put in like basically anything I want to is wells in Penhall. So actually, it doesn't really matter. What I want to do is that I uniformly stretches over the complete playfield and maybe change its color to be black and reduce the Alfa. What I want to achieve us. That the player, when he sees the difference between those two objects, I would say or a scene views. Then you can see this is lit up more than this one. So this is for me important, and I want the players to get the feeling off. Okay, this is a game over screen or a winning screen, so I make it, Ah, just darker. Also, I can block any recast inputs later on, so I'm unable to, you know, drag around pills. Meanwhile, playing the game. What I also want to have is probably another window in the center like, yeah, another image where I can't put him like all the info is, if I want to or and complain Oh, mainly used this one over here once. Getting there are 100 possibilities how you can lay out your game, how you can make it one easier or simpler for people. You can also make use of that for the poor screen later on. If you like to have a poor screen, even if I don't think that it is necessary for such a game as interest is time based and as well as a turn based, so actually doesn't really metaphor for us. Is that going to rename this one pause panel? And later on we can also you think about how we want this post panel toe act. There are several possibilities in here as well. Like, for example, we can move this from the left or from the top off from wherever into the scene. Or we just hide and unhygienic as simple as that. Just unable on deserve it, the game object of the pores panel So we can see the you know, all the input fields that we want to see. Basically okay, So once again, I want to probably put another image over here in the center where all my stuff is containing or just as I said before, a button for, you know, repeating or you re trying this round or going back to the main menu as well is once again old the text fields. Let's start with the text field. This can probably be a You win, you lose some titles, something So I just name it. You wouldn't lose in which is going to contain later on you lose or if you win, we can feel in all this data laid on by hand. For now, I just want to have anything inside to see how it looks. What's the fun toe? What's the size and how I want to put them correctly in the complete scene part over here or inside the panel. So they're probably later on, not go and overdue. It's size as well as anything else again. So I probably take out fun site of 40 and this is 40 is not going to imagine to here so bad . Probably were better Where's going was best fit and let the system do its best to fit this . Also, I want to center this. Of course, Israel brings in the top. This is also okay and maybe the maximum size is going to be 80. Once again, you can play around Wasel that bold italic and stuff like this. You can give all the information you can tinted red, blue, green, yellow, whatever you want once again, for example, even a yeah, you can. But once again put it anything you like in here. Later on, once again we feel in the data by code, meaning when we're winning, Then we say you win. When we're losing, we put in your loser. We don't put anything inside. Well, actually, it depends on how we are where we are at the moment. So once again, I want to put in, like as three other text elements, at least one which is as telling us maybe a score as well as based on the score. Also the turns. So maybe turns taken. And then we feel in once again all the data later on here as well. Eso put in the in the text you for now, just turns take in and then ah, the in the end, we gonna feel in any number and here later on maybe nine or 10 or whatever. And we know this later on because we completely take the info from the game manager and put this directly into the pore. Or, in this case, win or lose panel. This is actually not opposed, but a Windows panel I call this one panel. That's probably the better name and a bit more positive in this case. However, I gonna bring this text as well. Toby White. So the wind panel text, which is telling us that turns taking are gonna name this awake and later on easier find it and connected to where I want to. I give it the best fit and probably something up to 80 as well in total or until size. Um, but maybe not that big. So maybe this is going to be a raise, A good number or good size over here. Probably. I make it a bit longer. So when there are late on some changes in, you know, the tax is going to be bigger or smaller, whatever. Then I want to make sure that this is only change in size in the Langs, but not in the height. So I have enough yes, space as well as I can, and literally put in anything else later on a small. So what I can do is that, of course, I can duplicate this easily and bring this down like another line and or maybe two lines, whatever and can say at time taken. So when we later on put the time to and a timer inside the game, we can actually put this one as well in here and again. Maybe create another one. Maybe a bit down here. It's like your score or something, depending on how your score later on is going to have your be created. I gonna once again I can show you different ways, or I will show you at least one way how you can calculate score score based on, for example, how long it took or how many times that took, and so on and so force and all of that. Maybe this is all not filled in when you're losing. Maybe this is all empty when you're losing, Um, or at least the first to about there will be just like zero score because you know, you lost and there's nothing else you can do about it. Okay. And the last one in the wind panel, of course, I want to put a button as I said before, and this button can contain, like a back to whom is back to home text over here. So I back or back to menu and the scales back to menu. You can also put in any asking code triangles or whatever. We're gonna talk about this in a bit as well, and we can make this one as big as small as we like. Of course, we need to make sure that best fit is also selected for this little menu text of a hero but in text. And I want to make sure that the Texas pure black and not that smudgy gray. Okay, so we have now the back to menu. We can pick or places wherever we like to. We can put it directly in the center or here in the bottom. Actually, it doesn't really matter. Once again, it is a design decisions you have to make on your own, and I want to duplicate this button as well. And a director's over here to the other side. I tried to find the set of the correct one over here, and there's going to be to try again, um, button so we can basically feel in try again into this button once again, as you can see the size of the Texas going to stay the same as well as on the other side, so we don't have any design problems later on. When we press play, we want to make sure that nothing of these fancy elements are going to slip away. So I press press play once, just to see how it looks in total and also where it is at the moment, which is okay for me at the moment as well. And what I want to check is when I now go to ah, nine by 16 you can see it's literally tear staying at the same position and only down or the only difference currently is that we are not fitting everything else inside the screen . But I guess that's totally fine for the moment. And we can also already click on these buttons off course. There is nothing at the moment happening, However, this is what the designing off this little panel in the next video. We're gonna fill in all the data by code, into the buttons or into this on click events as well as, ah, calculate the turns taken at the time taken and probably also the score we needed or we want to calculate the stuff with 28. #27 Coding the WinPanel: welcome back to the course in the last port. We will creating the wind panel which has, like, several different text fields and two buttons we gonna make use off. We can also as akin as already explained in the last one. We can put this all stuff automatically inside the winning penalty. So what we need to have is a connecting to the game image as well as the win and lose condition connected to at this particular Scripture. Yeah, panel as well. How do we do this? The most important one is at first we need to connection to all these text fields. And the easiest one is we're going to create a small you, I handler for this particular wind panel which is has the connection to it. We make it so that it aesthetically available per round per level, whatever. And then we connect all the text fields directly to as well as the buttons. Well, the buttons are not necessarily Yeah, connect need to be connected to it, but because they're gonna have its own own click events. And I guess I'm gonna put those on click events into the game manager instead off the you. I panel. Okay, so let's create a script, right? Click into your scripts folder and name it you. I win handler or whatever. Win handler win lose handler. Basically, because we're also handing lose conditions, we can Well, once again, the name stuff however we like, as long as unity does not ah, hate us for doing so. Okay. Since we're need, we need connections to the tax elements sitting on the user interface or onto the wind panel. We need to make use off using unity engine, don't you? I for user interfaces, so we can know. Take care off a taxed images, buttons, whatever we police and liking where can basically talk to them and feel in any data we want . What does it mean is we can now create all those necessary text, element your variables and put them into the script and connect all the necessaries text fields inside of it. So what do we have? We have the wind panel which is just a game 100 you can later on in the game in a jar activated, deactivate also meaning or having the connected to the wind panel. We can always you talked with wind, lose handler from the game manager as well and fill in the corresponding data. Now, what I want to have is on this particular wind panel. I want to put this gripped and connect now like you. When you lose, I gonna make attacks field first and I name it. Maybe win lose text. So this is just going to be the one which is telling us if we want no lost. And since we want to automatically feeling or the corresponding data, we're gonna put this together like that. The next one is going to be that turns taken turns taken text once again. Always name your things accordingly. So, you know, get this is a text field off type text. You can also see this in the inspector, but as well as you know, you want to make sure that you know when you're later on cold and things What this is 1% about. There's just a little tip for me since I don't do not own. Haven't you renamed? Those are gonna rename them now. So I 100% Lee, they don't know what these are. This is going to be the time taken. Our tax. Basically, this one he is going to be the score text. You can also name it's cortex. Basically doesn't really matter for the moment. Whatever we gonna put these text fields inside always scripted as well. So time taken, we gonna take care of time in the moment. Or actually, but later on, depending on how fast we are and another textured for the score. So we call it score text. Okay, finally, we have the buttons. Once again, we can put the buttons as scripts directly, and he and the wind blows. Handler, actually doesn't really matter, since it is going to be just a function which is going to be performed on click. As you already know, I guess. Okay, So where is that little script? We can't be? Don't have anything. We haven't done anything for the moment. Now we can just put all those stuff together, meaning we put the windows handler onto the wind panel. So onto the image we created before with its black Alfa image on it. Now, when we connect the windows text over here, we never lose the connection When we, for example, create pre fabs. And that's why I want to talk to the wind panel directly. Keep that in mind for also for other project you're working on. Probably later on. Make sure that you dragon all these tax elements accordingly. So we don't have any false that stuff later on in here and what we know want to do is we want to make this Windows handlers study class so we can always take a call it or I said we don't need it since we need to connect into the game manager. Anyway, so we're gonna You're basically just drag in the wind, lose handler to wear the game manager by hand. Probably the best way, actually, not necessary, but possible. Okay, we don't need thought. We don't need update. We want to create our own functions. For example, we need a function which is containing all this info as an argument. So we can say it is coming going to be void. Update text fields or update text. You can once again named whatever you'll like. What we need to put in is, at first an inter jar or we can also put this one s a string already, but we want to a have it First a condition like a bull. Win or lose, we can also once again taken into jail. Sobule win. So when wind is true, of course, we're gonna show different tax. If Well, if it is lose, we're gonna put in other tax. And we need to confirm this once again over them gay manager, because he knows if we have won or lost, then the turn taking tanks is going to take an indigenous so turns it's going. Teoh once again put in and from the game manager as well. Then the time taken the time taken is probably afloat or a set of floats. We gonna talk about this and just ah, later on probably will make use of a big interject. I don't know at the moment are gonna take a time since we need Teoh put this time. Yeah, together the different anyways. So once again, it can maybe also be a string. So maybe would take a string as a pair of media. You know, actually, we can change this whenever we like to. We just need to make sure that we have everything in here once again we change or it can change all of that stuff later on and we're gonna have a score text that's going to be a vintage, I guess. So there's going to be the incoming score. We put everything into curly braces, as usual, Won't want to do, is at first we want to determine if we are winning or losing. We can create a switch in a statement or Justin if else statement or just in if statement and total. So if win So if that is going to be true, then we're gonna perform something if lose and open close parentheses, them one or as they did not win, like was an exclamation mark in front of it. So when we're losing, you can also once again command things out losing. Then we gonna feel in the text fields according into deterrence, the time and the score. What does it mean? In total, we gonna say we have a ah connected to the wind lose tax first. So when lose text a dot text, we need to confirm that this is going to be a string, so we always need to type in dot text. Now we can feel in anything like so at first as I already ah written down here. I can say in quotes, turns taken. Then we could put a colon and a space. Then we say behind the growth. The second quote, we gonna fill in the turns as an argument the it coming turns over here. As you can see, this is going to be the one were taken. We cannot to put this into ah into just into apprentices behind it. We're gonna need to set it, want to be equal to, And then we fill in all the necessary data. If you are not using the A string para media in front of here, you need to convert this one to string if you have two. But since we're passing in its drink tap pyramid that this is going to be automatically field and no matter over it is an indigent or float same for the other ones. Now, since we by the way, this is basically this is wrong. We want to have on turns taken text for this. What we want to do for when Loose Tank's gonna copy this name pretty quick. So and daughter text is equal to like you won and maybe some exclamation marks like this. So once again, this is going to be the one over here in the very top, this one. And of course, don't forget the line was a semi colon to end the turns. Take a text once again is not taking the turns We gonna place in or pass. And later on then we gonna have the time taken. Gonna copy that? And of course, time taken, daughter text or time Taken text. I'm sorry, I'm taking okay. I just did not named at the time taking text. That's why I was confused for a second time. Taking texts don't text is going to be equal to And now we can probably put in just the time or once again, a string para media as we have done before. It's going to be time taken and then colon space, and then we can put in plus And then we put the part time interview over here into the next line off code or in this as a second terra meter over here. Now we want to have a score. So again based, include with same. We're gonna say score text don't text is equal to your score cold in space plus a score. That's probably everything we need to do with the loose tanks. We can also do the same stuff if we like to. For the wind, for the win text. I mean, we're losing. We just say here, you lost or you lose. And of course, you can still give em anything. Any info as you police night, you can also create another. Yeah. Other input for that were no, no safe. Oh, by the way, it needs to be. We need to make sure that this needs to be public. Public update, text collapse. Otherwise, we don't have access to it. Okay, That's probably anything we need for the Windows handler. And in the next part, we're going to go into the game manager and fill in the data corresponding Teoh our calculations, for example. And don't forget to drink in the time taken text once again into this. Since I just renamed that I need to make sure that this is going to be correct. Don't forget to say if you're seen and your files and stuff like that and scripts and I gonna see you in the next video 29. #28 Show Win Panel: Welcome back to the course in this part. We want to create the gay manager function or we first need is a connection to the wind pedal we have created or want to have is when we are now making this one big. We have this lose condition in this wind condition, and we want to make sure that we put in, like any info from these wind conditions into the windows handler we created in the last video. How can we do that actually began in the performer? Create our own function and just let the function calculate and talk to the wind. Lose handler, What I want to do first, I probably want to have a public windows Hendra handler or we're gonna name a tender, and we can basically just a drank the game object into the game images. So we have an instant connection to this group. We don't need to get the component and all the other stuff and so on. It's a force and we can directly talk to the Windows Handler. Scripts update taxed, and what we're gonna do is re great. First, a function which is calculating, for example, score for us as well s maybe Yeah. I don't know. Something different. We can also put in at time. Like when we create a timer we couldn't put in basically anything we want and like into this. So and how do we do that for us? We create a void. Ah, yeah. Point function. Which, since we don't return anything, we just set things And we say update When Handler, for example, Once again, you can name it whatever you like. Since we have for the moment any option in here or anything we know about the game at the moment we can put all the info is directly into the windows handler. So what we can do is we can talk to the wind loose Hendler directly. Then we say update. Um I hope I have saved that. Yes. So I take this update text function and put this in here. So we knew Sandra. Oh, it's not directly the windows and about the handler. I'm sorry. So, hand little update tanks When we open, close the parentheses. We can see. At first we want to know. Did we won or that we lost. And what we can do is we can also set a ball here when lows and when we later on call it from win or lose condition, we know whatever this is going to be. So we put in win comma. So win once again in this case, is the argument over here. Don't can take the turn. The current turn s a value. So current turn is going to be the turns taken and two time in time. We probably for now just put a zero and or any other number or one. And in the last one, I'm not 1% sure. If that is or why that is going to be, like, underlined. Maybe we're gonna have to put this into something different and, yeah, let me just store an integer or create Ah, random interject pretty quick, equal to maybe 10. And then I just put in Rand over here. Well, the calculation once again later on comes whenever we had done was all that's on WordPress com again we're gonna need to score so we What you can take is maybe a random number. I ain't gonna take maybe 10,000 and then we ah, for like, one turn is worse. A towel 1000 So we can say 1000 divided or maybe 10,000 to have 10 turns 10,000 divided by current turn or something like that. Once again, we can calculate all of these things whenever we like and want into any year. Part of it also began later on calculate the time within it. So when we know when we gonna call the update win handler and we say in here is true. So since we want, we're gonna update this And of course, we're going to do the same in the lose, but And he is going to be, ah, Falls. So we have just connection to this, which is going to talk to the hand the directly and updated according to the current time score whatever we like and please in the wind Hanlon. We also need to make sure that we may be are activated, deactivate particular game objects. Probably. We're gonna do this in here in the handler as well meaning Hendra dot game object dot said act if and now we can probably set this one to be true after we have calculated everything and in start, we probably want to disable that So maybe we say hand then don't game object don't set active and is equal to false or in this case, in sprinted sees falls. So we do you activate the handler game object. We probably are not able to deactivate it in here, but we're gonna find out in just a second. So when we go back to unity and that the compiler run, he gonna probably argue about anything or not. If not, it's good. And when we now press play, we should disable automatically the wind panel. But since there isn't nor reverence, because we haven't be abroad the Hendler script onto this game manager, we need to put in the wind panel into the handler script. Let's try again. Boom! As you can see, the Penhall is deactivated now, which is absolutely correct. And we can now basically put in any pills we like to play with. Once again, we don't have anything. And when we're losing, we want to make sure that we're gonna get like and we know, lose one. As you can see, we lose. We turned taken to turn. So one and two at the time. Taken in this particular case once again is 10. Since we just calculated this one and the score is 5000. Actually, when we're losing, we want to put in maybe a zero or whatever it took, because whenever we are normally would using, we're gonna end up with zero. Anyways, since 1000 or 10,000 divided by 10 is going to be Yeah, thousands of very probably. We're gonna multiply this by a number as well to get the correct score. Once again, we can calculate the score Anyhow, in any time we like to a best way. Of course, before we try toe update the handler over here, so same can happen or should happen a waster you win button or you win panel, as we have seen, everything has been as we set it up almost. But we want to make sure that we were able to win now to see the Coric button or the correct panel. Where's you win in the middle or in here just to make sure we have written everything? Correct. What does it mean? We gonna go to the Haider image and deactivate this for a moment, so we have an easier play to update us or actually toe win. So we need to put in like or four pills in here. Put in everything we want to check and divide by zero is not possible since the current turn is asked zero and not one. What does that mean is actually ah, we need to make sure that the current turn is at least one when we're trying to put the wind condition together. So I guess the best way over here is increment in current turn by one, no matter what. So let's drive this once again. Probably there are some things we haven't considered yet. Based on the turns, we also deactivate things and like these, these models over here and as you can see now, it took as one turn hide image. Of course, this is what the warning is going from because it's cannot be unhitch didn. Whenever we're winning. And once again the slide in is going to be not working or is unable to talk to it whenever we are trying, you know, to teach 30. #29 Play Timer: Welcome back to the course in this course part. I want to create a little timer. Probably. You know this already, but actually from another video of May on YouTube, for example. But I want to show you everything once again in game in it. I want to make sure that I create a court routine and I e numerator this I numerator is going to take up for us. Um and I called playtime. This is going to take for us. Meanwhile, were playing the game. Everyone's a second. We want to update the playtime. What does it mean when we start this? Coubertin? Of course. We later on. Probably need to end it. Of course we need Teoh so Well, How do we do that at first we need to start it, of course. And we're going to start it here in the start. Masset So start co routine goes parentheses and in quotes. I want to call it play time. Make sure that this name is going to be 1% matching this name. So the function name off that if you are unsure, copy the name webs could be the name and put this directly here into or in between those quotes that are so nothing will fancy will happen. So what do we do? Is we unlimited? Lee, lead this one. Run. I'm gonna make a little note in here. It's everything for time. But first I want to have a crew. Very able an inter job, which is called playtime. There's going to be an individual. We gonna count up the wall time and then we have ah, seconds and minutes. Basically, we don't need to put in a year this second and minute because we're gonna take this numbers into consideration automatically in the i m. Aerator, but would also can do is we can feel in the data or change the data directly into it so we can say seconds and we're gonna put another integer minutes. As you can see, they are going to stay private since nobody needs access to him. And when we take any number, we can put it directly from the game manager to somewhere or from formal game injure to any script with any function we like to to keep on running the I numerator completely. You have the world time we need to put it into a while loop. So while true, so meaning while this is running, we're gonna put perform everything in here at the very end, it is super important that we yield Return new wait for seconds and an open close parentheses would say one. We gonna wait for one second and then we repeat everything inside the wire loop. As long as this is running, how do we do? That is, at first we combed up playtime. So playtime plus plus, this is going to be once again a variable for our complete time Over here, we can also claim later on playtime and between specific numbers. So it's not getting overdone now. We want to calculate seconds. Seconds is equal to play time divided by, I guess 60 model or 60 or display time. Bortolussi. I guess it's playtime. Model 60 model means we gonna put a like a clamp to this particular number of seconds will never be higher than 60 seconds. And that means then, when playtime reaches 60 it's automatically resenting itself to zero. Now we can take minutes at minutes. I showed you already. It's going to be playing time divided by 60 set because 60 is the maximum amount of minutes per hour and then we say model 60. So once again, 60 seconds are or playtime divided by 60 means 60 divided by 60 is one. So we have one minute when this is 60 when play them is 120 with two minutes and so on and so forth. And once again we kept this by six. Yeah, we kept that by 60. So it's not over doing anything over here Now. What we need to do is we need to place or take this time later on, whenever we're for example, stopping this co routine. We can read the data directly over here from the time panel and we can put this into our window, lose handler condition meaning in here, which is currently the random number which is standing for our time against Yes, we could put in anything we like to in whatever string perimeter, if we'd like to as well. So what we can do is we can literally tank or create a string off particular parts or stuff into that. How do we do this? First I want to change the argument in Windows handler to be a strength, since I guess it's easier to put in that. And when we know, want to do is or what I want to do is I want to calculate that based on seconds and minutes and put some quotes and stuff like that will not crudes but a cooling in between so I can created new ah, string timer or time is equal to. And now we take, um, several things in consideration. Minutes have to be left. So I say minutes dot to string and in the string. I want to put this into a decimal terra meter. So D 22 means it's the lengths off the string. So a maximum of two numbers is going to be shown. Then I can say, Plus, then I want to have a colon in between quotes and then another plus. And then I take the seconds. And of course, I want Teoh convert those to a string as well. Open those fantasies and I put this in a to a decimal two as well. So d to So now I have that string and now I can put the string here into that and I take just time as from the string pyramid argument, and I can get rid off into rent number over here. So this way we automatically know fill in the data. Now when we want to see the playtime also mean why we're playing. We gonna need a connection to a text field as well. Once again, we can't put even that text field into the wind lows handler, but the downside is we cannot see it. Meanwhile, playing. So we probably want to have, ah, connection to the textual directly in here in the game manager. What we can do is we can say using unity engine dot you I to have access to text fields and in here are gonna put in your tax field. It needs to be a public ones because we need to drag it into text, um, timer text, for example gonna save that. And now we can talk to time attacks and put in the same arguments. Meanwhile, playtime is running, so we can't say time or text. Don't text is equal to, and basically we're gonna do the same as we do here. We take minutes as the string perimeter and seconds as a string perimeter and put the time a text into the game managers text. You can also create an extra function for this if you like Teoh. But actually it doesn't need to be. It's not necessary. Probably you want not to wait in the very end, but at the very start for one second. Then you are up to do the or your poor probably up to do it as well. But I guess that's the best way over here to not fall into an unlimited loop. Just make sure 1% that the yield statement over here is represent inside the while loop. Okay. Now, while lose handler needs to be safety as well. Since once again, we're taking this time of text over here as a string para media, and we want to make sure that everything looks accordingly. Now the final thing we want to do is of course, we need a tax for a timer. We can put this once again anywhere we like to inside our playfield are gonna hide the wind panel. Pretty simple. Pretty quick. I change my resolution to be turned by 16 so it's eat better, and probably I put this in the very far. Right corner, maybe not too big, not too distracting. And as you can see, it is we don't care. Or actually, we don't need to take care of where it actually is going to be. So I just put a text field over here, make this one a white text. Maybe maybe also put once again, best fit into consideration. So it's big enough, and I direct this 1 may be over here and type and 00 colon 00 So I can see better and can also argue if that is going to be nicely seen big enough and all the other things. I'm gonna leave some space in between left and right and probably our anger this in the top right corner and drag it away once again if it so it's always staying on that position. So now I need to go to the game image and direct this text the time or text I'm gonna be. Name it pretty quick, timer text and put this into the game. Energis lot four time attacks. Don't forget to set the scene. I'm press play and see what's going on. Probably there's going to be no reference every exception or something. But as against see now it timer is going to be plate when we know deactivate the wind, penner or activate the wind panel again and the timer is running and we're playing. No matter if we're winning a losing and we're gonna put in like because we're cheating now or the correct numbers and stuff you can see the timer is automatically field in here by the time taken, or you also can see is the I numerator is as a process is still running in. The background we want to do is, of course, we want to stop the co routine whenever we are updating the wind handler, How do we do that? We say stop co protein and then we call it by its Derek name. Play time in quotes. This is important, and that's why we're taking playtime or starting playtime with codes and here, otherwise we are unable to do this. Let's test it out pretty quick again. So once the compiler is completely done and we press play and of course we cheat to win pretty quick, fast again, like so the orange one. Check. As you can see Now, the play timer here in the background is not running anymore. Because we stopped this particular one co protein with its Yep. Araneta, it took us one turn, and once again, our score is currently 10,000 and once again will be reduced by turns taken. I guess once again we can later on check out how we want to calculate the score may be based on time. Like how many seconds did the player took? And he gets like, um, something decreased by time, however whole long he took. And of course, we need to make sure that we calculate all of that stuff later on together. But you get the idea now about score about two time to again. We already have a timer. Right now we have the turns taken wherever win and lose condition. Now, in the next video, we're going to create the functions for the back to menu. Even if we don't have one as well as the try again button 31. #30 Win Panel Buttons: Welcome back to the course in this course. We want to pretty quickly create the button. Yes, on click events or functions were talking to Whenever we want to say, Let's try again this particular around or any round and see what's the easiest yet the easiest possibility to do so as well as probably also created back to menu function where we later on can pass in any yeah para meter we want or the level we want to load to, like at the scene. We want to load into a string perimeter as well as a possibility for an interview. Perimeter basically doesn't really matter. We can use boats, but I'm gonna show you at least one off those go back to the main game manager and let's create a on click event for these buttons on. We can also put this buys way into Ah, the Windows handler, if you are are happier with that, it actually doesn't really matter. Since it is related to the Windows handler, we can basically do this as well. Ah Proehl, we gonna do that? So in Windows handler, we create a new function. It needs to be a public off type void and we can say try again is going to be the function name. Want to call? And how do we actually try again? Of course. We just reload the scene. So we need to make sure we use using unity Engine that scene management this is worth we gonna This is the name space we're gonna make use off to reload scenes or load new scenes and all the other things. So what we can say is seen Manager don't load scene. And now we want to load the current scene. So what we can take as in as a para Mita is seen Manager don't get active scene and open God's presence is dot name Since it's taken a string perimeter to load a scene, that means we're going to reload the scene. Simple. Now we can also put in once again another pyramid a or another function public void back to menu, close parentheses And and here we can basically say seen manager, don't load scene. And then once again, we can put in a string perimeter or built index and yes, or a scene index. So these guys are going to be our year possible things over here instead of who is probably going to be number zero once again, you can also pass in the string para meter, for example, in quotes, menu. So when your scene is going to be called menu, then you're good to go. Don't forget, Forget to save and go back to the wind. Penhall And what you want to do is on the wind panels. Buttons like this one here is going to be our back. Too many about renames this and new Burton and the other one here. This is going to be our try again. Button into these on click events. You want to drag in the wind panel at first, over here and in function you go windows handler, and then you say, Try again. Same for the menu button. Over here you go to the on click event, then you pass in wind panel. And here you choose back to menu. When you pay your request a para meter. Then you can also like a string or interject but only one you can also see in just a moment gonna show you how it looks. String man, you name. Then you can men your name or seen name is probably a better about a choice scene name. Then you can take this para meter and put this over here in that line of coat. Gonna show you. Don't forget to save when this is now updating and the compilers completely done and a running, they're going to see a little para meter over here. So we're gonna take the same as you can see. Now we can put in a name here. For me. It's just menu. You can do the same once again, was the build index in India and then you're good to go when we now once against, want to try again. So we play the round. It doesn't really matter if we're winning or losing. Boast buttons are going to work the same on we check on, we check again. We can once again also lose the game pretty quick. Actually, it doesn't really matter for us on. We check. Then we can take it. Make use off the try again. Button over here. Try again. And it's completely loading a new scene, calculating a new riddle for us and all the other cool stuff. And we're starting all over with the time and was everything else. So once again, you can keep on and retrying this the whole time. You can check now. Okay, We're at 17. We check and and so on. And so, forests, because all the court routines and all the other stuff is going to become stopped anyways at this particular point And when we know, try again. Everything is starting back at zero. 32. #31 Calculating Score: welcome back to the course in this part. I want to talk about a bit more the score so we can calculate it. Something between let's say, the playtime or in this case, the time were taken to actually find the solution as well as the turns taken. So currently we have something like 10,000 as a maximum number of score, for example, and we divide this by current turn. That means that when we had taken like nine turns, the numbers resolute already off course, but also when we only take do Terance will already get this one divided by two, meaning we only have 5000 left already just because of two Turin's. So I wanted more like taking the time into consideration as well as for one turn. I want to give, like, you know, 1000 points less than the maximum possible terms or possible. Ah yeah, score in this case. So what does that mean? It all. Let's assume I want to have a player to be to get a maximum amount of 10,000 year points, but this is actually impossible to reach. I want that to be the maximum cap amount we can play around with numbers and values later on, let's say we gonna give it just a special points part of a here. So let's say end Max Points or Max score. I want us to be equal to 10,000. So I put this one here. So what I want to have is, like, I calculate the current scores. I maybe stores this year as well. So car friend, score and I want to set this one from the beginning. Of course, to be zero, this current score later on will be filled in according to once again, all these mathematic calculations were were able to do so whenever or before We're talking to the update text a year component here or script. How can we do that? We can create our own function for that because there are several possibilities to do that Since we want to keep everything clean, we say over here, void. Kill que late score. We don't need any input since we gonna take all these inputs directly from here from the variables we currently have. So what we wanna have is at first we want to set current score. Toby, um, the maximum score minus the current score times the 1000. Since this is going to be like 10,000 times, the lowest amount is going to be 1000 actually for one turn. So I want turn is giving us a coast or we need to pay 1000 score or points to actually take another term. How can we do that? So current score is equal to, and now we take the current turns taken. We multiply this by thousands of current turn times 1000. So this is the number we have. Let's say we have, like, two turns are taken and each turn could give us a coast off 10,000. So this is going to be the current score. But this is not enough, since we need to take the maximum score and take this current score minus the maximum score minus the current score. Current turned times that. So what I do is I say Max, score miners. I'm gonna take the apprentices away. Miners current turn times 1000. So that's the first calculation. What that mean is once again, when we have taken like two turns of one turn, we gonna take this one and take away the currents Turn times 1000. So when we take dental rinse, we have basically no, don't But no points left. If you want to still have points left, you can even take this number here and there, making 900 from it. What, as dad mean, actually is when we take like 10 turns, we still have some points left, which means by 10 Turin's it's going to be 1000 is going to be the possible score we gonna get now We want to take the calculation off the time into consideration as well. So we can now say it's for example, since one second probably coast US one score as well. So we can now take the current score and set this one minus equal time or, in this case, playtime. Let's assume we have a playtime off 202 100 seconds. In this case, we're gonna take the current score and to make this one minus equal the current plight time . So we re reduce it by seconds when one second is coasting us one time. If you want to multiply the coast or the timer over, you can always say we can double the playtime s score so we don't take the direct seconds. But probably you want to multiply this by two meaning when we are at 200 playtime, we can multiplies by doing. We have a coast off 400 instead of 200 so this is also optional. So when we're now done with Dad, we can't actually take this current score over here and put this over the into this calculation. But since we don't return anything from the calculated score, we probably want to change the type off that How do we do this? Of course. What we want to get is in return an integer value. So we just change the time from point to int. And also, when we are creating stuff like that, we need to return an integer as well. So what we can say at the very end, we want to return current score. But since we store current score here in this value, since it is not going to be a fixed value, we can basically get rid of that number as well. And we can make everything in here Temple rally. Let me show you what I mean. I take this line of code. I could I cut it out and put this over here. Now it's going to be an A. This current score indigent value is now a temporary very able so we can take and fill in the current score directly into thes. Don't forget to say and of course, we need to return current score whenever we are requesting this. So no, we create a temporary variable. We feel in every data from maximum score current turn as well as the number the multiplier we want to have per current turn. Then we decrease playtime by from the current score and then we'll return it. What did we do here is we now can request current score by returning us an indigent once again. So what you can do is before we update the text over here is we can now say calculate, score and what we're going to get as we request a dysfunction like over here and we get in return any integer back so we can feel an update, the taxed accordingly. So the only thing we don't do at the moment we don't do an A cap, meaning we want to make sure that when current score is smaller than zero, want to capital zero. So we can we can do? Yeah, there are several things we can use an mess f dot ca lamp between whatever the maximum amount is and zero. Or we could just put in an if statement. So, for example, if current score is smaller zero, then we want to make oil. Actually, it doesn't really matter of smaller or equal to zero are smaller than there. We want to set current score to be equal to zero, just to make sure that we don't have any under flow or any year were numbers later on like minus points, because we don't want to give the player minus points. Don't forget to say this group and go back to unity and let's see if the compiler has any problems. Was our new calculated function here. What was anything else, or maybe any other type of or whatever you like. Once done, we press play and tested out. Since we are or I probably are not able, I'm not able to win, but to lose, I can do a check here. Oh, by the way, we need Teoh, Think about all of that once again in terms of score, However, let's calculate what we have done here. When we usually lose, we lose, like up to 10. Turin's and everything will be taken completely. And guess what? Who maybe want to do is when we're losing. We're gonna give it, like a zero points, for example. So how does all the calculation now works? We take 13 seconds. We take it away from this so you can see 8187 points. So we gonna have that when we add those 13 seconds you to this points, we gonna end up to 8200 points, and then we add the two turns, which are ACOs off 900 points. So we increased that number. And by by that 1000 and 600 points once on 800 point. Sorry. And in the end, we're gonna end up with the 10,000 score. So our calculation now based on this input works 33. #32 Menu & Navigation: Welcome back to the course in the last port. We were actually taking care off score and how you want to know. I want to probably make use of it and how to calculate it. So since we have basically done was the complete game, let's say, mechanic, we can also now go into creating menus, going to create audio, going to create any info screens, how to place greens and all the other things. So this is more like an idea of how to do things since you learned literally everything you need, what I did actually aided a menu already. It is like I have a title. It's just a nim itch in a canvas. Same for my logo. I'm gonna put some text in the bottom line here, like for my website as well as a button which is going to give us a play button. In this case, I'm gonna zoom in a bit so he can see this one better, and I'm gonna tell you how I got this little triangle into it. So what I want to go into, of course, is the button itself. I can double click it to zoom in and When I go to text, you can see I have a text type here which is going to give me the try angle. How do you get this? Triangles? These trying hours are cold asking codes under this prank wreck again. And this asking codes can be found in any Google website. Like when you're Googling whenever you're going to any search engine, whatever you please. And like you're gonna show this pretty quick to you eso I'm gonna open my browser and I can go and make any use any sort engine. And I say Aero A s C C i or a a s c I i and then I should get something like an asking html code for website build us, for example. Actually, doesn't really matter where you want to go and get this. So what? You can see you get some arrows over here. When you just do a search, you can do the same for trying groaned as I did So a triangle A S c I so trying a symbols, A old symbols over here, old cure symbols. So as you can see all of these trying, it's impossible to make use off and you can copy this particular old keys or just that images in this particular case and place and directly into the field s Kinsey. This one here is the one I'm using. So I just market again. Also using anti one. Copy it. So control. See on the keyboard when you're a sitting on a on a on a PC, and then I go back and here, just paste that directly as you can see into the text field. This way, you can make use off all the symbols possible directly in text fields. If you don't like to use text, you can always make use off image components. So on the button you can put as an as you can see like you. I image directly on the button like so, and you can, of course, reduce its size. And you can put in any image off your liking for example, this one or your logo or whatever or pearl. So as you can see, this is another optional way together. Play but and Sibyl directly onto it. So make a use off a triangle shape instead of a yeah, it's so called shape and places directly on here. I'm gonna under this because I like the place Sign from the, um asking code. Once again, you can always go and make use of best fit if you like to, as well as giving it a specific let's say size, so you can always go into it and increase it directly. You can also set here the minimum size of guests at a specific point is going to be automatically increased. In this case, probably the actual phone size is kept by anyhow, this regular family fun site over here, So the minimum is probably 29. However, this is basically what you can do is or how to get a triangle symbol like a play one. You can also put in text. You can once again design all of these things on your own. And since you already also know how to animate things, you can also create animations for these pearls. You can make them fly around, create your own pools and off course, animate them, may make them maybe jump up and down whatever you once again, please like. And what you can also see is this background. Over here, it's a tile herbal. More or less tile, herbal on gain, object or texture. For me, this texture super slim, as it concedes, only 400 bytes. And when I double click that or open this one, you can see it a super small attend by 10 pixels in it's just was that's light through it. So what I did was that, as asked Lee, I put it this right or the setting to be off course ca lamp. So it's automatically you have wrapping Colome Ping type, and what I did is I put it a in image, and I put it that won't onto this image. So ah, I don't want to do anything. Was that image? So when I applied that over here, I set the image time to be tiled. So what does it mean is it automatically tiles the image as as much as it needs. For example, when I sent this one to simple and can see, it's just one image. But when I said this want to be tile, herbal or tiled Aiken tile, this one over the complete game screen. When I zoom in, you can see through the complete scene. You can also play around with the camera and give it a solid color. So you don't see the nasty background over there. You can make a blue blue green were rather yellow, whatever. And all of these transparent strikes for me personally are going to be become a bit tinted so I can make this one super blue whatever and like to and maybe a bit more so the camera shoes when you go in to maximize and play and of course, press play, you're gonna have ah, blue tint with some stripes of like nails. I don't know what they're called. You're gonna see those stripes and you can also do some animations once again wears those pearls flying around. Since you have these objects or this graphics already and of course, you can create your own image and center for me. I just created a little year brains yet brain animation Over here. I don't go over and cover this one as well, since it's going to take a razor a long one. But if you're interested into stuff like this, you can always check other courses out as well. So and what I want to do is, of course, when this button is going to be pressed. I want to have an action on it. So currently, my button does not have any on click event, so we can easily create a little script for all our menu handling. So, for example, I named the script menu Hendra or something or button hand look. And actually, once again, you can also even name this one. Not handler, but manager. Actually, it doesn't really matter. Let me name it. Um And you menu handler, If you have typos on and you see that over here that you have a typo, then you can always double Ah, click F two on the keyboard on PC and rename it, but you will instantly get an error message will. Usually when the compiler is done running it say's that something is wrong with the name off this image. So what you want to do is you want to also rename this one this class directly inside off this. Otherwise the solution probably does not get completely correct loaded. And of course, don't forget to save and get this update directly here. So you once again check out the compiler is doing its work Now you just need a non click event. Once again, you can make any or you create any public void and then you where you want to go to like a lute, seen as with probably an argument in quotes and or, uh, well, you're gonna pass in a string para leader and say scene seem to load or something as an argument. So you can always change this. And what you also want to do is you want to make sure that you're using the C management so yearning, using unity engine, adult, seen management. And now we can actually load anything we like to. So it's a scene management asi manager dot load scene And those brackets, the apprentices, we're gonna put in the scene to load argument or whatever it is. C note Gabi paste. That's good. When you want to rename things, you can always go here and say re factory name and everything according or connected to this will be automatically updated as well. So this one here will be updated as well, since it is making use of it. Okay. And that's pretty much it's No, we can't drink this menu handler to wherever we want to like onto the camera, for example, or any other empty game object. And yeah, that's pretty much everything you need to know to go from one scene to another. So I probably rename this object year land you Hendler or seen handler or pattern handler again and a direct this one over here. And finally I just put Oh, by the way, you can also put this directly on the button, if you like to. Then I add the on click event at the menu handler to it. And I call the script from the menu handler, which is called Load. Seen Any requests? Festering para media And for me, it is currently called Simple Scene. So once again, the simple scene is going to be the name off our seen here for me currently is a simple scene. I can also rename this to be demo of the level one or whatever the Yeah, whatever the level is going to represent. When we now click on that, we will get in. Ah, an argument off exception or something. Give me a sec. I'm going to write for years. So when I press on that, it usually does not look this menu as it did for me. Why could that happen? Is because inside the builds headings, this simple scene is already inside. But when we try to go from the sample seen back to the main menu has seen it wouldn't be here. So what we can do is we can always take the man using and plug it over here. We can also rearrange those, but you need to make sure that both seen the menu scene and the samples in or for you game seen whatever it always needs to be inside the build. Otherwise, this management or this buttons will not work. Don't forget to save the scene. If you have, you know, created your own stuff over here. Once again, I don't go over and cover or this image stuff. You can easily create your own ones in ah, escape or wherever you please and like And what I go is I go back to the simple scene and I want to make sure that my back to menu button is connected to it as well. So I click on it and check out. Okay, here's the menu, and this is going to be the same name for the menu seen. So whenever I'm losing or winning doesn't really matter, Then I want to make sure and press, of course, onto the back to many of us, and I want to make sure that I go back to the menu seen over here. So once again, if you don't know how to create a new scene, just go to file and say you seen and you can easily play around. Was that updated? Bring any canvases, images, logos and all the other things inside this particular menu. I showed you lying everything because the other one or asked, You don't need to put in anything else but the play menu. Or maybe you want to have some Where of my local, for example, you can put an info screen who has created that, and you can easily inside the canvas. Put a year another panel over. It was maybe a closed sign or something. You know how to earn able disabled this already And who was who was creating this game? What's the current version off the game and so on and so forth? But all of that is nothing. Fans it all, and you should be able to get this done and running on the right side. You probably want to have, like, an urn able disabled thing. And, um, like for sound. So you want to unable to December sound maybe on another button. Or you create a complete canvas with just our options on it, like a panel where the people, the players are able to just able to enable sounds or as effects, whatever is later on going to be implemented. 34. #33 Creating a harder mode: welcome back to the course in the last port. Actually, I did well without you. Basically, this little menu seen once again, we I don't cover, like how to create graphics. This is not to related to the course, but what I want to go over is I want to create another scene from the simple scene. What is this about is, I want to have, like, an easy mode and normal mode. Hard motor. Currently, sample scene is going to be a normal mode, I would say. And when we later on creates and buttons in the menu, for example, or another scene where we are able to pick different scenes with different that say as settings, we need to prepare scenes for that we could try to automate things. But through all these yeah changes, we would have to make like we need to have, like, five times a loop through or the solution boxes and all the other things we try to fit or fix all of these automatically, or basically, er enable us some Let's say, points or ways Teoh increase the ball or the pearl amount up to six, and I want to once again automate things as much as possible. But on the other hand, we need to fit something here and there into these boxes. Let's start. Was any eso currently this is going to be the normal motor. I don't have to do anything with that. But what I want to do that I want to duplicate this sample since I try to control the control seeing control the ah which doesn't work. So the best way is probably just completely take all off these things and copy them. Then we go to file new seen and then we paste everything before or after We have deleted everything over here. So now everything is a bank in here into this new scene and now I just ah, Cyprus, seen as a specific scene. And so I go to the scene's folder and say, This is going to be the very hard scene save. So now we have very hard and the sample scene, but both looking the same now. But the connector or basically the very hard one I want to have this one like using six pills instead of just four pills for another mode. You can also you know, you know, put in five pearls or super easy mode with just three pills. So a super easy probably is not. What you want about five polls is going to be something interesting for the player as well as six pills. So how do we do this? Or how do we set this one up? But first, make sure you are in the very hard You? Yes. Seen over here on. We now need to take care of that. Everything is set it up correctly. Let's start with solution books. Since this needs to contain instead off four slots, we need to contain five slots. So we gonna double IC 81 slot and do its row the great layer group. We need to reach size the spacer directly over here. Or probably we're gonna take the complete solution box for this. So and we're going to do this. We, uh, take away the hide image of a year. So we are actually able two yet resize the solution books as it has to be, so we can try to snap it to some You needed solution box or sizes as well. So now we have five slots in the solution box, which is okay. The high damage needs to be changed from long four to be long. Five, we created this one already in one of the first videos where we're taking care off the hide images. And now we need to pass in the same in foes to the play background as well as we need to set the pearl amount here, Toby five. So now we know that we have five things or five pearls in that, and we probably need to change this one in some lines of Cody and there as well, going to the play background. We're gonna need to drag this away until we are snapping to the size and, of course, all the handlers or inside the spacer or the holder in this case, I need to have five slots. So I delete the other ones, go to the slot spacer on duplicate the last slot by control deep. And when you see this, of course, the hint box is a bit off. So we direct the hint books with away. And of course, the check button is a bit in the way as well. So we can put this over here once again, if you are. If you want to create this one for six pills, you're gonna have to do the same. So maybe this is not going to be the heart, but the not very hard about the hard won. I just show you how you can do this. And then we go to the protector. This is going to be an automatically on yeah, resized image. So everything is fine. This is fine. And the checkbook is fine as well. The only downside for the hint books is it needs to be resized the bid since we need to fit in five pills now instead off four. So we want maybe to resize the box here as well. Once again, everything is a design decision. We need to check all of that. I can now drag in from my pre fabs any black pearl hint, or him pill into it and duplicate this five times. I can see it's not matching. So I dragged a bit more over here and the hint box itself. Of course, until all of these pills are able toe put in or match. And I can delete these in pills again. And my hair check box in this particular case is correct. I want to have a bit most based between those. So the check button is not to off. And that should be everything for this. And we can now take the slot or the holder in this particular case and duplicate this. Ah, yeah, like nine times again. So hold on Control and pressed the until everything matches. So now we have a big apply field. We need to put in five pills instead off four pills. So we need to track if that is also possible with all our coat. And since you know where we want to check all of these, we need to make consideration. Or we need to take care off that how many polls we need to place into of this? Let's first test it out. What's going to happen now? When we do this, we're gonna get an argument out of range exception inside the solution books since the slot list is not, ah year big enough, since we don't use all these slots inside spacer. So what we need to do is to take the last slot and put this also into the slot list. and we should be good to go. So now, since the consul is always helping us and tell us if we forgot anything, we need to take everything in consideration. Now, when we drag in our pills in here, as you can see, after four pills, the check button is already available, which is bad, since we want to make sure that all five are now accessible. So and depending on, of course, where we checked that into the riddle, of course. We want to make sure that five slots are going to be now checked. Meaning this introduced size off the places we want to take care off, as well as the amount of pearls we want to check as well as the poll amount. Once again here. This is what we gonna take already as an argument. Once again, we take this from the inspector, not from the script. So basically, this can be said to be anything or does not even need to be set to anything but in here. We no need to find a way how big these places need to be, as well as what this number is going to be about. Off course we can make use off the pull amount directly. So, for example, we can put in a switch or estate Ah, switch statement or if else statement whatever or just in if statement. So we can say if Pilla moaned is equal to four once again, you can put this in switch or in if statement then you wanted to create these places into just what you also want to do is we want to do the same stuff. If curl amount is equal to five, I want to do the same. But of course, the size off these are going to be different in this case is going to be an inter jail five or an array of five. And we were We need to, of course, Phil, and minus one minus one here in those two lines. Once again, this one here is not going to be number four in this particular case. But this is going to take Pearl amount in consideration. So it's looping. The Opel amount now inside of that place is one place. Do is not available for us at the moment. So we need Teoh initialize that beforehand. I guess so. We put this in here, and places do needs to be here as well. And then we feel the data according to that. But what we need to do is we need to take away this Inter Jess here, since we re arranged, um, accordingly, because they exist over here anyways. So let's see if that is going toe work. Also, we want to make sure that exact matches is going to be the pearl amount. And when we go down here when we do the white check, we also want to check for the pill amount a size. Basically, here is going to be the poll amount as well, and that should be. It's so we don't forget to safe, and we go back to unity and let's see if the compiler has any problems. Where's our very Ebel's? To get rid of this little error, we just need Teoh actually fill in that we're creating a new into term array, basically, and we can also define the lengths off this new interject already by using the pole amount into consideration here as well, and we're gonna do the same on the other side. So on the polices ah, to and we put this in here as well. So once again, this is going to be initialized over here. So it's going to be filled according to the poll moment size afterwards, surface, we create them, then we fill in the corresponding data. So to once again have all this miners won us over here inside those and in the very end, once again, we go to the white, check by whatever the poll amount is, and check this one out. But still, there are some things we need to change. You probably know already what I mean. But first that see that the era has gone. There we go. So no problems with initializing these numbers. What I want to check is, of course, is the solution box is completely corrected. Set it up as well. So I just say the hide image on UNP awes and as again C five slots are going to be filled by this hide or behind this hide area so everything is fine. And now the next thing on the last thing we need to change is going to be the drag books handling. So when we drank in four pills again, you can see it is checkable. So we need to take this and consideration as well for the dragging in script, which is sitting on our dragging on our holder and this holder already knows. Okay, we need to do this defined by the size of the pill ideas over here. And as you can see, the size is set to before. And what we need to do is we need to set this one to be five, or in this particular case, based on the pearl amount, how do we do this? We go to the dragging, boxy, subscript. As you can see, we're initializing this one based on a fixed number. In this case, once again, it's an into jail for or an integer array off the size of four. I would say we gonna create this and make sure that after we have created that, I guess we can initialize that in this particular case without any size. But in start, we need to set it. So we say hurl. I ds is equal to a new end. And then we re initialized that by now we need to talk again to the create Riddle to D script, which is called Riddle and I don't know if we have aesthetic instance off Riddle. No, we don't. So we can directly talk to riddle over here. So we take riddle dot and in here and we should see the pearl amount. And that's what we're going to take ss an argument off the interject race size. So and that's pretty much it. So we should be able now toe automatically update this one on start. We're gonna check this out in just a moment. I do not go and maximize and play. Now, I press start and this ended ideas array should be re sizing itself to be five, because the pill amount we were setting once again in the solution box in the create riddle to D is now taken and filled in correctly. Now, when we feel in five girls off four pills, this is not going to be checkable because we have a size a different size of a year. And what we need to do is of course, we need to fill in five and total. And why does Dad not work over here in the hand? And I'm a five element zero or every man for in this particular case is still zero. And this is because we forgot to set up the slot idea. I'm gonna delete all the whole That's pretty quick, except that the 1st 1 I go to a slot space again. As you can see, every slot has arm hits own I. D. So slot the very most. A slot to the left double click it. To see the very one of very 1st 1 is going to be zero. This one has an i d. Off number one i d to 83 and slot four should be having 84 as well. So now ever seeing should be set it out correctly, Wizened or wiz? That's lot idea, which is now correct. Now we can't duplicate the holder nine times again until the play field is full. We saved the scene and everything. We have set it up so far, make sure everything saves correctly and then we can try again. Now we feel in all the polls we like to, and as you can see, we can now check it out and it gives us an idea off. How many things are going to be correct and or not. And as you can see, it works the same way. Now what I want t do is I want to cheap really quick and see if this is the air. If we are able to win this so I just hide or hide the height image or the Haider image, I put in everything over here, put all of that inside of it. And as we can check now is like all pills should be now visible. Let me pretty quickly deactivate the wind panel. All five black pearls are insights of this works as well. And as you can see, we won on. We got this different score according to having five pills. Now we just need Teoh once again safe everything just to make sure. And we can know from the menu scene which you have probably already created, and take the very hard mode into consideration, like putting a director connection to this level onto a button. Don't forget that you need to put this scene inside the build settings as well, so just drag it into it and you're good to go by the way, the built index is going to be represented by the number you can see on the very right in the scene to build or scenes inbuilt stuff. So when you want to, instead of using seen names, want to use to build and next, that's where you find out which one is going to be the correct one. 35. #34 Impossible Mode: last but not least, let's create another super hard one. Like with six polls, as it concedes, going to become Raza small space now for putting all this expose plus star check, button, end plus or the other things because it probably would overload to the right. I want to show you some ways where you can how you can fix that, Since we cannot go in the height since the height is going to stay the same, we can actually do something with the button where once we have, like, six slots in row over here. So what I want to do is it for us? I take, like, all content again. Copy it by holding on control press, see and create a new scene. This scene is going, Teoh have are gonna put in like all the content. First I get rid off camera and directs and light and places complete. They want again in here so everything is in my scene. The next thing is I want to save this scene so safe scene s and go to Scene's folder and make this one like impossible. This is a very hard game or is going to be a very hard game for the players. So this is the impossible play moat. Once again, to make my life easier, I deactivate the wind panel and start once again with dissolution box. The solution box gets another slot. So I hold on control President and endured to its size. I want to resize the solution box as long as I get this next pill into it. There we go. Now I want to add is the say of the next six slot into the slot list at the very bottom. So I just drag it onto the slot list, number or name. Then I go and take my hide image, and I want to make sure that I put the long six number over here. So we have six question marks onto these polls on. We're good to go. As you can see already, it's taking up a lot enough space or not a good amount of space. We can still see our timer, since we didn't make it too big once again. All of that are design decisions. You gonna have to make on your own no matter what. Okay, so solution boxes done. So we need to make sure that we set the poll amount to be number six because we're taking six K six pills now as the correct amount, then going back to a play back or playback ground. And then we re size it once again to snap until we fit the same size as the solution boxes . And in our spacer, we get rid of all hold us, except the 1st 1 we're gonna put into the holder inside slot spacer in next slot. So we duplicate by control De so we can see this next slot and we increase its slot I d to five from four, which we prove forgot in the last video. And of course, we now want to make sure that the protectors all over the place, which is true, and we take the hint box and bring it to the right and keep a good amount of distance in between. Now, as you can see, the check button does not work as it's supposed to be or actually is not fitting. What we can do is now we can rotate it and place it still inside the screen. It should be still big enough to do so So what you can do is to take the check button and then you press on the right. Hold down the shift key where you can't snap to specific ankles are gonna do this. And as you can see, the sad rotation is now set to be 90 90 degrees and a bit so you can snap this automatically. And as you can see, this button now almost fits the height. Well, at least for me over here, off the check off the hint box. So when we're happy with the results, we can always still should be able to reach that at these with the mouse with the fingers on. When you're creating this game for mobile later on, you probably want Teoh resize the check. Ah, the hint box over here. Or maybe give it as a tang or you put this in one row and the check button under it is also possible, so you can still have everything in one row according to whatever it is supposed to do. Okey dokey. And that's probably everything we need to do with the slot spacer once again, although slots will have their own ideas corresponding to whatever they are after the protectors got has done the hint boxes automatically field anyways, and the check box or the check button is still working the same way. Code wise, we have made it so that everything is automatic. Singing is set up as well as the dragging box group later on was the pill I ds. Since it is always reading the pill, I d amount from the solution box. And now what we can do is of course, we can duplicate the spacer once again nine times by holding down control and press de on the keyboard. There we go. And now we should be able to play the game. If not, then off course. We will see it pretty quickly. If something is wrong with our game, we can check it and we're gonna see Okay, we have, like, three correctly done. And no, it's time to find out a quick solution to get to the very end. Once again, I want to make also sure, As you can see, this system works completely nice as we have created this one. So we can easily simply create our own game modes. Ah, and even a different ones. If you like as well what I want. Of course. Once again, I want to know if we are able to win this off course. We're always able to lose it because you know this amount off and decide the list off the holder is going not going to change. So of course this was wrong. I wanted to take a make sure that I'm able toe win. So I put in, like all the pearls corresponding to it. I make a tank. All of the black pearls are going to lend into it. We get our score time taking turns taken and that's it. Once again, we can go back to the menu if we like you, so we'll end up back into the many because we copied, like, all the content just into a new scene on we can play again. And in this case, this button is going to load the sample scene because we set it up like that. If you want once again go into the menu on create more different buttons which sending you to different scenes, you're absolutely able to do so 36. #35 Cleaning up: Welcome back to the course in the last two videos, we created different yeah, modes, basically or game modes in this car. In this part, I just want to do us more cleanup since, as you can see, when we're doing things that will be in force in the console, for example, when we drag around, we still have the D Brookline. We're beginning drag. When you double click those, you're gonna open up this correct script where this is coming from. So what you want to do is to clean it out is commanded completely out because it's unnecessary. You can also, once again, at the lead. The company line basically doesn't matter. Just make sure you d Buck. Yeah, you put away or clean off any kind of D book line you gonna see here Also, there are, yeah, just clear the consul. When you do changes, of course, it will react like that. They're also to other things, like in the game indigent. When we're winning and losing, let me open this one up pretty quick. So in the wind condition, you can see there's another debug line which I created You probably you have that as Well, you want to make sure that you don't put in you like you want your amazing in the debug line log, and you don't want the same into the loos condition like okay, put away or get rid off the debug line. Make sure you go through all your scripts wherever you probably have a D. Brookline left and clean everything off. This is important, since later on, you want to have it as clean as possible when you build the game and when you upload it somewhere, you don't want to have unnecessary data. Ah yeah, flowing around or print messages or D Brookline's inside the code, so make sure you get rid of everything you don't need inside the build or inside the game, especially once again about the D. Brookline's. Also make sure that there are no warnings left. Every yellow warning. It is not bad, but it's better to get rid like off all the warnings whenever they are coming. Some like, for example, you forgot Teoh Uh, put this him. It's here, for example. This is not it is still hidden. So what do you want to do is you want to earn able the hidden, hidden or the hide image in all your scenes, like in the impossible mode where I am currently and in the sample scene you want to make sure this is active as well as in the very hard one. Execute. See, I forgot to earn able or re unable this. This would always end up in, ah, strange things, and you want to make sure that you completely check out everything we have done. So for everything needs to be checked again, just to make sure the player itself does not have any surprising, weird things happening. Like when he see the solution From the first time off course, he's able to fill in the field, and everything is done so far. Also do polite tanks completely test your game 100 times and 100 modes and see if the impossible mode is even possible to beat. If not, think about how you can probably make it better or easier or whatever, or give them more possibilities to drank in pills. I know the impossible's green is rez a full already, but you have 100 more possibilities, even with scrawling windows where you can even put more pills into it like to give them even more turns. Also, you might want to get some more text over here like sent the player an info like, What's the current turn? And what's the maximum amount of turn so he can think off? Okay, I only have, like, two turns left. How can I improve myself? How can I get better? Faster, whatever. Or at least get the info. Okay, when there are more inside that a row of a year, he's not always he doesn't need to count them automated, you know, by hand or ah, well, most of the time you see how many you have left. But sometimes once again, if you're going over the size off this 10 playfield or hold us like when you go over here and your scroll or make this one scroll a bill, for example, they don't to have more solutions or persecution possibilities. You want to show that to the players? Well, so he's not like I'm done already. Why don't I see anything else? But I still have, like, four left or something. But how can I make use of them? So teach the player that show the player that he has more options. All of that info is yeah, necessary later on for the players. So make sure you also show them how to play the game onto a help screen or something like that before you even start a game and give him some more possibilities again. Four different, Yeah, palay gate or game styles, whatever. 37. #36 Menu Buttons: welcome back. Once again, I want to show you pretty quick how you can improve your menu based on the mod's you're gonna have. Ah, what I want to do is I just the duplicate this particular button, like, two times more, and I want to put in some text. So the player knows. Okay, there are, like, three modes, like normal mood hard mode or very hard, more or impossible mode. So we give them the possibility to change or actually choose the correct mood they want to play. How can we do that? We go to the button over here, which is currently the normal play button normal mode. And we want to do is or what I want to do is I just duplicate this one. And as you can see, it currently handles until that it is sending the player to the simple seen. So I want to put this very much in the top. So it's not interfering too much with the other design things I have created already. Probably I will go and you re size all of these things. Um, what I want to do some make this one a bit broader. So there's a bit more space on Guy can't put in text so going to the normal button and press on text I can say here normal And then I still keep this play our symbol over here when once again you can change the font. The size is whatever you please in like to that duplicate this one And to direct this down a bit and this is going to be not my normal mode, but maybe my hard mode or very hard load. And also you want to tell that players that this is going to be hard mode, hard moat and maybe I gonna put ah, like a normal moods. Text overhears Well, basically doesn't really matter. It's again. What? Ah, design decision you want to make as well as yeah, how you want this to be looking If you want to have them all the line to the left, you're absolutely free to do so. If you don't like this cemetery line over here and I duplicate the hard mode button again and bring this may be over here. So about the same distance to the other one. And of course, I renamed this tax to be the impossible mode or just impossible because it's really hard, I guess. And since this taxes toe to back and I probably once again and renamed this not to have moat inside as the word maybe just normal, hard and impossible. Actually, I don't, uh, distract the player or make him understandable that what's going to be impossible? There's no named no, but named as with the mod behind it. So that's what I want to play it to do so in normal button. I want, of course, have the sample seen in heart mode. I want to load another one, which is currently very hard. There's going to be once again the scene name we have created or we did here, and a possible I, of course, want to load impossible. And there we go only once. Thing once again keep in mind is go to the build settings in which you find and file, and make sure that you also add impossible. Otherwise, you don't have access to it. Make sure you added to the build settings, then close the buy button or the window once again save everything. Save the scene whenever you have change something off course, keep on saving, and that's pretty much it. So now when we plus play, we should be able to choose any mode we like. So, for example, we can take the normal mode, the Hartman or the impossible mode, my design of a year. My pearl runner, you had, you know, rotating around this brain. I wanna maybe put this one a bit more higher. So it's not two months overlaying like over here and maybe taking a rake. Castaway, I would like to press on. It doesn't, but I just want to make sure, okay, so and the final touches here once again, you want to make sure that all the levels are correctly loaded. As you can see, this one's little hard. And when we put out a press play again, we want to also see that impossible is able to load. That does work, and you want to go and check for maximize and play again and see if the buttons are staying in position, which they are doing, which is nice. And that's everything I can teach you so far for the menu button as well 38. #37 Update HideImage: while trying out the game on my own, I noticed that the hide image animation is ending too early when it comes to the positioning off the year off, the high damage itself. So what we need to do is we need to make sure that the high damage animation is going to go far enough outside of the view so the player can see the complete solution. So what we do is we go to the height of it itself best way, probably in the impossible mode now, and we go to the solution box, hide, image and s can see we still have the animation connected to it we want to do is we want to go and change its animations so we go to the animation, wouldn't know over here. And as you can see in this amount of time, like in two seconds, we're going to go to the anchor position to the right over there. What you also can see is it is still overlaying two pills or almost two pills, which is not good. When we want to do is we probably want to yeah, change that position accordingly so we can see it later on. Better I gonna disable the wind panel so I have a better access to it. Go to the market to the right, and I want to make sure that I take this now and drag it to the right completely or at least a bit more. So it's coming out of the way. Or we can also bring this completely out of the game window. We can even go and put this one up and down with scaled up and down Once again. It's another design decision you have to do anyways on your own. So meaning when we know saved that. Yeah, open Haider. We also need to make sure that open Idol Haider now needs the same exposition as we have in the open. Haider. So on the left, very last position over here, so best way is double click here or go to the ankle exposition and copy the complete value . Then change back to the open idol Haider, which is going to be this and change the position of the day as well. So when you know would actually the applied this one, you can see it's automatically popping to the correct position of the day. This is going to be the same position later on for the plot for the five lengths of images . So it's this. A distance from here is going to be a least bit bigger since we gonna scale. Or this is going to be a scaled object or scaled image down. So no problems at all. Nothing fancy. Don't forget Teoh, say the changes and, of course, deactivate or reactivate the wind panel. So it's available for us in the game view. So whenever we're losing or whenever we're winding, it is able to slide far enough away. Once again, you can always go into and yeah, make animations for each of these idle hydro's. But since we just corporate and pasted to complete content off all the scenes, we haven't done that so far, so you can probably create more animations for those different sliders over here. Once again, you can even ah yes, scales is one down. Make the pivot probably here in the bottom, and then scale up to half off the size or whatever you like, and police according once again, to the design decisions you make on your own. That's just what I wanted to tell you. So you don't. I wonder why this is going to be closed halfway. So whenever you encounter this problem makes you you just change it accordingly. 39. #38 Conclusion: as a conclusion off the complete serious I want to tell you once again thanks a lot for tuning in and joining the complete course. I hope you her learned allots. I will discover pretty quick what we have learned in the complete serious. And I hope to get some cool feedback from you like is it positive what you have learned? Is it negative or is it something what you forgot? Or maybe what are what you wanted to have more. I want your feet back and tell me wants good about the course. What's bad about the course? Does everything work? Are there any problems you have encountered? Maybe you need some more info is about whatever the designs are. Whatever let me know and write me a review or a message. Whatever. If you have any questions in the end, I want you to go out now, create a nice menu, scream however you like. Of course, you don't have to make whatever I have done in here because this is a design decision. I have decided for me on my own. But what I want you to do is like, optimize everything, make everything as beautiful as you can even think off and then just take this game as it is and release it, for example, into the Google play store into the Apple store wherever you want, in place or even on steam. A field is a super important super great and let people play your game and let them test it . But before hand, don't forget to optimize everything, clean up everything as we already have done and so on and so force. So pretty quick recap. What did we learned? We learned how a timer is going toe work. How would drag around pearls, how we snapped them into position and how to instantly eight new pearls. Meanwhile, we're letting them drop, so they are going to drop directly in position. Over here, we learned how to activate and deactivate those check buttons whenever the old slots are going to be full. We learned how to yeah, so up the hints or the correct ins, I would say for the player so they understand if they're good or not. Or actually, if there you're doing something wrong or right, we created an automatic function for the solution books, which is hiding or actually you're starting to hide, but I'm hiding. Whenever we made a process, a good one as well. And of course, we learned how Teoh so screens like windscreen or loose screen, how to calculate score on different behaviors, I would say as well as yet creating even harder Moz in total, like we were rearranging like all the items in between. We took care off that all the pros are working completely correct and nice. And of course, we learned how toe optimize code as much as possible, as well as cleaning up everything in the end. So no debug lines were run. No errors will appear as well as no stuff on. The warnings will be available in the console. So once again, do me a favor, release your game. Make it as nice as you like. Make it as your playable as it as you like, And maybe you challenge yourself. How about if you know, think about it. How would you implement stuff like pills with numbers, but not colors? Think about that obstinate, the possibilities and maybe create a mode where people are not going against colors or with color pills, but was number two pearls like a 1 to 8 or something like that, 1 to 6, and also maybe think about another mode, maybe like how you can use other or different as shapes, not just pills. Maybe you want to implement stuff like and hards stars whatever and mix them together like let the system pick from star shapes and hard shapes and pull shapes. But in that case, you might want to simplify that game. Motives to be maybe only have three solutions possible, for example, so like like four is the standard one but three and total, so it's still beatable in night, 10 rounds also think about how you could extend the 10 rounds or 10 turns maximum to be maybe 20 or 15 or whatever you think off. So create now a complete a p. K file. I bloated into the Google play store, and so, people, what you have done so far, once again, I'm totally thankful that you took this course and made it this far. This is absolutely great step you have done, and I hope you enjoyed the complete serious. Don't forget to check the bonus session or the bonus videos. If there are some available. And yes, thanks a lot for taking this course I hope you enjoyed. And I hope you're gonna have a good year future with all this continent you have learned in this course.