123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using wf;
- using Yotogis;
- public class YotogiOldVRSkillSelectManager : WfFadeBehaviour
- {
- public void Awake()
- {
- this.skillStorageObject = new GameObject();
- this.skillStorageObject.name = "skillStorageObject";
- this.skillStorageObject.transform.SetParent(base.transform, false);
- this.skillStorageObject.SetActive(false);
- if (this.init_pos_dic_.Count == 0)
- {
- this.init_pos_dic_.Add(this.cancelBtn, this.cancelBtn.transform.localPosition);
- }
- EventDelegate.Add(this.cancelBtn.onClick, new EventDelegate.Callback(this.OnClickCancel));
- this.cblConfigBtn.gameObject.SetActive(false);
- for (int i = 0; i < this.categorySelectTabPanel.transform.childCount; i++)
- {
- UIWFTabButton componentInChildren = this.categorySelectTabPanel.transform.GetChild(i).GetComponentInChildren<UIWFTabButton>();
- EventDelegate eventDelegate = new EventDelegate(this, "OnClickFromCategoryButton");
- EventDelegate.Parameter[] parameters = eventDelegate.parameters;
- parameters[0].value = this.categorySelectTabPanel.transform.GetChild(i).name;
- componentInChildren.onClick.Add(eventDelegate);
- }
- this.categorySelectTabPanel.UpdateChildren();
- this.selectCategoryName = YotogiOld.Category.淫欲.ToString();
- this.widget.alpha = 0f;
- this.stageSelectBtn.SetOnSelectEvent(new Action<StageOldUnitCircle>(this.OnClickStageSelect));
- }
- public override void OnStartedFadeIn()
- {
- this.uiMask.enabled = true;
- this.fadeInStartBgAlpha = this.bgSprite.alpha;
- this.fadeInStartBgSize = new Vector2((float)this.bgSprite.width, (float)this.bgSprite.height);
- }
- public override void OnStartedFadeOut()
- {
- this.uiMask.enabled = true;
- }
- public override void OnUpdateFadeIn(float val)
- {
- this.bgSprite.alpha = Mathf.Lerp(this.fadeInStartBgAlpha, 1f, val);
- this.bgSprite.width = (int)Mathf.Lerp(this.fadeInStartBgSize.x, this.bgSize.x, val);
- this.bgSprite.height = (int)Mathf.Lerp(this.fadeInStartBgSize.y, this.bgSize.y, val);
- this.widget.alpha = val;
- }
- public override void OnUpdateFadeOut(float val)
- {
- this.widget.alpha = val;
- }
- public override void OnCompleteFadeIn()
- {
- this.uiMask.enabled = false;
- }
- public override void OnCompleteFadeOut()
- {
- this.OnCompleteFadeIn();
- }
- public void SelectCategory(string category)
- {
- for (int i = 0; i < this.categorySelectTabPanel.transform.childCount; i++)
- {
- Transform child = this.categorySelectTabPanel.transform.GetChild(i);
- UIWFTabButton componentInChildren = child.GetComponentInChildren<UIWFTabButton>();
- if (category == child.name && componentInChildren.isEnabled)
- {
- this.categorySelectTabPanel.Select(componentInChildren);
- return;
- }
- }
- }
- public void SetCancelButtonText(string text)
- {
- this.cancelBtn.GetComponentInChildren<UILabel>().text = text;
- }
- public void UpdateData(Maid maid, YotogiOld.Stage stage, int spot_no)
- {
- bool isDaytime = GameMain.Instance.CharacterMgr.status.isDaytime;
- YotogiOld.StageData.SpotData spotData = YotogiOld.vr_stage_data_list[stage].spot_data[spot_no];
- this.stageSelectBtn.SetStageSpotData(YotogiOld.vr_stage_data_list[stage], spot_no);
- List<YotogiOld.VRSkillData> vrskillDataList = YotogiOld.GetVRSkillDataList(stage, spot_no);
- this.skill_data_ = new Dictionary<string, List<YotogiOld.VRSkillData>>();
- foreach (YotogiOld.VRSkillData vrskillData in vrskillDataList)
- {
- Skill.Old.Data skill = vrskillData.skill;
- string key = vrskillData.skill.category.ToString();
- bool flag = maid.status.yotogiSkill.oldDatas.ContainsKey(skill.id) && skill.IsExecMaid(maid.status);
- if (flag)
- {
- if (!this.skill_data_.ContainsKey(key))
- {
- this.skill_data_.Add(key, new List<YotogiOld.VRSkillData>());
- }
- this.skill_data_[key].Add(vrskillData);
- }
- }
- int num = 0;
- foreach (KeyValuePair<string, List<YotogiOld.VRSkillData>> keyValuePair in this.skill_data_)
- {
- if (num < keyValuePair.Value.Count)
- {
- num = keyValuePair.Value.Count;
- }
- }
- if (this.skillStorageObject.transform.childCount < num)
- {
- int num2 = num - this.skillStorageObject.transform.childCount;
- for (int i = 0; i < num2; i++)
- {
- this.CreateNewSkillUnit(this.skillStorageObject);
- }
- }
- string value = string.Empty;
- for (int j = 0; j < this.categorySelectTabPanel.transform.childCount; j++)
- {
- Transform child = this.categorySelectTabPanel.transform.GetChild(j);
- UIWFTabButton componentInChildren = child.GetComponentInChildren<UIWFTabButton>();
- bool flag2 = this.skill_data_.ContainsKey(child.name) && this.skill_data_[child.name].Count > 0;
- componentInChildren.SetSelect(false);
- componentInChildren.isEnabled = flag2;
- if (!flag2 && child.name == this.selectCategoryName)
- {
- this.selectCategoryName = string.Empty;
- }
- else if (flag2 && string.IsNullOrEmpty(value))
- {
- value = child.name;
- }
- }
- if (string.IsNullOrEmpty(this.selectCategoryName))
- {
- this.selectCategoryName = value;
- }
- List<Transform> list = new List<Transform>();
- for (int k = 0; k < this.skillUnitParent.childCount; k++)
- {
- list.Add(this.skillUnitParent.GetChild(k));
- }
- foreach (Transform transform in list)
- {
- transform.SetParent(this.skillStorageObject.transform, false);
- }
- UIScrollView componentInChildren2 = base.gameObject.GetComponentInChildren<UIScrollView>();
- Utility.ResetNGUI(componentInChildren2);
- this.SelectCategory(this.selectCategoryName);
- }
- private void OnClickFromCategoryButton(string category)
- {
- this.selectCategoryName = category;
- List<Transform> list = new List<Transform>();
- for (int i = 0; i < this.skillUnitParent.childCount; i++)
- {
- list.Add(this.skillUnitParent.GetChild(i));
- }
- foreach (Transform transform in list)
- {
- transform.SetParent(this.skillStorageObject.transform, false);
- }
- UIScrollView componentInChildren = base.gameObject.GetComponentInChildren<UIScrollView>();
- Utility.ResetNGUI(componentInChildren);
- if (!this.skill_data_.ContainsKey(category))
- {
- return;
- }
- Transform transform2 = this.skillStorageObject.transform;
- List<YotogiOld.VRSkillData> list2 = this.skill_data_[category];
- list.Clear();
- for (int j = 0; j < list2.Count; j++)
- {
- Transform transform3 = transform2.GetChild(j).transform;
- YotogiOldSkillUnitVR component = transform3.GetComponent<YotogiOldSkillUnitVR>();
- component.SetSkillData(list2[j]);
- component.isSelect = (this.selectedSkill == component.skill_data);
- list.Add(transform3);
- }
- foreach (Transform transform4 in list)
- {
- transform4.SetParent(this.skillUnitParent, false);
- }
- Utility.ResetNGUI(this.skillUnitParent.GetComponentInChildren<UIGrid>());
- Utility.ResetNGUI(componentInChildren);
- }
- private void OnClickSkillBtn(YotogiOldSkillUnitVR skill_data)
- {
- this.selectedSkill = skill_data.skill_data;
- YotogiOldManager.select_vr_skill_data = this.selectedSkill;
- EventDelegate.Execute(this.onClickEnterEvent);
- }
- private void OnClickStageSelect(StageOldUnitCircle circle)
- {
- if (this.uiMask.enabled)
- {
- return;
- }
- EventDelegate.Execute(this.onClickStageSelect);
- }
- private void OnClickCancel()
- {
- EventDelegate.Execute(this.onClickCancelEvent);
- }
- private YotogiOldSkillUnitVR CreateNewSkillUnit(GameObject root)
- {
- GameObject gameObject = Utility.CreatePrefab(root, "SceneYotogi/SkillSelect/Prefab/Old/SkillUnitVR", true);
- EventDelegate eventDelegate = new EventDelegate(this, "OnClickSkillBtn");
- EventDelegate.Parameter parameter = eventDelegate.parameters[0];
- parameter.obj = gameObject.GetComponent<YotogiOldSkillUnitVR>();
- gameObject.GetComponentInChildren<UIButton>().onClick.Add(eventDelegate);
- return gameObject.GetComponent<YotogiOldSkillUnitVR>();
- }
- [SerializeField]
- private UISprite bgSprite;
- [SerializeField]
- private Vector2 bgSize;
- [SerializeField]
- private StageOldUnitCircle stageSelectBtn;
- [SerializeField]
- private UIButton configBtn;
- [SerializeField]
- private UIButton vrConfigBtn;
- [SerializeField]
- private UIButton cblConfigBtn;
- [SerializeField]
- private UIButton cancelBtn;
- [SerializeField]
- private UIWidget widget;
- [SerializeField]
- private UIWFHitMasks uiMask;
- [SerializeField]
- private UIWFTabPanel categorySelectTabPanel;
- [SerializeField]
- private Transform skillUnitParent;
- [HideInInspector]
- public YotogiOld.VRSkillData selectedSkill;
- [HideInInspector]
- public List<EventDelegate> onClickEnterEvent = new List<EventDelegate>();
- [HideInInspector]
- public List<EventDelegate> onClickStageSelect = new List<EventDelegate>();
- [HideInInspector]
- public List<EventDelegate> onClickCancelEvent = new List<EventDelegate>();
- private GameObject skillStorageObject;
- private string selectCategoryName;
- private Dictionary<UIButton, Vector3> init_pos_dic_ = new Dictionary<UIButton, Vector3>();
- private Dictionary<string, List<YotogiOld.VRSkillData>> skill_data_ = new Dictionary<string, List<YotogiOld.VRSkillData>>();
- private float fadeInStartBgAlpha;
- private Vector2 fadeInStartBgSize;
- }
|