Question by
singhkumaravinash94 · Mar 08, 2018 at 12:08 AM ·
gameobjectscoreboardstack
Score increasing on landing on same stack
Hi, I am trying to create a stack jump game.I am facing an issue that even if a player is landing on previous tile the score is increasing.How should i correct it.
public class GameManager : MonoBehaviour {
public static GameManager instance;
public GameObject character;
private bool gameOver = false;
private int stackCount = 0;
public Text scoreText;
private void Awake()
{
if (instance == null)
{
instance = this;
}
else
{
Destroy(this);
}
}
// Use this for initialization
void Start () {
PlayerPrefs.SetInt("ScoreCount", 0);
}
// Update is called once per frame
void Update () {
scoreText.text = (PlayerPrefs.GetInt("ScoreCount")).ToString();
}
public void SetGameOver()
{
print("Game Over");
gameOver = true;
GetComponent<Enabler>().EnableObjects(true);
}
public bool GetGameOver()
{
return gameOver;
}
public GameObject GetCharacter()
{
return character;
}
public void IncrementStack()
{
stackCount++;
if (!GetGameOver())
{
PlayerPrefs.SetInt("ScoreCount", stackCount);
}
}
public int GetStackCount()
{
return stackCount;
}}
Can someone please help. Thank you in advance.
Comment