- Home /
Different score for each sprite.
Ok i have this script that works with my enemy script to produce a score, it works, however you get the same score for each sprite however i want to change how much you score when you click on each different sprite so that you could lose points if you kill the wrong thing. Can any point me in the right direction thanks
using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour
{
public GameObject Cursor;
public GUISkin theskin;
//Total number of hits
public int Hits = 0;
public GameObject badger;
public GameObject cow;
//Hit Limit needed to win
public int WinHits = 1000;
//Time limit
public float TimeLimit = 60.0f;
public SpriteRenderer WinObj = null;
public SpriteRenderer LoseObj = null;
// Use this for initialization
void Start ()
{
StartCoroutine(CheckWin());
}
// Update is called once per frame
void Update ()
{
//Update cursor position
Cursor.transform.position = new Vector3(Input.mousePosition.x - (Screen.width/2),Input.mousePosition.y - (Screen.height/2),0);
}
void OnGUI () {
GUI.skin = theskin;
GUI.Label (new Rect (500, 13, 100, 100), "" + 100*Hits);
}
IEnumerator CheckWin()
{
yield return new WaitForSeconds(TimeLimit);
//Check for win
if(100*Hits >= WinHits)
{
//Show game win message
WinObj.GetComponent<SpriteRenderer>().enabled = true;
}
else
{
//Show game lose message
LoseObj.GetComponent<SpriteRenderer>().enabled = true;
}
}
public void Hit()
{
if (badger) {
Hits --;
}
else if (cow){
Hits ++;
}
Comment