| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 | 
							- using System.Collections;
 
- using UnityEngine;
 
- using UI.LuckyBox;
 
- using System.Collections.Generic;
 
- using FairyGUI;
 
- using System.Threading;
 
- using System.Threading.Tasks;
 
- using System;
 
- using Random = UnityEngine.Random;
 
- namespace GFGGame
 
- {
 
-     public class LuckyBoxStarView : BaseWindow
 
-     {
 
-         private UI_LuckyBoxStarUI _ui;
 
-         private List<GObject> comStars = new List<GObject>();
 
-         private List<GObject> clickComStars = new List<GObject>();
 
-         private List<GObject> notClickComStars = new List<GObject>();
 
-         // private List<GameObject> _gameObjects = new List<GameObject>();
 
-         // private List<GoWrapper> _wrappers = new List<GoWrapper>();
 
-         // private List<GameObject> _gameObjects1 = new List<GameObject>();
 
-         // private List<GoWrapper> _wrappers1 = new List<GoWrapper>();
 
-         private List<EffectUI> dicEffect = new List<EffectUI>();
 
-         private List<EffectUI> effObj = new List<EffectUI>();
 
-         private EffectUI _effectUI1;
 
-         private EffectUI _effectUI2;
 
-         private EffectUI _effectUI3;
 
-         private GObject curComStar;//当前选中的星星
 
-         private Vector2 lastPos;//鼠标的上一个位置,每颗星星初始时默认为Vector2.right;
 
-         private List<ItemData> _rewardList;
 
-         private const int checkDistance = 40;//鼠标靠近星星周围加减40都算选中星星
 
-         private const int imgLineWidth = 10;//线的原始长度
 
-         private bool _isLuckyBox = true;//是抽奖(true),是限时主题活动(false)
 
-         private bool showGuide = false;
 
-         public override void Dispose()
 
-         {
 
-             EffectUIPool.Recycle(_effectUI1);
 
-             _effectUI1 = null;
 
-             EffectUIPool.Recycle(_effectUI2);
 
-             _effectUI2 = null;
 
-             EffectUIPool.Recycle(_effectUI3);
 
-             _effectUI3 = null;
 
-             if (_ui != null)
 
-             {
 
-                 _ui.Dispose();
 
-                 _ui = null;
 
-             }
 
-             base.Dispose();
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             int index = 0;
 
-             GObject star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
 
-             while (star != null && star.visible == true)
 
-             {
 
-                 UI_ComStar comStar = UI_ComStar.Proxy(star);
 
-                 for (int i = comStar.target.numChildren - 1; i >= 0; i--)
 
-                 {
 
-                     if (comStar.target.GetChildAt(i).name == "comLine") continue;
 
-                     var starchild = comStar.target.RemoveChildAt(i);
 
-                     starchild.Dispose();
 
-                 }
 
-                 index++;
 
-                 star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
 
-                 UI_ComStar.ProxyEnd();
 
-             }
 
-             for (int i = 0; i < dicEffect.Count; i++)
 
-             {
 
-                 EffectUIPool.Recycle(dicEffect[i]);
 
-                 dicEffect[i] = null;
 
-             }
 
-             for (int i = 0; i < effObj.Count; i++)
 
-             {
 
-                 EffectUIPool.Recycle(effObj[i]);
 
-                 effObj[i] = null;
 
-             }
 
-             notClickComStars.Clear();
 
-             clickComStars.Clear();
 
-             dicEffect.Clear();
 
-             effObj.Clear();
 
-             Timers.inst.Remove(CheckGuide);
 
-             Debug.Log("OnHide  LuckyBoxStarView");
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             _ui = UI_LuckyBoxStarUI.Create();
 
-             this.viewCom = _ui.target;
 
-             isfullScreen = true;
 
-             _ui.m_btnBack.visible = false;
 
-             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
 
-             UpdateEffect();
 
-         }
 
-         private void UpdateEffect()
 
-         {
 
-             _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holder_star, "ui_LuckyBox", "bg_liuxing");
 
-             _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holder_bg, "ui_LuckyBox", "bg_thing");
 
-             _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holder_cloud, "ui_LuckyBox", "bg_cloud");
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             Debug.Log("OnShown:  LuckyBoxStarView");
 
