TaskUI.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class TaskUI : MonoBehaviour
  6. {
  7. internal string MissionName;
  8. public Text Name;
  9. public Text[] Description;
  10. public Image[] CheckImage;
  11. int currIndex;
  12. bool check;
  13. public void Init(Quest quest)
  14. {
  15. Name.text = quest.Description;
  16. for (int i = 0; i < Mathf.Min(2,quest.tasks.Length); i++)
  17. {
  18. Description[i].text = quest.tasks[i].Description;
  19. }
  20. MissionName = quest.Description;
  21. }
  22. public void CheckTask(int index)
  23. {
  24. if (index < 2)
  25. {
  26. currIndex = index;
  27. check = true;
  28. }
  29. }
  30. public void LoadChecked(int index)
  31. {
  32. if (index < 2)
  33. {
  34. for (int i = 0; i < index; i++)
  35. {
  36. CheckImage[i].fillAmount = 1;
  37. }
  38. }
  39. }
  40. // Use this for initialization
  41. void Start()
  42. {
  43. }
  44. // Update is called once per frame
  45. void Update()
  46. {
  47. if (check)
  48. {
  49. CheckImage[currIndex].fillAmount += Time.deltaTime;
  50. if (CheckImage[currIndex].fillAmount >= 1)
  51. {
  52. check = false;
  53. if (currIndex == CheckImage.Length - 1)
  54. {
  55. Invoke("Remove", 1);
  56. }
  57. }
  58. }
  59. }
  60. void Remove()
  61. {
  62. Destroy(gameObject);
  63. }
  64. }