feature: Added lives
This commit is contained in:
parent
fa82f69ed5
commit
84a34deec6
19 changed files with 1036 additions and 134 deletions
36
Assets/Scripts/Flow/Lives.cs
Normal file
36
Assets/Scripts/Flow/Lives.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue