How to count stars in a World ...

Help, support and information for our Game Framework Unity Asset.
If posting about the assets in the extras bundle then please use the appropriate forum.
Post Reply
tenfiddy
Posts: 24
Joined: Wed Jul 24, 2019 9:02 pm

How to count stars in a World ...

Post by tenfiddy » Wed Aug 28, 2019 12:46 am

In my game I have 12 levels per world and each level has 3 stars ...so 36 possible stars to win. I wanted to be able to count the Stars Won per world and display that number on the World Selection button. So it would say, as an example, 24 /36 ...

How can I do this?

Right now I am counting the total coins in the entire game. And the value of 1 star = 1 coin. It works, but...

In the game you can only score a max of 3 stars for that scene / puzzle no matter how many times you try, but when using your playmaker scripts, I could only set or change coins in the scene (on the level or player) and each option would automatically add coins to the player total. So, if you played a scene 4 times and got 1 star each time, the player would get 4 coins. Not good, they should only get 1. So, I also wrote a playmaker FSM that gets the star count at the beginning of the scene and then compares it to the new star count.

Then, If its more, it adds only the difference to the players coins. But I had to use a method call to set the total coin value in the scene at the end.

mahewitt
Site Admin
Posts: 273
Joined: Thu May 05, 2016 8:06 pm

Re: How to count stars in a World ...

Post by mahewitt » Sat Aug 31, 2019 5:33 pm

The coins shouldn't be added to the player as you go, although there are options in the GameOver window that add level scores to player score (None|Always|On Win). Perhaps this is set? If you can verify this in the chear window - you should be able to see if the player score / coins are updated as you go.

In the World objects there is a property LevelStarCountTotal that you can access to get the total number of stars won. You can access the Worlds through GameManager.Instance.Worlds. This is an enumerator so you can use it within a foreach block, or reference it's Selected or Items properties

tenfiddy
Posts: 24
Joined: Wed Jul 24, 2019 9:02 pm

Re: How to count stars in a World ...

Post by tenfiddy » Mon Sep 02, 2019 1:26 pm

I am not a normal c# programmer - I am a hacker of code...and a playmaker visual programmer. I want you to know what I am doing so that you might be able to help.
THIS IS THE NEWEST VERSION.

So when scoring a level, at scene start, I get the Level.StarsWonCount from your LevelManager (via playmaker "Get Property') and save it as a variable. Then I calculate the actual stars pending on my level. It's much more complex than using your conditional statement, in my game you can get stars, but you may blow something up (or some other reason) and then the score will not count. Then, If you win (by getting the thing in the bucket). I simply calculate if you got a better score than the starting score and interact with your script via playmaker.

If level has no stars yet - I use playmaker "Level Set Coins" - and set it my pending stars (1 coin = 1 star)

If level has a score - I use playmaker "Level Set Coins" - and set the score if it is greater than the old one.

Then I call the GameOver method from the LevelManager and set to bool to "Is Won" (via playmaker Call Method)

And ... the Update Player Coins and Update Player Score, on GameOver, is set to "None". (THIS IS WHAT WAS SCREWING ME UP)

I show the Total Amount of Stars in that world by grabbing the World.Selected.LevelStarCountTotal from your GameManager (via playmaker "Get Property')

Simple - and working. Thanks
Last edited by tenfiddy on Mon Sep 02, 2019 6:50 pm, edited 4 times in total.

tenfiddy
Posts: 24
Joined: Wed Jul 24, 2019 9:02 pm

Re: How to count stars in a World ...

Post by tenfiddy » Mon Sep 02, 2019 1:41 pm

BUT - This is where I need help.

TOTAL STARS IN THE ENTIRE GAME.

As in the total of all worlds combined. I was going to do this by giving player coins to match stars and getting the total. But having problems. Is there an way or a variable that I can get?

SHOWING THE WORLD STARS ON EACH WORLD BUTTON

I can't seem to access the enumerator via playmaker. I currently, am able to get variables from your script via playmaker "Get Property" an can see Level Star counts on only the current selected level I am playing (and unlocked status). But can get the info needed to display it per world. I even tried the playmaker enum scripts but cannot get the needed info.
I have tried changing the world via "set property" and then grabbing the LevelStarTotal... in a loop and saving in an array...but nothing...can't seem to get any data except current level. There has to be a way.

I want to be able to show the number of stars acquired in a world on the World Button. So the player will know they have, for example, 20/36 stars in that world before selecting it.

I cannot figure out how to access, for example, the star count for world 3 while I am on world 1. Is there a way for to access this (given my limited knowledge of c#)? I was hoping to find a table, an array or something that I could grab and hack. Or a playerpref... I would love to be able to simply have a :
World 1 = 20,unlocked
World 2 = 14,unlocked
World 3 = 0, locked

But how could I make this or get the info? I would like to have this info auto-populate on the world buttons.

mahewitt
Site Admin
Posts: 273
Joined: Thu May 05, 2016 8:06 pm

Re: How to count stars in a World ...

Post by mahewitt » Sat Sep 07, 2019 7:29 am


Post Reply