feature: Added lives

This commit is contained in:
Gerard Gascón 2024-01-27 20:17:18 +01:00
parent fa82f69ed5
commit 84a34deec6
19 changed files with 1036 additions and 134 deletions

View file

@ -0,0 +1,36 @@
using System;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
namespace Flow {
public class Lives : MonoBehaviour {
[SerializeField] private Image[] lives;
[SerializeField] private Sprite correctLive;
[SerializeField] private Sprite wrongLive;
public int CurrentLives { private set; get; }
private void Awake() {
ResetLives();
}
public void Wrong() {
CurrentLives--;
int timesHurt = lives.Length - CurrentLives;
for (int i = 0; i < timesHurt; i++) {
lives[i].sprite = wrongLive;
}
}
public void ResetLives() {
CurrentLives = lives.Length;
foreach (Image life in lives) {
life.sprite = correctLive;
}
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4ac00191cb424148b6fbefc0c595175b
timeCreated: 1706381399