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:
--===================================================================================
-- SPIN
AddChatCommand("spin", {info="play the fruit machine"}, function (player)
if (player.lastspin and ((_time - player.lastspin) <=60)) then
return false, "sorry fruit machine overheated";
end
if (player:IsDead() or player.actor:GetSpectatorMode()~=0) then
return false, "only in game"
end
if (player.spintime) then
return false, "wait for the last spin to finish"
end
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>"};
local spins = 100; player.spintime = true;
for i = 1, spins do
Script.SetTimer(i * 70, function()
spins = spins - 1;
if (spins>75) then
player.winline1 = reels[math.random(1,#reels)]; player.winline2 = reels[math.random(1,#reels)]; player.winline3 = reels[math.random(1,#reels)];
elseif (spins>50) then
player.winline2 = reels[math.random(1,#reels)]; player.winline3 = reels[math.random(1,#reels)];
elseif (spins>25) then
player.winline3 = reels[math.random(1,#reels)];
end
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);
if (spins<1 and player.winline1==reels[4] and player.winline2==reels[4] and player.winline3==reels[4]) then
g_gameRules:AwardPPCount(player.id, 10000);
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");
g_gameRules.onClient:ClMDAlert(player.actor:GetChannel(), "");
Script.SetTimer( 2500,function() player.spintime = false; end);
end);
g_gameRules.game:SendTextMessage(TextMessageInfo, "! WIN:SPIN :: "..player:GetName().." :: JACKPOT :: 7~7~7 :: 10000 POINTS !", TextMessageToAll);
elseif (spins<1 and player.winline1==reels[3] and player.winline2==reels[3] and player.winline3==reels[3]) then
g_gameRules:AwardPPCount(player.id, 5000);
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");
g_gameRules.onClient:ClMDAlert(player.actor:GetChannel(), "");
Script.SetTimer( 2500,function() player.spintime = false; end);
end);
g_gameRules.game:SendTextMessage(TextMessageInfo, "! WIN:SPIN :: "..player:GetName().." :: BAR~BAR~BAR :: 5000 POINTS !", TextMessageToAll);
elseif (spins<1 and player.winline1==reels[2] and player.winline2==reels[2] and player.winline3==reels[2]) then
g_gameRules:AwardPPCount(player.id, 1000);
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");
g_gameRules.onClient:ClMDAlert(player.actor:GetChannel(), "");
Script.SetTimer( 2500,function() player.spintime = false; end);
end);
g_gameRules.game:SendTextMessage(TextMessageInfo, "! WIN:SPIN :: "..player:GetName()..":: X~X~X :: 1000 POINTS !", TextMessageToAll);
elseif (spins<1) then
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");
Script.SetTimer( 2500,function() player.spintime = false; end); -- to allow flash messages to end before starting new spin
end);
end
end);
end
player.lastspin = _time;
return true;
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