using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using wf; using Yotogis; public class FreeSkillSelect : MonoBehaviour { public void Awake() { if (this.update_obj_dic_ != null) { return; } this.update_obj_dic_ = new Dictionary(); Func func = delegate(GameObject top_obj) { GameObject childObject = UTY.GetChildObject(top_obj, "Content", false); FreeSkillSelect.UpdateObject updateObject = new FreeSkillSelect.UpdateObject(); updateObject.storage_obj = UTY.GetChildObject(childObject, "StorageRoom", true); updateObject.arrow_obj = UTY.GetChildObject(top_obj, "Arrow", false); updateObject.ui_panel = childObject.GetComponent(); updateObject.scroll_view = childObject.GetComponent(); updateObject.button_parent = UTY.GetChildObject(childObject, "GridParent", false); updateObject.ui_grid = updateObject.button_parent.GetComponent(); updateObject.tab_panel = updateObject.button_parent.GetComponent(); return updateObject; }; string[] array = new string[] { "TypeCategoryViewer", "CategoryViewer", "SkillSelectViewer", "LevelViewer", "StageSelectViewer" }; string[] array2 = new string[] { "タイプ", "カテゴリー", "スキル", "レベル", "ステージ" }; for (int i = 0; i < array.Length; i++) { this.update_obj_dic_.Add(array2[i], func(UTY.GetChildObject(base.gameObject, array[i], false))); } this.select_stage_ = (this.user_request_stage = YotogiStage.GetAllDatas(true)[0]); } public void Start() { } public void SetMaid(Maid maid) { this.maid_ = maid; } public void SetYotogiManager(YotogiManager yotogi_mgr) { this.yotogi_mgr_ = yotogi_mgr; } public void CreateInstanceButton() { if (this.button_data_list_ != null) { return; } FreeSkillSelect.UpdateObject updateObject = this.update_obj_dic_["ステージ"]; FreeSkillSelect.UpdateObject updateObject2 = this.update_obj_dic_["タイプ"]; FreeSkillSelect.UpdateObject updateObject3 = this.update_obj_dic_["レベル"]; foreach (KeyValuePair keyValuePair in this.update_obj_dic_) { FreeSkillSelect.UpdateObject value = keyValuePair.Value; value.Clear(); value.Update(); } int clubGrade = GameMain.Instance.CharacterMgr.status.clubGrade; HashSet hashSet = new HashSet(); List allDatas = YotogiStage.GetAllDatas(true); allDatas.Sort(); foreach (YotogiStage.Data data in allDatas) { if (data.isYotogiPlayable(clubGrade, false)) { string a = string.Empty; for (int i = 0; i < 2; i++) { if (!string.IsNullOrEmpty(data.prefabName[i]) && !(a == data.prefabName[i])) { GameObject gameObject = Utility.CreatePrefab(updateObject.button_parent, "SceneYotogi/StageSelect/Prefab/StageUnit", true); a = (gameObject.name = data.prefabName[0]); YotogiStageUnit component = gameObject.GetComponent(); component.SetStageData(data, true, i == 0); component.SetOnSelectEvent(new YotogiStageUnit.OnSelectEvent(this.OnClickStageEvent)); component.is_change_bg = false; if (!hashSet.Contains(data.id)) { hashSet.Add(data.id); } } } } } updateObject.Update(); this.button_data_list_ = FreeSkillSelect.CreateButtonData(this.maid_, hashSet); GameObject button_parent = updateObject3.button_parent; for (int j = 0; j < 3; j++) { EventDelegate onclick_event = new EventDelegate(this, "OnClickLevelBtnEvent"); UIWFTabButton uiwftabButton = this.CreateTypeAndCategoryButton(updateObject3, "Lv." + (j + 1).ToString(), true, onclick_event); uiwftabButton.name = (j + 1).ToString(); } updateObject3.Update(); List childList = updateObject3.ui_grid.GetChildList(); for (int k = 0; k < childList.Count; k++) { UIWFTabButton componentInChildren = childList[k].gameObject.GetComponentInChildren(); if (!(componentInChildren == null) && componentInChildren.isEnabled) { updateObject3.tab_panel.Select(componentInChildren); break; } } GameObject button_parent2 = updateObject2.button_parent; for (int l = 0; l < this.button_data_list_.Count; l++) { FreeSkillSelect.ButtonData buttonData = this.button_data_list_[l]; EventDelegate eventDelegate = new EventDelegate(this, "OnClickTypeBtnEvent"); eventDelegate.parameters[0].value = buttonData; if (buttonData.children_list.Count != 0) { buttonData.tab_button_obj = this.CreateTypeAndCategoryButton(updateObject2, buttonData.name, 0 < this.button_data_list_[l].children_list.Count, eventDelegate); } } updateObject2.Update(); childList = updateObject2.ui_grid.GetChildList(); for (int m = 0; m < childList.Count; m++) { UIWFTabButton componentInChildren2 = childList[m].gameObject.GetComponentInChildren(); if (!(componentInChildren2 == null) && componentInChildren2.isEnabled) { updateObject2.tab_panel.Select(componentInChildren2); break; } } } public void SelectSkill(Skill.Data skill, YotogiStage.Data stage_data) { if (skill == null) { return; } FreeSkillSelect.ButtonData buttonData = null; FreeSkillSelect.ButtonData buttonData2 = null; FreeSkillSelect.ButtonData buttonData3 = null; bool flag = true; int num = 0; while (num < this.button_data_list_.Count && flag) { buttonData = this.button_data_list_[num]; int num2 = 0; while (num2 < buttonData.children_list.Count && flag) { buttonData2 = buttonData.children_list[num2]; int num3 = 0; while (num3 < buttonData2.children_list.Count && flag) { buttonData3 = buttonData2.children_list[num3]; if (buttonData3.skill_data == skill) { flag = false; } num3++; } num2++; } num++; } if (flag) { return; } if (!buttonData.tab_button_obj.isSelected) { this.update_obj_dic_["タイプ"].tab_panel.Select(buttonData.tab_button_obj); } if (!buttonData2.tab_button_obj.isSelected) { this.update_obj_dic_["カテゴリー"].tab_panel.Select(buttonData2.tab_button_obj); } this.user_request_stage = stage_data; if (!buttonData3.tab_button_obj.isSelected) { this.update_obj_dic_["スキル"].tab_panel.Select(buttonData3.tab_button_obj); } } public void FixSkill() { if (this.yotogi_mgr_ == null || this.yotogi_mgr_.maid == null) { return; } YotogiStageSelectManager.SelectStage(this.select_stage, this.is_day_time_); KeyValuePair[] playSkillArray = new KeyValuePair[] { new KeyValuePair(this.select_skill, false) }; this.yotogi_mgr_.SetPlaySkillArray(playSkillArray); } private void CreateCategory(FreeSkillSelect.ButtonData type_button_data) { FreeSkillSelect.UpdateObject updateObject = this.update_obj_dic_["カテゴリー"]; updateObject.MoveStorageRoom(true); updateObject.Clear(); GameObject button_parent = updateObject.button_parent; bool lockNTRPlay = GameMain.Instance.CharacterMgr.status.lockNTRPlay; int i = 0; while (i < type_button_data.children_list.Count) { FreeSkillSelect.ButtonData buttonData = type_button_data.children_list[i]; if (!lockNTRPlay) { goto IL_87; } Yotogi.Category category = (Yotogi.Category)Enum.Parse(typeof(Yotogi.Category), buttonData.name); if (category != Yotogi.Category.交換 && category != Yotogi.Category.乱交) { goto IL_87; } IL_E7: i++; continue; IL_87: bool flag = buttonData.children_list != null && 0 < buttonData.children_list.Count; EventDelegate eventDelegate = null; if (flag) { eventDelegate = new EventDelegate(this, "OnClickCategoryBtnEvent"); eventDelegate.parameters[0].value = buttonData; } buttonData.tab_button_obj = this.CreateTypeAndCategoryButton(updateObject, buttonData.name, flag, eventDelegate); goto IL_E7; } updateObject.Update(); List childList = updateObject.ui_grid.GetChildList(); for (int j = 0; j < childList.Count; j++) { UIWFTabButton componentInChildren = childList[j].gameObject.GetComponentInChildren(); if (!(componentInChildren == null) && componentInChildren.isEnabled) { updateObject.tab_panel.Select(componentInChildren); break; } } } private void CreateSkill(FreeSkillSelect.ButtonData skill_button_data) { FreeSkillSelect.UpdateObject updateObject = this.update_obj_dic_["スキル"]; updateObject.MoveStorageRoom(true); updateObject.Clear(); GameObject button_parent = updateObject.button_parent; for (int i = 0; i < skill_button_data.children_list.Count; i++) { FreeSkillSelect.ButtonData buttonData = skill_button_data.children_list[i]; if (buttonData.skill_data != null) { EventDelegate eventDelegate = new EventDelegate(this, "OnClickSkillBtnEvent"); eventDelegate.parameters[0].value = buttonData; buttonData.tab_button_obj = this.CreateSkillButton(buttonData.skill_data, eventDelegate); } } updateObject.Update(); List childList = updateObject.ui_grid.GetChildList(); for (int j = 0; j < childList.Count; j++) { UIWFTabButton componentInChildren = childList[j].gameObject.GetComponentInChildren(); if (!(componentInChildren == null) && componentInChildren.isEnabled) { updateObject.tab_panel.Select(componentInChildren); break; } } } private void CreateStage(Skill.Data skill_data) { FreeSkillSelect.UpdateObject updateObject = this.update_obj_dic_["ステージ"]; YotogiStage.Data data = this.user_request_stage; UIWFTabButton uiwftabButton = null; updateObject.tab_panel.ResetSelect(); List childList = updateObject.ui_grid.GetChildList(); for (int i = 0; i < childList.Count; i++) { YotogiStageUnit component = childList[i].gameObject.GetComponent(); UIWFTabButton componentInChildren = childList[i].gameObject.GetComponentInChildren(); if (componentInChildren.isSelected) { componentInChildren.SetSelect(false); } if (componentInChildren.isEnabled != skill_data.IsExecStage(component.stage_data)) { componentInChildren.isEnabled = skill_data.IsExecStage(component.stage_data); if (componentInChildren.isEnabled) { component.thumbnail_sprite.color = new Color(1f, 1f, 1f, 1f); } else { component.thumbnail_sprite.color = new Color(0.6f, 0.6f, 0.6f, 1f); } } if (data == component.stage_data && componentInChildren.isEnabled) { uiwftabButton = componentInChildren; } } if (uiwftabButton != null) { updateObject.tab_panel.Select(uiwftabButton); } else { for (int j = 0; j < childList.Count; j++) { UIWFTabButton componentInChildren2 = childList[j].gameObject.GetComponentInChildren(); if (!(componentInChildren2 == null) && componentInChildren2.isEnabled) { updateObject.tab_panel.Select(componentInChildren2); break; } } this.user_request_stage = data; } } private UIWFTabButton CreateSkillButton(Skill.Data skill_data, EventDelegate onclick_event) { if (skill_data == null) { return null; } FreeSkillSelect.UpdateObject updateObject = this.update_obj_dic_["スキル"]; GameObject gameObject = updateObject.MoveButtonParent(); if (gameObject == null) { gameObject = Utility.CreatePrefab(updateObject.button_parent, "SceneYotogi/FreeMode/FreeSkillButton", true); } UTY.GetChildObject(gameObject, "title", false).GetComponent().text = skill_data.name; gameObject.name = skill_data.name; UIWFTabButton component = UTY.GetChildObject(gameObject, "BG", false).GetComponent(); if (onclick_event != null) { component.onClick.Add(onclick_event); } return component; } private UIWFTabButton CreateTypeAndCategoryButton(FreeSkillSelect.UpdateObject update_obj, string name, bool enabled, EventDelegate onclick_event) { GameObject gameObject = update_obj.MoveButtonParent(); if (gameObject == null) { gameObject = Utility.CreatePrefab(update_obj.button_parent, "SceneYotogi/SkillSelect/Prefab/CategoryBtn", true); } UTY.GetChildObject(gameObject, "Label", false).GetComponent().text = name; UIWFTabButton component = UTY.GetChildObject(gameObject, "Button", false).GetComponent(); gameObject.name = name; component.isEnabled = enabled; if (enabled && onclick_event != null) { component.onClick.Add(onclick_event); } return component; } private void OnClickTypeBtnEvent(FreeSkillSelect.ButtonData type_btn_data) { this.update_obj_dic_["タイプ"].UpdateArrow(type_btn_data.tab_button_obj.gameObject); this.CreateCategory(type_btn_data); } private void OnClickCategoryBtnEvent(FreeSkillSelect.ButtonData categorybtn_data) { this.update_obj_dic_["カテゴリー"].UpdateArrow(categorybtn_data.tab_button_obj.gameObject); this.CreateSkill(categorybtn_data); } private void OnClickSkillBtnEvent(FreeSkillSelect.ButtonData skill_data) { this.update_obj_dic_["スキル"].UpdateArrow(skill_data.tab_button_obj.gameObject); this.select_skill_ = skill_data.skill_data; this.CreateStage(skill_data.skill_data); } private void OnClickLevelBtnEvent() { this.update_obj_dic_["レベル"].UpdateArrow(UIButton.current.gameObject); this.yotogi_mgr_.fix_skill_level = int.Parse(UIButton.current.gameObject.name); } private void OnClickStageEvent(YotogiStageUnit stage_unit) { this.select_stage_ = (this.user_request_stage = stage_unit.stage_data); this.is_day_time_ = stage_unit.is_daytime; this.FixSkill(); } private static List CreateButtonData(Maid maid, HashSet selectableStageIds) { List list = new List(); Dictionary>> type_data_dic = new Dictionary>>(); List> list2 = new List>(); list2.Add(new KeyValuePair(Skill.Data.SpecialConditionType.Null, "通常")); list2.Add(new KeyValuePair(Skill.Data.SpecialConditionType.Drunk, "酔い")); list2.Add(new KeyValuePair(Skill.Data.SpecialConditionType.Mask, "目隠し")); list2.Add(new KeyValuePair(Skill.Data.SpecialConditionType.Drug, "媚薬")); list2.Add(new KeyValuePair(Skill.Data.SpecialConditionType.Confess, "告白")); list2.Add(new KeyValuePair(Skill.Data.SpecialConditionType.Faint, "気絶")); for (int i = 0; i < list2.Count; i++) { FreeSkillSelect.ButtonData buttonData = new FreeSkillSelect.ButtonData(); buttonData.children_list = new List(); buttonData.name = list2[i].Value; buttonData.condition_type = list2[i].Key; list.Add(buttonData); type_data_dic.Add(buttonData.condition_type, new KeyValuePair>(buttonData, new Dictionary())); } for (int j = 0; j < list.Count; j++) { for (int k = 0; k < 8; k++) { FreeSkillSelect.ButtonData buttonData2 = list[j]; FreeSkillSelect.ButtonData buttonData3 = new FreeSkillSelect.ButtonData(); buttonData3.children_list = new List(); FreeSkillSelect.ButtonData buttonData4 = buttonData3; Yotogi.Category category = (Yotogi.Category)k; buttonData4.name = category.ToString(); buttonData3.parent = buttonData2; buttonData2.children_list.Add(buttonData3); type_data_dic[list[j].condition_type].Value.Add(buttonData3.name, buttonData3); } } CharacterMgr characterMgr = GameMain.Instance.CharacterMgr; int[] keyArray = maid.status.yotogiSkill.datas.GetKeyArray(); Dictionary> dictionary = new Dictionary>(); for (int l = 0; l < keyArray.Length; l++) { Skill.Data data = Skill.Get(keyArray[l]); bool flag = false; foreach (int item in data.playable_stageid_list) { flag = selectableStageIds.Contains(item); if (flag) { break; } } if (flag) { int category2 = (int)data.category; if (!dictionary.ContainsKey(category2)) { dictionary.Add(category2, new List()); } dictionary[category2].Add(data); } } foreach (KeyValuePair> keyValuePair in dictionary) { List value = keyValuePair.Value; value.Sort((Skill.Data a, Skill.Data b) => a.sortId - b.sortId); } List list3 = new List(); foreach (KeyValuePair> keyValuePair2 in dictionary) { List value2 = keyValuePair2.Value; foreach (Skill.Data item2 in value2) { list3.Add(item2); } } foreach (Skill.Data data2 in list3) { if (1 < data2.player_num) { int num = 0; for (int m = 0; m < characterMgr.GetMaidCount(); m++) { if (!(characterMgr.GetMaid(m) != null)) { break; } num++; } if (num < data2.player_num) { continue; } } if (data2.IsExecMaid(maid.status)) { FreeSkillSelect.ButtonData buttonData5 = type_data_dic[data2.specialConditionType].Value[data2.category.ToString()]; if (buttonData5 != null) { FreeSkillSelect.ButtonData buttonData6 = new FreeSkillSelect.ButtonData(); buttonData6.parent = buttonData5; buttonData6.name = data2.name; buttonData6.skill_data = data2; buttonData5.children_list.Add(buttonData6); } } } Action action = delegate(Skill.Data.SpecialConditionType type) { Dictionary value3 = type_data_dic[type].Value; HashSet hashSet = new HashSet(); List list4 = new List(); foreach (KeyValuePair keyValuePair3 in value3) { if (keyValuePair3.Value.children_list != null && 1 <= keyValuePair3.Value.children_list.Count && !hashSet.Contains(keyValuePair3.Key)) { hashSet.Add(keyValuePair3.Key); list4.Add(keyValuePair3.Value); } } type_data_dic[type].Key.children_list = list4; }; foreach (FreeSkillSelect.ButtonData buttonData7 in list) { if (buttonData7.condition_type != Skill.Data.SpecialConditionType.Null) { action(buttonData7.condition_type); } } return list; } private static FreeSkillSelect.ButtonData GetButtonData(List check_list, string name) { FreeSkillSelect.ButtonData result = null; if (check_list == null || string.IsNullOrEmpty(name)) { return result; } for (int i = 0; i < check_list.Count; i++) { if (check_list[i] != null) { if (!string.IsNullOrEmpty(check_list[i].name) && check_list[i].name == name) { result = check_list[i]; break; } } } return result; } public YotogiStage.Data select_stage { get { return this.select_stage_; } } public Skill.Data select_skill { get { return this.select_skill_; } } private Maid maid_; private List button_data_list_; private Dictionary update_obj_dic_; private YotogiManager yotogi_mgr_; private Skill.Data select_skill_; private YotogiStage.Data select_stage_; private bool is_day_time_ = true; private YotogiStage.Data user_request_stage; private class ButtonData { public UIWFTabButton tab_button_obj; public FreeSkillSelect.ButtonData parent; public List children_list; public string name; public Skill.Data skill_data; public Skill.Data.SpecialConditionType condition_type; } private class UpdateObject { public void Update() { this.ui_grid.Reposition(); this.tab_panel.UpdateChildren(); this.scroll_view.ResetPosition(); this.ui_panel.UpdateAnchors(); } public void MoveStorageRoom(bool click_event_clear) { if (this.storage_obj == null) { return; } Transform transform = this.button_parent.transform; Transform transform2 = this.storage_obj.transform; while (0 < transform.childCount) { GameObject gameObject = transform.GetChild(0).gameObject; UIWFTabButton componentInChildren = gameObject.GetComponentInChildren(); if (componentInChildren != null) { componentInChildren.SetSelect(false); if (click_event_clear) { componentInChildren.onClick.Clear(); } } gameObject.transform.SetParent(transform2, false); gameObject.transform.localPosition = Vector3.zero; } transform.DetachChildren(); } public GameObject MoveButtonParent() { if (this.storage_obj == null) { return null; } GameObject gameObject = null; Transform transform = this.button_parent.transform; Transform transform2 = this.storage_obj.transform; if (0 < transform2.childCount) { gameObject = transform2.GetChild(0).gameObject; gameObject.transform.SetParent(transform, false); } return gameObject; } public GameObject MoveButtonParent(string object_name) { if (this.storage_obj == null || string.IsNullOrEmpty(object_name)) { return null; } GameObject gameObject = null; Transform transform = this.button_parent.transform; Transform transform2 = this.storage_obj.transform; for (int i = 0; i < transform2.childCount; i++) { if (transform2.GetChild(i).name == object_name) { gameObject = transform2.GetChild(i).gameObject; gameObject.transform.SetParent(transform, false); break; } } return gameObject; } public void UpdateArrow(GameObject target_obj) { if (this.arrow_obj == null || target_obj == null) { return; } Vector3 position = target_obj.transform.TransformPoint(new Vector3(0f, 0f, 0f)); Vector3 local_pos = this.arrow_obj.transform.parent.InverseTransformPoint(position); local_pos.x = this.arrow_obj.transform.localPosition.x; local_pos.y += 18f; Hashtable args = TweenHash.EaseOutQuint(TweenHash.Type.Position, local_pos, 0.3f); iTween.MoveTo(this.arrow_obj, args); } public void Clear() { Transform transform = this.button_parent.transform; for (int i = 0; i < transform.childCount; i++) { UnityEngine.Object.Destroy(transform.GetChild(i).gameObject); } transform.DetachChildren(); } public GameObject button_parent; public UIGrid ui_grid; public UIWFTabPanel tab_panel; public UIScrollView scroll_view; public UIPanel ui_panel; public GameObject arrow_obj; public GameObject storage_obj; } }