123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- using FairyGUI;
- using UI.Main;
- using UI.CommonGame;
- using UnityEngine;
- using System.Collections.Generic;
- using ET;
- namespace GFGGame
- {
- public class MainUIView : BaseView
- {
- private UI_MainUI _ui;
- private GameObject _scenePrefab;
- private GameObject _sceneObject;
- private ValueBarController _valueBarController;
- private float effectTime = 0.7f;
- private bool isOpen = false;
- private GButton _btnGongGao;
- private GButton _btnHaoYou;
- private GButton _btnYouJian;
- private GButton _btnRenWu;
- private GButton _btnPengYouQuan;
- private GButton _btnJInShu;
- private GButton _btnTianGong;
- private GButton _btnStore;
- private GButton _btnTuJian;
- private GameObject _effectObj0;
- private GoWrapper _wrapper0;
- private GameObject _effectObj1;
- private GoWrapper _wrapper1;
- private GameObject _effectObj2;
- private GoWrapper _wrapper2;
- private GameObject _effectObj3;
- private GoWrapper _wrapper3;
- private GameObject _effectObj4;
- private GoWrapper _wrapper4;
- private GameObject _effectObj0_1;
- private GoWrapper _wrapper0_1;
- private GameObject _effectObj1_1;
- private GoWrapper _wrapper1_1;
- private GameObject _effectObj2_1;
- private GoWrapper _wrapper2_1;
- private GameObject _effectObj3_1;
- private GoWrapper _wrapper3_1;
- private GameObject _effectObj4_1;
- private GoWrapper _wrapper4_1;
- private GameObject _effectObj5;
- private GoWrapper _wrapper5;
- public override void Dispose()
- {
- _valueBarController.Dispose();
- _valueBarController = null;
- SceneController.DestroyObjectFromView(_effectObj0);
- SceneController.DestroyObjectFromView(_effectObj1);
- SceneController.DestroyObjectFromView(_effectObj2);
- SceneController.DestroyObjectFromView(_effectObj3);
- SceneController.DestroyObjectFromView(_effectObj4);
- SceneController.DestroyObjectFromView(_effectObj0_1);
- SceneController.DestroyObjectFromView(_effectObj1_1);
- SceneController.DestroyObjectFromView(_effectObj2_1);
- SceneController.DestroyObjectFromView(_effectObj3_1);
- SceneController.DestroyObjectFromView(_effectObj4_1);
- base.Dispose();
- }
- protected override void Init()
- {
- base.Init();
- packageName = UI_MainUI.PACKAGE_NAME;
- _ui = UI_MainUI.Create();
- viewCom = _ui.target;
- isfullScreen = true;
- _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneMain"));
- }
- protected override void OnInit()
- {
- base.OnInit();
- _valueBarController = new ValueBarController(_ui.m_valueBar);
- _btnGongGao = _ui.m_list.GetChild("btnGongGao").asButton;
- _btnHaoYou = _ui.m_list.GetChild("btnHaoYou").asButton;
- _btnYouJian = _ui.m_list.GetChild("btnYouJian").asButton;
- _btnRenWu = _ui.m_list.GetChild("btnRenWu").asButton;
- _btnPengYouQuan = _ui.m_list.GetChild("btnPengYouQuan").asButton;
- _btnStore = _ui.m_list.GetChild("btnStore").asButton;
- _btnTianGong = _ui.m_list.GetChild("btnTianGong").asButton;
- _btnTuJian = _ui.m_list.GetChild("btnTuJian").asButton;
- _btnJInShu = _ui.m_list.GetChild("btnJInShu").asButton;
- // _btnGongGao.visible = false;
- // _btnHaoYou.visible = false;
- _btnRenWu.visible = false;
- _btnPengYouQuan.visible = false;
- _btnJInShu.visible = false;
- _btnTianGong.visible = false;
- _ui.m_btnMain.target.onTouchBegin.Add(OnClickBtnMain);
- _ui.m_btnHuanZhuang.target.onTouchBegin.Add(OnClickBtnHuanZhuang);
- _ui.m_btnZhaiXing.target.onTouchBegin.Add(OnClickBtnZhaiXing);
- _ui.m_btnXiuFang.target.onTouchBegin.Add(OnClickBtnXiuFang);
- _ui.m_btnCiPai.target.onTouchBegin.Add(OnClickBtnCiPai);
- _ui.m_btnStudio.target.onTouchBegin.Add(OnClickBtnStudio);
- _ui.m_btnField.target.onTouchBegin.Add(OnClickBtnField);
- _ui.m_headBar.target.onClick.Add(OnClickHeadBar);
- _btnStore.onClick.Add(OnClickBtnStore);
- _btnTuJian.onClick.Add(OnClickBtnTuJian);
- _btnYouJian.onClick.Add(OnClickBtnYouJian);
- _btnHaoYou.onClick.Add(OnClickBtnHaoYou);
- _btnGongGao.onClick.Add(OnClickBtnGongGao);
- AddEffect();
- EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnNumericChange);
- }
- protected override void OnShown()
- {
- base.OnShown();
- _ui.m_btnChange.selected = true;
- _ui.m_headBar.m_txtName.text = RoleDataManager.roleName;
- if (_sceneObject == null)
- {
- _sceneObject = GameObject.Instantiate(_scenePrefab);
- }
- SceneController.UpdateMainScene(_sceneObject);
- UpdateRoleLvl();
- _valueBarController.OnShown();
- CheckFunOpen();
- // UpdateToCheckGuide();
- Timers.inst.AddUpdate(Update);
- }
- protected override void OnHide()
- {
- base.OnHide();
- if (_sceneObject != null)
- {
- GameObject.Destroy(_sceneObject);
- _sceneObject = null;
- }
- _valueBarController.OnHide();
- Timers.inst.Remove(Update);
- }
- private void AddEffect()
- {
- string resPath0 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_xf_tx");
- SceneController.AddObjectToView(_effectObj0, _wrapper0, _ui.m_btnXiuFang.m_holder, resPath0, out _effectObj0, out _wrapper0);
- SceneController.AddObjectToView(_effectObj1, _wrapper1, _ui.m_btnHuanZhuang.m_holder, resPath0, out _effectObj1, out _wrapper1);
- SceneController.AddObjectToView(_effectObj2, _wrapper2, _ui.m_btnZhaiXing.m_holder, resPath0, out _effectObj2, out _wrapper2);
- SceneController.AddObjectToView(_effectObj3, _wrapper3, _ui.m_btnCiPai.m_holder, resPath0, out _effectObj3, out _wrapper3);
- string resPath1 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zzl_tx");
- SceneController.AddObjectToView(_effectObj4, _wrapper4, _ui.m_btnMain.m_holder, resPath1, out _effectObj4, out _wrapper4);
- string resPath3 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zjm_dj");
- SceneController.AddObjectToView(_effectObj0_1, _wrapper0_1, _ui.m_btnXiuFang.m_holder1, resPath3, out _effectObj0_1, out _wrapper0_1);
- SceneController.AddObjectToView(_effectObj1_1, _wrapper1_1, _ui.m_btnHuanZhuang.m_holder1, resPath3, out _effectObj1_1, out _wrapper1_1);
- SceneController.AddObjectToView(_effectObj2_1, _wrapper2_1, _ui.m_btnZhaiXing.m_holder1, resPath3, out _effectObj2_1, out _wrapper2_1);
- SceneController.AddObjectToView(_effectObj3_1, _wrapper3_1, _ui.m_btnCiPai.m_holder1, resPath3, out _effectObj3_1, out _wrapper3_1);
- SceneController.AddObjectToView(_effectObj4_1, _wrapper4_1, _ui.m_btnMain.m_holder1, resPath3, out _effectObj4_1, out _wrapper4_1);
- string resPath2 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zjm_tx");
- SceneController.AddObjectToView(_effectObj5, _wrapper5, _ui.m_headBar.m_holder, resPath2, out _effectObj5, out _wrapper5);
- }
- private void OnClickBtnMain()
- {
- if (isOpen) return;
- isOpen = true;
- _ui.m_btnMain.m_holder1.visible = true;
- Timers.inst.Add(effectTime, 1, (param) =>
- {
- _ui.m_btnMain.m_holder1.visible = false;
- // this.Hide();
- ViewManager.Show(ViewName.STORY_CHAPTER_LIST_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
- isOpen = false; ;
- });
- }
- private void OnClickBtnHuanZhuang()
- {
- if (isOpen) return;
- isOpen = true;
- _ui.m_btnHuanZhuang.m_holder1.visible = true;
- Timers.inst.Add(effectTime, 1, (param) =>
- {
- _ui.m_btnHuanZhuang.m_holder1.visible = false;
- this.Hide();
- ViewManager.Show(ViewName.DRESS_UP_VIEW);
- isOpen = false;
- });
- }
- private void OnClickBtnZhaiXing()
- {
- if (isOpen) return;
- isOpen = true;
- _ui.m_btnZhaiXing.m_holder1.visible = true;
- Timers.inst.Add(effectTime, 1, (param) =>
- {
- _ui.m_btnZhaiXing.m_holder1.visible = false;
- ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, null, false, true);
- isOpen = false;
- });
- }
- private void OnClickBtnXiuFang()
- {
- if (isOpen) return;
- isOpen = true;
- _ui.m_btnXiuFang.m_holder1.visible = true;
- Timers.inst.Add(effectTime, 1, (param) =>
- {
- _ui.m_btnXiuFang.m_holder1.visible = false;
- ViewManager.Show(ViewName.XIU_FANG_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
- isOpen = false;
- });
- }
- private void OnClickBtnCiPai()
- {
- if (isOpen) return;
- isOpen = true;
- _ui.m_btnCiPai.m_holder1.visible = true;
- Timers.inst.Add(effectTime, 1, (param) =>
- {
- _ui.m_btnCiPai.m_holder1.visible = false;
- ViewManager.Show(ViewName.CARD_DETAIL_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
- isOpen = false;
- });
- }
- private void OnClickBtnStudio()
- {
- ViewManager.Show<StudioView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
- }
- private void OnClickBtnField()
- {
- ViewManager.Show<FieldView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
- }
- private void OnClickBtnStore()
- {
- ViewManager.Show(ViewName.RECHARGE_STORE_VIEW);
- }
- private void OnClickBtnTuJian()
- {
- ViewManager.Show(ViewName.FIELD_GUIDE_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
- }
- private void OnClickBtnYouJian()
- {
- ViewManager.Show<MailView>();
- }
- private void OnClickBtnHaoYou()
- {
- ViewManager.Show<FriendView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData }, true);
- }
- private void OnClickBtnGongGao()
- {
- // /null, new object[] { ViewName.MAINUI_VIEW, this.viewData }
- ViewManager.Show<NoticeView>();
- }
- private void OnClickHeadBar()
- {
- ViewManager.Show(ViewName.ROLE_INFO_VIEW);
- }
- private void CheckFunOpen()
- {
- _ui.m_btnXiuFang.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(XiuFangView).Name, false);
- _ui.m_btnMain.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StoryChapterListView).Name, false);
- _ui.m_btnStudio.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StudioView).Name, false);
- _ui.m_btnHuanZhuang.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(DressUpView).Name, false);
- _ui.m_btnZhaiXing.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(LuckyBoxView).Name, false);
- _ui.m_btnCiPai.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(CardDetailView).Name, false);
- }
- private void Update(object param)
- {
- if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home))
- {
- Alert.Show("我会想你的")
- .SetLeftButton(true, "继续游戏")
- .SetRightButton(true, "退出游戏", (object data) =>
- {
- Application.Quit();
- });
- }
- }
- private void OnNumericChange(EventContext context)
- {
- if ((int)context.data == NumericType.Lvl)
- {
- UpdateRoleLvl();
- }
- }
- private void UpdateRoleLvl()
- {
- _ui.m_headBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
- }
- protected override void UpdateToCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- GuideController.TryGuide(_ui.m_btnZhaiXing.target, ConstGuideId.LUCKY_BOX, 2, "“摘星”里可以通过星辰的力量获得服饰", -1, false);
- GuideController.TryCompleteGuide(ConstGuideId.FREEDOM_DRESS, 6);
- GuideController.TryGuide(_ui.m_btnHuanZhuang.target, ConstGuideId.FREEDOM_DRESS, 2, "在这里,可以自由搭配服饰和分享哦~", -1, false);
- GuideController.TryGuide(_ui.m_btnXiuFang.target, ConstGuideId.CLOTHING_SYNTHETIC, 5, "绣坊里增添了新功能", -1, true);
- GuideController.TryCompleteGuide(ConstGuideId.CLOTHING_SYNTHETIC, 11);
- GuideController.TryGuide(_ui.m_btnCiPai.target, ConstGuideId.UP_CARD_STAR, 2, "已经收集了足够的材料,可以给词牌升星了", -1, false);
- GuideController.TryGuide(_ui.m_btnHuanZhuang.target, ConstGuideId.PHOTOGRAPH, 2, "点这里看看吧", -1, false);
- }
- }
- }
|