Advertisement
Zuvi

Untitled

Jul 31st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class ChangeIcon : MonoBehaviour
  7. {
  8.  
  9. public GameObject stage1Black;
  10. public GameObject stage1Colour;
  11. public GameObject stage2Black;
  12. public GameObject stage2Colour;
  13. public GameObject stage3Black;
  14. public GameObject stage3Colour;
  15.  
  16. public Sprite[] blackArray;
  17. public Sprite[] colourArray;
  18.  
  19. public float ffilled;
  20. public int version;
  21.  
  22. // Start is called before the first frame update
  23. void Awake()
  24. {
  25. if (blackArray.Length > 0)
  26. {
  27. stage1Black.GetComponent<Image>().sprite = blackArray[0];
  28. stage1Colour.GetComponent<Image>().sprite = colourArray[0];
  29. }
  30.  
  31. //stage1Black.SetActive(false);
  32. //stage1Colour.SetActive(false);
  33. stage1Colour.GetComponent<Image>().fillAmount = 0.0f;
  34. //stage2Black.SetActive(false);
  35. stage2Colour.SetActive(false);
  36. //stage3Black.SetActive(false);
  37. stage3Colour.SetActive(false);
  38.  
  39. ffilled = 0;
  40. version = 1;
  41. }
  42.  
  43. public void SetFilled(float filled)
  44. {
  45. // Debug.Log("Som vo funkcii SetFilled: " + filled);
  46. /*
  47. filled = 1;
  48. ffilled = 1;
  49.  
  50. stage1Colour.GetComponent<Image>().fillAmount =1;*/
  51.  
  52. ffilled = filled;
  53. if (filled < 10)
  54. {
  55. if (blackArray.Length > 0)
  56. {
  57. stage1Black.GetComponent<Image>().sprite = blackArray[0];
  58. stage1Colour.GetComponent<Image>().sprite = colourArray[0];
  59. }
  60. // Debug.Log("Som vo funkcii SetFilled 2: " + ffilled);
  61. stage1Colour.GetComponent<Image>().fillAmount = ffilled / 10;
  62. stage2Colour.SetActive(false);
  63. stage3Colour.SetActive(false);
  64. }
  65. else if (filled < 20 && filled >= 10)
  66. {
  67. if (blackArray.Length > 0)
  68. {
  69. stage1Black.GetComponent<Image>().sprite = blackArray[1];
  70. stage1Colour.GetComponent<Image>().sprite = colourArray[1];
  71. }
  72. stage2Black.SetActive(true);
  73. stage2Colour.SetActive(true);
  74. stage3Colour.SetActive(false);
  75. stage1Colour.GetComponent<Image>().fillAmount = 1;
  76. stage2Colour.GetComponent<Image>().fillAmount = (ffilled - 10) / 10;
  77. }
  78. else //if (filled < 30 && filled >= 20)
  79. {
  80. if (blackArray.Length > 0)
  81. {
  82. stage1Black.GetComponent<Image>().sprite = blackArray[2];
  83. stage1Colour.GetComponent<Image>().sprite = colourArray[2];
  84. }
  85. stage3Black.SetActive(true);
  86. stage3Colour.SetActive(true);
  87. stage2Black.SetActive(true);
  88. stage2Colour.SetActive(true);
  89. stage1Colour.GetComponent<Image>().fillAmount = 1;
  90. stage2Colour.GetComponent<Image>().fillAmount = 1;
  91. stage3Colour.GetComponent<Image>().fillAmount = (ffilled - 20) / 10;
  92. }
  93. }
  94.  
  95. // Update is called once per frame
  96.  
  97. /*public void ChangeStat(GameObject g)
  98. {
  99. StartCoroutine(StartAnimation(g));
  100. }
  101.  
  102. IEnumerator StartAnimation(GameObject g)
  103. {
  104. g.GetComponent<Animator>().Play("ChangeStat", -1, 0);
  105. yield return new WaitForSeconds(1.0f);
  106. }*/
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement