Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class ChangeIcon : MonoBehaviour
- {
- public GameObject stage1Black;
- public GameObject stage1Colour;
- public GameObject stage2Black;
- public GameObject stage2Colour;
- public GameObject stage3Black;
- public GameObject stage3Colour;
- public Sprite[] blackArray;
- public Sprite[] colourArray;
- public float ffilled;
- public int version;
- // Start is called before the first frame update
- void Awake()
- {
- if (blackArray.Length > 0)
- {
- stage1Black.GetComponent<Image>().sprite = blackArray[0];
- stage1Colour.GetComponent<Image>().sprite = colourArray[0];
- }
- //stage1Black.SetActive(false);
- //stage1Colour.SetActive(false);
- stage1Colour.GetComponent<Image>().fillAmount = 0.0f;
- //stage2Black.SetActive(false);
- stage2Colour.SetActive(false);
- //stage3Black.SetActive(false);
- stage3Colour.SetActive(false);
- ffilled = 0;
- version = 1;
- }
- public void SetFilled(float filled)
- {
- // Debug.Log("Som vo funkcii SetFilled: " + filled);
- /*
- filled = 1;
- ffilled = 1;
- stage1Colour.GetComponent<Image>().fillAmount =1;*/
- ffilled = filled;
- if (filled < 10)
- {
- if (blackArray.Length > 0)
- {
- stage1Black.GetComponent<Image>().sprite = blackArray[0];
- stage1Colour.GetComponent<Image>().sprite = colourArray[0];
- }
- // Debug.Log("Som vo funkcii SetFilled 2: " + ffilled);
- stage1Colour.GetComponent<Image>().fillAmount = ffilled / 10;
- stage2Colour.SetActive(false);
- stage3Colour.SetActive(false);
- }
- else if (filled < 20 && filled >= 10)
- {
- if (blackArray.Length > 0)
- {
- stage1Black.GetComponent<Image>().sprite = blackArray[1];
- stage1Colour.GetComponent<Image>().sprite = colourArray[1];
- }
- stage2Black.SetActive(true);
- stage2Colour.SetActive(true);
- stage3Colour.SetActive(false);
- stage1Colour.GetComponent<Image>().fillAmount = 1;
- stage2Colour.GetComponent<Image>().fillAmount = (ffilled - 10) / 10;
- }
- else //if (filled < 30 && filled >= 20)
- {
- if (blackArray.Length > 0)
- {
- stage1Black.GetComponent<Image>().sprite = blackArray[2];
- stage1Colour.GetComponent<Image>().sprite = colourArray[2];
- }
- stage3Black.SetActive(true);
- stage3Colour.SetActive(true);
- stage2Black.SetActive(true);
- stage2Colour.SetActive(true);
- stage1Colour.GetComponent<Image>().fillAmount = 1;
- stage2Colour.GetComponent<Image>().fillAmount = 1;
- stage3Colour.GetComponent<Image>().fillAmount = (ffilled - 20) / 10;
- }
- }
- // Update is called once per frame
- /*public void ChangeStat(GameObject g)
- {
- StartCoroutine(StartAnimation(g));
- }
- IEnumerator StartAnimation(GameObject g)
- {
- g.GetComponent<Animator>().Play("ChangeStat", -1, 0);
- yield return new WaitForSeconds(1.0f);
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement