Hey guys so I am struggling the best way to approach this situation.
So I have 5 frames in my ovenScreen.mcChar
movie clip. Each is a character that the player can unlock. If the player has enough coins then they can go to the prize screen to get a random unlockable character.
Here is how it is setup so far:
private function getPrizeHandler(e:MouseEvent):void
{
//Check if prize is locked or unlocked then unlock item/ loop through random number frames
frameLoop = randomNumber(1, 5);
ovenScreen.mcChar.gotoAndStop(frameLoop);
if (frameLoop == 1 && !sharedObjectCharacters.data.sharedHotDog)
{
sharedHotDog = true;
sharedObjectCharacters.data.sharedHotDog = sharedHotDog;
sharedObjectCharacters.flush ();
}else
if (frameLoop == 2 && !sharedObjectCharacters.data.sharedTaco)
{
sharedTaco = true;
sharedObjectCharacters.data.sharedTaco = sharedTaco;
sharedObjectCharacters.flush ();
}else
if (frameLoop == 3 && !sharedObjectCharacters.data.sharedDonut)
{
sharedDonut = true;
sharedObjectCharacters.data.sharedDonut = sharedDonut;
sharedObjectCharacters.flush ();
}else
if (frameLoop == 4 && !sharedObjectCharacters.data.sharedCoffee)
{
sharedCoffee = true;
sharedObjectCharacters.data.sharedCoffee = sharedCoffee;
sharedObjectCharacters.flush ();
}else
if (frameLoop == 5 && !sharedObjectCharacters.data.sharedPancakes)
{
sharedPancakes = true;
sharedObjectCharacters.data.sharedPancakes = sharedPancakes;
sharedObjectCharacters.flush ();
}
////////////////////////////////////////
ovenScreen.gotoAndPlay(2); //play animations
TweenLite.delayedCall(3.5, prizeConfettie);
ovenScreen.removeEventListener(MouseEvent.CLICK, getPrizeHandler);
}
As you can see I have the var frameLoop
which is a random number from 1 - 5. So the character unlocked will be random and show the random unlocked character. I use the if statements to check if the random number lands on that certain frame and its not the case that it is unlocked then unlock it and save the data.
Now this all works fine but How could I go about fixing it to where if the Item is already unlocked to sort through a different frame number. So if the frameLoop lands on 2 and that character is already unlocked then repeat the random frame number until it lands on a locked character. I was thinking of setting up an array of numbers maybe that approach might be a logical one but not sure how to go about doing so.
Any help would be appreciated thanks.
Aucun commentaire:
Enregistrer un commentaire