123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227 |
- 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 = Resources.Load<GameRuntimeConfig>("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 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]));
- }
- }
- HideDialogBox(false);
- // if (guideConfig.SpeakerStyle == 3)
- // {
- // HideDialogBox(false);
- // }
- // else
- // {
- // HideDialogBox();
- // }
- // if (IsUseServerData)
- // {
- // PlayerManager.Instance.PlayerGuideDataComponent.UpdateData(configID);
- // await HttpSendManager.Instance.SendSaveGuideDataRequest(configID, SaveGuideDataCallBack); //记录服务器
- // }
- if (guideConfig.IsSkip == 1)
- {
- IsStepSkip = true;
- NextGuide();
- return;
- }
- if (guideConfig.Highlighting == 0)
- {
- SetfxTransVisiable(false);
- }
- 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();
- // if (guideConfig.SpeakerStyle == 3)
- // {
- // HideDialogBox(false);
- // }
- // else
- // {
- // HideDialogBox();
- // }
- HideDialogBox();
- SetfxTransVisiable(false);
- SetMaskTarget(null);
- SetFingerVisiable(false);
- SetBlackBaseVisiable(false);
- }
- public void TweenAlpha()
- {
- }
- }
- }
|