123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using I2.Loc;
- using Schedule;
- using UnityEngine;
- public class TaskUnit : MonoBehaviour
- {
- public ScheduleCSVData.ScheduleBase schedule { get; protected set; }
- public bool isSelected
- {
- get
- {
- return this.SelectCursor.alpha != 0f;
- }
- }
- public void Init(ScheduleTaskViewer taskViewer)
- {
- this.viewer = taskViewer;
- this.Icon = UTY.GetChildObject(base.gameObject, "Main", false).GetComponent<UITexture>();
- this.Button = this.Icon.GetComponent<UIButton>();
- this.SelectCursor = UTY.GetChildObject(base.gameObject, "Main/SelectCursor", false).GetComponent<UISprite>();
- this.TitleLabel = UTY.GetChildObject(base.gameObject, "Title", false).GetComponent<UILabel>();
- this.TitleLocalize = this.TitleLabel.GetComponent<Localize>();
- this.AddOnClickEvent();
- this.onHoverOverEvent = new Action<ScheduleCSVData.ScheduleBase>(this.viewer.onHoverOverEvent);
- this.onHoverOutEvent = new Action<ScheduleCSVData.ScheduleBase>(this.viewer.onHoverOutEvent);
- UIEventTrigger[] componentsInChildren = base.GetComponentsInChildren<UIEventTrigger>();
- foreach (UIEventTrigger uieventTrigger in componentsInChildren)
- {
- uieventTrigger.onHoverOut.Clear();
- EventDelegate.Add(uieventTrigger.onHoverOut, new EventDelegate.Callback(this.OnHoverOut));
- uieventTrigger.onHoverOver.Clear();
- EventDelegate.Add(uieventTrigger.onHoverOver, new EventDelegate.Callback(this.OnHoverOver));
- }
- }
- private void Update()
- {
- this.Monitor();
- }
- protected virtual void Monitor()
- {
- }
- protected virtual void AddOnClickEvent()
- {
- EventDelegate eventDelegate = new EventDelegate(this.viewer, "OnClickTaskUnit");
- eventDelegate.parameters[0].value = this;
- EventDelegate.Add(this.Button.onClick, eventDelegate);
- }
- public void SetData(ScheduleTaskCtrl.TaskType taskType, ScheduleTaskViewer viewer, ScheduleTaskViewer.ViewData viewData)
- {
- this.taskType = taskType;
- this.viewer = viewer;
- this.viewData = viewData;
- this.schedule = viewData.schedule;
- this.taskName = this.schedule.name;
- this.SelectCursor.alpha = 0f;
- this.TitleLabel.text = this.schedule.name;
- if (LocalizationManager.GetTermData("SceneFacilityManagement/施設名/" + this.schedule.name) != null)
- {
- this.TitleLocalize.SetTerm("SceneFacilityManagement/施設名/" + this.schedule.name);
- }
- else
- {
- this.TitleLocalize.SetTerm("SceneDaily/スケジュール/項目/" + this.schedule.name.Replace("×", "_"));
- }
- this.Icon.mainTexture = viewer.TmpData(taskType).icons[this.schedule.icon];
- }
- public bool isEnabled
- {
- get
- {
- return this.Button.isEnabled;
- }
- set
- {
- this.Button.isEnabled = value;
- this.TitleLabel.color = ((!this.Button.isEnabled) ? Color.gray : Color.white);
- }
- }
- public void SetSelect(bool is_select)
- {
- if (is_select && this.isEnabled)
- {
- this.SelectCursor.alpha = 1f;
- this.Button.defaultColor = Color.white;
- this.Button.SetState(UIButtonColor.State.Normal, false);
- BoxCollider component = this.Button.GetComponent<BoxCollider>();
- if (component != null)
- {
- component.size = Vector3.zero;
- }
- }
- else
- {
- this.SelectCursor.alpha = 0f;
- this.Button.defaultColor = this.backup_default_color_;
- BoxCollider component2 = this.Button.GetComponent<BoxCollider>();
- if (component2 != null)
- {
- UIWidget component3 = this.Button.GetComponent<UIWidget>();
- if (component3 != null)
- {
- Vector2 localSize = component3.localSize;
- component2.size = new Vector3(localSize.x, localSize.y, 0f);
- }
- }
- }
- }
- protected virtual void OnHoverOver()
- {
- if (this.onHoverOverEvent == null)
- {
- return;
- }
- this.onHoverOverEvent(this.schedule);
- this.isHover = true;
- }
- protected virtual void OnHoverOut()
- {
- if (this.onHoverOutEvent == null)
- {
- return;
- }
- this.onHoverOutEvent(this.schedule);
- this.isHover = false;
- }
- protected void SetTaskRank(GameObject go, int rank)
- {
- List<GameObject> list = new List<GameObject>();
- GameObject childObject = UTY.GetChildObject(go, "Stars/Icon", false);
- IEnumerator enumerator = childObject.transform.GetEnumerator();
- try
- {
- while (enumerator.MoveNext())
- {
- object obj = enumerator.Current;
- Transform transform = (Transform)obj;
- list.Add(transform.gameObject);
- }
- }
- finally
- {
- IDisposable disposable;
- if ((disposable = (enumerator as IDisposable)) != null)
- {
- disposable.Dispose();
- }
- }
- int count = list.Count;
- for (int i = 0; i < count; i++)
- {
- if (rank > i)
- {
- list[i].SetActive(true);
- }
- else
- {
- list[i].SetActive(false);
- }
- }
- }
- protected void SetExpRatio(GameObject go, int expRatio)
- {
- List<GameObject> list = new List<GameObject>();
- GameObject childObject = UTY.GetChildObject(go, "ExpRatio/ValueGroup", false);
- IEnumerator enumerator = childObject.transform.GetEnumerator();
- try
- {
- while (enumerator.MoveNext())
- {
- object obj = enumerator.Current;
- Transform transform = (Transform)obj;
- list.Add(transform.gameObject);
- }
- }
- finally
- {
- IDisposable disposable;
- if ((disposable = (enumerator as IDisposable)) != null)
- {
- disposable.Dispose();
- }
- }
- int count = list.Count;
- for (int i = 0; i < count; i++)
- {
- if (expRatio > i)
- {
- list[i].SetActive(true);
- }
- else
- {
- list[i].SetActive(false);
- }
- }
- }
- public void AdjustmentTitlePos(GameObject obj, ScheduleTaskCtrl.TaskButton taskButton, bool active = true)
- {
- UTY.GetChildObject(obj, "Stars", false).SetActive(active);
- UTY.GetChildObject(obj, "ExpRatio", false).SetActive(active);
- Transform transform = UTY.GetChildObject(obj, "Title", false).transform;
- Vector3 localPosition = transform.localPosition;
- if (!Product.supportMultiLanguage)
- {
- localPosition.y = -27f;
- }
- if (this.taskType == ScheduleTaskCtrl.TaskType.Training)
- {
- ScheduleTaskCtrl.TrainingTaskButton trainingTaskButton = (ScheduleTaskCtrl.TrainingTaskButton)taskButton;
- if (trainingTaskButton.type == ScheduleCSVData.TrainingType.Travel)
- {
- localPosition.y = -55f;
- }
- }
- if (this.taskType == ScheduleTaskCtrl.TaskType.Work)
- {
- if (ScheduleCSVData.faclilityPowerUpWorkId == this.schedule.id)
- {
- localPosition.y = (float)(Product.supportMultiLanguage ? -35 : -51);
- }
- else if (Product.supportMultiLanguage)
- {
- localPosition.y = -15f;
- }
- }
- transform.localPosition = localPosition;
- }
- protected ScheduleTaskViewer viewer;
- protected ScheduleTaskViewer.ViewData viewData;
- public GameObject removePrarent;
- [SerializeField]
- private bool isHover;
- public Action<ScheduleCSVData.ScheduleBase> onHoverOverEvent;
- public Action<ScheduleCSVData.ScheduleBase> onHoverOutEvent;
- [SerializeField]
- protected string taskName;
- public UITexture Icon;
- public UIButton Button;
- public UISprite SelectCursor;
- public UILabel TitleLabel;
- public Localize TitleLocalize;
- public ScheduleTaskCtrl.TaskType taskType;
- protected Color backup_default_color_ = new Color(1f, 1f, 1f, 0.6f);
- }
|