12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232 |
- using System;
- using System.Collections.Generic;
- using Core.Language;
- using Excel2Json;
- using Fort23.Core;
- using Fort23.Mono.Phases;
- using Fort23.UTool;
- using GameLogic.Bag;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.UI;
- using Utility;
- using Utility.CTween;
- namespace Fort23.Mono
- {
- public class PlayerGuideManager : Singleton<PlayerGuideManager>
- {
- public bool isSkip = false;
- public bool isUnLockAll = false;
- /// <summary>
- /// 调试模式.
- /// </summary>
- public bool isDebugging;
- public List<int> debugPhase = new List<int>();
- public UnityAction overCallBack;
- /// <summary>
- /// 是否完成强制引导
- /// </summary>
- public bool isForceDone = true;
- /// <summary>
- /// 是否完成非强制引导
- /// </summary>
- public bool isTriggerDone = true;
- /// <summary>
- /// 手指
- /// </summary>
- public Transform finger;
- /// <summary>
- /// 黑底Obj
- /// </summary>
- public GameObject blackBaseObj;
- /// <summary>
- /// 新手引导表
- /// </summary>
- public PlayerGuideConfig guideConfig;
- /// <summary>
- /// 光圈(方)
- /// </summary>
- public Transform fxTrans01;
- /// <summary>
- /// 光圈(圆)
- /// </summary>
- public Transform fxTrans02;
- /// <summary>
- /// 高亮区域
- /// </summary>
- // public GameObject fxHighLightObj;
- public Image highLightSpr;
- /// <summary>
- /// 保存 被改变父级的引用
- /// </summary>
- private Transform myMother;
- /// <summary>
- /// 被改变的目标
- /// </summary>
- private GameObject target;
- /// <summary>
- /// 引导目标上一次的坐标
- /// </summary>
- private Vector3 lastPos;
- /// <summary>
- /// 当前引导id
- /// </summary>
- public int curPhase = -1;
- /// <summary>
- /// 当前步骤
- /// </summary>
- public int curStep;
- // private bool mIsNew = false;
- //
- // public bool IsNewUser
- // {
- // get { return mIsNew; }
- // set { mIsNew = value; }
- // }
- public DialogBox dialogBox = new DialogBox();
- public IGuideLogic guideLogic;
- /// <summary>
- /// 简化配置用.
- /// </summary>
- public bool isReadFingerPos;
- public bool isInitGuide = false;
- public GameRuntimeConfig GameRuntimeConfig;
- public Map<int, int> ALLGuideStepData = new Map<int, int>();
- public PlayerGuideManager()
- {
- InitGuide();
- }
- /// <summary>
- /// 引导重置
- /// </summary>
- /// <param name="id"></param>
- public void GuideReset(int id)
- {
- if (AccountFileInfo.Instance.playerData.phaseKey.Contains(id))
- {
- int maxCount = 0;
- if (ALLGuideStepData.ContainsKey(id))
- {
- maxCount = ALLGuideStepData[id];
- }
- var idx = AccountFileInfo.Instance.playerData.phaseKey.IndexOf(id);
- if (AccountFileInfo.Instance.playerData.phaseValue[idx] < maxCount)
- {
- AccountFileInfo.Instance.playerData.phaseValue[idx] = -1;
- }
- }
- }
- /// <summary>
- /// 新手引导是否能做 步数从0开始 需要看对应逻辑所在的索引
- /// </summary>
- /// <param name="groupID"></param>
- /// <returns></returns>
- public bool GuideIsCanDo(int groupID, int curstep = 0)
- {
- // if (!(groupID == 9 || groupID == 910 || groupID == 320))
- // {
- // return false;
- // }
- // if (groupID != 330)
- // {
- // return false;
- // }
- // if (GuideIsCanDo(5))
- // {
- // return false;
- // }
- if (curstep > 1 && guideLogic == null)
- {
- return false;
- }
- if (AccountFileInfo.Instance.playerData == null) //todo 容错测试场景没有玩家数据
- {
- LogTool.Log("AccountFileInfo.Instance.playerSetting = " + AccountFileInfo.Instance.playerData);
- return false;
- }
- if (isSkip)
- {
- return false;
- }
- if (isDebugging)
- {
- if (!debugPhase.Contains(groupID) !)
- {
- return false;
- }
- }
- if (guideLogic != null)
- {
- if (guideLogic.guideID != groupID)
- {
- return false;
- }
- }
- //
- // if (!isDebugging) //如果不是指定调试就要判断是否能触发
- // {
- // if (groupID >= 0)
- // {
- // int configId = (groupID + 1) * 100 + 1;
- // PlayerGuideConfig playerGuideConfig = ConfigComponent.Instance.Get<PlayerGuideConfig>(configId);
- //
- // if (playerGuideConfig.NeedLevel > PlayerManager.Instance.Level)
- // {
- // return false;
- // }
- // }
- // }
- int maxCount = 0;
- if (ALLGuideStepData.ContainsKey(groupID))
- {
- maxCount = ALLGuideStepData[groupID];
- }
- int step = GetPhaseStep(groupID);
- if (curstep != -1) //判断这个新手引导这一步能否做
- {
- if (curstep <= step)
- {
- return false;
- }
- if (curstep - step > 1) //只能比当前步数多1才可以执行
- {
- return false;
- }
- }
- if (step >= maxCount)
- {
- return false;
- }
- return true;
- }
- public TimerEntity _timerEntity;
- public void ChangeBtnSkip()
- {
- GuidePanel guidePanel = UIManager.Instance.GetComponent<GuidePanel>();
- if (guidePanel != null)
- guidePanel.Btn_Skip.gameObject.SetActive(false);
- _timerEntity?.Dispose();
- _timerEntity = null;
- _timerEntity = TimerComponent.Instance.AddTimer(10000, () =>
- {
- if (UIManager.Instance.GetComponent<GuidePanel>() != null)
- UIManager.Instance.GetComponent<GuidePanel>().Btn_Skip.gameObject.SetActive(true);
- });
- }
- /// <summary>
- /// 引导初始化
- /// </summary>
- public void InitGuide()
- {
- foreach (var playerGuideConfig in ConfigComponent.Instance.GetAll<PlayerGuideConfig>())
- {
- if (!ALLGuideStepData.ContainsKey(playerGuideConfig.groupID))
- {
- ALLGuideStepData.Add(playerGuideConfig.groupID, 1);
- }
- else
- {
- ALLGuideStepData[playerGuideConfig.groupID] += 1;
- }
- }
- //
- // EventManager.Instance.AddEventListener(CustomEventType.NextGuide, RunNextGuide);
- GameRuntimeConfig = GameApplction.gameApplction.gameRuntimeConfig;
- LogTool.Log("InitGuide************************");
- if (isInitGuide)
- {
- LogTool.Log("已初始化");
- return;
- }
- isSkip = GameRuntimeConfig.isSkip;
- isDebugging = GameRuntimeConfig.isDebug;
- isUnLockAll = GameRuntimeConfig.isUnlockAll;
- // #if UNITY_IPHONE || UNITY_ANDROID&&!UNITY_EDITOR
- // IsUseServerData = true;
- // #endif
- //
- #if !UNITY_EDITOR
- // isSkip = false;
- // isDebugging = false;
- // isUnLockAll = false;
- // IsUseServerData = true;
- #endif
- List<int> ids = new List<int>();
- if (GameRuntimeConfig.debugPhase.x != 0)
- {
- ids.Add((int)GameRuntimeConfig.debugPhase.x);
- }
- if (GameRuntimeConfig.debugPhase.y != 0)
- {
- ids.Add((int)GameRuntimeConfig.debugPhase.y);
- }
- if (GameRuntimeConfig.debugPhase.z != 0)
- {
- ids.Add((int)GameRuntimeConfig.debugPhase.z);
- }
- if (GameRuntimeConfig.debugPhase.w != 0)
- {
- ids.Add((int)GameRuntimeConfig.debugPhase.w);
- }
- debugPhase = ids;
- if (isDebugging)
- {
- for (var i = 0; i < debugPhase.Count; i++)
- {
- if (AccountFileInfo.Instance.playerData.phaseKey.Contains((int)debugPhase[i]))
- {
- var idx = AccountFileInfo.Instance.playerData.phaseKey.IndexOf(debugPhase[i]);
- AccountFileInfo.Instance.playerData.phaseValue[idx] = -1;
- }
- }
- }
- if (isSkip || isDebugging)
- {
- isInitGuide = true;
- isForceDone = true;
- return;
- }
- isForceDone = AccountFileInfo.Instance.playerData.isForceDone;
- // curPhase = AccountFileInfo.Instance.playerData.curPhase;
- // curStep = AccountFileInfo.Instance.playerData.curStep;
- //完成强制引导
- if (isForceDone)
- {
- isInitGuide = true;
- return;
- }
- //新用户,从未做过新手引导
- // if (PlayerManager.Instance.curGuideGroupId == 0 && curPhase <= 0)
- // {
- // curPhase = 0;
- // }
- // //没有引导记录,但有游戏记录(不是第一次玩)
- // else if (PlayerManager.Instance.currStageId > 1 && curPhase <= 0)
- // {
- // LogTool.Warning("玩家更换了设备,或者本地引导记录被删除,跳过所有强制引导:" + PlayerManager.Instance.PlayerId);
- // isForceDone = true;
- // isInitGuide = true;
- // AccountFileInfo.Instance.playerSetting.isForceDone = true;
- // AccountFileInfo.Instance.Save();
- // return;
- // }
- // else if (PlayerManager.Instance.currStageId > 10)
- // {
- // LogTool.Warning("超过10关了,强制引导已经完成:" + PlayerManager.Instance.PlayerId);
- // isForceDone = true;
- // isInitGuide = true;
- // AccountFileInfo.Instance.playerSetting.isForceDone = true;
- // AccountFileInfo.Instance.Save();
- // return;
- // }
- // else
- // {
- //
- // }
- isInitGuide = true;
- }
- private int GetPhaseStep(int key)
- {
- if (AccountFileInfo.Instance.playerData.phaseKey.Contains(key))
- {
- int idx = AccountFileInfo.Instance.playerData.phaseKey.IndexOf(key);
- return AccountFileInfo.Instance.playerData.phaseValue[idx];
- }
- else
- {
- return -1;
- }
- }
- /// <summary>
- /// 将目标加到新手引导的Panel里面.
- /// </summary>
- /// <param name="target"></param>
- public void JoinMe(GameObject target)
- {
- finger.gameObject.SetActive(false);
- if (target == null)
- {
- LogTool.Log("______" + "找不到目标");
- return;
- }
- Transform transform = UIManager.Instance.GetComponent<GuidePanel>().transform;
- if (target.transform.parent.Equals(transform))
- {
- LogTool.Log("______" + "重复改变目标的父节点,自动忽略,可能是断网重连造成的,请检查");
- return;
- }
- this.lastPos = target.transform.localPosition;
- myMother = target.transform.parent;
- this.target = target;
- target.transform.parent = transform;
- target.transform.localScale = Vector3.one;
- fxTrans01.gameObject.SetActive(true);
- fxTrans01.position = target.transform.position;
- }
- /// <summary>
- /// 还原对象
- /// </summary>
- public void ReductionTargetObject()
- {
- target.transform.parent = myMother;
- target.transform.localPosition = lastPos;
- }
- public void JoinMe(GameObject target, Vector3 vector3)
- {
- if (target == null)
- {
- LogTool.Log("______" + "找不到目标");
- return;
- }
- Transform transform = UIManager.Instance.GetComponent<GuidePanel>().transform;
- if (target.transform.parent.Equals(transform))
- {
- LogTool.Log("______" + "重复改变目标的父节点,自动忽略,可能是断网重连造成的,请检查");
- return;
- }
- this.lastPos = target.transform.localPosition;
- myMother = target.transform.parent;
- this.target = target;
- target.transform.parent = transform;
- target.transform.localScale = Vector3.one;
- fxTrans01.gameObject.SetActive(true);
- fxTrans01.parent = target.transform;
- fxTrans01.localPosition = vector3;
- fxTrans01.parent = transform;
- finger.gameObject.SetActive(false);
- }
- public void RestGuide()
- {
- curPhase = 0;
- curStep = 0;
- }
- /// <summary>
- /// 设置新手引导
- /// </summary>
- /// <param name="phase"></param>
- public async CTask SetGuid(int phase)
- {
- if (isDebugging)
- {
- if (!debugPhase.Contains(phase))
- {
- return;
- }
- }
- if (isSkip)
- {
- return;
- }
- if (guideLogic != null)
- {
- return;
- }
- UIManager.Instance.SetEventSystemEnable(false);
- curPhase = phase;
- guideLogic = null;
- guideLogic = GetIGuideLogic(curPhase);
- GuidePanel guildPanel =
- await UIManager.Instance.LoadAndOpenPanel<GuidePanel>(null, UILayer.Top, isFocus: false);
- dialogBox.Init();
- UIManager.Instance.SetEventSystemEnable(true);
- finger = guildPanel.GuideHand;
- fxTrans01 = guildPanel.FocusFrame01;
- fxTrans02 = guildPanel.FocusFrame02;
- blackBaseObj = guildPanel.Btn_Bg.gameObject;
- guideLogic.SavePhase(curPhase);
- guideLogic.ClearList();
- guideLogic.Active();
- guideLogic.Begin();
- NextGuideEx();
- }
- public IGuideLogic GetIGuideLogic(int groupId)
- {
- string typeName = " Fort23.Mono.Phases.Phase" + groupId;
- IGuideLogic guideLogic = null;
- System.Type type = System.Type.GetType(typeName);
- if (type == null)
- {
- LogTool.Error("没有找到Phase" + groupId + "脚本");
- return null;
- }
- object[] constructorArgs = new object[] { this };
- guideLogic = (IGuideLogic)Activator.CreateInstance(type, constructorArgs);
- // switch (groupId)
- // {
- // case 1:
- // guideLogic = new Phase1(this);
- // break;
- // case 2:
- // guideLogic = new Phase2(this);
- // break;
- // case 3:
- // guideLogic = new Phase3(this);
- // break;
- // }
- return guideLogic;
- }
- /// <summary>
- /// 关闭引导,重置到初始状态.
- /// </summary>
- public void ResetPlayerGuide()
- {
- Transform transform = UIManager.Instance.GetComponent<GuidePanel>().transform;
- finger.transform.parent = transform;
- finger.transform.localScale = new Vector3(1, 1, 1);
- SetFingerVisiable(false);
- }
- public void SetFingerVisiable(bool b, string playName = "Loop")
- {
- finger.gameObject.SetActive(b);
- GuidePanel guidePanel = UIManager.Instance.GetComponent<GuidePanel>();
- switch (guideConfig.FingerType)
- {
- case 1:
- guidePanel.GuideHandState.ChangeState(0);
- break;
- case 2:
- guidePanel.GuideHandState.ChangeState(1);
- break;
- case 3:
- guidePanel.GuideHandState.ChangeState(2);
- break;
- case 4:
- playName = "changan";
- guidePanel.GuideHandState.ChangeState(1);
- break;
- case -1:
- finger.gameObject.SetActive(false);
- break;
- }
- SetFingerAnimation(playName);
- }
- public void SetFingerSize(Vector3 size)
- {
- finger.localScale = size;
- }
- public void SetfxTransVisiable(bool b, int type = 0)
- {
- switch (type)
- {
- case 0:
- fxTrans01.gameObject.SetActive(b);
- break;
- case 1:
- fxTrans02.gameObject.SetActive(b);
- break;
- }
- }
- public void SetfxTransImageVisiable(bool b, int type = 0)
- {
- switch (type)
- {
- case 0:
- fxTrans01.gameObject.GetComponent<MyImage>().enabled = b;
- break;
- case 1:
- fxTrans02.gameObject.GetComponent<MyImage>().enabled = b;
- break;
- }
- }
- public void SetBlackBaseVisiable(bool b)
- {
- blackBaseObj.gameObject.SetActive(b);
- }
- public void SetBlackA(byte b)
- {
- Color c = new Color32(0, 0, 0, b);
- blackBaseObj.gameObject.GetComponent<Image>().color = c;
- }
- public void FinishATriggerGuide()
- {
- SetBlackBaseVisiable(false);
- if (guideLogic != null)
- {
- guideLogic = null;
- }
- }
- public bool IsStepSkip = false;
- public async CTask ConfigLogic(int configID, System.Action action, int diTyp = 1, string str = null)
- {
- IsStepSkip = false;
- guideConfig = ConfigComponent.Instance.Get<PlayerGuideConfig>(configID);
- if (guideConfig.AwardItem != null)
- {
- for (var i = 0; i < guideConfig.AwardItem.Length; i++)
- {
- PlayerManager.Instance.BagController.AddItem(new ItemInfo(guideConfig.AwardItem[i],
- guideConfig.AwardItemNum[i]));
- }
- }
- if (guideConfig.desc == -1)
- {
- HideDialogBox();
- }
- else
- {
- HideDialogBox(false);
- }
- if (guideConfig.IsSkip == 1)
- {
- IsStepSkip = true;
- NextGuide();
- return;
- }
- if (guideConfig.Highlighting == 0)
- {
- SetfxTransImageVisiable(false);
- }
- else
- {
- SetfxTransImageVisiable(true);
- }
- int[] fPos = guideConfig.fingerPos;
- int[] dPos = guideConfig.dialogPos;
- isReadFingerPos = true;
- SetFingerVisiable(false);
- SetFingerPos(fPos);
- SetDialogPos(dPos);
- SetBlackBaseVisiable(true);
- SetBlackAlpha(guideConfig.blackAlpha);
- ShowDialogBox(action, str);
- await dialogBox.SetDiTex(guideConfig, guideConfig.SpeakerImage);
- UIManager.Instance.SetEventSystemEnable(true);
- }
- /// <summary>
- /// 下一步引导
- /// </summary>
- public async void NextGuide()
- {
- if (BreakGuide(guideLogic))
- {
- return;
- }
- try
- {
- //容错:
- await guideLogic.Guide();
- }
- catch (System.Exception e)
- {
- LogTool.Error("打印异常信息:" + e);
- ResetPlayerGuide();
- CloseForceGuide();
- LogTool.Error("引导出错,出错步骤,Phase=" + curPhase + "-" + curStep);
- }
- EventManager.Instance.Dispatch(CustomEventType.NextGuide, null);
- }
- public CTask CanDoNextCTask;
- public async void RunNextGuide(IEventData eventData)
- {
- if (CanDoNextCTask != null)
- {
- await CanDoNextCTask;
- NextGuideEx();
- }
- else
- {
- NextGuideEx();
- }
- CanDoNextCTask = null;
- }
- public void NextGuideEx()
- {
- if (BreakGuide(guideLogic))
- {
- return;
- }
- try
- {
- //容错:
- guideLogic.Guide();
- }
- catch (System.Exception e)
- {
- LogTool.Error("打印异常信息:" + e);
- ResetPlayerGuide();
- CloseForceGuide();
- LogTool.Error("引导出错,出错步骤,Phase=" + curPhase + "-" + curStep);
- }
- ChangeBtnSkip();
- }
- private bool BreakGuide(IGuideLogic guideLogic)
- {
- //#if UNITY_EDITOR
- if (isSkip)
- {
- this.guideLogic = null;
- return true;
- }
- //#endif
- if (guideLogic == null)
- {
- return true;
- }
- if (guideLogic.isSkipGuide)
- {
- LogTool.Log("引导开启条件不符合,不再执行");
- this.guideLogic = null;
- return true;
- }
- //强制和非强制引导都完成
- if (isForceDone && isTriggerDone)
- {
- LogTool.Log("引导完成");
- this.guideLogic = null;
- return true;
- }
- return false;
- }
- public void SkipGuide()
- {
- }
- /// <summary>
- /// 关闭强制引导
- /// </summary>
- public void CloseForceGuide()
- {
- HideDialogBox();
- isForceDone = true;
- SetBlackBaseVisiable(false);
- if (guideLogic != null)
- {
- guideLogic = null;
- }
- overCallBack?.Invoke();
- overCallBack = null;
- UIManager.Instance.HideUIUIPanel<GuidePanel>(UIDestroyType.ImmediatelyDestroy);
- }
- public void SetBlackAlpha(float f)
- {
- if (f == 0)
- {
- f = 0.05f;
- }
- Color color = blackBaseObj.GetComponent<Image>().color;
- color.a = f;
- blackBaseObj.GetComponent<Image>().color = color;
- }
- public BetterList<string> dialogList = new BetterList<string>();
- public void HideDialogBox(bool isHide = true)
- {
- GuidePanel guidePanel = UIManager.Instance.GetComponent<GuidePanel>();
- if (guidePanel != null)
- {
- guidePanel.DialogBoxState.gameObject.SetActive(!isHide);
- // if (isHide)
- // {
- // guidePanel.DialogBoxState.gameObject.SetActive(false);
- // }
- }
- }
- /// <summary>
- /// 显示对话框
- /// </summary>
- public void ShowDialogBox(System.Action action = null, string key = null)
- {
- if (guideConfig.desc == -1)
- {
- action?.Invoke();
- action = null;
- return;
- }
- GuidePanel guidePanel = UIManager.Instance.GetComponent<GuidePanel>();
- switch (guideConfig.SpeakerStyle)
- {
- case 1:
- guidePanel.DialogBoxState.ChangeState(0);
- break;
- case 2:
- guidePanel.DialogBoxState.ChangeState(1);
- break;
- case 3:
- guidePanel.DialogBoxState.ChangeState(2);
- break;
- case 4:
- guidePanel.DialogBoxState.ChangeState(3);
- break;
- }
- dialogBox.ChangeState(guideConfig.SpeakerStyle);
- if (guideConfig.SpeakerStyle != 3)
- {
- SetDialogPos(guideConfig.dialogPos);
- }
- string str = null;
- if (key == null)
- {
- str = LanguageManager.Instance.Text(guideConfig.desc);
- }
- else
- {
- str = string.Format(LanguageManager.Instance.Text(guideConfig.desc), key);
- }
- string[] textArr = str.Split(';');
- dialogList.Clear();
- foreach (string tex in textArr)
- {
- dialogList.Add(tex);
- }
- dialogBox.Open(dialogList, action);
- }
- private void SetDialogPos(int[] dPos)
- {
- if (dPos != null)
- {
- Vector3 pos = new Vector3(dPos[0], dPos[1], 0);
- float ratio = Screen.width / 750f;
- pos.x *= ratio;
- dialogBox.MessageBG.localPosition = pos;
- }
- else
- {
- dialogBox.MessageBG.localPosition = new Vector3(-125, -100, 0);
- }
- }
- private void SetNpcPos(int[] nPos)
- {
- if (nPos != null)
- {
- Vector3 pos = new Vector3(nPos[0], nPos[1], 0);
- // dialogBox.UISpiritLoader.transform.localPosition = pos;
- }
- else
- {
- // dialogBox.UISpiritLoader.transform.localPosition = new Vector3(422, -100, 0);
- }
- }
- public void SetFingerPos(Vector3 pos, GameObject gameObject = null)
- {
- if (gameObject != null)
- {
- finger.GetComponent<RectTransform>().pivot = gameObject.GetComponent<RectTransform>().pivot;
- }
- else
- {
- finger.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
- }
- finger.transform.localPosition = pos;
- }
- private CustomVectorTween _customVectorTween;
- public void SetFingerTweenMove(Vector3 starPos, Vector3 endPos, float time)
- {
- // SetFingerAnimation("Loop");
- _customVectorTween?.Kill();
- _customVectorTween = null;
- _customVectorTween = CustomTweenManager
- .To(() => starPos, x => SetFingerPos(x), endPos, time, finger.gameObject)
- .SetEase(CustomTweenEX.CustomAnimationCurve.Line).SetLoop(true);
- }
- public void SetFingerAnimation(string playerName)
- {
- // SetFingerAnimation("Loop");
- finger.GetComponent<Animator>().Play(playerName);
- }
- private void SetFingerPos(int[] fPos)
- {
- SetFingerPos(new Vector3(9999, 9999, 0));
- if (fPos != null && fPos.Length >= 2)
- {
- Vector3 pos = new Vector3(fPos[0], fPos[1], 0);
- SetFingerPos(pos);
- }
- else
- {
- isReadFingerPos = false;
- }
- // if (guideConfig.reversalFinger == 1)
- // {
- // finger.transform.localScale = new Vector3(1, 1, 1);
- // }
- // else if (guideConfig.reversalFinger == 2)
- // {
- // finger.transform.localScale = new Vector3(-1, 1, 1);
- // }
- }
- public Vector2 GetProperPos(Vector3 pos, Vector2 size, GameObject gameObject = null)
- {
- if (gameObject != null)
- {
- Vector2 pivot = gameObject.GetComponent<RectTransform>().pivot;
- Vector2 pivot1 = pivot - Vector2.one * 0.5f;
- float x = pos.x - size.x * pivot1.x;
- float y = pos.y - size.y * pivot1.y;
- return new Vector2(x, y);
- }
- else
- {
- return pos;
- }
- }
- /// <summary>
- /// 设置展示框的大小和位置 如果有锚点同步传入对应gameobject
- /// </summary>
- /// <param name="pos"></param>
- /// <param name="size"></param>
- /// <param name="type">0是矩阵 1是圆形</param>
- /// <param name="gameObject"></param>
- public void SetShowFramePosAndSize(Vector3 pos, Vector2 size, int type = 0, GameObject gameObject = null)
- {
- switch (type)
- {
- case 0:
- if (gameObject != null)
- {
- RectTransform rectTransform = gameObject.GetComponent<RectTransform>();
- Vector2 pivot = rectTransform.pivot;
- Vector2 pivot1 = pivot - Vector2.one * 0.5f;
- float x = pos.x - size.x * pivot1.x;
- float y = pos.y - size.y * pivot1.y;
- fxTrans01.transform.localPosition = new Vector3(x, y, 0);
- //fxTrans01.GetComponent<RectTransform>().pivot = gameObject.GetComponent<RectTransform>().pivot;
- }
- else
- {
- fxTrans01.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
- fxTrans01.transform.localPosition = pos;
- }
- fxTrans01.GetComponent<RectTransform>().sizeDelta = size * 2f;
- CustomTweenManager.To(() => fxTrans01.GetComponent<RectTransform>().sizeDelta,
- x => fxTrans01.GetComponent<RectTransform>().sizeDelta = x,
- size, 0.3f, fxTrans01.gameObject).OnComplete(
- () => { fxTrans01.GetComponent<RectTransform>().sizeDelta = size; })
- .SetEase(CustomTweenEX.CustomAnimationCurve.InExpo);
- //fxTrans01.GetComponent<RectTransform>().sizeDelta = size;
- break;
- case 1:
- if (gameObject != null)
- {
- fxTrans02.GetComponent<RectTransform>().pivot = gameObject.GetComponent<RectTransform>().pivot;
- }
- else
- {
- fxTrans02.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
- }
- fxTrans02.transform.localPosition = pos;
- fxTrans02.GetComponent<RectTransform>().sizeDelta = size;
- break;
- }
- }
- public Vector3 Setpos(Vector3 pos, Vector2 size, GameObject gameObject)
- {
- RectTransform rectTransform = gameObject.GetComponent<RectTransform>();
- Vector2 pivot = rectTransform.pivot;
- Vector2 pivot1 = pivot - Vector2.one * 0.5f;
- float x = pos.x - size.x * pivot1.x;
- float y = pos.y - size.y * pivot1.y;
- return new Vector3(x, y, 0);
- }
- /// <summary>
- /// 设置文本大小
- /// </summary>
- /// <param name="size"></param>
- public void SetDilogBGSize(Vector2 size)
- {
- dialogBox.MessageBG.GetComponent<RectTransform>().sizeDelta = size;
- }
- /// <summary>
- /// 设置mpc大小
- /// </summary>
- /// <param name="scale"></param>
- public void SetNpcSize(int[] scale)
- {
- dialogBox.UISpiritLoader.GetComponent<RectTransform>().sizeDelta = new Vector2(scale[0], scale[1]);
- dialogBox.UISpiritLoader.SetLoaderSpirit();
- }
- public Vector3 WorldPosToLocalPos(Vector3 pos)
- {
- Vector3 localPos = UIManager.Instance.GetComponent<GuidePanel>().transform.InverseTransformPoint(pos);
- return localPos;
- }
- public void SetMaskTarget(GameObject gameObject)
- {
- // if (guideConfig.ForceOnclick == 0)
- // {
- // return;
- // }
- UIManager.Instance.GetComponent<GuidePanel>().SetTarget(gameObject);
- }
- public void SetOnClickMask(bool value)
- {
- SetOnClickMaskSize(Vector2.zero);
- UIManager.Instance.GetComponent<GuidePanel>().OnClickMask.onClick.RemoveAllListeners();
- UIManager.Instance.GetComponent<GuidePanel>().SetOnClickMask(value);
- }
- public void SetOnClickMaskSize(Vector2 size)
- {
- UIManager.Instance.GetComponent<GuidePanel>().SetOnClickMaskSize(size);
- }
- public void SetOnClickMaskOnClickAction(UnityAction unityAction)
- {
- UIManager.Instance.GetComponent<GuidePanel>().SetOnClickMaskOnClickAction(unityAction);
- }
- /// <summary>
- /// 阶段初始化
- /// </summary>
- public void StepInit()
- {
- UIManager.Instance.SetEventSystemEnable(false);
- _customVectorTween?.Kill();
- _customVectorTween = null;
- UIManager.Instance.GetComponent<GuidePanel>().transform.SetAsLastSibling();
- HideDialogBox();
- SetfxTransVisiable(false);
- SetMaskTarget(null);
- SetFingerVisiable(false);
- SetBlackBaseVisiable(false);
- }
- public void TweenAlpha()
- {
- }
- }
- }
|