Question by
TooLate · Oct 23, 2017 at 08:12 PM ·
scorescore systemscoringscores
Scoring different amount of points
Hi,
I trying to build a scoring system which gives different amount of points depending on how many times player presses the button. I am using a code which changes the color of the object every time it is pressed. I would like this code work in a way that the first press would give one point for the player, second press three points and the third press would give the player minus four points so he would have zero points like in the beginning of the game.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CCButton : MonoBehaviour {
public Material[] materials;
public Renderer Rend;
private int index = 1;
public void buttonPressed()
{
if (materials.Length == 0)
return;
index += 1;
if (index == materials.Length + 1)
index = 1;
ScoreManager.score += 1;
print(index);
Rend.sharedMaterial = materials[index - 1];
}
}
Comment