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

29 lines
709 B
C#

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;
}
}
}