123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using wf;
- public class CostumePartsEnabledCtrl : MonoBehaviour
- {
- public void Init(GameObject goCostumePartsEnabledPanel)
- {
- if (this.m_sceneEdit != null)
- {
- return;
- }
- this.m_sceneEdit = GameObject.Find("__SceneEdit__").GetComponent<SceneEdit>();
- foreach (MPN key in this.m_sceneEdit.enabledMpns)
- {
- this.testForced.Add(key, true);
- }
- this.m_notSettingIcon = (Resources.Load("SceneEdit/RandomPreset/Texture/_I_del") as Texture2D);
- this.CreateRandomItem(goCostumePartsEnabledPanel);
- this.LoadMaidPropData();
- }
- public void CreateRandomItem(GameObject goRandomPresetPanel)
- {
- Dictionary<MPN, SceneEditInfo.CCateNameType> dicPartsTypePair = SceneEditInfo.m_dicPartsTypePair;
- this.m_dicItemBtn = new Dictionary<string, RandomPresetButton>();
- bool flag = false;
- foreach (KeyValuePair<MPN, SceneEditInfo.CCateNameType> keyValuePair in dicPartsTypePair)
- {
- RandomPresetContent.MPNMapping mpnmapping;
- if (RandomPresetContent.m_dicMPNMapping.TryGetValue(keyValuePair.Key, out mpnmapping))
- {
- string text;
- if (RandomPresetContent.m_dicCategoryMapping.TryGetValue(keyValuePair.Value.m_eMenuCate, out text))
- {
- GameObject childObject = UTY.GetChildObject(goRandomPresetPanel, "Contents/Buttons/" + mpnmapping.m_buttonName, true);
- if (!(childObject == null))
- {
- childObject.SetActive(false);
- NDebug.Assert(childObject != null, string.Concat(new string[]
- {
- "ランダムプリセットのボタン[",
- mpnmapping.m_buttonTitle,
- "]のオブジェクト、[",
- mpnmapping.m_buttonName,
- "]が見つかりませんでした"
- }));
- if (keyValuePair.Value.m_eType == SceneEditInfo.CCateNameType.EType.Item)
- {
- if (this.m_sceneEdit.enabledMpns.Contains(keyValuePair.Key))
- {
- if (keyValuePair.Key != MPN.acckamisub)
- {
- childObject.SetActive(true);
- UTY.GetChildObject(childObject, "Title", false).GetComponent<UILabel>().text = mpnmapping.m_buttonTitle;
- if (keyValuePair.Key == MPN.hairt)
- {
- UILabel component = UTY.GetChildObject(childObject, "Title", false).GetComponent<UILabel>();
- component.text += " &\nリボン";
- }
- UIButton component2 = childObject.GetComponent<UIButton>();
- if (!flag)
- {
- this.activeColor = new Color(component2.defaultColor.r, component2.defaultColor.g, component2.defaultColor.b, 1f);
- this.inActiveColor = component2.defaultColor;
- flag = true;
- }
- SceneEditInfo.CCateNameType.EType eType = keyValuePair.Value.m_eType;
- ItemTypeRandomPresetButton itemTypeRandomPresetButton = new ItemTypeRandomPresetButton();
- itemTypeRandomPresetButton.m_menuCategory = keyValuePair.Value.m_eMenuCate;
- itemTypeRandomPresetButton.m_eButtonType = eType;
- itemTypeRandomPresetButton.m_name = mpnmapping.m_buttonName;
- itemTypeRandomPresetButton.m_mpn = keyValuePair.Key;
- itemTypeRandomPresetButton.m_btnButton = component2;
- itemTypeRandomPresetButton.m_bBtnActive = false;
- itemTypeRandomPresetButton.m_executionOrder = mpnmapping.m_executionOrder;
- itemTypeRandomPresetButton.m_txtItem = UTY.GetChildObject(childObject, "Item", false).GetComponent<UITexture>();
- this.m_dicItemBtn.Add(itemTypeRandomPresetButton.m_name, itemTypeRandomPresetButton);
- }
- }
- }
- }
- }
- }
- }
- UITable component3 = UTY.GetChildObject(goRandomPresetPanel, "Contents/Buttons", false).GetComponent<UITable>();
- Utility.ResetNGUI(component3);
- component3.repositionNow = true;
- }
- public void LoadMaidPropData()
- {
- Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
- Action<SceneEditInfo.EMenuCategory, MPN, UITexture> action = delegate(SceneEditInfo.EMenuCategory category, MPN mpn, UITexture tex)
- {
- int num = maid.GetProp(mpn).nTempFileNameRID;
- foreach (SceneEdit.SubPropMpnData subPropMpnData in this.m_sceneEdit.subPropDatas)
- {
- if (mpn == subPropMpnData.mpn)
- {
- if (subPropMpnData.manager.sloatItems != null && subPropMpnData.manager.sloatItems[0].menuItem != null)
- {
- num = subPropMpnData.manager.sloatItems[0].menuItem.m_nMenuFileRID;
- }
- break;
- }
- }
- Texture2D mainTexture;
- if (num == 0)
- {
- mainTexture = this.m_notSettingIcon;
- }
- else
- {
- mainTexture = this.GetTextureByRid(category, mpn, num);
- }
- tex.mainTexture = mainTexture;
- };
- Facility tempSelectFacility = GameMain.Instance.FacilityMgr.tempSelectFacility;
- NDebug.Assert(tempSelectFacility != null, "現在選択中の施設がnullです");
- foreach (KeyValuePair<string, RandomPresetButton> keyValuePair in this.m_dicItemBtn)
- {
- RandomPresetButton value = keyValuePair.Value;
- action(value.m_menuCategory, value.m_mpn, value.m_txtItem);
- bool costumeForced = tempSelectFacility.GetCostumeForced(value.m_mpn);
- this.SetButtonActive(value, costumeForced);
- if (value.m_mpn == MPN.hairt)
- {
- UITexture component = UTY.GetChildObject(value.m_btnButton.gameObject, "Item2", false).GetComponent<UITexture>();
- action(SceneEditInfo.EMenuCategory.アクセサリ, MPN.acckamisub, component);
- }
- }
- }
- public void OnButtonClick(string clickBtnName)
- {
- RandomPresetButton randomPresetButton = this.m_dicItemBtn[clickBtnName];
- this.SetButtonActive(randomPresetButton, !randomPresetButton.m_bBtnActive);
- }
- public void OnAllButtonClick(bool active)
- {
- foreach (KeyValuePair<string, RandomPresetButton> keyValuePair in this.m_dicItemBtn)
- {
- this.SetButtonActive(keyValuePair.Value, active);
- }
- }
- public void SetButtonActive(RandomPresetButton itemData, bool active)
- {
- Facility tempSelectFacility = GameMain.Instance.FacilityMgr.tempSelectFacility;
- tempSelectFacility.SetCostumeForced(itemData.m_mpn, active);
- if (itemData.m_mpn == MPN.hairt)
- {
- this.testForced[MPN.acckamisub] = active;
- }
- tempSelectFacility.SetCostumeForced(MPN.acckamisub, active);
- itemData.m_bBtnActive = active;
- if (itemData.m_bBtnActive)
- {
- itemData.m_btnButton.defaultColor = this.activeColor;
- }
- else
- {
- itemData.m_btnButton.defaultColor = this.inActiveColor;
- }
- }
- private Texture2D GetTextureByRid(SceneEditInfo.EMenuCategory eMenuCategory, MPN btnMpn, int rid)
- {
- List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
- foreach (SceneEdit.SCategory scategory in categoryList)
- {
- if (scategory.m_eCategory == eMenuCategory)
- {
- foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
- {
- if (spartsType.m_mpn == btnMpn)
- {
- foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu)
- {
- if (smenuItem.m_nMenuFileRID == rid)
- {
- if (smenuItem.m_boDelOnly)
- {
- return smenuItem.m_texIcon;
- }
- return smenuItem.m_texIcon;
- }
- }
- return this.m_notSettingIcon;
- }
- }
- }
- }
- return null;
- }
- private SceneEdit m_sceneEdit;
- private Dictionary<string, RandomPresetButton> m_dicItemBtn;
- private Color activeColor;
- private Color inActiveColor;
- private Texture2D m_notSettingIcon;
- private Dictionary<MPN, bool> testForced = new Dictionary<MPN, bool>();
- }
|