Search Unity

Fruit Machine, concept fleshing out/ideas help required

Discussion in 'Scripting' started by San_Holo, Oct 29, 2014.

  1. San_Holo

    San_Holo

    Joined:
    Sep 26, 2014
    Posts:
    152
    Hi,

    I'm using Unity to develop my very first 2D style shump-shooter and at the end of every boss-level your presented with an interim screen which is like a fruit machine, reels spin, awards are given for lines and there'll be hidden bonuses etc before you move on to the next level, I'm not too sure how to present to the player the fruit machine but I can come to that later once I've set it up, now I'm new to Unity but not to games and coding and I'm slowly picking things up via tutorials etc so please bear with me.

    OK so simple concept, fruit-machine level/interim screen akin to the 777's found in Daytona-USA arcade game or at the end of the C64 game Uridium, a simple chance element for the next round offering bonuses like lives or power-ups or what-ever and then your off... so to do this I know it'll be mostly script driven but what about the reels? 3D perhaps? with textures, I suppose through scripting I could control the rotation transform of a reel say and...hmmm anyway, below is a code snippet I made for another game which used so called 'chat-commands' and it was for a first person shooter game, multiplayer but we hacked and modded the internal back-end so to speak and thought up all kinds of weird and wonderful ideas & enhancements which really gave an extra sweet customization to our 'clan' as it were, anyway below is the code for !spin a simple fruit machine, written in Lua, it worked, became quite popular, so I thought I'd imagine it again in a 2D shooter, just for fun, code below:
    Code (csharp):
    1.  
    2.   --===================================================================================
    3.   -- SPIN
    4.    
    5.   AddChatCommand("spin", {info="play the fruit machine"}, function (player)
    6.   if (player.lastspin and ((_time - player.lastspin) <=60)) then
    7.   return false, "sorry fruit machine overheated";
    8.   end
    9.   if (player:IsDead() or player.actor:GetSpectatorMode()~=0) then
    10.   return false, "only in game"
    11.   end
    12.   if (player.spintime) then
    13.   return false, "wait for the last spin to finish"
    14.   end
    15.   local reels = {"<font color=\"#646464\">~<font color=\"#646464\">O</font><font color=\"#646464\">~</font>","<font color=\"#646464\">~</font><font color=\"#379f3c\">X</font><font color=\"#646464\">~</font>","<font color=\"#3f82cd\">BAR</font>","<font color=\"#646464\">~</font><font color=\"#e02222\">7</font><font color=\"#646464\">~</font>"};
    16.   local spins = 100; player.spintime = true;
    17.   for i = 1, spins do
    18.   Script.SetTimer(i * 70, function()
    19.   spins = spins - 1;
    20.   if (spins>75) then
    21.   player.winline1 = reels[math.random(1,#reels)]; player.winline2 = reels[math.random(1,#reels)]; player.winline3 = reels[math.random(1,#reels)];
    22.   elseif (spins>50) then
    23.   player.winline2 = reels[math.random(1,#reels)]; player.winline3 = reels[math.random(1,#reels)];
    24.   elseif (spins>25) then
    25.   player.winline3 = reels[math.random(1,#reels)];
    26.   end
    27.   g_gameRules.game:SendTextMessage(TextMessageBig, string.format("<font size=\"30\"><b><font color=\"#dadada\">WIN</font><font color=\"#acacac\"> : ( </font>"..player.winline1.." <font color=\"#646464\">|</font> "..player.winline2.." <font color=\"#646464\">|</font> "..player.winline3.."<font color=\"#acacac\"> ) : </font><font color=\"#dadada\">LINE</font></font></b></font>"), TextMessageToClient, player.id);
    28.   if (spins<1 and player.winline1==reels[4] and player.winline2==reels[4] and player.winline3==reels[4]) then
    29.   g_gameRules:AwardPPCount(player.id, 10000);
    30.   Script.SetTimer( 500,function() FlashMessage:ToPlayer(player, 50, "~7~ | ~7~ | ~7~", "#8a2323", "#ff0000", "<font size=\"30\"><b><font color=\"#7d7d7d\">WIN : (</font><font color=\"#59c93a\"> </b>%s<b> </font><font color=\"#7d7d7d\">) : LINE");
    31.   g_gameRules.onClient:ClMDAlert(player.actor:GetChannel(), "");
    32.   Script.SetTimer( 2500,function() player.spintime = false; end);
    33.   end);
    34.   g_gameRules.game:SendTextMessage(TextMessageInfo, "! WIN:SPIN :: "..player:GetName().." :: JACKPOT :: 7~7~7 :: 10000 POINTS !", TextMessageToAll);
    35.   elseif (spins<1 and player.winline1==reels[3] and player.winline2==reels[3] and player.winline3==reels[3]) then
    36.   g_gameRules:AwardPPCount(player.id, 5000);
    37.   Script.SetTimer( 500,function() FlashMessage:ToPlayer(player, 50, "BAR | BAR | BAR", "#2a5d88", "#008aff", "<font size=\"30\"><b><font color=\"#7d7d7d\">WIN : (</font><font color=\"#59c93a\"> </b>%s<b> </font><font color=\"#7d7d7d\">) : LINE");
    38.   g_gameRules.onClient:ClMDAlert(player.actor:GetChannel(), "");
    39.   Script.SetTimer( 2500,function() player.spintime = false; end);
    40.   end);
    41.   g_gameRules.game:SendTextMessage(TextMessageInfo, "! WIN:SPIN :: "..player:GetName().." :: BAR~BAR~BAR :: 5000 POINTS !", TextMessageToAll);
    42.   elseif (spins<1 and player.winline1==reels[2] and player.winline2==reels[2] and player.winline3==reels[2]) then
    43.   g_gameRules:AwardPPCount(player.id, 1000);
    44.   Script.SetTimer( 500,function() FlashMessage:ToPlayer(player, 50, "~X~ | ~X~ | ~X~", "#3e7541", "#1cdc25", "<font size=\"30\"><b><font color=\"#7d7d7d\">WIN : (</font><font color=\"#59c93a\"> </b>%s<b> </font><font color=\"#7d7d7d\">) : LINE");
    45.   g_gameRules.onClient:ClMDAlert(player.actor:GetChannel(), "");
    46.   Script.SetTimer( 2500,function() player.spintime = false; end);
    47.   end);
    48.   g_gameRules.game:SendTextMessage(TextMessageInfo, "! WIN:SPIN :: "..player:GetName()..":: X~X~X :: 1000 POINTS !", TextMessageToAll);
    49.   elseif (spins<1) then
    50.   Script.SetTimer( 500,function() FlashMessage:ToPlayer(player, 50, "~ SPIN ~ OVER ~", "#af3838", "#ff0000", "<font size=\"30\"><b><font color=\"#7d7d7d\">WIN : (</font><font color=\"#59c93a\"> </b>%s<b> </font><font color=\"#7d7d7d\">) : LINE");
    51.   Script.SetTimer( 2500,function() player.spintime = false; end); -- to allow flash messages to end before starting new spin
    52.   end);
    53.   end
    54.   end);
    55.   end
    56.   player.lastspin = _time;
    57.   return true;
    58.   end);
    So that's the old code, I'm sure in time I'll understand C-sharp a bit more fully concerning Unity and I am doing, but just thought I'd pass by you chaps and see if you couldn't inspire me or through some ideas my way, I'll post an update as & when, cheers
     
  2. San_Holo

    San_Holo

    Joined:
    Sep 26, 2014
    Posts:
    152
    Ever played the arcade game Cosmo-gang from 1991? or seen the C64 game Uridium at the end of every cleared level? or the 777 boxes in Daytona USA? well I'm hoping to have something like this which at the end of every level there is a fruit machine type chance element which spins and shows either a winning line (all random chance) which will award an extra life or points... or a non-winning line and nothing is awarded and onto the next level you go...

    So the code above was for a text fruit machine used as a 'chat command' in another game which I wrote, now I'm thinking for this new version I could perhaps create three 3D reels or some kinda of 3D model of a simple box enclosing three round thin 3D wheels textured to show various awards... or I could do it in code/text, I wanted the reels to show all the symbols rather than just showing a single line of symbols being randomly jumbled up so to speak.

    Not sure how I could capture the correct winning lines, the code above just checks what the player has and adjusts accordingly after all spins have finished, anyway I hope to share it here when done, cheers