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(); this.Button = this.Icon.GetComponent(); this.SelectCursor = UTY.GetChildObject(base.gameObject, "Main/SelectCursor", false).GetComponent(); this.TitleLabel = UTY.GetChildObject(base.gameObject, "Title", false).GetComponent(); this.TitleLocalize = this.TitleLabel.GetComponent(); this.AddOnClickEvent(); this.onHoverOverEvent = new Action(this.viewer.onHoverOverEvent); this.onHoverOutEvent = new Action(this.viewer.onHoverOutEvent); UIEventTrigger[] componentsInChildren = base.GetComponentsInChildren(); 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); } 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(); if (component != null) { component.size = Vector3.zero; } } else { this.SelectCursor.alpha = 0f; this.Button.defaultColor = this.backup_default_color_; BoxCollider component2 = this.Button.GetComponent(); if (component2 != null) { UIWidget component3 = this.Button.GetComponent(); 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 list = new List(); 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 list = new List(); 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 onHoverOverEvent; public Action 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); }