Score script
Increase score over time
public class ScoreManager : MonoBehaviour {
public static float score = 1f;
public float scorescale = 0.2f;
public static float scoreMultiplier = 1f;
public static float enemyPoints = 0f;
public Text TextScore;
public GameObject scoreScreen;
// Use this for initialization
void Start ()
{
score = 0f;
}
// Update is called once per frame
void Update ()
{
if (PlayerDie.PlayerAlive == true)
{
score = score+ (scorescale*scoreMultiplier*Time.time); //score growth rate increases over time
// add code to make score scale reset to 0 every time damage is taken.
TextScore = scoreScreen.GetComponent();
TextScore.text = Mathf.Floor(score).ToString();
}
}
}
Score increment by 50 with basic enemy killed
void OnTriggerEnter (Collider col)
{
if (col.gameObject.tag == "Bullet")
{
Rigidbody newTrail = Instantiate(explode,transform.position,transform.rotation) as Rigidbody; //instantiate particle explosion animation
newTrail.AddForce(transform.forward*explodeVelocity,ForceMode.VelocityChange);
ScoreManager.score = (ScoreManager.score + 50); // add 50 points to score when enemy is killed
Debug.Log ("enemy dead");
Destroy (gameObject);
}
}
This part of code on the EnemyDie script (Destroys enemies when they come into contact with a bullet) creates a small particle explosion effect and adds a flat value of 50 to the player’s score. In the future I plan to change the flat value to a float variable so I can change score values depending on the type of enemy. I would also like to implement a score multiplier based on enemies destroyed in quick succession.

UI text displaying updating score value
In the future I would like a way to give visual feedback on how much score the player is getting for destroying enemies, for example a ‘+50’ could pop up next to the score each time an enemy with the score value of 50 is destroyed.








