123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- using System;
- using System.Collections.Generic;
- using I2.Loc;
- using MaidStatus;
- using UnityEngine;
- using wf;
- using Yotogis;
- public class YotogiSkillListManager : MonoBehaviour
- {
- public static Dictionary<int, YotogiSkillListManager.Data> CreateDatas(Status status, bool specialConditionCheck, Skill.Data.SpecialConditionType type = Skill.Data.SpecialConditionType.Null)
- {
- Dictionary<int, YotogiSkillListManager.Data> dictionary = new Dictionary<int, YotogiSkillListManager.Data>();
- List<KeyValuePair<string[], bool>> list = new List<KeyValuePair<string[], bool>>();
- foreach (SortedDictionary<int, Skill.Data> sortedDictionary in Skill.skill_data_list)
- {
- foreach (KeyValuePair<int, Skill.Data> keyValuePair in sortedDictionary)
- {
- list.Clear();
- Skill.Data value = keyValuePair.Value;
- if (!specialConditionCheck || value.specialConditionType == type)
- {
- if (value.IsExecSeikeiken(status.seikeiken) && value.IsExecRelation(status.relation) && value.IsExecContract(status.contract) && value.IsExecPersonal(status.personal))
- {
- YotogiSkillData yotogiSkillData = status.yotogiSkill.Get(value.id);
- if (yotogiSkillData == null)
- {
- if (value.getcondition_data.yotogi_class != null && !value.getcondition_data.yotogi_class.learnConditions.isFutureLearnPossible(status))
- {
- continue;
- }
- list = value.getcondition_data.CreateConditionTextAndStaturResults(status);
- }
- if (list.Count == 0)
- {
- list.Add(new KeyValuePair<string[], bool>(new string[]
- {
- "MaidStatus/条件文/なし"
- }, true));
- }
- YotogiSkillListManager.Data data = new YotogiSkillListManager.Data();
- data.skillData = value;
- data.conditionDatas = list.ToArray();
- data.maidStatusSkillData = yotogiSkillData;
- dictionary.Add(data.skillData.id, data);
- }
- }
- }
- }
- return dictionary;
- }
- public static Dictionary<int, YotogiSkillListManager.Data> CreateDatasOld(Status status)
- {
- Dictionary<int, YotogiSkillListManager.Data> dictionary = new Dictionary<int, YotogiSkillListManager.Data>();
- List<KeyValuePair<string[], bool>> list = new List<KeyValuePair<string[], bool>>();
- foreach (SortedDictionary<int, Skill.Old.Data> sortedDictionary in Skill.Old.skill_data_list)
- {
- foreach (KeyValuePair<int, Skill.Old.Data> keyValuePair in sortedDictionary)
- {
- list.Clear();
- Skill.Old.Data value = keyValuePair.Value;
- if (value.IsExecSeikeiken(status.seikeiken) && value.IsExecRelation(status.relation))
- {
- YotogiSkillData yotogiSkillData = status.yotogiSkill.Get(value.id);
- if (yotogiSkillData == null)
- {
- list = value.getcondition_data.CreateConditionTextAndStaturResults(status);
- }
- if (list.Count == 0)
- {
- list.Add(new KeyValuePair<string[], bool>(new string[]
- {
- "MaidStatus/条件文/なし"
- }, true));
- }
- YotogiSkillListManager.Data data = new YotogiSkillListManager.Data();
- data.skillDataOld = value;
- data.conditionDatas = list.ToArray();
- data.maidStatusSkillData = yotogiSkillData;
- dictionary.Add(value.id, data);
- }
- }
- }
- return dictionary;
- }
- private void Awake()
- {
- if (this.conditionDatas != null)
- {
- return;
- }
- this.itemGrid = this.contentObject.GetComponent<UIGrid>();
- NDebug.AssertNull(this.itemGrid != null);
- this.conditionList = this.conditionsObject.GetComponentInChildren<UIWFConditionList>();
- NDebug.AssertNull(this.conditionList != null);
- this.conditionBG = UTY.GetChildObject(this.conditionsObject, "BG", false).GetComponent<UIWidget>();
- for (int i = 0; i < 50; i++)
- {
- this.InstantiateSkillItem(this.storageObject);
- }
- this.conditionDatas = new Dictionary<int, KeyValuePair<string[], Color>[]>();
- this.instansToSkillDatas = new Dictionary<int, KeyValuePair<Skill.Data, Skill.Old.Data>>();
- this.conditionsObject.SetActive(false);
- }
- public void CreateData(Maid maid)
- {
- if (this.conditionDatas == null)
- {
- this.Awake();
- }
- this.DeleteItemAllObject();
- this.conditionDatas.Clear();
- this.instansToSkillDatas.Clear();
- Utility.ResetNGUI(this.itemGrid);
- Utility.ResetNGUI(this.scrollView);
- List<KeyValuePair<string, Color>> list = new List<KeyValuePair<string, Color>>();
- int num = 0;
- Dictionary<int, YotogiSkillListManager.Data> dictionary;
- if (MaidManagement.compatibilityMode)
- {
- dictionary = YotogiSkillListManager.CreateDatasOld(maid.status);
- }
- else
- {
- dictionary = YotogiSkillListManager.CreateDatas(maid.status, false, Skill.Data.SpecialConditionType.Null);
- }
- List<YotogiSkillListManager.Data> list2 = new List<YotogiSkillListManager.Data>();
- bool lockNTRPlay = GameMain.Instance.CharacterMgr.status.lockNTRPlay;
- foreach (KeyValuePair<int, YotogiSkillListManager.Data> keyValuePair in dictionary)
- {
- YotogiSkillListManager.Data value = keyValuePair.Value;
- if (value.skillData != null)
- {
- if (!value.skillData.IsSkillListDisplay(lockNTRPlay))
- {
- continue;
- }
- }
- else if (value.skillDataOld != null && lockNTRPlay && (value.skillDataOld.category == YotogiOld.Category.交換 || value.skillDataOld.category == YotogiOld.Category.乱交))
- {
- continue;
- }
- if (value.skillData != null && value.skillData.getcondition_data.requestPersonals.Length != 0)
- {
- list2.Add(value);
- }
- else
- {
- string skillName = (value.skillData == null) ? value.skillDataOld.name : value.skillData.name;
- string skillNameTerm = (value.skillData == null) ? value.skillDataOld.name : value.skillData.termName;
- int skillId = (value.skillData == null) ? value.skillDataOld.id : value.skillData.id;
- GameObject gameObject = this.CreateItemObject(maid, ++num, skillName, skillNameTerm, skillId);
- if (0 < value.conditionDatas.Length)
- {
- List<KeyValuePair<string[], Color>> list3 = new List<KeyValuePair<string[], Color>>();
- foreach (KeyValuePair<string[], bool> keyValuePair2 in value.conditionDatas)
- {
- list3.Add(new KeyValuePair<string[], Color>(keyValuePair2.Key, (!keyValuePair2.Value) ? Color.gray : Color.white));
- }
- this.conditionDatas.Add(gameObject.GetInstanceID(), list3.ToArray());
- this.instansToSkillDatas.Add(gameObject.GetInstanceID(), new KeyValuePair<Skill.Data, Skill.Old.Data>(value.skillData, value.skillDataOld));
- }
- }
- }
- foreach (YotogiSkillListManager.Data data in list2)
- {
- string skillName2 = (data.skillData == null) ? data.skillDataOld.name : data.skillData.name;
- string skillNameTerm2 = (data.skillData == null) ? data.skillDataOld.name : data.skillData.termName;
- int skillId2 = (data.skillData == null) ? data.skillDataOld.id : data.skillData.id;
- GameObject gameObject2 = this.CreateItemObject(maid, -1, skillName2, skillNameTerm2, skillId2);
- if (0 < data.conditionDatas.Length)
- {
- List<KeyValuePair<string[], Color>> list4 = new List<KeyValuePair<string[], Color>>();
- if (data.skillData != null)
- {
- foreach (Personal.Data data2 in data.skillData.getcondition_data.requestPersonals)
- {
- if (maid.status.personal.id == data2.id)
- {
- string text = Product.SPP ? maid.status.personal.termName : maid.status.personal.drawName;
- list4.Add(new KeyValuePair<string[], Color>(new string[]
- {
- "MaidStatus/条件文/ヒロインタイプ {0}",
- text
- }, Color.white));
- break;
- }
- }
- }
- foreach (KeyValuePair<string[], bool> keyValuePair3 in data.conditionDatas)
- {
- list4.Add(new KeyValuePair<string[], Color>(keyValuePair3.Key, (!keyValuePair3.Value) ? Color.gray : Color.white));
- }
- this.conditionDatas.Add(gameObject2.GetInstanceID(), list4.ToArray());
- this.instansToSkillDatas.Add(gameObject2.GetInstanceID(), new KeyValuePair<Skill.Data, Skill.Old.Data>(data.skillData, data.skillDataOld));
- }
- }
- Utility.ResetNGUI(this.itemGrid);
- Utility.ResetNGUI(this.scrollView);
- }
- private void OnEnable()
- {
- Utility.ResetNGUI(this.itemGrid);
- Utility.ResetNGUI(this.scrollView);
- this.OnHoverOutItem();
- }
- private GameObject InstantiateSkillItem(GameObject parent)
- {
- GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/Profile/Prefab/ProfileYotogiSkillItem", true);
- UIEventTrigger component = gameObject.GetComponent<UIEventTrigger>();
- EventDelegate eventDelegate = new EventDelegate(this, "OnHoverOverItem");
- eventDelegate.parameters[0].value = gameObject.GetInstanceID();
- EventDelegate.Add(component.onHoverOver, eventDelegate);
- EventDelegate.Add(component.onHoverOut, new EventDelegate.Callback(this.OnHoverOutItem));
- return gameObject;
- }
- private void OnHoverOverItem(int instanceId)
- {
- if (this.conditionDatas.ContainsKey(instanceId))
- {
- KeyValuePair<Skill.Data, Skill.Old.Data> keyValuePair = this.instansToSkillDatas[instanceId];
- this.conditionTitleLabel.text = ((keyValuePair.Key == null) ? keyValuePair.Value.name : keyValuePair.Key.name) + " 取得条件";
- if (Product.SPP)
- {
- Localize component = this.conditionTitleLabel.GetComponent<Localize>();
- if (component != null)
- {
- string term = (keyValuePair.Key == null) ? keyValuePair.Value.name : keyValuePair.Key.termName;
- Localize.ArgsPair[] termArgs = new Localize.ArgsPair[]
- {
- Localize.ArgsPair.Create(" {0}", false),
- Localize.ArgsPair.Create("System/取得条件", true)
- };
- component.TermArgs = termArgs;
- component.SetTerm(term);
- }
- }
- this.conditionList.SetTexts(this.conditionDatas[instanceId], 500);
- this.conditionBG.height = 90 + this.conditionList.height;
- this.conditionsObject.SetActive(true);
- }
- else
- {
- this.OnHoverOutItem();
- }
- }
- private void OnHoverOutItem()
- {
- this.conditionsObject.SetActive(false);
- }
- private GameObject CreateItemObject(Maid maid, int no, string skillName, string skillNameTerm, int skillId)
- {
- GameObject gameObject;
- if (this.storageObject.transform.childCount == 0)
- {
- gameObject = this.InstantiateSkillItem(this.storageObject);
- }
- else
- {
- gameObject = this.storageObject.transform.GetChild(0).gameObject;
- }
- gameObject.transform.SetParent(this.contentObject.transform, false);
- if (0 <= no)
- {
- gameObject.name = no.ToString("D4");
- }
- else
- {
- gameObject.name = "EX";
- }
- UILabel component = UTY.GetChildObject(gameObject, "Number/Value", false).GetComponent<UILabel>();
- if (0 <= no)
- {
- component.text = no.ToString();
- }
- else
- {
- component.text = "EX";
- }
- UILabel component2 = UTY.GetChildObject(gameObject, "SkillName/Value", false).GetComponent<UILabel>();
- component2.text = skillName;
- Localize component3 = component2.GetComponent<Localize>();
- if (component3 != null)
- {
- component3.SetTerm(skillNameTerm);
- }
- UISprite component4 = UTY.GetChildObject(gameObject, "LevelOfAchievement/Icon", false).GetComponent<UISprite>();
- int num = (!maid.status.yotogiSkill.Contains(skillId)) ? 0 : maid.status.yotogiSkill.Get(skillId).level;
- string spriteName = "profile_yotogiskill_sign_minus";
- if (num != 1)
- {
- if (num != 2)
- {
- if (num == 3)
- {
- spriteName = "cm3d2_edit_profile_yotogiskill_sign_nijumaru";
- }
- }
- else
- {
- spriteName = "cm3d2_edit_profile_yotogiskill_sign_maru";
- }
- }
- else
- {
- spriteName = "cm3d2_edit_profile_yotogiskill_sign_sankaku";
- }
- if (maid.status.yotogiSkill.Contains(skillId) && maid.status.yotogiSkill.Get(skillId).playCount == 0u)
- {
- spriteName = "cm3d2_edit_profile_yotogiskill_sign_batu";
- }
- component4.spriteName = spriteName;
- component2.color = ((num != 0) ? Color.white : Color.gray);
- gameObject.GetComponent<BoxCollider>().enabled = (num == 0);
- return gameObject;
- }
- private void DeleteItemAllObject()
- {
- List<GameObject> list = new List<GameObject>();
- for (int i = 0; i < this.contentObject.transform.childCount; i++)
- {
- list.Add(this.contentObject.transform.GetChild(i).gameObject);
- }
- foreach (GameObject obj in list)
- {
- this.DeleteItemObject(obj);
- }
- }
- private void DeleteItemObject(GameObject obj)
- {
- if (obj.transform.parent != this.storageObject.transform)
- {
- obj.transform.SetParent(this.storageObject.transform, false);
- }
- }
- [SerializeField]
- private GameObject storageObject;
- [SerializeField]
- private GameObject contentObject;
- [SerializeField]
- private UIScrollView scrollView;
- [SerializeField]
- private GameObject conditionsObject;
- [SerializeField]
- private UILabel conditionTitleLabel;
- private UIGrid itemGrid;
- private UIWFConditionList conditionList;
- private UIWidget conditionBG;
- private Dictionary<int, KeyValuePair<string[], Color>[]> conditionDatas;
- private Dictionary<int, KeyValuePair<Skill.Data, Skill.Old.Data>> instansToSkillDatas;
- public class Data
- {
- public bool enabled
- {
- get
- {
- return this.maidStatusSkillData != null;
- }
- }
- public Skill.Data skillData;
- public Skill.Old.Data skillDataOld;
- public KeyValuePair<string[], bool>[] conditionDatas;
- public YotogiSkillData maidStatusSkillData;
- }
- }
|