- Home /
Question by
Momin1 · Sep 14, 2016 at 02:16 AM ·
c#scripting problemscore systemlevels
How to give score only once for each level?
hi...In my game i have many levels.Each level have 3 objectives.For completing one objective in each level the player gets one star.the value of all the stars player gets in all the levels is saved as totalstars.now the problem is i want increment the value of totalstars only once for each objective in each level.for example if players plays level 1 for first time and completes one objective he get 1 total star but when he again plays level one and completes only the same objective again the value of total stars should not increase.How can i do this? i hope i made it clear enough.Below is one of the objective.
void OnTriggerEnter2D (Collider2D Ball)
{
EndGame.SetActive (true);
WinStar.SetActive (true);
PlayerPrefs.SetInt ("Level" + CurrentLevel.ToString () + "_win", 1);
deactive ();
COuntAndTime ();
TotalStars.Totalstars += 1; //this value should increase only once for each objective in each level.
TotalStars.totstar.Save ();
}
Comment