-             _ui.target.onTouchBegin.Add(OnClickUIBegin);
 
-             _ui.target.onTouchMove.Add(OnClickUIMove);
 
-             _ui.target.onTouchEnd.Add(OnClickUIEnd);
 
-             _ui.m_effEnd.visible = false;
 
-             _rewardList = LuckyBoxDataManager.Instance.RewardList;
 
-             _ui.m_ctrlBuyType.selectedIndex = _rewardList != null && _rewardList.Count > 1 ? 1 : 0;
 
-             _isLuckyBox = LuckyBoxDataManager.Instance.luckyBoxIds.IndexOf(LuckyBoxDataManager.Instance.currentBoxId) >= 0;
 
-             _ui.m_ctrlRewardsType.selectedIndex = LuckyBoxDataManager.Instance.luckyBoxIndex;// _isLuckyBox ? (LuckyBoxDataManager.Instance.currentBoxId - 1) : 0;
 
-             // string resPath = string.Format("cj_tp_{0}", _isLuckyBox ? LuckyBoxDataManager.Instance.currentBoxId : 1);
 
-             _ui.m_bg.url = ResPathUtil.GetBgImgPath("zx_bg");
 
-             ResetStartView();
 
-             Timers.inst.AddUpdate(CheckGuide);
 
-         }
 
-         private void ResetStartView()
 
-         {
 
-             showGuide = GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX_LINE) <= 0;
 
-             curComStar = null;
 
-             for (int i = 0; i < comStars.Count; i++) {
 
-                 comStars.RemoveAt(i);
 
-             }
 
-             comStars.Clear();
 
-             int index = 0;
 
-             GObject star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
 
-             while (star != null && star.visible == true)
 
-             {
 
-                 UI_ComStar comStar = UI_ComStar.Proxy(star);
 
-                 comStar.m_comLine.target.visible = true;
 
-                 comStar.m_c1.selectedIndex = 0;
 
-                 comStar.m_comLine.target.width = imgLineWidth;
 
-                 comStar.m_comLine.target.rotation = 0;
 
-                 float scale = Random.Range(0.5f, 1f);
 
-                 float rotation = Random.Range(0, 360);
 
-                 GComponent gcom = CreateEffect(comStar, 1, _isLuckyBox ? "STAR_Ready_Bule" : "STAR_Ready"); ;
 
-                 gcom.visible = true;
 
-                 comStar.target.AddChildAt(gcom, 1);
 
-                 gcom.scale = new Vector2(scale, scale);
 
-                 gcom.rotation = rotation;
 
-                 GComponent gcom1 = CreateEffect(comStar, 2, _isLuckyBox ? "STAR_Bule" : "STAR");
 
-                 gcom1.visible = false;
 
-                 comStar.target.AddChildAt(gcom1, 2);
 
-                 gcom1.scale = new Vector2(scale, scale);
 
-                 gcom1.rotation = rotation;
 
-                 star.data = new Vector2(comStar.target.x, comStar.target.y);
 
-                 comStars.Add(star);
 
-                 index++;
 
-                 star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
 
-                 UI_ComStar.ProxyEnd();
 
-             }
 
-         }
 
-         private GComponent CreateEffect(UI_ComStar comStar, int index, string name)
 
-         {
 
-             GComponent gcom;
 
-             if (comStar.target.numChildren > index)
 
-             {
 
-                 gcom = comStar.target.GetChildAt(index).asCom;
 
-             }
 
-             else
 
-             {
 
-                 gcom = UIPackage.CreateObject("LuckyBox", "ComHolder").asCom;
 
-                 EffectUI _effectUI = EffectUIPool.CreateEffectUI(gcom.GetChild("holder").asGraph, "ui_LuckyBox", name);
 
-                 dicEffect.Add(_effectUI);
 
-             }
 
-             return gcom;
 
-         }
 
-         private void OnClickUIBegin(EventContext context)
 
-         {
 
-             context.CaptureTouch();
 
-             InputEvent inputEvent = (InputEvent)context.data;
 
-             Vector2 mousePos = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
 
-             CheckNearbyPos(mousePos);
 
-         }
 
-         private void OnClickUIMove(EventContext context)
 
