| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 |
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using cfg.GfgCfg;
- using ET;
- using FairyGUI;
- using UI.MatchingCompetition;
- using UnityEngine;
- using UnityEngine.UI;
- namespace GFGGame
- {
- class MatchingCompetitionSelectView : BaseWindow
- {
- private UI_MatchingCompetitionSelectUI _ui;
- private int _seasonIndex = 0;
- private bool isRefresh = false;
- private JudgingRoundOpenCfg judgingCfg;
- private GameObject _sceneObjectLeft;
- private GameObject _sceneObjectRight;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- }
- if (_sceneObjectLeft != null)
- {
- PrefabManager.Instance.Restore(_sceneObjectLeft);
- _sceneObjectLeft = null;
- }
- if (_sceneObjectRight != null)
- {
- PrefabManager.Instance.Restore(_sceneObjectRight);
- _sceneObjectRight = null;
- }
- _ui = null;
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_MatchingCompetitionSelectUI.PACKAGE_NAME;
- _ui = UI_MatchingCompetitionSelectUI.Create();
- this.viewCom = _ui.target;
- isReturnView = true;
- isfullScreen = true;
- _ui.m_BtnBack.onClick.Add(OnClickBtnBack);
- _ui.m_select1.target.onClick.Add(OnClickBtnSelect1);
- _ui.m_select2.target.onClick.Add(OnClickBtnSelect2);
- _ui.m_ruleBtn.onClick.Add(MatchingCompetitionDataManager.Instance.OnClickBtnRule);
- }
- protected override void OnShown()
- {
- base.OnShown();
- _ui.m_bg.url = ResPathUtil.GetBgImgPath("pxs_bj");
- _ui.m_BtnBack.touchable = true;
- _ui.m_titleText.text = CommonDataManager.Tables.TblJudgingRoundOpenCfg
- .DataList[MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason - 1].Name;
- //isRefresh = (bool)this.viewData;
- judgingCfg =
- CommonDataManager.Tables.TblJudgingRoundOpenCfg.GetOrDefault(MatchingCompetitionDataManager.Instance
- .MatchingCompetitionSeason);
- UpdateView();
- UpdatePlayer();
- //UpdateDressLeft();
- ViewManager.Hide<ModalStatusView>();
- Timers.inst.AddUpdate(CheckGuide);
- }
- protected override void OnHide()
- {
- if (_sceneObjectLeft != null)
- {
- PrefabManager.Instance.Restore(_sceneObjectLeft);
- _sceneObjectLeft = null;
- }
- if (_sceneObjectRight != null)
- {
- PrefabManager.Instance.Restore(_sceneObjectRight);
- _sceneObjectRight = null;
- }
- MatchingCompetitionDataManager.Instance.DressPropIndex = 0;
- Timers.inst.Remove(CheckGuide);
- base.OnHide();
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH, UpdatePlayer);
- //EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateDressLeft);
- EventAgent.AddEventListener(ConstMessage.REWARDVIEW_CLOTHER, ShowReward);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH, UpdatePlayer);
- //EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateDressLeft);
- EventAgent.RemoveEventListener(ConstMessage.REWARDVIEW_CLOTHER, ShowReward);
- }
- private void ShowReward()
- {
- if (MatchingCompetitionDataManager.Instance.SpecialBonusList != null &&
- MatchingCompetitionDataManager.Instance.SpecialBonusList.Count > 0)
- {
- ViewManager.Show<MatchingCompetitionRewardView>(new object[]
- { ItemUtil.CreateItemDataList(MatchingCompetitionDataManager.Instance.SpecialBonusList), null });
- MatchingCompetitionDataManager.Instance.SpecialBonusList = null;
- }
- }
- #region 宇谦把调用到的这个都注释掉了,具体这段代码的意思我也懒得去理解了, 反正没在用
- // private async void UpdateDressLeft()
- // {
- // //ViewManager.Show<ModalStatusView>("获取搭配数据中...");
- // MatchingLeftDataManager.Instance.itemGameObjs.Clear();
- // MatchingRightDataManager.Instance.itemGameObjs.Clear();
- // PhotographDataManager.Instance.itemGameObjs.Clear();
- // PhotographDataManager.Instance.dressUpObj?.Dispose();
- // PhotographDataManager.Instance.dressUpObj = new DressUpObj();
- // if (_sceneObjectLeft == null)
- // {
- // _sceneObjectLeft = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("ScenePhotograph"));
- // // 创建render texture
- // renderTexureLeft = new RenderTexture((int)_ui.m_playerShow1.target.width,
- // (int)_ui.m_playerShow2.target.height, 24);
- //
- // // 换装父节点 + 相机
- // Camera camera = _sceneObjectLeft.transform.Find("Camera").GetComponent<Camera>();
- // camera.gameObject.SetActive(true);
- // camera.targetTexture = renderTexureLeft;
- // // 创建RawImg
- // }
- //
- // PhotographSceneManager.Instance.sceneObject = _sceneObjectLeft;
- // if (MatchingLeftDataManager.Instance.DressUpBgID == 0)
- // {
- // PhotographSceneManager.Instance.AddBgItem(CommonDataManager.Tables.TblItemCfg.GetOrDefault(180001));
- // }
- // else
- // {
- // PhotographSceneManager.Instance.AddBgItem(
- // CommonDataManager.Tables.TblItemCfg.GetOrDefault(MatchingLeftDataManager.Instance.DressUpBgID));
- // }
- //
- // PhotographSceneManager.Instance.AddBodyItem(1);
- // GameObject bodyParent = _sceneObjectLeft.transform.Find("Scene/Role").gameObject;
- // PhotographDataManager.Instance.dressUpObj.setSceneObj(_sceneObjectLeft, false, true, bodyParent, false,
- // null);
- // PhotographDataManager.Instance.dressUpObj.PutOnDressUpData(
- // MatchingLeftDataManager.Instance.MathingDressDate);
- //
- // //对搭配赛特殊处理
- // foreach (var item in MatchingLeftDataManager.Instance.DressPropTransInfoDic)
- // {
- // if (item.Key == MatchingLeftDataManager.Instance.roleID)
- // {
- // continue;
- // }
- // else
- // {
- // List<int> idList = MatchingCompetitionDataManager.Instance.GetIDListByString(item.Key);
- // ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(idList[0]);
- // if (idList.Count > 1)
- // {
- // MatchingCompetitionDataManager.Instance.AddSceneItemOne(itemCfg, idList[1], idList[2]);
- // }
- // else
- // {
- // MatchingCompetitionDataManager.Instance.AddSceneItem(itemCfg, false);
- // }
- // //MatchingCompetitionDataManager.Instance.AddSceneItemOne(itemCfg, idList[1], idList[2]);
- // }
- // }
- //
- // await Task.Delay(200);
- // MatchingLeftDataManager.Instance.InsertGameObjectList();
- // for (int i = 0; i < MatchingLeftDataManager.Instance.itemGameObjs.Count; i++)
- // {
- // GameObject itemGObj = MatchingLeftDataManager.Instance.itemGameObjs[i];
- // TransformData itemdata = new TransformData();
- // if (MatchingLeftDataManager.Instance.DressPropTransInfoDic.ContainsKey(itemGObj.name))
- // {
- // itemdata = MatchingLeftDataManager.Instance.DressPropTransInfoDic[itemGObj.name];
- // }
- //
- // MatchingLeftDataManager.Instance.itemGameObjs[i].transform.position = itemdata.position;
- // if (MatchingLeftDataManager.Instance.itemGameObjs[i].name == "Role")
- // {
- // if (itemdata.position.y >= -5 || itemdata.position.y <= 5)
- // {
- // MatchingLeftDataManager.Instance.itemGameObjs[i].transform.position =
- // new Vector3(itemdata.position.x, 0, 0);
- // }
- //
- // if (itemdata.position.x >= -5 || itemdata.position.x <= 5)
- // {
- // MatchingLeftDataManager.Instance.itemGameObjs[i].transform.position = new Vector3(0,
- // MatchingLeftDataManager.Instance.itemGameObjs[i].transform.position.y, 0);
- // }
- // }
- //
- // MatchingLeftDataManager.Instance.itemGameObjs[i].transform.Rotate(itemGObj.transform.eulerAngles.x,
- // itemGObj.transform.eulerAngles.y, itemdata.rotationZ);
- // MatchingLeftDataManager.Instance.itemGameObjs[i].transform.localScale = itemdata.scale;
- // PhotographUtil.Instance.ChangeLayer(MatchingLeftDataManager.Instance.itemGameObjs[i],
- // i * PhotographDataManager.layerCount, "up");
- // }
- //
- // PhotographUtil.Instance.ChangeLayer(MatchingLeftDataManager.Instance.roleGameobj,
- // 2 * PhotographDataManager.layerCount, "up");
- // await Task.Delay(50);
- // UpdateDressRigh();
- // }
- // private async void UpdateDressRigh()
- // {
- // MatchingRightDataManager.Instance.itemGameObjs.Clear();
- // PhotographDataManager.Instance.itemGameObjs.Clear();
- // PhotographDataManager.Instance.dressUpObj?.Dispose();
- // PhotographDataManager.Instance.dressUpObj = new DressUpObj();
- // if (_sceneObjectRight == null)
- // {
- // _sceneObjectRight =
- // PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("ScenePhotograph"));
- // // 创建render texture
- // renderTexureRight = new RenderTexture((int)_ui.m_playerShow1.target.width,
- // (int)_ui.m_playerShow2.target.height, 24);
- //
- // // 换装父节点 + 相机
- // Camera camera = _sceneObjectRight.transform.Find("Camera").GetComponent<Camera>();
- // camera.gameObject.SetActive(true);
- // camera.targetTexture = renderTexureRight;
- // }
- //
- // PhotographSceneManager.Instance.sceneObject = _sceneObjectRight;
- // if (MatchingRightDataManager.Instance.DressUpBgID == 0)
- // {
- // PhotographSceneManager.Instance.AddBgItem(CommonDataManager.Tables.TblItemCfg.GetOrDefault(180004));
- // }
- // else
- // {
- // PhotographSceneManager.Instance.AddBgItem(
- // CommonDataManager.Tables.TblItemCfg.GetOrDefault(MatchingRightDataManager.Instance.DressUpBgID));
- // }
- //
- // PhotographSceneManager.Instance.AddBodyItem(2);
- // GameObject bodyParent = _sceneObjectRight.transform.Find("Scene/Role").gameObject;
- // PhotographDataManager.Instance.dressUpObj.setSceneObj(_sceneObjectRight, false, true, bodyParent, false,
- // null);
- // PhotographDataManager.Instance.dressUpObj.PutOnDressUpData(MatchingRightDataManager.Instance
- // .MathingDressDate);
- //
- // //对搭配赛特殊处理
- // foreach (var item in MatchingRightDataManager.Instance.DressPropTransInfoDic)
- // {
- // if (item.Key == MatchingRightDataManager.Instance.roleID)
- // {
- // continue;
- // }
- // else
- // {
- // List<int> idList = MatchingCompetitionDataManager.Instance.GetIDListByString(item.Key);
- // ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(idList[0]);
- // if (idList.Count > 1)
- // {
- // MatchingCompetitionDataManager.Instance.AddSceneItemOne(itemCfg, idList[1], idList[2]);
- // }
- // else
- // {
- // MatchingCompetitionDataManager.Instance.AddSceneItem(itemCfg, false);
- // }
- // //MatchingCompetitionDataManager.Instance.AddSceneItemOne(itemCfg, idList[1], idList[2]);
- // }
- // }
- //
- // await Task.Delay(200);
- // MatchingRightDataManager.Instance.InsertGameObjectList();
- // for (int i = 0; i < MatchingRightDataManager.Instance.itemGameObjs.Count; i++)
- // {
- // GameObject itemGObj = MatchingRightDataManager.Instance.itemGameObjs[i];
- // TransformData itemdata = new TransformData();
- // if (MatchingRightDataManager.Instance.DressPropTransInfoDic.ContainsKey(itemGObj.name))
- // {
- // itemdata = MatchingRightDataManager.Instance.DressPropTransInfoDic[itemGObj.name];
- // }
- //
- // MatchingRightDataManager.Instance.itemGameObjs[i].transform.position = itemdata.position;
- // if (MatchingRightDataManager.Instance.itemGameObjs[i].name == "Role")
- // {
- // if (itemdata.position.y >= -5 || itemdata.position.y <= 5)
- // {
- // MatchingRightDataManager.Instance.itemGameObjs[i].transform.position =
- // new Vector3(itemdata.position.x, 0, 0);
- // }
- //
- // if (itemdata.position.x >= -5 || itemdata.position.x <= 5)
- // {
- // MatchingRightDataManager.Instance.itemGameObjs[i].transform.position = new Vector3(0,
- // MatchingRightDataManager.Instance.itemGameObjs[i].transform.position.y, 0);
- // }
- // }
- //
- // MatchingRightDataManager.Instance.itemGameObjs[i].transform.Rotate(itemGObj.transform.eulerAngles.x,
- // itemGObj.transform.eulerAngles.y, itemdata.rotationZ);
- // MatchingRightDataManager.Instance.itemGameObjs[i].transform.localScale = itemdata.scale;
- // PhotographUtil.Instance.ChangeLayer(MatchingRightDataManager.Instance.itemGameObjs[i],
- // i * PhotographDataManager.layerCount, "up");
- // }
- //
- // PhotographUtil.Instance.ChangeLayer(MatchingRightDataManager.Instance.roleGameobj,
- // 2 * PhotographDataManager.layerCount, "up");
- // await Task.Delay(50);
- // _sceneObjectRight.transform.position = new Vector3(50, 50, 50);
- // UpdatePlayer();
- // }
- #endregion
- private RenderTexture renderTexureLeft;
- private RenderTexture renderTexureRight;
- private void UpdatePlayer()
- {
- //_ui.m_playerShow1.m_playerImage.m_playerImage.texture = new NTexture(renderTexureLeft);
- //_ui.m_playerShow2.m_playerImage.m_playerImage.texture = new NTexture(renderTexureRight);
- _ui.m_playerShow1.m_playerImage.m_playerImage.texture =
- MatchingLeftDataManager.Instance.LeftRoleInfo.Ntexture;
- _ui.m_playerShow2.m_playerImage.m_playerImage.texture =
- MatchingRightDataManager.Instance.RightRoleInfo.Ntexture;
- MatchingPhotoWorksData otherLeftdata = MatchingLeftDataManager.Instance.LeftRoleInfo;
- JudgingRoundRoleInfo otherLeftInfo = otherLeftdata.JudgingInfo;
- RoleInfoManager.Instance.UpdateHead(_ui.m_player1.m_head, otherLeftInfo.HeadItemId,
- otherLeftInfo.HeadBorderItemId);
- _ui.m_player1.m_nameText.text = otherLeftInfo.RoleName.ToString();
- _ui.m_select1.m_numText.visible = false;
- _ui.m_player1.m_nameText.visible = false;
- _ui.m_select1.m_numText.text = otherLeftInfo.Score.ToString();
- MatchingPhotoWorksData otherRightdata = MatchingRightDataManager.Instance.RightRoleInfo;
- JudgingRoundRoleInfo otherRightInfo = otherRightdata.JudgingInfo;
- RoleInfoManager.Instance.UpdateHead(_ui.m_player2.m_head, otherRightInfo.HeadItemId,
- otherRightInfo.HeadBorderItemId);
- _ui.m_player2.m_nameText.text = otherRightInfo.RoleName.ToString();
- _ui.m_select2.m_numText.visible = false;
- _ui.m_player2.m_nameText.visible = false;
- _ui.m_select2.m_numText.text = otherRightInfo.Score.ToString();
- ViewManager.Hide<ModalStatusView>();
- }
- private void UpdateView()
- {
- _ui.m_selectText1.alpha = 0;
- _ui.m_selectText2.alpha = 0;
- _ui.m_timeText.text = string.Format("剩余次数:{0}",
- Mathf.Max(0, judgingCfg.FreeTimes - MatchingCompetitionDataManager.Instance.MatchingRemainingTimes));
- }
- private void OnClickBtnBack()
- {
- _ui.m_BtnBack.touchable = true;
- ViewManager.GoBackFrom(typeof(MatchingCompetitionSelectView).FullName);
- }
- private async void OnClickBtnSelect1()
- {
- if ((judgingCfg.FreeTimes - MatchingCompetitionDataManager.Instance.MatchingRemainingTimes) <= 0)
- {
- PromptController.Instance.ShowFloatTextPrompt("评选次数不足");
- return;
- }
- bool result = await MatchingCompetitionSproxy.ReqCheckMatchingCompetitionWork(
- MatchingLeftDataManager.Instance.LeftRoleInfo.JudgingInfo.WorksId,
- MatchingRightDataManager.Instance.RightRoleInfo.JudgingInfo.WorksId
- );
- if (result)
- {
- _ui.m_select1.m_c1.selectedIndex = 1;
- _ui.m_select1.m_numText.visible = true;
- _ui.m_select2.m_numText.visible = true;
- _ui.m_player1.m_nameText.visible = true;
- _ui.m_player2.m_nameText.visible = true;
- _ui.m_select1.m_numText.text = string.Format("心动值{0}",
- MatchingLeftDataManager.Instance.LeftRoleInfo.JudgingInfo.Score.ToString());
- _ui.m_timeText.text = string.Format("剩余次数:{0}",
- Mathf.Max(0,
- judgingCfg.FreeTimes - MatchingCompetitionDataManager.Instance.MatchingRemainingTimes));
- }
- _ui.m_t0.Play(async () =>
- {
- bool resulst = await MatchingCompetitionSproxy.ReqGetTwoPlayers();
- if (resulst)
- {
- if (_sceneObjectLeft != null)
- {
- PrefabManager.Instance.Restore(_sceneObjectLeft);
- _sceneObjectLeft = null;
- }
- if (_sceneObjectRight != null)
- {
- PrefabManager.Instance.Restore(_sceneObjectRight);
- _sceneObjectRight = null;
- }
- //UpdateDressLeft();
- UpdateView();
- }
- });
- }
- private async void OnClickBtnSelect2()
- {
- if ((judgingCfg.FreeTimes - MatchingCompetitionDataManager.Instance.MatchingRemainingTimes) <= 0)
- {
- PromptController.Instance.ShowFloatTextPrompt("评选次数不足");
- return;
- }
- bool result = await MatchingCompetitionSproxy.ReqCheckMatchingCompetitionWork(
- MatchingRightDataManager.Instance.RightRoleInfo.JudgingInfo.WorksId,
- MatchingLeftDataManager.Instance.LeftRoleInfo.JudgingInfo.WorksId
- );
- if (result)
- {
- _ui.m_select2.m_c1.selectedIndex = 1;
- _ui.m_select1.m_numText.visible = true;
- _ui.m_select2.m_numText.visible = true;
- _ui.m_player1.m_nameText.visible = true;
- _ui.m_player2.m_nameText.visible = true;
- _ui.m_select2.m_numText.text = string.Format("心动值{0}",
- MatchingRightDataManager.Instance.RightRoleInfo.JudgingInfo.Score.ToString());
- _ui.m_timeText.text = string.Format("剩余次数:{0}",
- Mathf.Max(0,
- judgingCfg.FreeTimes - MatchingCompetitionDataManager.Instance.MatchingRemainingTimes));
- }
- _ui.m_t1.Play(async () =>
- {
- bool resulst = await MatchingCompetitionSproxy.ReqGetTwoPlayers();
- if (resulst)
- {
- if (_sceneObjectLeft != null)
- {
- PrefabManager.Instance.Restore(_sceneObjectLeft);
- _sceneObjectLeft = null;
- }
- if (_sceneObjectRight != null)
- {
- PrefabManager.Instance.Restore(_sceneObjectRight);
- _sceneObjectRight = null;
- }
- // UpdateDressLeft();
- UpdateView();
- }
- });
- }
- private void CheckGuide(object param)
- {
- if (GuideDataManager.IsGuideFinish("DAPEISAI_2") <= 0)
- {
- UpdateToCheckGuide(null);
- }
- else
- {
- Timers.inst.Remove(CheckGuide);
- }
- }
- protected override void UpdateToCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- GuideController.TryGuide(_ui.m_select1.target, "DAPEISAI_2", 3, "选择你喜欢的搭配!");
- GuideController.TryCompleteGuide("DAPEISAI_2", 3);
- }
- }
- }
|