1
Fork 0
mirror of https://github.com/Steffo99/beat-td.git synced 2024-11-23 15:54:18 +00:00
beat-td/Assets/Scripts/SpriteOnLives.cs

30 lines
709 B
C#
Raw Normal View History

2018-04-23 08:45:40 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpriteOnLives : MonoBehaviour {
public Sprite higherSprite;
public Sprite lowerSprite;
public int livesThreshold;
private GameStatus gameStatus;
private SpriteRenderer spriteRenderer;
void Start () {
gameStatus = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameStatus>();
spriteRenderer = gameObject.GetComponent<SpriteRenderer>();
}
void Update () {
if(gameStatus.lives >= livesThreshold)
{
spriteRenderer.sprite = higherSprite;
}
else
{
spriteRenderer.sprite = lowerSprite;
}
}
}