-         {
 
-             InputEvent inputEvent = (InputEvent)context.data;
 
-             Vector2 mousePos = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
 
-             CheckNearbyPos(mousePos);
 
-             if (comStars.Count == 0)//所有星星都点亮了主动结束
 
-             {
 
-                 this.OnClickUIEnd();
 
-             }
 
-         }
 
-         //检测鼠标附近的星星
 
-         private void CheckNearbyPos(Vector2 mousePos)
 
-         {
 
-             for (int i = comStars.Count - 1; i >= 0; i--)
 
-             {
 
-                 Vector2 comStarPos = (Vector2)comStars[i].data;
 
-                 if (IsSamePos(mousePos, comStarPos))
 
-                 {
 
-                     if (curComStar != null)
 
-                     {
 
-                         SetCurComStarTransfrom(comStarPos);
 
-                     }
 
-                     UI_ComStar comStar = UI_ComStar.Proxy(comStars[i]);
 
-                     comStar.target.GetChildAt(2).asCom.visible = true;
 
-                     // comStar.target.GetChildAt(1).asCom.visible = false;
 
-                     string resPath = _isLuckyBox ? "LINE_Bule" : "LINE";
 
-                     EffectUI _effectUI = EffectUIPool.CreateEffectUI(comStar.m_comLine.m_holder, "ui_LuckyBox", resPath);
 
-                     effObj.Add(_effectUI);
 
-                     UI_ComStar.ProxyEnd();
 
-                     curComStar = comStars[i];
 
-                     lastPos = Vector2.right;
 
-                     clickComStars.Add(comStars[i]);
 
-                     comStars.RemoveAt(i);
 
-                 }
 
-                 else
 
-                 {
 
-                     if (curComStar != null)
 
-                     {
 
-                         Vector2 curPos = mousePos - (Vector2)curComStar.data;
 
-                         SetCurComStarTransfrom(mousePos);
 
-                         lastPos = curPos;
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         private void SetCurComStarTransfrom(Vector2 targetPos)
 
-         {
 
-             Vector2 curPos = targetPos - (Vector2)curComStar.data;
 
-             float angle = Vector3.Angle(lastPos, curPos); //求出两向量之间的夹角 
 
-             Vector3 normal = Vector3.Cross(lastPos, curPos);//叉乘求出法线向量 
 
-             angle *= Mathf.Sign(Vector3.Dot(normal, Vector3.forward));  //Mathf.Sign()求符号,Vector3.Dot()求方向,求法线向量与物体上方向向量点乘,结果为1或-1,修正旋转方向 
 
-             UI_ComStar comStar = UI_ComStar.Proxy(curComStar);
 
-             comStar.m_comLine.target.rotation += angle;
 
-             comStar.m_comLine.target.width = Vector2.Distance(targetPos, (Vector2)curComStar.data);
 
-             UI_ComStar.ProxyEnd();
 
-         }
 
-         private void OnClickUIEnd()
 
-         {
 
-             if (clickComStars.Count <= 0) return;
 
-             UI_ComStar comStar = UI_ComStar.Proxy(clickComStars[clickComStars.Count - 1]);
 
-             comStar.m_comLine.target.visible = false;
 
-             UI_ComStar.ProxyEnd();
 
-             if (showGuide && clickComStars.Count < 2)
 
-             {
 
-                 ResetStartView();
 
-             }
 
-             else
 
-             {
 
-                 // CheckNotClickComStar();
 
-                 // SetComStarDarken();
 
-                 RemoveListener();
 
-                 // Timers.inst.Add(1f, 1, SetClickComStarAni);
 
-                 Timers.inst.Add(0.5f, 1, SetEndEffect);
 
-             }
 
-         }
 
-         // private void CheckNotClickComStar()
 
-         // {
 
-         //     int index = 0;
 
-         //     GObject star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
 
-         //     while (star != null && star.visible == true)
 
-         //     {
 
-         //         if (clickComStars.IndexOf(star) < 0)
 
-         //         {
 
-         //             notClickComStars.Add(star);
 
-         //         }
 
-         //         index++;
 
-         //         star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
 
-         //     }
 
-         // }
 
-         // private void SetComStarDarken()
 
-         // {
 
-         //     for (int i = 0; i < notClickComStars.Count; i++)
 
-         //     {
 
-         //         UI_ComStar notClickComStar = UI_ComStar.Proxy(notClickComStars[i]);
 
-         //         notClickComStar.m_comLine.target.visible = false;
 
-         //         notClickComStar.target.GetChildAt(3).asCom.visible = true;
 
-         //         notClickComStar.target.GetChildAt(1).asCom.visible = false;
 
-         //         UI_ComStar.ProxyEnd();
 
-         //     }
 
-         // }
 
-         // private void SetClickComStarAni(object param)
 
-         // {
 
-         //     for (int i = 0; i < clickComStars.Count; i++)
 
-         //     {
 
-         //         UI_ComStar comStar = UI_ComStar.Proxy(clickComStars[i]);
 
-         //         comStar.target.GetChildAt(4).asCom.visible = true;
 
-         //         UI_ComStar.ProxyEnd();
 
-         //     }
 
-         //     Timers.inst.Add(0.5f, 1, SetEndEffect);
 
-         // }
 
-         private void SetEndEffect(object param)
 
-         {
 
-             _ui.m_effEnd.visible = true;
 
-             _ui.m_effEnd.SetPlaySettings(0, -1, 1, -1);
 
-             Timers.inst.Add(0.6f, 1, ClickUIEnd);
 
-             // ClickUIEnd(null);
 
-             TryCompleteGuide();
 
-         }
 
-         private void ClickUIEnd(object param)
 
-         {
 
-             if (curComStar != null)
 
-             {
 
-                 RemoveListener();
 
-                 // ViewManager.Show<LuckyBoxBonusView>(new object[] { _rewardList });
 
-                 ViewManager.Show<LuckyBoxNewDressView>(_rewardList);
 
-                 this.Hide();
 
-             }
 
-         }
 
-         private bool IsSamePos(Vector2 mousePos, Vector2 comStarPos)
 
-         {
 
-             return (mousePos.x < comStarPos.x + checkDistance) && (mousePos.x > comStarPos.x - checkDistance) && (mousePos.y < comStarPos.y + checkDistance) && (mousePos.y > comStarPos.y - checkDistance);
 
-         }
 
-         private void RemoveListener()
 
-         {
 
-             _ui.target.onTouchBegin.Remove(OnClickUIBegin);
 
-             _ui.target.onTouchMove.Remove(OnClickUIMove);
 
-             _ui.target.onTouchEnd.Remove(OnClickUIEnd);
 
-         }
 
-         private void OnClickBtnBack()
 
-         {
 
-             this.Hide();
 
-             RemoveListener();
 
-             ViewManager.Show<LuckyBoxView>();
 
-         }
 
-         private void CheckGuide(object param)
 
-         {
 
-             if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX_LINE) <= 0)
 
-             {
 
-                 UpdateToCheckGuide(null);
 
-             }
 
-             else
 
-             {
 
-                 Timers.inst.Remove(CheckGuide);
 
-             }
 
-         }
 
-         protected override void UpdateToCheckGuide(object param)
 
-         {
 
-             if (!ViewManager.CheckIsTopView(this.viewCom)) return;
 
-             GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.LUCKY_BOX_LINE);
 
-             // GuideController.TryCompleteGuide(ConstGuideId.LUCKY_BOX, 4);
 
-             GuideController.TryGuide(null, ConstGuideId.LUCKY_BOX_LINE, 1, "点击将星连接在一起。", -1, true, (int)(this.viewCom.height - 200), true);
 
-             TryCompleteGuide();
 
-         }
 
-         protected override void TryCompleteGuide()
 
-         {
 
-             if (clickComStars.Count >= 2)
 
-             {
 
-                 // GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.LUCKY_BOX_LINE);
 
-                 GuideController.TryCompleteGuideIndex(ConstGuideId.LUCKY_BOX_LINE, 1);
 
-                 GuideController.TryCompleteGuide(ConstGuideId.LUCKY_BOX_LINE, 1);
 
-             }
 
-             else
 
-             {
 
-                 GuideDataManager.SetGuideIndexState(GuideDataManager.currentGuideId, GuideDataManager.currentGuideIdIndex, 0);
 
-                 GuideDataManager.currentGuideIdIndex = 3;
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |