using System; using System.Collections; using System.Collections.Generic; using com.workman.cm3d2.scene.dailyEtc; using UnityEngine; using wf; public class SceneUserEditMain : WfScreenChildren { public override void Awake() { base.Awake(); NDebug.Assert(this.colorSliders.Length == 3, "colorSliders配列は3つ,RGBとして設定してください"); EventDelegate.Add(this.playerNameInput.onChange, new EventDelegate.Callback(this.OnChangePlayerName)); EventDelegate.Add(this.alphaSlider.onChange, new EventDelegate.Callback(this.OnChangeAlphaSlider)); EventDelegate.Add(this.abdomenSlider.onChange, new EventDelegate.Callback(this.OnChangeAbdomenSlider)); this.colorPalette.onChangeValue.Clear(); this.colorPalette.onChangeValue.Add(new Action(this.OnChangeBodyColor)); foreach (UISlider uislider in this.colorSliders) { EventDelegate.Add(uislider.onChange, new EventDelegate.Callback(this.OnChangeSingleBodyColor)); } EventDelegate.Add(this.playerNameRandomButton.onClick, delegate() { this.playerNameInput.RemoveFocus(); this.playerNameInput.value = MaidRandomName.GetPlayerName(); }); EventDelegate.Add(this.okButton.onClick, new EventDelegate.Callback(this.OnClickOK)); } public void Start() { GameMain.Instance.StartCoroutine(this.SetupManEditManager()); } public void OnDestroy() { if (this.manEditManager != null) { this.manEditManager.Destroy(); this.manEditManager = null; } if (GameMain.Instance.MainCamera != null) { GameMain.Instance.MainCamera.SetTargetOffset(Vector3.zero, false); } } private IEnumerator SetupManEditManager() { GameMain.Instance.LoadIcon.NextLoadIcontImmediatelyDisplay(); GameMain.Instance.LoadIcon.force_draw_new = true; do { yield return null; } while (!GameMain.Instance.MenuDataBase.JobFinished()); GameMain.Instance.LoadIcon.force_draw_new = false; this.manEditManager = new PhotoManEditManager(); List[] itemLists = new List[] { this.manEditManager.man_head_menu_list, this.manEditManager.man_body_menu_list }; UIWFTabPanel[] tagetPanels = new UIWFTabPanel[] { this.HeadItemTabPanel, this.BodyItemTabPanel }; EventDelegate.Callback[] callBackFunctions = new EventDelegate.Callback[] { new EventDelegate.Callback(this.OnSelectManHeadItem), new EventDelegate.Callback(this.OnSelectManHeadItem) }; for (int i = 0; i < itemLists.Length; i++) { UIWFTabPanel uiwftabPanel = tagetPanels[i]; EventDelegate.Callback callback = callBackFunctions[i]; foreach (SceneEdit.SMenuItem smenuItem in itemLists[i]) { GameObject gameObject = Utility.CreatePrefab(uiwftabPanel.gameObject, "ScenePhotoMode/EditItemIcon", true); if (smenuItem.m_texIconRef != null) { Sprite sprite2D = Sprite.Create(smenuItem.m_texIconRef, new Rect(0f, 0f, (float)smenuItem.m_texIconRef.width, (float)smenuItem.m_texIconRef.height), default(Vector2)); UI2DSprite componentInChildren = gameObject.GetComponentInChildren(); componentInChildren.sprite2D = sprite2D; componentInChildren.SetDimensions(smenuItem.m_texIconRef.width, smenuItem.m_texIconRef.height); UISprite component = UTY.GetChildObject(gameObject, "Frame", false).GetComponent(); component.SetDimensions(74, 74); } UIWFTabButton component2 = gameObject.GetComponent(); component2.name = smenuItem.m_nMenuFileRID.ToString(); EventDelegate.Add(component2.onSelect, callback); } Utility.ResetNGUI(uiwftabPanel.GetComponent()); Utility.ResetNGUI(uiwftabPanel.transform.parent.GetComponent()); uiwftabPanel.UpdateChildren(); } do { yield return null; } while (!this.calledOnCallEvent && GameMain.Instance.CharacterMgr.IsBusy()); this.CallAfter(); this.completedSetUp = true; yield break; } protected override void OnCall() { this.calledOnCallEvent = true; } protected void CallAfter() { this.fadeWaitCount = 0; GameMain.Instance.MainLight.Reset(); GameMain.Instance.CharacterMgr.ResetCharaPosAll(); GameMain.Instance.CharacterMgr.DeactivateCharaAll(); GameUtility.ResetCameraZero(); if (!(base.parent_mgr as SceneUserEditManager).isFirstEdist) { this.playerNameInput.GetComponent().enabled = false; this.playerNameRandomButton.gameObject.SetActive(false); } if (GameMain.Instance.CharacterMgr.status.isDaytime) { GameMain.Instance.BgMgr.ChangeBg(DailyAPI.dayBg); } else { GameMain.Instance.BgMgr.ChangeBg(DailyAPI.nightBg); } GameMain.Instance.SoundMgr.PlayBGM(this.bgmFile, 0.5f, true); CameraMain mainCamera = GameMain.Instance.MainCamera; mainCamera.Reset(CameraMain.CameraType.Target, true); mainCamera.SetTargetPos(new Vector3(0.08306749f, 1.299064f, 0.0249091f), true); mainCamera.SetDistance(2.2f, true); mainCamera.SetAroundAngle(new Vector2(177.9044f, 2.546583f), true); mainCamera.SetTargetOffset(new Vector3((float)Screen.width / 3f * 2f - (float)Screen.width / 2f, 0f, 0f), false); Maid man = GameMain.Instance.CharacterMgr.GetMan(0); this.manController = new PhotoManEditManager.Controller(man); man.Visible = true; man.AllProcProp(); man.body0.SetChinkoVisible(false); string fn = "man_porse01.anm"; man.CrossFade(fn, false, true, false, 0f, 1f); this.playerNameInput.value = GameMain.Instance.CharacterMgr.status.playerName; string b = man.GetProp("head").nFileNameRID.ToString(); UIWFTabButton[] componentsInChildren = this.HeadItemTabPanel.GetComponentsInChildren(); foreach (UIWFTabButton uiwftabButton in componentsInChildren) { if (uiwftabButton.name == b) { this.HeadItemTabPanel.Select(uiwftabButton); break; } } string b2 = man.GetProp("body").nFileNameRID.ToString(); UIWFTabButton[] componentsInChildren2 = this.BodyItemTabPanel.GetComponentsInChildren(); foreach (UIWFTabButton uiwftabButton2 in componentsInChildren2) { if (uiwftabButton2.name == b2) { this.BodyItemTabPanel.Select(uiwftabButton2); break; } } this.alphaSlider.value = (float)this.manController.alpha / 100f; this.alphaLabel.text = this.manController.alpha.ToString(); this.abdomenSlider.value = this.manController.fat; float num = (float)System.Math.Round((double)this.manController.fat, 2, MidpointRounding.AwayFromZero) * 100f; this.abdomenLabel.text = num.ToString(); this.colorPalette.SetColor(this.manController.color); uGUITutorialPanel.OpenTutorial("SceneUserEdit", null, false); } public void UpdateBodyColorNumText() { if (this.manController == null) { return; } float[] array = new float[] { this.manController.color.r, this.manController.color.g, this.manController.color.b }; for (int i = 0; i < this.colorLabels.Length; i++) { float num = (float)System.Math.Round((double)array[i], 4, MidpointRounding.AwayFromZero); int num2 = (int)(num * 255f); this.colorLabels[i].text = num2.ToString(); } } protected override bool IsCallFadeIn() { this.fadeWaitCount++; return 2 < this.fadeWaitCount && this.completedSetUp; } private void OnChangePlayerName() { GameMain.Instance.CharacterMgr.status.playerName = this.playerNameInput.value; if (this.playerNameInput.value != GameMain.Instance.CharacterMgr.status.playerName) { this.playerNameInput.value = GameMain.Instance.CharacterMgr.status.playerName; } } public void OnSelectManHeadItem() { UIWFSelectButton current = UIWFSelectButton.current; if (this.manController == null || !current.isSelected) { return; } bool flag = false; int num = int.Parse(current.name); List[] array = new List[] { this.manEditManager.man_head_menu_list, this.manEditManager.man_body_menu_list }; foreach (List list in array) { foreach (SceneEdit.SMenuItem smenuItem in list) { if (num == smenuItem.m_nMenuFileRID) { this.manController.SetMenu(smenuItem); flag = (smenuItem.m_mpn == MPN.head); break; } } } if (!flag) { string fn = "man_porse01.anm"; this.manController.man.CrossFade(fn, false, true, false, 0f, 1f); } } public override void Update() { base.Update(); if (this.manController == null) { return; } if (this.manController.alpha.ToString() != this.alphaLabel.text) { this.alphaSlider.value = (float)this.manController.alpha / 100f; } } private void OnChangeAlphaSlider() { if (this.manController == null) { return; } int alpha = (int)System.Math.Ceiling((double)(this.alphaSlider.value * 100f)); this.manController.alpha = alpha; this.alphaLabel.text = alpha.ToString(); } private void OnChangeAbdomenSlider() { if (this.manController == null) { return; } this.manController.fat = (float)System.Math.Round((double)this.abdomenSlider.value, 2, MidpointRounding.AwayFromZero); float num = (float)System.Math.Round((double)this.manController.fat, 2, MidpointRounding.AwayFromZero); float num2 = num * 100f; this.abdomenLabel.text = num2.ToString(); } private void OnChangeBodyColor(Color color) { if (this.manController == null) { return; } this.manController.color = color; color = this.manController.color; float[] array = new float[] { color.r, color.g, color.b }; for (int i = 0; i < this.colorSliders.Length; i++) { List onChange = this.colorSliders[i].onChange; this.colorSliders[i].onChange = new List(); this.colorSliders[i].value = array[i]; this.colorSliders[i].onChange = onChange; } this.UpdateBodyColorNumText(); } private void OnChangeSingleBodyColor() { if (this.manController == null) { return; } Color color = new Color(this.colorSliders[0].value, this.colorSliders[1].value, this.colorSliders[2].value); this.manController.color = color; color = this.manController.color; List> onChangeValue = this.colorPalette.onChangeValue; this.colorPalette.onChangeValue = new List>(); this.colorPalette.SetColor(color); this.colorPalette.onChangeValue = onChangeValue; this.UpdateBodyColorNumText(); } protected override void OnFinish() { if (this.manController != null && this.manController.man != null) { this.manController.man.Visible = false; } base.parent_mgr.CallScreen("Move"); } public void OnClickOK() { this.Finish(); } [SerializeField] private string bgmFile = "BGM009.ogg"; [SerializeField] private UIInput playerNameInput; [SerializeField] private UIButton playerNameRandomButton; [SerializeField] private UIWFTabPanel HeadItemTabPanel; [SerializeField] private UIWFTabPanel BodyItemTabPanel; [SerializeField] private UISlider alphaSlider; [SerializeField] private UILabel alphaLabel; [SerializeField] private UISlider abdomenSlider; [SerializeField] private UILabel abdomenLabel; [SerializeField] private ColorrPaletteParts colorPalette; [SerializeField] private UISlider[] colorSliders; [SerializeField] private UILabel[] colorLabels; [SerializeField] private UIButton okButton; private PhotoManEditManager manEditManager; private PhotoManEditManager.Controller manController; private int fadeWaitCount; private bool calledOnCallEvent; private bool completedSetUp; }