I followed this tutorial recently and now I have a really nice slot game with 3 different reels and a bunch of other cool stuff! Thankyou for this, very helpful!
You can do the long if/else structure better by just using a loop. Count the amount of times "Seven" or "Cherry", etc. appears. If it appears 2 times it means you won, if it appears 3 times it means you won even harder. Then after that, multiple the points with whatever value it was. For example x2 is it is Bar, or x3 if it is Cherry.
Thanks for the tutorial Alexander! I simplified the group of if else statements in CheckResults a little by checking for 3 in a row first. The doing a switch statement. if (row1Result == row2Result && row2Result == row3Result)
Nice tutorial. I will use this in my next game to give reward to player. One more thing. After every tutorial content quality is increasing.👍👍👍. Nice work. 👍👍👍
Nice tutorial! It works almost perfectly. The only problem I have is that when I build the game, I can’t see the prize text anymore. In the editor, though, it works fine.
Followed your example ... thanks ... In order to get around the code for the results, I just made an "integer" array to store if the locations matched. If it did it would increment the value in the "integer" array. I also have another array of the "Names" of all the possible results. Since both arrays are the same in length .... I can compare the value in one array to the next. So if "Apples" are the first item in the "Name" array ... and the first item in the "integer" array is a two... then i got two "Apples"
sir can you tell me i use interstitial ad in app that is not publish in play Store and the revenue that is generated from this app is legal or ad mob allow this because i have no developer account i made game and i publish my game in different social media and in my page that is made for my game it is legal or not. Because i am a student and i have not enough money to buy a developer account please tell me i its legal then i make more games otherwise i can not wast my time
Great video! I am wondering how can I add a scoring system that adds and subtracts the prize numbers. Is there a simple fix for that? I wonder if you have a tutorial on that maybe
Hey! I've been watching your tutorials for a while and i think they're pretty great! I have a tutorial idea for you. Could you do a button that unzooms when you click on it and when you unclick, it rezooms at normal zoom. Thanks!
Brother is it possible to change the button sprite on runtime in unity i am making a shop section and for this i need my player to change into certain shapes so can you help me
Well in the end, when i drag n drop the script into the GameControl , it doesn't show me the prize text and the elements where i should put the rows. Any idea why is this happening?
11:48, here's an idea I have Create an array of the string representation of each of the possible values. Also create 2 dictionaries. 1 dictionary to pair up each string with its 3 symbol value, and another for it's 4 string value. In the check results method, we iterate over the array of strings, first checking if all 3 equal that symbol, then if at least 2 equal that symbol. Obviously, we would want to put a break statement if either of these scenarios is true for a particular symbol. Then if the 3 symbol possibility is true, we access the 3 symbol dictionary to get the correct value, and set prizeValue to that value. Access the 2 symbol dictionary if that situation is correct. As a general rule, we want to stay DRY when writing code.
Also, you probably would want to create an enum for the different symbols, and set values based on that enum, rather than doing a string representation. You can easily create an array of these from the enum type.
Sir please answer I put the code correctly but I got the 155 errors Rows does not contain a definition for stoppedSloat and no accessible extension method stopped Sloat accepting a Frist argument of type rows
So the row switch stantment can be replaced with random += (3 - (random % 3)); my scale was bigger, so instead of having lots of switches. I used random += (7 - (random % 7)); it makes the spin last for one extra spin if the number is base 7 though.
for results check method, I have implemented following code ; private void CheckResults() { //if number1 row equals to both number 2 and number 3 it means 2 and 3 also equals meaning we dont need to check them seperately if (rows[0].stoppedSlot.Equals(rows[1].stoppedSlot) && rows[0].stoppedSlot.Equals(rows[2].stoppedSlot) ) { switch (rows[0].stoppedSlot) { case "WaterMelon": prizeValue = 300; break; case "Cherry": prizeValue = 200; break; default: break; } } resultsChecked = true; }
Hey ive been struggling with this one. I myself and my partner have both looked through the code and it looks identical to what youve shown but nothing is working. is there any way i can get in contact with you and maybe send you over my code so you could take a peak at it and let me know where i went wrong?
For the long if/else mess, I used a switch on the middle slot, an enum ordered by most expensive to cheapest (highest prize to lowest), and a secondary function that just checks rows[0] for a match, rows[2] for a match (and both again for 'extra reward' on a triple match), then returns matchCount * enumValue * 100; where matchCount is the checks above and enumValue is just the (int)enumParameter. The returned value is shoved into prizeValue. Note however then the prize values will be the result of a function and not hardcoded, but you can make it hardcoded with set values by altering the secondary function, even making a tertiary function for reward values, which would separate match searching and reward output, two separate tasks in checking results anyways. More maintainable code. One could also define the values in the enums to be something binary-esque (not actually binary, ternary maybe, because you want unique values for all combinations of the following calculation and there's 3 possible values of matchCount) and calculate matchCount*enumValue then search for that value in some lookup table instead.
Why it says that: "error CS0246: The type or namespace name 'Row' could not be found (are you missing a using directive or an assembly reference?)", I made it exactly like you.
Would you be willing to help me figure out my coding for my payout system, using Android Studio? If not, it's totally ok. I know it's annoying work, but I'm so lost, I figured it doesn't hurt to ask.
Hello Alexander! Thank you for your tutorial. in Row.cs script the interval between each "slot" is 0.75, they move each y-0.25 (please refer to the Rotate() method), but how do you get them to stop exactly on the right place so the interval remains 0.75? For example they stop at: y=-3.5, y= -2.75, .... y= 0.25. y= 1..., if the slot moves by steps of 0.25, how come the slot doesn't stop at for example, y= 1.25, or y=-1.50?? Please explain further :)
@M i have code but i don't want to make a game for you Because i have 1 ideea of game And I make from him more than 50.000 euro 100% Only 3-4script I make And I have a very good market strategy ✌
print("1st: " + rows[0].stoppedSlot.ToString()); print("2st: " + rows[0].stoppedSlot.ToString()); print("3st: " + rows[0].stoppedSlot.ToString()); print("4st: " + rows[0].stoppedSlot.ToString()); print("5st: " + rows[0].stoppedSlot.ToString()); when i print it it just print 1st 2nd .. not the value in rows[0].stoppedSlot
Pretty cool, but could you include the script with the graphic assets? I downloaded the graphics but I really don't want to try typing your script in from the video.
Привет! Спасибо за туториал, но возникла маленькая проблемка. Не срабатывает OnMouseDown. Всё делал в точности с уроком, повторял каждое действие, коллайдер стоит на геймобж, стоит галочка, что это триггер, но бесполезно, сколько ни тыкай. Помогите)
Мужик, ну ты же понимаешь, что тут чистый хардкод? Если ты захочешь разширять игру, то нужно будет ещё больше хардкодить. Но есть один плюс - это единственный туториал
@@AlexanderZotov Collider is set as you describe in video but not work. Even inside function of OnMouseDown is working ok when I use inputkey function.
for the huge if statement : Dictionary duplicates = new Dictionary(); for (int i =0; i < rows.Length; ++1) { string slotValue = rows[i].stoppedSlot; if ( duplicates.ContainsKey(slotValue)) duplicates[slotVallue]++; else duplicates[slotValue] = 1; } foreach(KeyValuePair duplicate in duplicates) { AwardPrizeForSlotsOf(duplicate.Key, duplicate.Value); } private void AwardPrizeFor3SlotsOf(string slotValue, int duplicateCount) { switch(slotValue) { case "Diamond": if (duplicateCount == 3) prizeValue = 200; else if (duplicateCount == 2) prizeValue = 100; break; [...] } } For multiple of 3 : Random.Range(20, 34) * 3; you'll have the same result, but without the need for a swich over %3.
@@AlexanderZotov не посланник, но в последнее время зачастил его смотреть, ахах Теперь не могу смотреть ролики, где вот такой страшненький код, аж передёргивает Хотя, честно говоря, такой эффект у меня был ещё до знакомства с каналом Сакутина (даже от собственного кода) Перфекционизм течёт в наших венах, так сказать
@@AlexanderZotov идеальный код - миф, но говнокод - вполне себе реальность. Нахрена делать двадцать ифов, если можно управиться с ОДНИМ??? К непостижимому идеалу нужно хотя бы стремиться
@@MelonKR4 Мне больше непонятна патологическая неприязнь к if у многих "крутых" программистов. Надо просто дышать глубже в случае такого приступа - помогает.
it's a good tutorial thx but here private void Update () { if (!rows[0].rowStopped || !rows[1].rowStopped || !rows[2].rowStopped) { prizeValue = 0; prizeText.enabled = false; resultsChecked = false; } Update have an error "Update can't be call for trame if MonoBehaviour is active" 2 days i search the problem '-.-,
I followed this tutorial recently and now I have a really nice slot game with 3 different reels and a bunch of other cool stuff! Thankyou for this, very helpful!
Happy to help
You can do the long if/else structure better by just using a loop.
Count the amount of times "Seven" or "Cherry", etc. appears.
If it appears 2 times it means you won, if it appears 3 times it means you won even harder.
Then after that, multiple the points with whatever value it was. For example x2 is it is Bar, or x3 if it is Cherry.
Cool! Thanks for your suggestion!
Donny Estee Can you help me pls pls 🙏🙏🙏🙏
Thanks for the tutorial Alexander! I simplified the group of if else statements in CheckResults a little by checking for 3 in a row first. The doing a switch statement.
if (row1Result == row2Result && row2Result == row3Result)
Great idea! Thanks for sharing!
Great and amazing job mate, i have done step by step and it worked, keep up the great work and i wish you a great new year and happy holidays :D
Thanks!
Nice tutorial. I will use this in my next game to give reward to player. One more thing. After every tutorial content quality is increasing.👍👍👍. Nice work. 👍👍👍
Thank you very much!
Very awesome tutorial and breakdown Alex!! :) I'll try to optimize the prize check (any 2 and 3 of a kind) code, and this is a nice little challenge
Thanks ;-) There are a couple of suggestions about code optimizing already in the comments by the way.
I realize I'm kinda randomly asking but does anybody know a good website to stream new series online ?
@Rodrigo Luka I dunno I watch on flixportal. You can find it thru google :P -chaim
@Chaim Clark thank you, signed up and it seems to work =) I really appreciate it !
@Rodrigo Luka You are welcome xD
The higher this value is ... The smaller game object appears...
SUCH A POEM
Nice tutorial! It works almost perfectly. The only problem I have is that when I build the game, I can’t see the prize text anymore. In the editor, though, it works fine.
Thank you So much for this tutorial needed it so much bro!!
You are great among other Unity developers. I learnt lots of by your way. thank you
Thank you very much for your feedback!
@@AlexanderZotov its honor for me
;-)
Followed your example ... thanks ... In order to get around the code for the results, I just made an "integer" array to store if the locations matched.
If it did it would increment the value in the "integer" array. I also have another array of the "Names" of all the possible results.
Since both arrays are the same in length .... I can compare the value in one array to the next.
So if "Apples" are the first item in the "Name" array ... and the first item in the "integer" array is a two... then i got two "Apples"
Great! Thanks for your feedback!
thank you , easy to understand and follow , you got a new follow !
Lovely! As always great content
Thank you, I've been looking for a slot machine game
You are welcome! Share it! Let everyone know that there is a tutorial about it now ;-)
@@AlexanderZotov I will do
Thanks!
Great! Very informative!
Thanks a lot!
Alexander thank you very much. Just the video i need.
**Well done Alexander 👍**
Thank you!
@@AlexanderZotov You are welcome my friend!
really love it bro , thanks :*
You are welcome ;-)
My [SerializeField] private Row[ ] rows; comes with a namespacing error, but I followed the script to the letter.
you help me a lot for learning unity thanks
You are welcome! Thanks for watching :-)
sir can you tell me i use interstitial ad in app that is not publish in play Store and the revenue that is generated from this app is legal or ad mob allow this because i have no developer account i made game and i publish my game in different social media and in my page that is made for my game it is legal or not. Because i am a student and i have not enough money to buy a developer account please tell me i its legal then i make more games otherwise i can not wast my time
Great video! I am wondering how can I add a scoring system that adds and subtracts the prize numbers. Is there a simple fix for that? I wonder if you have a tutorial on that maybe
Do you have the full script available to share for learning only. Thanks
Amazing work,as ever.
Thank you!
Great video!!
Thank you!
How do you connect wallet to this. Pay in and pay out ?
Great video !
Thank you!
where is the code so that I dont have to type everything? maybe i missed it but i did not find it anywhere in the description of the video.
please someone give me project files ive tried everything but the row never go to theri place they are always diferent
Okay so I have a slot with numbers from 1 to 10 and I want to spin it with the button pressed. How to do that?
Hey! I've been watching your tutorials for a while and i think they're pretty great! I have a tutorial idea for you. Could you do a button that unzooms when you click on it and when you unclick, it rezooms at normal zoom. Thanks!
Thank you! I'll think about it.
@@AlexanderZotov 😁
@@AlexanderZotov I just wanna know... did you think about it? :D
@@AlexanderZotov did u think about it?
I have different positions for transform.position.y in unity and mobile device. How to fix it?
i press the handle and it does its thing but the rows dont rotate... just the handle moves. did everthing you said ... ?
It the same system for making a '' open case '' or '' mystery box of skins'' in a FPS Game ?
can someone help me my row does not stop spinning and in Row.cs the lines from 41 to 90 are marked as "unreachable code detected".
Brother is it possible to change the button sprite on runtime in unity i am making a shop section and for this i need my player to change into certain shapes so can you help me
Well in the end, when i drag n drop the script into the GameControl , it doesn't show me the prize text and the elements where i should put the rows. Any idea why is this happening?
Действительно хороший туториал! Так как на всем Ютубе нет ничего подобного! Спасибо!)
Спасибо! Да, со слот машинами напряженка.
11:48, here's an idea I have
Create an array of the string representation of each of the possible values. Also create 2 dictionaries. 1 dictionary to pair up each string with its 3 symbol value, and another for it's 4 string value. In the check results method, we iterate over the array of strings, first checking if all 3 equal that symbol, then if at least 2 equal that symbol. Obviously, we would want to put a break statement if either of these scenarios is true for a particular symbol. Then if the 3 symbol possibility is true, we access the 3 symbol dictionary to get the correct value, and set prizeValue to that value. Access the 2 symbol dictionary if that situation is correct. As a general rule, we want to stay DRY when writing code.
Also, you probably would want to create an enum for the different symbols, and set values based on that enum, rather than doing a string representation. You can easily create an array of these from the enum type.
hi I want to know why Random.Range is (60,100) ? if I wanna change how can I change the Range?
After making my android game, in my phone says like "error unable to initialize unity engine" please help me!!!!😣😣😣😣😣
you are GOD? your work is amazing! thanks, in my game you have one place on the credits bleive me!! :D
Of course I am ;-) Can't wait to see your game! Thank you!
Sir please answer I put the code correctly but I got the 155 errors
Rows does not contain a definition for stoppedSloat and no accessible extension method stopped Sloat accepting a Frist argument of type rows
Fantastic!!!
Thank you
Hi, Thanks for creating the video. May i know which part of the code control the spinning animation?
So the row switch stantment can be replaced with
random += (3 - (random % 3));
my scale was bigger, so instead of having lots of switches. I used
random += (7 - (random % 7));
it makes the spin last for one extra spin if the number is base 7 though.
i need help if you provide your slot machine project
Hey, Switch Statment in my project is not working can you help?
for results check method, I have implemented following code ;
private void CheckResults()
{
//if number1 row equals to both number 2 and number 3 it means 2 and 3 also equals meaning we dont need to check them seperately
if (rows[0].stoppedSlot.Equals(rows[1].stoppedSlot) && rows[0].stoppedSlot.Equals(rows[2].stoppedSlot) )
{
switch (rows[0].stoppedSlot)
{
case "WaterMelon":
prizeValue = 300;
break;
case "Cherry":
prizeValue = 200;
break;
default:
break;
}
}
resultsChecked = true;
}
Hello friend, great work! Inquiry, is it normal that I only let you pull the handle once?
please give me the full project link sir only for learning please
отличный урок, побольше бы таких.
Спасибо! Я над ним работал неделю ;-) Хотелось бы побольше таких, но очень утомительно :-)
@@AlexanderZotov Ну, главное качество, а не количество.
Сложный вопрос ;-) Качественное количество :-)
Hi, could you share the complete unity project?
perfect video .how to add sound when the handle pull up?
I have several videos about sounds.
@@AlexanderZotov I understand your teaching.. thanks a lot
Good video.
Thank you!
@@AlexanderZotov can you create a cupom of your course in udemy for i POST in my group?
Sure, why not
Hi, how did you create a tutorial for how to play the game we developed? (unity)
I can see the future ;-)
@@AlexanderZotov So funny 😜👍
Hey ive been struggling with this one. I myself and my partner have both looked through the code and it looks identical to what youve shown but nothing is working. is there any way i can get in contact with you and maybe send you over my code so you could take a peak at it and let me know where i went wrong?
Hi! What exactly doesn't work?
@@AlexanderZotov currently nothing works the handle doesnt rotate and the reels dont start spinning
It's hard to say just like that what is wrong. The best way to figure it out is to take a look at the whole project.
@@taeworldcj6998 Same for me
same. nothing works at all
For the long if/else mess, I used a switch on the middle slot, an enum ordered by most expensive to cheapest (highest prize to lowest), and a secondary function that just checks rows[0] for a match, rows[2] for a match (and both again for 'extra reward' on a triple match), then returns matchCount * enumValue * 100; where matchCount is the checks above and enumValue is just the (int)enumParameter. The returned value is shoved into prizeValue.
Note however then the prize values will be the result of a function and not hardcoded, but you can make it hardcoded with set values by altering the secondary function, even making a tertiary function for reward values, which would separate match searching and reward output, two separate tasks in checking results anyways. More maintainable code.
One could also define the values in the enums to be something binary-esque (not actually binary, ternary maybe, because you want unique values for all combinations of the following calculation and there's 3 possible values of matchCount) and calculate matchCount*enumValue then search for that value in some lookup table instead.
Thank you very much!
Can you be more specific in this case please, for all the newbies
Why it says that: "error CS0246: The type or namespace name 'Row' could not be found (are you missing a using directive or an assembly reference?)", I made it exactly like you.
Row is another class and same classes need to have the same namespace if u have a namespace already
@@iulianlordpyro490 If I put a link to the code can you help me? I'm new to programming.
tnks good game, you speak game bingo ? and generation cards ?
Awesome :)
Thank you!
nice video! Would you mind to make a tutorial for 3x5 slot game please? I would like to pay for that👍
you can do that if the button is pressed the machine the band of the machine stops
You are amazing
Thank you very much!
Would you help me with some smooth rotation? seems so robotically... How I can create a smooth rotation?
It won't work with me.
can you help me?
@@Mario-xl6ii need more details
Iulian LordPyro Can you Send me a dm ok Discord ? My id
VyocsHD#9470
thx thx thx
How about to teach on joints?? Hinge and all other? One video per joints with practical.??
Would you be willing to help me figure out my coding for my payout system, using Android Studio? If not, it's totally ok. I know it's annoying work, but I'm so lost, I figured it doesn't hurt to ask.
Hello Alexander! Thank you for your tutorial. in Row.cs script the interval between each "slot" is 0.75, they move each y-0.25 (please refer to the Rotate() method), but how do you get them to stop exactly on the right place so the interval remains 0.75? For example they stop at: y=-3.5, y= -2.75, .... y= 0.25. y= 1..., if the slot moves by steps of 0.25, how come the slot doesn't stop at for example, y= 1.25, or y=-1.50?? Please explain further :)
14:25
@@gamesdisk Thanks!
I can use you rows icons for my game??
That are not mine. I got it from vecteezy dot com.
@@AlexanderZotov ok thanks✌
@M my?
@M yes is easy if you have time
@M i have code but i don't want to make a game for you
Because i have 1 ideea of game
And I make from him more than 50.000 euro 100%
Only 3-4script I make
And I have a very good market strategy ✌
nice bro
Thank you!
thanks a lot
You are welcome!
thank you
Can we use your Slot Machine Art in our games ?
Hi, anyone knows how much (costs) to develop a mobile games apps?
From zero to eternity.
The type or namespace name Row could not be found
please make a video on paint simple sprite with brush coloring
every thing is working fine but getting stoppedSlot string empty every time .
Maybe some variable misspelled or something like that.
@@AlexanderZotov if (transform.position.y == -27.8f)
{
stoppedSlot = "10CLOVER";
print("10CLOVER");
}
else if (transform.position.y == -25.06f)
{
stoppedSlot = "10DIAMOND";
print("%10DIAMOND");
}
else if (transform.position.y == -22.32f)
{
stoppedSlot = "10HEART";
print("%10HEART");
}
else if (transform.position.y == -19.58f)
{
stoppedSlot = "10SPADES"; print("%10SPADES");
}
print("1st: " + rows[0].stoppedSlot.ToString());
print("2st: " + rows[0].stoppedSlot.ToString());
print("3st: " + rows[0].stoppedSlot.ToString());
print("4st: " + rows[0].stoppedSlot.ToString());
print("5st: " + rows[0].stoppedSlot.ToString());
when i print it it just print 1st 2nd .. not the value in rows[0].stoppedSlot
@@AlexanderZotov every time i just receive for one row not for all
Pretty cool, but could you include the script with the graphic assets? I downloaded the graphics but I really don't want to try typing your script in from the video.
How can I make it in 3D
Привет! Спасибо за туториал, но возникла маленькая проблемка. Не срабатывает OnMouseDown. Всё делал в точности с уроком, повторял каждое действие, коллайдер стоит на геймобж, стоит галочка, что это триггер, но бесполезно, сколько ни тыкай. Помогите)
Может быть триггер срабатывает, а дело совсем в другом.
А может быть опечатка в названии метода.
can u link the scripts please
Can you do a connect 4 game and rock paper scissors..Please 😜👀😆✨👍😂🎊🎂
I can draw graphic designs but I can't make program 👁💧👄💧👁
Класс!
Спасибо!
Viral Kukadiya
1 second ago
hello i have follow your video but i am not seen pool row so please how to make pool row1,row2,and row3
7:34 удивился, что на русском написано "файл, правка, вид"
Мужик, ну ты же понимаешь, что тут чистый хардкод?
Если ты захочешь разширять игру, то нужно будет ещё больше хардкодить.
Но есть один плюс - это единственный туториал
Это не хардкор :-) это хардбас
И стартовая площадка
Никто ж не мешает переосмыслить, улучшить. Согласись-ка? ;-)
И да, я вас богом Юнити молю, не включайте тут Сакутина ;-)
@@AlexanderZotov Конечно, но я говорю как есть. Если делать что бы "работало", то без вопросов, а так это пример того как игры делать не желательно
Can you give us the 2 codes? Pls
How did that go?
@@kylebedell3731 yeah i cant drag the row script and having 2 rotates causing errors
11:00 Dude, you did not..
Hi "OnMouseDown" not working
Maybe you forgot to add a collider?
@@AlexanderZotov Hi
Thanks for reply. I have added Box collider 2d in “GameControl” object.
So, doesn't it still work?
@@AlexanderZotov Collider is set as you describe in video but not work. Even inside function of OnMouseDown is working ok when I use inputkey function.
Then a mistake is somewhere else I guess.
How you download this and how to add in Unity...bdw tnx for video!
Hope this one can help you ua-cam.com/video/2ZGFYMnQXf8/v-deo.html
Make a roulette game buddy
for the huge if statement :
Dictionary duplicates = new Dictionary();
for (int i =0; i < rows.Length; ++1)
{
string slotValue = rows[i].stoppedSlot;
if ( duplicates.ContainsKey(slotValue))
duplicates[slotVallue]++;
else
duplicates[slotValue] = 1;
}
foreach(KeyValuePair duplicate in duplicates)
{
AwardPrizeForSlotsOf(duplicate.Key, duplicate.Value);
}
private void AwardPrizeFor3SlotsOf(string slotValue, int duplicateCount)
{
switch(slotValue)
{
case "Diamond":
if (duplicateCount == 3)
prizeValue = 200;
else if (duplicateCount == 2)
prizeValue = 100;
break;
[...]
}
}
For multiple of 3 :
Random.Range(20, 34) * 3;
you'll have the same result, but without the need for a swich over %3.
tutorial super qix game please
Thanks!
'Row.rowStopped' is inaccessible due to its protection level
please solve this error please
Smae error with stoppedSloat
What is wrong?
private int randomValue;
private float timeInter;
public bool RowStopped;
public string StoppedSlot;
void Start()
{
RowStopped = true;
GameCon.HandlePulled += StartRot;
}
void StartRot()
{
StoppedSlot = "";
StartCoroutine("Rotate");
}
private IEnumerator Rotatee()
{
RowStopped = false;
timeInter = 0.025f;
for (int i = 0; i < 30; i++)
{
if (transform.position.y Mathf.RoundToInt(randomValue * 0.5f))
timeInter = 0.1f;
if (i > Mathf.RoundToInt(randomValue * 0.75f))
timeInter = 0.15f;
if (i > Mathf.RoundToInt(randomValue * 0.95f))
timeInter = 0.2f;
yield return new WaitForSeconds(timeInter);
}
if (transform.position.y == -3.5f)
StoppedSlot = "Diamond";
else if(transform.position.y == -2.75f)
StoppedSlot = "Crwon";
else if (transform.position.y == -2f)
StoppedSlot = "Melon";
else if (transform.position.y == -1.25f)
StoppedSlot = "Bar";
else if (transform.position.y == -0.5f)
StoppedSlot = "Seven";
else if (transform.position.y == -0.25)
StoppedSlot = "Cherry";
else if (transform.position.y == -1f)
StoppedSlot = "Lemon";
else if (transform.position.y == -1.75f)
StoppedSlot = "Diamond";
RowStopped = true;
}
private void OnDestroy()
{
GameCon.HandlePulled -= StartRot;
}
}
///////////////////////
public class GameCon : MonoBehaviour
{
public static event Action HandlePulled = delegate { };
[SerializeField]
public Text prize;
[SerializeField]
public Row[] rows;
[SerializeField]
public Transform handle;
public int Prize;
public bool resultChecked = false;
private void Update()
{
if(!rows[0].RowStopped || !rows[1].RowStopped || !rows[2].RowStopped)
{
Prize = 0;
prize.enabled = false;
resultChecked = false;
}
if(rows[0].RowStopped && rows[1].RowStopped && rows[2].RowStopped && !resultChecked)
{
CheckResults();
prize.enabled = true;
prize.text = "Prize: " + Prize;
}
}
void OnMousClick()
{
if (rows[0].RowStopped && rows[1].RowStopped && rows[2].RowStopped)
StartCoroutine("Pull");
}
private IEnumerator Pull()
{
for (int i = 0; i < 15; i += 5)
{
handle.Rotate(0f, 0f, i);
yield return new WaitForSeconds(0.1f);
}
HandlePulled();
for (int i = 0; i < 15; i += 5)
{
yield return new WaitForSeconds(0.1f);
}
}
private void CheckResults()
{
if (rows[0].StoppedSlot == "Diamond"
&& rows[1].StoppedSlot == "Diamond"
&& rows[2].StoppedSlot == "Diamond")
Prize = 200;
else if (rows[0].StoppedSlot == "Crown"
&& rows[1].StoppedSlot == "Crown"
&& rows[2].StoppedSlot == "Crown")
Prize = 400;
else if (rows[0].StoppedSlot == "Melon"
&& rows[1].StoppedSlot == "Melon"
&& rows[2].StoppedSlot == "Melon")
Prize = 400;
else if (rows[0].StoppedSlot == "Bar"
&& rows[1].StoppedSlot == "Bar"
&& rows[2].StoppedSlot == "Bar")
Prize = 400;
else if (rows[0].StoppedSlot == "Seven"
&& rows[1].StoppedSlot == "Seven"
&& rows[2].StoppedSlot == "Seven")
Prize = 400;
else if (rows[0].StoppedSlot == "Cherry"
&& rows[1].StoppedSlot == "Cherry"
&& rows[2].StoppedSlot == "Cherry")
Prize = 400;
else if (rows[0].StoppedSlot == "Lemon"
&& rows[1].StoppedSlot == "Lemon"
&& rows[2].StoppedSlot == "Lemon")
Prize = 400;
else if (((rows[0].StoppedSlot == rows[1].StoppedSlot)
&& (rows[0].StoppedSlot == "Diamond"))
|| ((rows[0].StoppedSlot == rows[2].StoppedSlot)
&& (rows[0].StoppedSlot == "Diamond"))
|| ((rows[1].StoppedSlot == rows[2].StoppedSlot)
&& (rows[1].StoppedSlot == "Diamond")))
Prize = 300;
else if (((rows[0].StoppedSlot == rows[1].StoppedSlot)
&& (rows[0].StoppedSlot == "Crown"))
|| ((rows[0].StoppedSlot == rows[2].StoppedSlot)
&& (rows[0].StoppedSlot == "Crown"))
|| ((rows[1].StoppedSlot == rows[2].StoppedSlot)
&& (rows[1].StoppedSlot == "Crown")))
Prize = 300;
else if (((rows[0].StoppedSlot == rows[1].StoppedSlot)
&& (rows[0].StoppedSlot == "Melon"))
|| ((rows[0].StoppedSlot == rows[2].StoppedSlot)
&& (rows[0].StoppedSlot == "Melon"))
|| ((rows[1].StoppedSlot == rows[2].StoppedSlot)
&& (rows[1].StoppedSlot == "Melon")))
Prize = 300;
else if (((rows[0].StoppedSlot == rows[1].StoppedSlot)
&& (rows[0].StoppedSlot == "Bar"))
|| ((rows[0].StoppedSlot == rows[2].StoppedSlot)
&& (rows[0].StoppedSlot == "Bar"))
|| ((rows[1].StoppedSlot == rows[2].StoppedSlot)
&& (rows[1].StoppedSlot == "Bar")))
Prize = 300;
else if (((rows[0].StoppedSlot == rows[1].StoppedSlot)
&& (rows[0].StoppedSlot == "Seven"))
|| ((rows[0].StoppedSlot == rows[2].StoppedSlot)
&& (rows[0].StoppedSlot == "Seven"))
|| ((rows[1].StoppedSlot == rows[2].StoppedSlot)
&& (rows[1].StoppedSlot == "Seven")))
Prize = 300;
else if (((rows[0].StoppedSlot == rows[1].StoppedSlot)
&& (rows[0].StoppedSlot == "Cherry"))
|| ((rows[0].StoppedSlot == rows[2].StoppedSlot)
&& (rows[0].StoppedSlot == "Cherry"))
|| ((rows[1].StoppedSlot == rows[2].StoppedSlot)
&& (rows[1].StoppedSlot == "Cherry")))
Prize = 300;
else if (((rows[0].StoppedSlot == rows[1].StoppedSlot)
&& (rows[0].StoppedSlot == "Lemon"))
|| ((rows[0].StoppedSlot == rows[2].StoppedSlot)
&& (rows[0].StoppedSlot == "Lemon"))
|| ((rows[1].StoppedSlot == rows[2].StoppedSlot)
&& (rows[1].StoppedSlot == "Lemon")))
Prize = 300;
resultChecked = true;
}
}
handle[i].Rotate(0f, 0f, i);
you can provide source code ..
Код, конечно, адское говно, но урок, наверное, полезен для новичков
Ты чё, посланник Сакутина?
@@AlexanderZotov не посланник, но в последнее время зачастил его смотреть, ахах
Теперь не могу смотреть ролики, где вот такой страшненький код, аж передёргивает
Хотя, честно говоря, такой эффект у меня был ещё до знакомства с каналом Сакутина (даже от собственного кода)
Перфекционизм течёт в наших венах, так сказать
Идеальный код - это миф.
@@AlexanderZotov идеальный код - миф, но говнокод - вполне себе реальность. Нахрена делать двадцать ифов, если можно управиться с ОДНИМ??? К непостижимому идеалу нужно хотя бы стремиться
@@MelonKR4 Мне больше непонятна патологическая неприязнь к if у многих "крутых" программистов. Надо просто дышать глубже в случае такого приступа - помогает.
Can anyone sent the scripts in the comments
nicwe
Thanks!
it's a good tutorial thx but here
private void Update ()
{
if (!rows[0].rowStopped || !rows[1].rowStopped || !rows[2].rowStopped)
{
prizeValue = 0;
prizeText.enabled = false;
resultsChecked = false;
}
Update have an error "Update can't be call for trame if MonoBehaviour is active"
2 days i search the problem '-.-,
I want to play that machine
Just do it :-)
@@AlexanderZotov how do I get it ? 😄
@@AlexanderZotov can you make a tutorial video how to make slot machine 3×5 with bet and credit