using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using UnityEngine; using wf; public class PlacementWindow : BaseMaidPhotoWindow { public override void Awake() { base.Awake(); this.PartsTransForm.onChangeAxisVisibleType.Add(new Action(this.OnChangeAxisVisibleType)); EventDelegate.Add(this.CameraFocusButton.onClick, new EventDelegate.Callback(this.OnClickCameraFocus)); EventDelegate.Add(this.DeActiveButton.onClick, new EventDelegate.Callback(this.OnClickDeActive)); this.VisibleCheckButton.onClick.Add(new Action(this.OnClickVisibleCheckButton)); this.camera_move_support_ = base.gameObject.AddComponent(); EventDelegate.Add(this.CallEditButton.onClick, delegate() { base.mgr.CallEditSceneFunction(base.mgr.select_maid); }); } public override void Start() { base.Start(); this.chara_mgr_ = GameMain.Instance.CharacterMgr; List list = new List(); for (int i = 0; i < this.chara_mgr_.GetStockMaidCount(); i++) { Maid stockMaid = this.chara_mgr_.GetStockMaid(i); if (!(stockMaid == null)) { list.Add(stockMaid); } } List list2 = list; if (PlacementWindow.<>f__mg$cache0 == null) { PlacementWindow.<>f__mg$cache0 = new Comparison(CharacterSelectManager.SortMaidStandardNoSchedule); } list2.Sort(PlacementWindow.<>f__mg$cache0); for (int j = 0; j < this.chara_mgr_.GetManCount(); j++) { Maid man = this.chara_mgr_.GetMan(j); if (!(man == null) && !man.boNPC) { PhotoManEditManager.Controller controller = new PhotoManEditManager.Controller(man); if (j != 0) { man.SetUpModel("_I_man.menu"); controller.color = new Color(0f, 0.09f, 1f); controller.fat = 0.2f; man.AllProcProp(); } PlacementWindow.ManDataBackup value = default(PlacementWindow.ManDataBackup); value.color = controller.color; value.fat = controller.fat; value.parts_visible = true; value.head_item_rid = controller.head_menu_rid; this.man_backup_data_dic_.Add(man.status.guid, value); list.Add(man); } } UIGrid component = UTY.GetChildObject(this.content_game_object, "ListParent/Contents/UnitParent", false).GetComponent(); UIScrollView component2 = UTY.GetChildObject(this.content_game_object, "ListParent/Contents", false).GetComponent(); for (int k = 0; k < list.Count; k++) { GameObject f_goParent = Utility.CreatePrefab(component.gameObject, "ScenePhotoMode/SimpleMaidPlatePlacement", true); PlacementWindow.PlateData plateData = new PlacementWindow.PlateData(); plateData.maid = list[k]; plateData.plate = UTY.GetChildObject(f_goParent, "Plate", false).GetComponent(); plateData.plate.SetMaidData(list[k]); plateData.btn = UTY.GetChildObject(f_goParent, "Plate/Plate/TopButton", false).GetComponent(); plateData.def_btn_color = new Color(1f, 1f, 1f, 0.7f); plateData.select_btn = UTY.GetChildObject(f_goParent, "Plate/Button", false).GetComponent(); plateData.select_btn.isEnabled = false; EventDelegate.Add(plateData.select_btn.onClick, new EventDelegate.Callback(this.OnClickMaid)); plateData.bg_sprite = UTY.GetChildObject(f_goParent, "Plate/Plate/BG", false).GetComponent(); plateData.select_frame = UTY.GetChildObject(f_goParent, "Plate/Plate/SelectFrame", false).GetComponent(); EventDelegate.Add(plateData.btn.onClick, new EventDelegate.Callback(this.OnClickPlacementBtn)); this.maid_data_list_.Add(plateData); } component.Reposition(); component2.ResetPosition(); this.UpdateChildren(); UIButtonColor cameraFocusButton = this.CameraFocusButton; bool flag = false; this.VisibleCheckButton.enabled = flag; flag = flag; this.DeActiveButton.isEnabled = flag; flag = flag; this.CallEditButton.isEnabled = flag; cameraFocusButton.isEnabled = flag; this.is_first_ = true; this.call_deserialize_ = false; } public void OnDestroy() { if (GameMain.Instance == null || GameMain.Instance.CharacterMgr == null) { return; } } public override void Update() { if (this.is_first_) { this.UpdateList(); this.is_first_ = false; } if (Input.GetKeyDown(KeyCode.F1)) { this.PartsTransForm.NextAxis(); } if (Input.GetKeyDown(KeyCode.F2) && this.CameraFocusButton.isEnabled) { this.OnClickCameraFocus(); } if (this.new_load_maid_data_list_.Count == 0 || this.chara_mgr_.IsBusy()) { if (!this.chara_mgr_.IsBusy() && this.maid_casule_collider_hash_.Count != 0) { bool flag = false; using (Dictionary.Enumerator enumerator = this.maid_casule_collider_hash_.GetEnumerator()) { if (enumerator.MoveNext()) { KeyValuePair keyValuePair = enumerator.Current; flag = keyValuePair.Value.enabled; } } if (GameMain.Instance.VRMode) { if (!OvrIK.IsVRIKMode && !flag) { foreach (KeyValuePair keyValuePair2 in this.maid_casule_collider_hash_) { keyValuePair2.Value.enabled = true; } } } else if (Input.GetKey(KeyCode.Tab) && !flag) { foreach (KeyValuePair keyValuePair3 in this.maid_casule_collider_hash_) { keyValuePair3.Value.enabled = true; } } else if (!Input.GetKey(KeyCode.Tab) && flag) { foreach (KeyValuePair keyValuePair4 in this.maid_casule_collider_hash_) { keyValuePair4.Value.enabled = false; } } } return; } for (int i = 0; i < this.new_load_maid_data_list_.Count; i++) { PlacementWindow.MaidSlotData maidSlotData = this.new_load_maid_data_list_[i]; Maid maid = maidSlotData.maid; this.active_maid_list_.Add(maidSlotData); maid.transform.position = Vector3.zero; maid.transform.rotation = default(Quaternion); maid.transform.localScale = Vector3.one; maid.body0.SetBoneHitHeightY(-1000f); base.mgr.OnMaidAddEvent(maid, this.call_deserialize_); } if (this.call_deserialize_) { base.mgr.OnFinishMaidDeserializeLoad(); } this.call_deserialize_ = false; this.SetSelectMaid(this.new_load_maid_data_list_[0].maid); this.new_load_maid_data_list_.Clear(); GameMain.Instance.MainCamera.FadeIn(0.3f, false, null, true, true, default(Color)); } public int GetActiveMaidCount() { return this.active_maid_list_.Count; } private void SetSelectMaid(Maid maid) { if (maid == null) { base.mgr.OnMaidChangeEvent(null); return; } bool flag = false; for (int i = 0; i < this.GetMaidOrManCount(maid); i++) { if (this.GetMaidOrMan(maid, i) == maid) { flag = true; break; } } if (flag && maid.boMAN && !maid.Visible) { flag = false; } if (!flag) { return; } base.mgr.OnMaidChangeEvent(maid); this.UpdateList(); } public override void OnMaidChangeEvent(Maid maid) { base.OnMaidChangeEvent(maid); UIButtonColor cameraFocusButton = this.CameraFocusButton; bool flag = maid != null; this.VisibleCheckButton.enabled = flag; flag = flag; this.DeActiveButton.isEnabled = flag; flag = flag; this.CallEditButton.isEnabled = flag; cameraFocusButton.isEnabled = flag; if (maid != null && maid.boMAN) { this.CallEditButton.isEnabled = false; } this.VisibleCheckButton.check = (maid != null && maid.transform.GetChild(0).localScale.x != 0f); if (maid != null) { this.PartsTransForm.SetObject(maid.gameObject); this.PartsTransForm.ScaleInput.SetInitVector(Vector3.one); } else { this.PartsTransForm.SetObject(null); } this.OnChangeAxisVisibleType(); } public override void OnMaidRemoveEvent(Maid maid) { base.OnMaidRemoveEvent(maid); if (this.transtarget_maid_dic_.ContainsKey(maid)) { this.transtarget_maid_dic_[maid].Delete(); this.transtarget_maid_dic_.Remove(maid); } this.UpdateList(); } public override void OnMaidAddEvent(Maid maid, bool is_deserialize_load) { base.OnMaidAddEvent(maid, is_deserialize_load); Dictionary maidStoreData = base.GetMaidStoreData(maid); if (!is_deserialize_load) { maidStoreData["position"] = Vector3.zero.ToString(); maidStoreData["rotation"] = Quaternion.identity.ToString(); maidStoreData["scale"] = Vector3.one.ToString(); maidStoreData["visible"] = true.ToString(); } maid.transform.position = Parse.Vector3(maidStoreData["position"]); maid.transform.rotation = Parse.Quaternion(maidStoreData["rotation"]); maid.transform.localScale = Parse.Vector3(maidStoreData["scale"]); if (bool.Parse(maidStoreData["visible"])) { maid.transform.GetChild(0).localScale = Vector3.one; } else { maid.transform.GetChild(0).localScale = Vector3.zero; } this.transtarget_maid_dic_.Add(maid, new PhotoTransTargetObject(maid.gameObject, string.Empty, string.Empty, PhotoTransTargetObject.Type.Maid, new Vector2(this.PartsTransForm.ScaleInput.SliderMin, this.PartsTransForm.ScaleInput.SliderMax))); if (GameMain.Instance.VRMode) { MeshRenderer componentInChildren = this.transtarget_maid_dic_[maid].axis_obj.GetComponentInChildren(); if (componentInChildren != null) { componentInChildren.enabled = false; } BoxCollider[] componentsInChildren = this.transtarget_maid_dic_[maid].axis_obj.GetComponentsInChildren(); foreach (BoxCollider boxCollider in componentsInChildren) { boxCollider.enabled = false; } } if (maid.boMAN) { return; } MaidColliderCollect maidColliderCollect = MaidColliderCollect.AddColliderCollect(maid); List list = maidColliderCollect.AddCollider(MaidColliderCollect.ColliderType.Grab); for (int j = 0; j < list.Count; j++) { ColliderEvent colliderEvent = list[j].gameObject.AddComponent(); colliderEvent.onMouseUp = new Action(maid.OnMouseUp); this.maid_casule_collider_hash_.Add(list[j].GetInstanceID(), list[j]); } using (Dictionary.Enumerator enumerator = this.maid_casule_collider_hash_.GetEnumerator()) { if (enumerator.MoveNext()) { KeyValuePair keyValuePair = enumerator.Current; keyValuePair.Value.enabled = true; } } maid.onMouseUpEvent = new Action(this.OnMouseUpFromMaid); } private void OnMouseUpFromMaid(Maid maid) { if (Input.GetKey(KeyCode.Tab) && base.mgr.select_maid != maid) { this.SetSelectMaid(maid); MouseExposition @object = MouseExposition.GetObject(); string draw_text = maid.status.firstName + " " + maid.status.lastName + "を選択しました"; @object.SetText(draw_text, 2f); } } private void UpdateList() { HashSet hashSet = new HashSet(); for (int i = 0; i < this.chara_mgr_.GetMaidCount(); i++) { Maid maid = this.chara_mgr_.GetMaid(i); if (!(maid == null)) { if (!hashSet.Contains(maid.status.guid)) { hashSet.Add(maid.status.guid); } } } for (int j = 0; j < this.chara_mgr_.GetManCount(); j++) { Maid man = this.chara_mgr_.GetMan(j); if (!(man == null) && man.Visible) { if (!hashSet.Contains(man.status.guid)) { hashSet.Add(man.status.guid); } } } for (int k = 0; k < this.maid_data_list_.Count; k++) { if (hashSet.Contains(this.maid_data_list_[k].maid.status.guid)) { this.maid_data_list_[k].btn.isEnabled = false; this.maid_data_list_[k].select_btn.isEnabled = true; if (base.mgr.select_maid == this.maid_data_list_[k].maid) { this.maid_data_list_[k].select_btn.SetSelect(true); } else { this.maid_data_list_[k].select_btn.SetSelect(false); } } else { this.maid_data_list_[k].btn.isEnabled = true; this.maid_data_list_[k].select_btn.SetSelect(false); this.maid_data_list_[k].select_btn.isEnabled = false; } } } public void OnClickMaid() { if (this.chara_mgr_.IsBusy()) { return; } PlacementWindow.PlateData plateData = null; for (int i = 0; i < this.maid_data_list_.Count; i++) { if (this.maid_data_list_[i].select_btn == UIButton.current) { plateData = this.maid_data_list_[i]; break; } } if (plateData == null) { return; } this.SetSelectMaid(plateData.maid); } private void OnClickPlacementBtn() { if (this.chara_mgr_.IsBusy()) { return; } PlacementWindow.PlateData plateData = null; for (int i = 0; i < this.maid_data_list_.Count; i++) { if (!(UIButton.current != this.maid_data_list_[i].btn)) { plateData = this.maid_data_list_[i]; break; } } bool flag = false; for (int j = 0; j < this.GetMaidOrManCount(plateData.maid); j++) { if (this.GetMaidOrMan(plateData.maid, j) == plateData.maid) { flag = true; break; } } if (flag && plateData.maid.boMAN && !plateData.maid.Visible) { flag = false; } if (flag) { this.DeActiveMaid(plateData.maid, false); } else { int num = 0; if (!plateData.maid.boMAN) { for (int k = 0; k < this.GetMaidOrManCount(plateData.maid); k++) { num += ((!(this.GetMaidOrMan(plateData.maid, k) != null)) ? 0 : 1); } } else { for (int l = 0; l < this.GetMaidOrManCount(plateData.maid); l++) { if (this.GetMaidOrMan(plateData.maid, l) != null && plateData.maid.Visible) { num++; } } } if (!plateData.maid.boMAN && 12 <= num) { GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/キャラ選択/ダイアログ/これ以上メイドを配置する事はできません", null, SystemDialog.TYPE.OK, null, null); } else if (plateData.maid.boMAN && 5 <= num) { GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/キャラ選択/ダイアログ/これ以上男を配置する事はできません", null, SystemDialog.TYPE.OK, null, null); } else { this.ActiveMaid(plateData.maid); } } } private void ActiveMaid(Maid maid) { if (maid == null) { return; } List list = new List(); uint num = 0u; for (int i = 0; i < this.active_maid_list_.Count; i++) { if (this.active_maid_list_[i].maid == maid) { list.Add(this.active_maid_list_[i]); } if (num < this.active_maid_list_[i].sort_no) { num = this.active_maid_list_[i].sort_no; } } for (int j = 0; j < list.Count; j++) { this.active_maid_list_.Remove(list[j]); } this.active_maid_list_.Sort(); int k = 0; while (k < this.GetMaidOrManCount(maid)) { if (!maid.boMAN) { if (!(this.GetMaidOrMan(maid, k) != null)) { goto IL_107; } } else if (!(this.GetMaidOrMan(maid, k) != maid)) { goto IL_107; } k++; continue; IL_107: this.SetActiveMaidOrMan(maid, k); maid.Visible = true; maid.AllProcPropSeqStart(); PlacementWindow.MaidSlotData maidSlotData = new PlacementWindow.MaidSlotData(); maidSlotData.maid = maid; maidSlotData.sort_no = num + 1u; maidSlotData.slot_no = k; this.new_load_maid_data_list_.Add(maidSlotData); break; } if (this.chara_mgr_.IsBusy()) { GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color)); } } public void DeActiveMaid(Maid maid, bool on_reset_call = false) { if (this.chara_mgr_.IsBusy() || maid == null) { return; } List list = new List(); for (int i = 0; i < this.active_maid_list_.Count; i++) { if (this.active_maid_list_[i].maid == maid) { list.Add(this.active_maid_list_[i]); } } bool flag = false; for (int j = 0; j < list.Count; j++) { if (list[j].maid == base.mgr.select_maid) { flag = true; } this.active_maid_list_.Remove(list[j]); } this.active_maid_list_.Sort(); if (flag) { if (0 < this.active_maid_list_.Count && !on_reset_call) { this.SetSelectMaid(this.active_maid_list_[0].maid); } else { this.SetSelectMaid(null); } } for (int k = 0; k < this.GetMaidOrManCount(maid); k++) { Maid maidOrMan = this.GetMaidOrMan(maid, k); if (maidOrMan == maid) { maidOrMan.transform.position = Vector3.zero; maidOrMan.transform.rotation = Quaternion.identity; maidOrMan.transform.localScale = Vector3.one; maidOrMan.transform.GetChild(0).localScale = Vector3.one; maidOrMan.ResetAll(); CapsuleCollider[] componentsInChildren = maid.GetComponentsInChildren(); if (componentsInChildren.Length == 0) { this.maid_casule_collider_hash_.Clear(); } for (int l = 0; l < componentsInChildren.Length; l++) { this.maid_casule_collider_hash_.Remove(componentsInChildren[l].GetInstanceID()); ColliderEvent component = componentsInChildren[l].GetComponent(); if (component != null) { UnityEngine.Object.Destroy(component); } UnityEngine.Object.Destroy(componentsInChildren[l]); } maid.onMouseUpEvent = null; base.mgr.OnMaidRemoveEventPrev(maid); if (!maid.boMAN) { this.DeactivateMaidOrMan(maid); } else { int m; for (m = 0; m < this.chara_mgr_.GetManCount(); m++) { if (this.chara_mgr_.GetMan(m) == maid) { break; } } this.chara_mgr_.CharaVisible(m, false, true); } base.mgr.OnMaidRemoveEvent(maid); break; } } } protected void OnChangeAxisVisibleType() { WindowPartsTransform.AxisVisibleType axis_visible_type = this.PartsTransForm.axis_visible_type; PhotoTransTargetObject photoTransTargetObject = null; foreach (KeyValuePair keyValuePair in this.transtarget_maid_dic_) { if (keyValuePair.Value.axis_obj != null) { keyValuePair.Value.axis_obj.Visible = false; } if (keyValuePair.Value.rotate_obj != null) { keyValuePair.Value.rotate_obj.Visible = false; } } if (base.mgr.select_maid != null) { photoTransTargetObject = this.transtarget_maid_dic_[base.mgr.select_maid]; } if (photoTransTargetObject == null || photoTransTargetObject.obj == null || photoTransTargetObject.axis_obj == null) { return; } if (axis_visible_type == WindowPartsTransform.AxisVisibleType.UnVisible) { photoTransTargetObject.axis_obj.Visible = false; photoTransTargetObject.rotate_obj.Visible = false; } else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Position) { photoTransTargetObject.axis_obj.Visible = true; photoTransTargetObject.rotate_obj.Visible = false; } else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Rotate) { photoTransTargetObject.axis_obj.Visible = false; photoTransTargetObject.rotate_obj.Visible = true; } } public void OnClickVisibleCheckButton(WFCheckBox check_box) { if (base.mgr.select_maid == null) { return; } if (check_box.check) { base.mgr.select_maid.gameObject.transform.GetChild(0).localScale = Vector3.one; } else { base.mgr.select_maid.gameObject.transform.GetChild(0).localScale = Vector3.zero; } } public void OnClickCameraFocus() { if (base.mgr.select_maid == null || base.mgr.select_maid.body0 == null) { return; } Transform bone; if (!base.mgr.select_maid.boMAN) { bone = base.mgr.select_maid.body0.GetBone("Bip01 Head"); } else { bone = base.mgr.select_maid.body0.GetBone("ManBip Head"); } Vector3 position = bone.position; float distance = 1.6f; Vector2 aroundAngle = new Vector2(-180f, 4.7f); this.camera_move_support_.StartCameraPosition(position, distance, aroundAngle); } public void OnClickDeActive() { this.DeActiveMaid(base.mgr.select_maid, false); } public override void OnReset() { for (int i = 0; i < this.chara_mgr_.GetMaidCount(); i++) { if (this.chara_mgr_.GetMaid(i) != null) { this.DeActiveMaid(this.chara_mgr_.GetMaid(i), true); } } for (int j = 0; j < this.chara_mgr_.GetManCount(); j++) { if (this.chara_mgr_.GetMan(j) != null && this.chara_mgr_.GetMan(j).Visible) { this.DeActiveMaid(this.chara_mgr_.GetMan(j), true); } } } public override void OnDeserializeEvent() { List maidStoreGuidList = base.mgr.GetMaidStoreGuidList(); for (int i = 0; i < maidStoreGuidList.Count; i++) { this.call_deserialize_ = true; Maid maid = GameMain.Instance.CharacterMgr.GetStockMaid(maidStoreGuidList[i]); if (maid == null) { maid = GameMain.Instance.CharacterMgr.GetStockMan(maidStoreGuidList[i]); } maid.transform.position = Vector3.zero; maid.transform.rotation = Quaternion.identity; maid.transform.localScale = Vector3.one; maid.transform.GetChild(0).localScale = Vector3.one; this.ActiveMaid(maid); } } private int GetMaidOrManCount(Maid maid) { return maid.boMAN ? this.chara_mgr_.GetManCount() : this.chara_mgr_.GetMaidCount(); } private Maid GetMaidOrMan(Maid maid, int slot_no) { return maid.boMAN ? this.chara_mgr_.GetMan(slot_no) : this.chara_mgr_.GetMaid(slot_no); } private void SetActiveMaidOrMan(Maid maid, int slot_no) { if (!maid.boMAN) { this.chara_mgr_.SetActiveMaid(maid, slot_no); } else { this.chara_mgr_.SetActiveMan(maid, slot_no); } } private void DeactivateMaidOrMan(Maid maid) { if (!maid.boMAN) { this.chara_mgr_.DeactivateMaid(maid); } else { this.chara_mgr_.DeactivateMan(maid); } } public Dictionary man_backup_data_dic { get { return this.man_backup_data_dic_; } } public List maid_list { get { List list = new List(); foreach (PlacementWindow.PlateData plateData in this.maid_data_list_) { list.Add(plateData.maid); } return list; } } public WindowPartsTransform PartsTransForm; public UIButton CameraFocusButton; public WFCheckBox VisibleCheckButton; public UIButton DeActiveButton; public UIButton CallEditButton; private bool is_first_; private WfCameraMoveSupport camera_move_support_; private CharacterMgr chara_mgr_; private List maid_data_list_ = new List(); private List active_maid_list_ = new List(); private Dictionary transtarget_maid_dic_ = new Dictionary(); private Dictionary maid_casule_collider_hash_ = new Dictionary(); private bool call_deserialize_; private List new_load_maid_data_list_ = new List(); private Dictionary man_backup_data_dic_ = new Dictionary(); [CompilerGenerated] private static Comparison <>f__mg$cache0; public struct ManDataBackup { public Color color; public float fat; public bool parts_visible; public int head_item_rid; } private class PlateData { public Maid maid; public Color def_btn_color; public SimpleMaidPlate plate; public UIButton btn; public UIWFTabButton select_btn; public UISprite bg_sprite; public UISprite select_frame; } private class MaidSlotData : IComparable { public int CompareTo(object obj) { if (obj == null) { return 1; } if (base.GetType() != obj.GetType()) { NDebug.Assert("error", false); } return this.sort_no.CompareTo(((PlacementWindow.MaidSlotData)obj).sort_no); } public Maid maid; public uint sort_no; public int slot_no; } }