public void Healthed(int amountInHalfHealths) { for (int i = 0; i < amountInHalfHealths; i++) { Image currentImage = hearthImages[currentPosition]; switch (currentContainerState) { case containerState.Full: currentPosition++; currentImage = hearthImages[currentPosition]; currentImage.sprite = halfContainer; currentContainerState = containerState.Half; break; case containerState.Half: currentImage.sprite = fullContainer; currentContainerState = containerState.Full; break; case containerState.Empty: currentImage.sprite = halfContainer; currentContainerState = containerState.Half; break; } } }
void Start() { audioSource = GetComponent <AudioSource>(); hearthImages = new List <Image>(); Image[] images = GetComponentsInChildren <Image>(); foreach (Image image in images) { if (image.tag == "Container") { hearthImages.Add(image); image.sprite = fullContainer; } } currentPosition = hearthImages.Count - 1; currentContainerState = containerState.Full; }
public void Damaged() { Image currentImage = hearthImages[currentPosition]; switch (currentContainerState) { case containerState.Full: currentImage.sprite = halfContainer; currentContainerState = containerState.Half; break; case containerState.Half: currentImage.sprite = emptyContainer; currentContainerState = containerState.Full; currentPosition--; break; } }