using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using com.workman.cm3d2.scene.dailyEtc; using Schedule; using UnityEngine; public class UIDragDropMaidStatus : UIDragDropItem { protected override void Start() { this.m_parent = base.transform.parent.transform.parent.gameObject; this.mTrans = base.transform.parent; this.startLocalPosX = this.mTrans.transform.localPosition.x; GameObject f_goParent = GameObject.Find("/UI Root"); SceneMgr component = UTY.GetChildObject(f_goParent, "Manager", false).GetComponent(); this.m_scheduleMgr = component.GetManager(); this.mCollider = base.gameObject.GetComponent(); this.mCollider2D = base.gameObject.GetComponent(); this.mButton = base.GetComponent(); this.mDragScrollView = base.GetComponent(); } protected override void OnDragDropStart() { if (UICamera.currentTouchID != -1) { return; } base.OnDragDropStart(); } protected override void OnDragDropRelease(GameObject surface) { this.m_surface = surface; base.OnDragDropRelease(surface); } protected override void OnDragDropEnd() { this.ChangeSlotInfo(this.m_surface); if (this.mTable != null) { this.mTable.onReposition = new UITable.OnReposition(this.AdjustPosX); } else if (this.mGrid != null) { } } private void AdjustPosX() { if (this.mTrans != null) { this.mTrans.transform.localPosition = new Vector2(this.startLocalPosX, this.mTrans.transform.localPosition.y); } } private void ChangeSlotInfo(GameObject surface) { string name = base.transform.name; string name2 = surface.name; if (name2.Contains("slot")) { this.ChangeSlotData(name, name2); this.ChangeButtonNameForSlotNo(surface); this.ChangeCurrentActiveButton(name, name2); } this.Sort(); } private void ChangeCurrentActiveButton(string srcName, string destName) { string currentActiveButton = this.m_scheduleMgr.CurrentActiveButton; string text = this.ToSlotNo(srcName); string text2 = this.ToSlotNo(destName); if (!string.IsNullOrEmpty(currentActiveButton)) { if (currentActiveButton.Contains(text)) { this.m_scheduleMgr.CurrentActiveButton = this.ReplaceSlotNo(currentActiveButton, text2); this.m_scheduleMgr.SetActiveSlotNo(text2); } else if (currentActiveButton.Contains(text2)) { this.m_scheduleMgr.CurrentActiveButton = this.ReplaceSlotNo(currentActiveButton, text); this.m_scheduleMgr.SetActiveSlotNo(text); } } } private void ChangeButtonNameForSlotNo(GameObject surface) { string text = this.ToSlotNo(base.transform.name); string text2 = this.ToSlotNo(surface.name); IEnumerator enumerator = base.transform.parent.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform transform = (Transform)obj; GameObject gameObject = transform.gameObject; gameObject.name = this.ReplaceSlotNo(gameObject.name, text2); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } IEnumerator enumerator2 = surface.transform.parent.GetEnumerator(); try { while (enumerator2.MoveNext()) { object obj2 = enumerator2.Current; Transform transform2 = (Transform)obj2; GameObject gameObject2 = transform2.gameObject; gameObject2.name = this.ReplaceSlotNo(gameObject2.name, text); } } finally { IDisposable disposable2; if ((disposable2 = (enumerator2 as IDisposable)) != null) { disposable2.Dispose(); } } GameObject gameObject3 = surface.transform.parent.gameObject; gameObject3.name = text; GameObject gameObject4 = base.transform.parent.gameObject; gameObject4.name = text2; } private string ReplaceSlotNo(string src, string destSlotNo) { string text = "slot_\\d+"; return Regex.Replace(src, text, destSlotNo); } private void ChangeSlotData(string srcName, string destName) { Dictionary maidStatusAndTask = this.m_scheduleMgr.GetMaidStatusAndTask(); string text = this.ToSlotNo(srcName); string text2 = this.ToSlotNo(destName); ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null; if (!maidStatusAndTask.TryGetValue(text, out maidStatusAndTaskUnit)) { Debug.LogError(string.Format("不適切なスロットが選択されました。選択されたスロットNo={0}", text)); } ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit2 = null; if (!maidStatusAndTask.TryGetValue(text2, out maidStatusAndTaskUnit2)) { Debug.LogError(string.Format("不適切なスロットが選択されました。選択されたスロットNo={0}", maidStatusAndTaskUnit2)); } ScheduleScene scheduleApi = this.m_scheduleMgr.GetScheduleApi(); Maid maidBySlotNo = this.m_scheduleMgr.GetMaidBySlotNo(text); Maid maidBySlotNo2 = this.m_scheduleMgr.GetMaidBySlotNo(text2); maidStatusAndTaskUnit2.slotNo = int.Parse(text.Replace("slot_", string.Empty)); maidStatusAndTask[text] = maidStatusAndTaskUnit2; maidStatusAndTaskUnit.slotNo = int.Parse(text2.Replace("slot_", string.Empty)); maidStatusAndTask[text2] = maidStatusAndTaskUnit; scheduleApi.SetSlot_Safe(maidStatusAndTaskUnit.slotNo, maidBySlotNo, false, true); scheduleApi.SetSlot_Safe(maidStatusAndTaskUnit2.slotNo, maidBySlotNo2, false, true); } private void Sort() { List list = new List(); IEnumerator enumerator = this.m_parent.transform.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform transform = (Transform)obj; GameObject gameObject = transform.gameObject; list.Add(gameObject); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } this.m_parent.transform.DetachChildren(); IOrderedEnumerable orderedEnumerable = from go in list orderby ScheduleCtrl.ToIntSlotNo(go.name) select go; foreach (GameObject child in orderedEnumerable) { this.SetTransformInfo(this.m_parent, child); } } private string ToSlotNo(string buttonName) { ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName); return slotByButtonName.slotNo; } private void DelChildGameObject(GameObject goParent) { IEnumerator enumerator = goParent.transform.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform transform = (Transform)obj; UnityEngine.Object.Destroy(transform.gameObject); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } goParent.transform.DetachChildren(); } private void SetTransformInfo(GameObject parent, GameObject child) { child.transform.parent = parent.transform; } private ScheduleMgr m_scheduleMgr; private GameObject m_parent; private GameObject m_surface; private Vector2 startLocalPos = Vector2.zero; private string pattern; private bool cancel; private float startLocalPosX; private int frameCount; private const string DROPABLE_MARK = "slot"; private const string uiRootPath = "/UI Root"; private const int LeftClick = -1; }