1 00:00:04,050 --> 00:00:04,410 ‫All right. 2 00:00:04,410 --> 00:00:05,080 ‫Welcome back. 3 00:00:05,100 --> 00:00:07,350 ‫Now let's go ahead and create a high score. 4 00:00:07,380 --> 00:00:08,670 ‫You probably know how to do that. 5 00:00:08,670 --> 00:00:10,590 ‫So please go ahead and try that. 6 00:00:10,860 --> 00:00:13,210 ‫Just try to do to create a high score. 7 00:00:13,230 --> 00:00:14,670 ‫Add a high score to the game. 8 00:00:15,670 --> 00:00:15,970 ‫All right. 9 00:00:15,970 --> 00:00:16,780 ‫I hope you tried it. 10 00:00:16,780 --> 00:00:21,600 ‫So I'm going to duplicate the score and I'm going to call it high score text now. 11 00:00:21,610 --> 00:00:23,800 ‫High score text. 12 00:00:26,140 --> 00:00:29,920 ‫Now in the game manager, I will have to change some things. 13 00:00:29,920 --> 00:00:31,150 ‫So let's go there. 14 00:00:31,300 --> 00:00:33,070 ‫Let's add a new text here. 15 00:00:33,070 --> 00:00:36,040 ‫Public text. 16 00:00:36,220 --> 00:00:38,440 ‫High score text. 17 00:00:40,540 --> 00:00:48,160 ‫And I will need an awake method here because at one point I will need to get the high score from our 18 00:00:48,400 --> 00:00:49,450 ‫player press. 19 00:00:50,050 --> 00:00:52,550 ‫So let's go ahead and create one here. 20 00:00:52,570 --> 00:00:54,220 ‫Private void. 21 00:00:54,220 --> 00:00:54,910 ‫Awake. 22 00:00:57,680 --> 00:00:58,820 ‫Get high score. 23 00:01:00,110 --> 00:01:03,620 ‫Now, what we'll need is, of course, a get high score method. 24 00:01:04,940 --> 00:01:10,220 ‫So public int get high score. 25 00:01:11,480 --> 00:01:21,260 ‫And what we do here is we set I create a new variable called I and we get the player press at the position 26 00:01:21,260 --> 00:01:23,810 ‫get int high score. 27 00:01:25,430 --> 00:01:27,980 ‫And now you might say, hey, there's nothing, there's nothing in there. 28 00:01:27,980 --> 00:01:29,530 ‫How could you get that? 29 00:01:29,540 --> 00:01:31,610 ‫Well, we will set it up in a second. 30 00:01:31,610 --> 00:01:34,190 ‫So what would be a good position to set the high score? 31 00:01:34,190 --> 00:01:36,890 ‫Because here we only get the high score from the player press. 32 00:01:36,890 --> 00:01:42,020 ‫So from our little storage, we can store minor data. 33 00:01:42,850 --> 00:01:45,330 ‫A good point would be when we increase the score. 34 00:01:45,340 --> 00:01:50,140 ‫So in here we should check if the current score is higher than the high score. 35 00:01:50,140 --> 00:01:53,200 ‫And if that's the case, please go ahead and set the score. 36 00:01:53,710 --> 00:01:55,270 ‫So how do we do that? 37 00:01:55,480 --> 00:01:58,080 ‫We can simply check here. 38 00:01:58,090 --> 00:02:02,950 ‫Score higher, then get high score. 39 00:02:05,650 --> 00:02:06,970 ‫And if that's the case. 40 00:02:09,700 --> 00:02:13,840 ‫You just play a press that set it. 41 00:02:15,430 --> 00:02:21,250 ‫And here we need two values a string, which is the key and the value that we want to set there. 42 00:02:21,250 --> 00:02:26,770 ‫So the key is high score and the value that we want to set is score. 43 00:02:26,800 --> 00:02:28,840 ‫So we simply set the score here. 44 00:02:29,080 --> 00:02:37,090 ‫Well, that's not enough, because we also need to assign the high score text text property with our 45 00:02:37,090 --> 00:02:37,960 ‫new value. 46 00:02:37,960 --> 00:02:40,270 ‫So score to string. 47 00:02:41,380 --> 00:02:45,310 ‫And now that we have that, we can go ahead and get the high score on a wake. 48 00:02:45,340 --> 00:02:55,240 ‫So let's get the high score text to text and set it to best colon. 49 00:02:55,750 --> 00:03:00,220 ‫Plus get high score to string. 50 00:03:03,060 --> 00:03:03,720 ‫All right. 51 00:03:03,720 --> 00:03:05,190 ‫So let's check that out. 52 00:03:06,060 --> 00:03:08,070 ‫Let's go back to save the script. 53 00:03:08,460 --> 00:03:11,310 ‫Save the scene, by the way, and run the code. 54 00:03:11,940 --> 00:03:13,440 ‫So let's get some points. 55 00:03:14,190 --> 00:03:14,970 ‫Enter. 56 00:03:15,770 --> 00:03:20,450 ‫Actually I have a null point of reference, of course, as the game manager doesn't know the high score 57 00:03:20,450 --> 00:03:22,970 ‫text yet, so let's grab that in there. 58 00:03:23,420 --> 00:03:26,240 ‫Now we can go ahead and run the game again. 59 00:03:26,360 --> 00:03:27,710 ‫So now let's see. 60 00:03:28,280 --> 00:03:29,870 ‫The score is not perfectly. 61 00:03:29,870 --> 00:03:32,150 ‫The high score is not set at the perfect position. 62 00:03:32,150 --> 00:03:34,640 ‫So maybe let's change that. 63 00:03:34,640 --> 00:03:40,940 ‫Let's move it down to -150 or maybe 120. 64 00:03:40,940 --> 00:03:43,160 ‫Yeah, -120 should be fine. 65 00:03:43,280 --> 00:03:45,440 ‫And maybe let's scale it down a notch. 66 00:03:45,440 --> 00:03:49,160 ‫So let's go to, I don't know, maybe 70. 67 00:03:49,460 --> 00:03:50,720 ‫I think that should be good. 68 00:03:51,290 --> 00:03:52,580 ‫Now, let's try it again. 69 00:03:55,510 --> 00:03:57,400 ‫That we are best zero. 70 00:03:57,430 --> 00:03:59,200 ‫Now let's press enter. 71 00:03:59,500 --> 00:04:05,940 ‫And now, as you can see, the two was stored and now our best score is two. 72 00:04:06,040 --> 00:04:06,970 ‫Let's run it again. 73 00:04:06,970 --> 00:04:08,620 ‫Let's try to get three points. 74 00:04:08,710 --> 00:04:09,400 ‫There we are. 75 00:04:09,580 --> 00:04:12,130 ‫Our best score is three. 76 00:04:13,630 --> 00:04:16,840 ‫Now, you might say, okay, best three is set up there. 77 00:04:16,870 --> 00:04:20,800 ‫Now, maybe we should set it up in our method as well. 78 00:04:21,450 --> 00:04:22,260 ‫So. 79 00:04:22,920 --> 00:04:23,850 ‫Let's go there. 80 00:04:25,330 --> 00:04:27,160 ‫Because here we just say. 81 00:04:28,520 --> 00:04:29,230 ‫Set. 82 00:04:29,540 --> 00:04:31,250 ‫Score to string. 83 00:04:31,290 --> 00:04:41,570 ‫But what we should do here is maybe best colon, empty space plus score to string. 84 00:04:41,690 --> 00:04:46,070 ‫Now the best colon will be set up and shown all the time. 85 00:04:46,070 --> 00:04:49,430 ‫So if we get points, we should still see it. 86 00:04:50,690 --> 00:04:51,350 ‫All right. 87 00:04:52,190 --> 00:04:58,190 ‫Well, unfortunately, we can't get more points now because we don't have more crystals on the game, 88 00:04:58,190 --> 00:04:59,990 ‫but we will fix that later on. 89 00:05:00,320 --> 00:05:00,680 ‫Great. 90 00:05:00,680 --> 00:05:02,330 ‫So I hope you manage to do that. 91 00:05:02,330 --> 00:05:07,180 ‫And in the next video, we are going to add a crystal effect. 92 00:05:07,190 --> 00:05:08,180 ‫So see you there.