| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 | 
using UI.Guide;using FairyGUI;using UnityEngine;using System.Collections.Generic;using System;namespace GFGGame{    public class GuideView : BaseView    {        private UI_GuideUI _ui;        private GObject guideTarget = null;        private string guideKey;        private int guideId;        private int guideIndex;        private int _countGuideRect = 0;//需要找到引导对象没有找到对象的帧数计数        private bool justHint;//仅提示,无遮罩,点击任何地方可关闭引导        private bool NoTips;//无遮罩,无点击特效        private float compTxtY = 0;//提示语位置        private string txtContent = "";        private EffectUI _effectUI1;                public override void Dispose()        {            EffectUIPool.Recycle(_effectUI1);            _effectUI1 = null;            if (_ui != null)            {                _ui.Dispose();                _ui = null;            }            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            viewAnimationType = EnumViewAnimationType.None;            packageName = UI_GuideUI.PACKAGE_NAME;            _ui = UI_GuideUI.Create();            this.viewCom = _ui.target;            this.layer = ConstViewLayer.GUIDE;            //this.viewCom.sortingOrder = ConstSortingOrder.Guide;            isfullScreen = true;            _ui.m_loaMask.onClick.Add(OnClickTarget);            _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_comHolder.m_holder, "ui_zjm", "ui_zjm_xszy", 90);        }        protected override void OnShown()        {            base.OnShown();            List<object> dataList = viewData as List<object>;            guideTarget = dataList[0] as GObject;            guideKey = (string)dataList[1];            txtContent = (string)dataList[2];            guideId = (int)dataList[3];            guideIndex = (int)dataList[4];            compTxtY = (float)dataList[5];            justHint = (bool)dataList[6];            NoTips = (bool)dataList[7];            GRoot.inst.touchable = true;            MainDataManager.Instance.CanSwipe = false;            UpdateComTxt(txtContent);            _ui.m_mask.target.visible = false;            _ui.m_loaMask.visible = false;            _ui.m_grhMask.visible = false;            if (guideTarget != null)            {                _ui.m_grhMask.visible = true;                _ui.m_comHolder.target.visible = false;                Timers.inst.Add(0.3f, 1, UpdateTime);                // _ui.m_mask.target.visible = true;                // _ui.m_comHolder.target.visible = true;                guideTarget.onClick.Add(OnClickTarget);            }            else            {                _ui.m_loaMask.visible = true;                if (compTxtY > 0)                {                    _ui.m_compTxt.target.y = compTxtY;                }                _ui.m_comHolder.target.visible = false;                _ui.m_compTxt.target.visible = !String.IsNullOrEmpty(txtContent);            }            if (justHint)            {                _ui.m_mask.target.visible = false;                _ui.m_loaMask.visible = true;            }            if (NoTips)            {                _ui.m_mask.target.visible = false;                _ui.m_comHolder.target.visible = false;            }            //一些特殊引导            GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.STUDIO_PORCELAIN);   //作室书简修复            GuideCfg cfg1 = GuideCfgArray.Instance.GetCfg(ConstGuideId.STUDIO_FILING);  //引导查阅建档            GuideCfg cfg2 = GuideCfgArray.Instance.GetCfg(ConstGuideId.FIELD);  //田野调查            GuideCfg cfg4 = GuideCfgArray.Instance.GetCfg(ConstGuideId.STUDIO_PROPERTY);   //书简修复            GuideCfg cfg5 = GuideCfgArray.Instance.GetCfg(ConstGuideId.FREEDOM_DRESS);   //换装和拍照            if (guideId == cfg.id && guideIndex == 2 || guideId == cfg1.id && guideIndex == 2 || guideId == cfg2.id && guideIndex == 1 || guideId == cfg4.id && guideIndex == 1 || guideId == cfg5.id && guideIndex == 1)            {                _ui.m_loaMask.visible = false;                MainDataManager.Instance.CanSwipe = true;                Timers.inst.AddUpdate(UpdateStudioMetalGuide);            }            GuideCfg cfg3 = GuideCfgArray.Instance.GetCfg(ConstGuideId.LUCKY_BOX_LINE); // 引导抽奖连线            if (guideId == cfg3.id && guideIndex == 1)            {                _ui.m_mask.target.visible = false;                _ui.m_loaMask.visible = false;            }        }        protected override void OnHide()        {            Timers.inst.Remove(UpdateTime);            Timers.inst.Remove(UpdateGuideRect);            Timers.inst.Remove(UpdateStudioMetalGuide);            _ui.m_comHolder.target.visible = false;            _ui.m_compTxt.target.visible = false;            _ui.m_grhMask.visible = true;            guideTarget = null;            base.OnHide();            // EventAgent.DispatchEvent(ConstMessage.GUIDE_VIEW_HIDE);        }        private void UpdateComTxt(string txtContent)        {            if (String.IsNullOrEmpty(txtContent))            {                _ui.m_compTxt.target.visible = false;            }            else            {                _ui.m_compTxt.m_txt.text = txtContent;                if (this._ui.m_compTxt.m_txt.textHeight > this._ui.m_compTxt.m_txt.textFormat.size * 2)                {                    this._ui.m_compTxt.m_txt.align = AlignType.Left;                }                else                {                    this._ui.m_compTxt.m_txt.align = AlignType.Center;                }                this._ui.m_compTxt.m_txtBg.height = this._ui.m_compTxt.m_txtBg.initHeight;                if (this._ui.m_compTxt.m_txt.textHeight > this._ui.m_compTxt.m_txt.textFormat.size * 3)                {                    this._ui.m_compTxt.m_txtBg.height = this._ui.m_compTxt.m_txtBg.height + this._ui.m_compTxt.m_txt.textFormat.size;                }            }        }        private void UpdateTime(object param = null)        {            _countGuideRect = 0;            Timers.inst.AddUpdate(UpdateGuideRect);        }        private void UpdateGuideRect(object param = null)        {            if (!isShowing)            {                Timers.inst.Remove(UpdateGuideRect);                return;            }            if (guideTarget != null)            {                Vector2 pos = guideTarget.LocalToGlobal(Vector2.zero);                Vector2 logicScreenPos = _ui.target.GlobalToLocal(pos);                // pos = _ui.m_mask.target.GlobalToLocal(pos);                logicScreenPos.x = logicScreenPos.x + guideTarget.width / 2;                logicScreenPos.y = logicScreenPos.y + guideTarget.height / 2;                if (_ui.m_mask.m_guideArea.xy == logicScreenPos)                {                    //Timers.inst.Remove(UpdateGuideRect);                    _ui.m_comHolder.target.xy = _ui.m_mask.m_guideArea.xy;                    if (logicScreenPos.x > GRoot.inst.width / 2)                    {                        _ui.m_comHolder.m_c1.selectedIndex = 0;//手在左边                    }                    else                    {                        _ui.m_comHolder.m_c1.selectedIndex = 1;//手在右边                    }                    _ui.m_comHolder.target.visible = !NoTips;                    _ui.m_mask.target.visible = !NoTips;                    _ui.m_grhMask.visible = false;                    _ui.m_compTxt.target.visible = !String.IsNullOrEmpty(txtContent);                    int padding = 100;                    if (logicScreenPos.y < GRoot.inst.height - 700)                    {                        _ui.m_compTxt.target.y = logicScreenPos.y + _ui.m_comHolder.target.height + padding;//在下                    }                    else                    {                        _ui.m_compTxt.target.y = logicScreenPos.y - _ui.m_comHolder.target.height - _ui.m_compTxt.target.height - padding;//在上                    }                    if (compTxtY > 0)                    {                        _ui.m_compTxt.target.y = compTxtY;                    }                    return;                }                _ui.m_mask.m_guideArea.SetXY(logicScreenPos.x, logicScreenPos.y);            }            else {                _countGuideRect += 1;                //找不到引导对象3秒后关闭引导界面                if (_countGuideRect > 3 * 60) {                    this.Hide();                }            }        }        private void UpdateStudioMetalGuide(object param)        {            if (MainDataManager.Instance.ViewType == 1)            {                OnClickTarget();            }        }        private void OnClickTarget()        {            if (guideTarget != null) guideTarget.onClick.Remove(OnClickTarget);            GuideController.TryCompleteGuideIndex(guideKey, guideIndex);        }    }}
 |