using System; using System.Collections.Generic; using I2.Loc; using UnityEngine; using wf; public class ObjectManagerWindow : BaseMaidPhotoWindow { public override void Awake() { base.Awake(); this.camera_move_support_ = base.gameObject.AddComponent(); this.scroll_view_ = NGUITools.FindInParents(this.Grid.transform); EventDelegate.Add(this.CameraFocusButton.onClick, new EventDelegate.Callback(this.OnClickCameraFocus)); this.VisibleCheckButton.onClick.Add(delegate(WFCheckBox check_box) { if (this.select_trans_target_ != null && this.select_trans_target_.obj != null) { this.select_trans_target_.obj.SetActive(check_box.check); } }); EventDelegate.Add(this.RemoveButton.onClick, delegate() { if (this.select_trans_target_.obj == null || this.select_trans_target_.type == PhotoTransTargetObject.Type.BG) { return; } this.createBgObjectWindow.RemoveObject(this.select_trans_target_.obj); }); this.CheckCreateWindowVisible.onClick.Add(delegate(WFCheckBox check_box) { this.createBgObjectWindow.visible = check_box.check; if (check_box.check) { this.CheckAttacWindowVisible.check = false; this.AttachPointWindow.visible = false; } }); this.createBgObjectWindow.GetButtonOnClickEventList(BasePhotoSubWindow.BtnType.End).Add(delegate { this.CheckCreateWindowVisible.check = false; foreach (Action action in this.CheckCreateWindowVisible.onClick) { action(this.CheckCreateWindowVisible); } }); this.createBgObjectWindow.SetButtonEnabled(BasePhotoSubWindow.BtnType.End, true, false); this.AttachPointWindow.onStateTextChangeEvent = delegate(string text) { this.AttachPointStateLabel.text = text; if (GameUty.supportMultiLanguage) { string termPrefix = string.Empty; string term; if (text.LastIndexOf(" : ") != -1) { int num = text.LastIndexOf(" : ") + 3; termPrefix = text.Substring(0, num); term = "ScenePhotoMode/アタッチポイント/" + text.Substring(num); } else { term = "ScenePhotoMode/アタッチポイント/" + text; } Localize component = this.AttachPointStateLabel.GetComponent(); if (component != null) { component.TermPrefix = termPrefix; component.SetTerm(term); } } }; this.AttachPointWindow.gameObject.SetActive(true); WFCheckBox checkAttacWindowVisible = this.CheckAttacWindowVisible; bool flag = false; this.CheckAttacWindowVisible.enabled = flag; checkAttacWindowVisible.check = flag; this.AttachPointWindow.SetButtonEnabled(BasePhotoSubWindow.BtnType.End, true, false); this.AttachPointWindow.GetButtonOnClickEventList(BasePhotoSubWindow.BtnType.End).Add(delegate { this.CheckAttacWindowVisible.check = false; foreach (Action action in this.CheckAttacWindowVisible.onClick) { action(this.CheckAttacWindowVisible); } }); this.CheckAttacWindowVisible.onClick.Add(delegate(WFCheckBox check_box) { this.AttachPointWindow.visible = check_box.check; if (check_box.check) { this.CheckCreateWindowVisible.check = false; this.createBgObjectWindow.visible = false; } }); this.PartsTransForm.onChangeAxisVisibleType.Add(new Action(this.OnChangeAxisVisibleType)); this.target_list_.Add(new PhotoTransTargetObject(null, "選択なし", "ScenePhotoMode/選択なし", PhotoTransTargetObject.Type.Maid, Vector2.zero)); this.CreateTabButton(this.Grid.gameObject, this.target_list_[0]); this.TabPanel.UpdateChildren(); this.TabPanel.Select(this.Grid.GetChild(0).gameObject.GetComponent()); this.Grid.sorting = UIGrid.Sorting.Vertical; Utility.ResetNGUI(this.Grid); Utility.ResetNGUI(this.scroll_view_); this.UpdateChildren(); } public override void Start() { base.Start(); this.AttachPointWindow.gameObject.SetActive(false); } public new void Update() { if (Input.GetKeyDown(KeyCode.F3)) { this.PartsTransForm.NextAxis(); } if (Input.GetKeyDown(KeyCode.F4) && this.CameraFocusButton.isEnabled) { this.OnClickCameraFocus(); } } public void OnSelectItem(PhotoTransTargetObject select) { this.select_trans_target_ = select; if (select == null) { return; } if (select.obj == null || select.type == PhotoTransTargetObject.Type.BG) { this.RemoveButton.gameObject.SetActive(false); this.AttachPointWindow.gameObject.SetActive(false); WFCheckBox checkAttacWindowVisible = this.CheckAttacWindowVisible; bool flag = false; this.CheckAttacWindowVisible.visible = flag; flag = flag; this.CheckAttacWindowVisible.check = flag; checkAttacWindowVisible.enabled = flag; this.AttachPointWindow.onStateTextChangeEvent("設定不可"); } else { this.RemoveButton.gameObject.SetActive(true); this.AttachPointWindow.gameObject.SetActive(true); this.CheckAttacWindowVisible.enabled = (this.AttachPointWindow.activeMaidListCount != 0); this.CheckAttacWindowVisible.visible = true; this.CheckAttacWindowVisible.check = this.AttachPointWindow.visible; foreach (Action action in this.CheckAttacWindowVisible.onClick) { action(this.CheckAttacWindowVisible); } } if (select != null && select.obj != null && select.axis_obj != null && select.rotate_obj != null) { select.axis_obj.Visible = (select.rotate_obj.Visible = false); } if (select.obj != null) { UIButtonColor cameraFocusButton = this.CameraFocusButton; bool flag = true; this.VisibleCheckButton.enabled = flag; cameraFocusButton.isEnabled = flag; this.VisibleCheckButton.check = select.obj.activeSelf; if (select.type == PhotoTransTargetObject.Type.BG) { this.VisibleCheckButton.visible = false; } else { this.VisibleCheckButton.visible = true; } } else { this.VisibleCheckButton.visible = false; UIButtonColor cameraFocusButton2 = this.CameraFocusButton; bool flag = false; this.VisibleCheckButton.check = flag; flag = flag; this.VisibleCheckButton.enabled = flag; cameraFocusButton2.isEnabled = flag; } this.PartsTransForm.SetObject(select.obj, Vector3.zero, Vector3.zero, Vector3.one); this.OnChangeAxisVisibleType(); this.AttachPointWindow.OnSelectItem(select); } public override void OnMaidAddEvent(Maid maid, bool is_deserialize_load) { if (is_deserialize_load) { foreach (PhotoTransTargetObject photoTransTargetObject in this.target_list_) { if (!string.IsNullOrEmpty(photoTransTargetObject.attach_maid_guid) && !(photoTransTargetObject.attach_maid_guid != maid.status.guid)) { Transform transform = photoTransTargetObject.obj.transform; Vector3 position = transform.position; Quaternion rotation = transform.rotation; photoTransTargetObject.Attach(photoTransTargetObject.attachi_point, false, maid); transform.localPosition = photoTransTargetObject.attachi_local_pos; transform.localRotation = photoTransTargetObject.attachi_local_rotate; } } } this.AttachPointWindow.OnMaidAddEvent(maid, is_deserialize_load); if (this.CheckAttacWindowVisible.visible) { this.CheckAttacWindowVisible.enabled = (this.AttachPointWindow.activeMaidListCount != 0); } } public override void OnMaidRemoveEventPrev(Maid maid) { List list = new List(); foreach (PhotoTransTargetObject photoTransTargetObject in this.target_list_) { if (photoTransTargetObject.attachi_point != PhotoTransTargetObject.AttachPoint.Null && photoTransTargetObject.attach_maid_guid == maid.status.guid) { list.Add(photoTransTargetObject.obj); } } for (int i = 0; i < list.Count; i++) { this.createBgObjectWindow.RemoveObject(list[i]); } this.AttachPointWindow.OnMaidRemoveEventPrev(maid); if (this.AttachPointWindow.activeMaidList.Count <= 0) { this.CheckAttacWindowVisible.check = false; foreach (Action action in this.CheckAttacWindowVisible.onClick) { action(this.CheckAttacWindowVisible); } } if (this.CheckAttacWindowVisible.visible) { this.CheckAttacWindowVisible.enabled = (this.AttachPointWindow.activeMaidListCount != 0); } } public PhotoTransTargetObject AddTransTargetObject(GameObject target_obj, string draw_name, string nameTerm, PhotoTransTargetObject.Type type) { if (target_obj == null) { return null; } PhotoTransTargetObject photoTransTargetObject = new PhotoTransTargetObject(target_obj, draw_name, nameTerm, type, new Vector2(this.PartsTransForm.ScaleInput.SliderMin, this.PartsTransForm.ScaleInput.SliderMax)); if (GameMain.Instance.VRMode && type != PhotoTransTargetObject.Type.BG) { MeshRenderer componentInChildren = photoTransTargetObject.axis_obj.GetComponentInChildren(); if (componentInChildren != null) { componentInChildren.enabled = false; } BoxCollider[] componentsInChildren = photoTransTargetObject.axis_obj.GetComponentsInChildren(); foreach (BoxCollider boxCollider in componentsInChildren) { boxCollider.enabled = false; } } this.target_list_.Add(photoTransTargetObject); this.target_list_.Sort(); UIWFTabButton uiwftabButton = this.CreateTabButton(this.Grid.gameObject, photoTransTargetObject); UIEventTrigger[] componentsInChildren2 = uiwftabButton.gameObject.GetComponentsInChildren(); List onPress = this.Grid.GetChild(0).GetComponent().onPress; for (int j = 0; j < componentsInChildren2.Length; j++) { componentsInChildren2[j].onPress = onPress; } Dictionary dictionary = new Dictionary(); List childList = this.Grid.GetChildList(); for (int k = 0; k < childList.Count; k++) { dictionary.Add(childList[k].name, childList[k].transform); } for (int l = 0; l < this.target_list_.Count; l++) { if (dictionary.ContainsKey(this.target_list_[l].guid)) { dictionary[this.target_list_[l].guid].localPosition = new Vector3(0f, (float)(l * 10), 0f); } } this.TabPanel.UpdateChildren(); this.Grid.Reposition(); this.scroll_view_.UpdatePosition(); if (this.change_bg_ && type == PhotoTransTargetObject.Type.BG) { this.TabPanel.Select(uiwftabButton); this.change_bg_ = false; } return photoTransTargetObject; } public void RemoveTransTargetObject(GameObject target_obj) { if (target_obj == null) { return; } bool flag = false; this.change_bg_ = false; UIWFTabButton selectButtonObject = this.TabPanel.GetSelectButtonObject(); string text = string.Empty; for (int i = 0; i < this.target_list_.Count; i++) { if (this.target_list_[i].obj == target_obj) { flag = (this.target_list_[i].type == PhotoTransTargetObject.Type.BG); if (flag && selectButtonObject != null && this.target_list_[i].guid == selectButtonObject.name) { this.change_bg_ = true; } text = this.target_list_[i].guid; this.target_list_[i].Delete(); this.target_list_.RemoveAt(i); break; } } if (!string.IsNullOrEmpty(text)) { if (selectButtonObject != null && selectButtonObject.name == text) { List childList = this.Grid.GetChildList(); for (int j = 0; j < childList.Count; j++) { if (childList[j].name == text) { if (j + 1 < childList.Count) { this.TabPanel.Select(this.Grid.GetChild(j + 1).gameObject.GetComponent()); } else { this.TabPanel.Select(this.Grid.GetChild(j - 1).gameObject.GetComponent()); } break; } } } List childList2 = this.Grid.GetChildList(); for (int k = 0; k < childList2.Count; k++) { if (childList2[k].gameObject.name == text) { childList2[k].gameObject.transform.SetParent(null, false); UnityEngine.Object.Destroy(childList2[k].gameObject); } } int num = 12; if (flag) { num--; } Utility.ResetNGUI(this.Grid); if (this.Grid.GetChildList().Count <= num) { Utility.ResetNGUI(this.scroll_view_); } else { this.scroll_view_.UpdatePosition(); this.scroll_view_.UpdateScrollbars(); } this.TabPanel.UpdateChildren(); } } protected void OnChangeAxisVisibleType() { WindowPartsTransform.AxisVisibleType axis_visible_type = this.PartsTransForm.axis_visible_type; for (int i = 0; i < this.target_list_.Count; i++) { PhotoTransTargetObject photoTransTargetObject = this.target_list_[i]; if (photoTransTargetObject != null && !(photoTransTargetObject.obj == null)) { if (axis_visible_type == WindowPartsTransform.AxisVisibleType.UnVisible || photoTransTargetObject == null || photoTransTargetObject.obj == null || photoTransTargetObject != this.select_trans_target_) { if (photoTransTargetObject.axis_obj != null) { photoTransTargetObject.axis_obj.Visible = false; } if (photoTransTargetObject.rotate_obj != null) { photoTransTargetObject.rotate_obj.Visible = false; } } else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Position) { if (photoTransTargetObject.axis_obj != null) { photoTransTargetObject.axis_obj.Visible = true; } if (photoTransTargetObject.rotate_obj != null) { photoTransTargetObject.rotate_obj.Visible = false; } } else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Rotate) { if (photoTransTargetObject.axis_obj != null) { photoTransTargetObject.axis_obj.Visible = false; } if (photoTransTargetObject.rotate_obj != null) { photoTransTargetObject.rotate_obj.Visible = true; } } } } } public void OnClickCameraFocus() { if (this.select_trans_target_ == null || this.select_trans_target_.obj == null) { return; } Vector3 position = this.select_trans_target_.obj.transform.position; float distance = 4f; Vector2 aroundAngle = new Vector2(-180f, 4.7f); this.camera_move_support_.StartCameraPosition(position, distance, aroundAngle); } private UIWFTabButton CreateTabButton(GameObject parent_obj, PhotoTransTargetObject target) { GameObject gameObject = Utility.CreatePrefab(parent_obj, "ScenePhotoMode/WindowListItem", true); gameObject.name = target.guid.ToString(); gameObject.GetComponentInChildren().text = target.draw_name; Localize componentInChildren = gameObject.GetComponentInChildren(); if (componentInChildren != null && GameUty.supportMultiLanguage) { componentInChildren.SetTerm(target.nameTerm); } UIWFTabButton component = gameObject.GetComponent(); EventDelegate.Add(component.onSelect, delegate() { if (!UIWFSelectButton.current.isSelected) { return; } for (int i = 0; i < this.target_list_.Count; i++) { if (this.target_list_[i].guid == UIWFSelectButton.current.name) { this.OnSelectItem(this.target_list_[i]); break; } } }); return component; } public override void OnSerializeEvent() { Dictionary> woldStoreData = base.GetWoldStoreData(); woldStoreData.Clear(); this.createBgObjectWindow.OnSerializeEvent(ref woldStoreData); foreach (PhotoTransTargetObject photoTransTargetObject in this.target_list_) { if (!(photoTransTargetObject.obj == null) && photoTransTargetObject.type != PhotoTransTargetObject.Type.BG) { Dictionary dictionary = woldStoreData[photoTransTargetObject.obj.name]; dictionary["attachi_point"] = photoTransTargetObject.attachi_point.ToString(); dictionary["attachi_maid_guid"] = photoTransTargetObject.attach_maid_guid.ToString(); dictionary["attachi_local_pos"] = photoTransTargetObject.obj.transform.localPosition.ToString("G9"); dictionary["attachi_local_rotation"] = photoTransTargetObject.obj.transform.localRotation.ToString("G9"); } } } public override void OnDeserializeEvent() { Dictionary> woldStoreData = base.GetWoldStoreData(); List list = new List(); foreach (KeyValuePair> keyValuePair in woldStoreData) { string key = keyValuePair.Key; Dictionary value = keyValuePair.Value; string text = value["attachi_maid_guid"]; if (!string.IsNullOrEmpty(text)) { if (!PhotoWindowManager.maidGuidReplaceDic.ContainsKey(text)) { value["attachi_maid_guid"] = text; } else if (string.IsNullOrEmpty(PhotoWindowManager.maidGuidReplaceDic[text])) { list.Add(key); } else { value["attachi_maid_guid"] = PhotoWindowManager.maidGuidReplaceDic[text]; } } } foreach (string key2 in list) { woldStoreData.Remove(key2); } this.createBgObjectWindow.OnDeserializeEvent(ref woldStoreData); foreach (KeyValuePair> keyValuePair2 in woldStoreData) { string key3 = keyValuePair2.Key; Dictionary value2 = keyValuePair2.Value; string text2 = value2["attachi_maid_guid"]; PhotoTransTargetObject.AttachPoint attachi_point = (PhotoTransTargetObject.AttachPoint)Enum.Parse(typeof(PhotoTransTargetObject.AttachPoint), value2["attachi_point"]); Vector3 attachi_local_pos = Parse.Vector3(value2["attachi_local_pos"]); Quaternion attachi_local_rotate = Parse.Quaternion(value2["attachi_local_rotation"]); if (!string.IsNullOrEmpty(text2)) { for (int i = 0; i < this.target_list_.Count; i++) { if (this.target_list_[i].obj != null && this.target_list_[i].obj.name == key3) { this.target_list_[i].attach_maid_guid = text2; this.target_list_[i].attachi_point = attachi_point; this.target_list_[i].attachi_local_pos = attachi_local_pos; this.target_list_[i].attachi_local_rotate = attachi_local_rotate; break; } } } } this.TabPanel.Select(this.Grid.GetChild(0).gameObject.GetComponent()); this.Grid.Reposition(); this.scroll_view_.ResetPosition(); } public override KeyValuePair> Serialize() { KeyValuePair> result = base.Serialize(); Dictionary value = result.Value; this.AttachPointWindow.Serialize(ref value); result = new KeyValuePair>(result.Key, value); return result; } public override void Deserialize(Dictionary> data) { base.Deserialize(data); string key = base.gameObject.name + "title"; if (!data.ContainsKey(key)) { return; } Dictionary deserializeData = data[key]; this.AttachPointWindow.Deserialize(deserializeData); this.CheckCreateWindowVisible.check = this.createBgObjectWindow.visible; } public WFCheckBox CheckCreateWindowVisible; public CreateBGObjectSubWindow createBgObjectWindow; public WFCheckBox CheckAttacWindowVisible; public AttachPointSubWindow AttachPointWindow; public UILabel AttachPointStateLabel; public UIButton RemoveButton; public UIGrid Grid; public UIWFTabPanel TabPanel; public WindowPartsTransform PartsTransForm; public UIButton CameraFocusButton; public WFCheckBox VisibleCheckButton; private List target_list_ = new List(); private bool change_bg_; private PhotoTransTargetObject select_trans_target_; private WfCameraMoveSupport camera_move_support_; private UIScrollView scroll_view_; }