12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TaskUI : MonoBehaviour
- {
- internal string MissionName;
- public Text Name;
- public Text[] Description;
- public Image[] CheckImage;
- int currIndex;
- bool check;
- public void Init(Quest quest)
- {
- Name.text = quest.Description;
- for (int i = 0; i < Mathf.Min(2,quest.tasks.Length); i++)
- {
- Description[i].text = quest.tasks[i].Description;
- }
- MissionName = quest.Description;
- }
- public void CheckTask(int index)
- {
- if (index < 2)
- {
- currIndex = index;
- check = true;
- }
- }
- public void LoadChecked(int index)
- {
- if (index < 2)
- {
- for (int i = 0; i < index; i++)
- {
- CheckImage[i].fillAmount = 1;
- }
- }
- }
- // Use this for initialization
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- if (check)
- {
- CheckImage[currIndex].fillAmount += Time.deltaTime;
- if (CheckImage[currIndex].fillAmount >= 1)
- {
- check = false;
- if (currIndex == CheckImage.Length - 1)
- {
- Invoke("Remove", 1);
- }
- }
- }
- }
- void Remove()
- {
- Destroy(gameObject);
- }
- }
|