public void CheckTriggerData(uint guideId, UIEventDelegate dlg) { GuideDefine.LocalGuideData localGuideData = null; if (DataManager.Manager <GuideManager>().TryGetGuideLocalData(ID, out localGuideData)) { if (null != localGuideData.GuideTargetObj) { GuideTrigger trigger = localGuideData.GuideTargetObj.GetComponent <GuideTrigger>(); if (null == trigger) { trigger = localGuideData.GuideTargetObj.AddComponent <GuideTrigger>(); trigger.InitTrigger(localGuideData.ID, dlg); } else { trigger.AddTriggerId(localGuideData.ID); } //如果没有事件触发,需要手动添加碰撞器触发引导事件 if (localGuideData.TriggerEventType == GuideDefine.GuideTriggerEventType.None) { BoxCollider boxCollider = localGuideData.GuideTargetObj.GetComponent <BoxCollider>(); if (null == boxCollider) { boxCollider = localGuideData.GuideTargetObj.AddComponent <BoxCollider>(); boxCollider.size = localGuideData.GuideTargetObjLocalBounds.size; boxCollider.center = localGuideData.GuideTargetObjLocalBounds.center; } } } } }
private void Awake() { #if !UNITY_EDITOR try { #endif Instance = this; MainCamera.gameObject.AddComponent <CameraController>(); MainCamera.gameObject.AddComponent <CameraShake>(); gameObject.AddComponent <InputManager>(); //Scene = gameObject.GetComponent<Scene>(); SceneEffect = gameObject.AddComponent <SceneEffectManager>(); GuideTrigger = gameObject.AddComponent <GuideTrigger>(); mControl = gameObject.AddComponent <GameControl>(); var mTime = Game.Instance.ServerTime; ShadowReceiverLayerMask = LayerMask.GetMask(GAMELAYER.ShadowReceiver, GAMELAYER.Terrain); LoadOver = false; EventDispatcher.Instance.AddEventListener(DungeonCompleteEvent.EVENT_TYPE, OnDungeonComplete); #if !UNITY_EDITOR } catch (Exception ex) { Logger.Error(ex.ToString()); } #endif }
/// <summary> /// 刷新已经显示的引导可见状态 /// </summary> private void RefreshShowGuideVisbieStatus(UIDefine.GameObjMoveData moveData = null) { if (null != m_dic_showGuide && m_dic_showGuide.Count > 0) { bool visible = false; GuideTrigger gTrigger = null; foreach (KeyValuePair <uint, UIUnconstraintGrid> pair in m_dic_showGuide) { GuideDefine.LocalGuideData localData = null; if (!DataManager.Manager <GuideManager>().TryGetGuideLocalData(pair.Key, out localData)) { continue; } visible = DataManager.Manager <GuideManager>().IsGuideUIStatusReady(pair.Key) && UIManager.IsObjVisibleByCamera(localData.GuideTargetObj); if (visible && null != moveData && null != moveData.Objs && moveData.Objs.Contains(localData.GuideTargetObj)) { switch (moveData.Status) { case UIDefine.GameObjMoveStatus.MoveToInvisible: case UIDefine.GameObjMoveStatus.Invisible: visible = false; break; case UIDefine.GameObjMoveStatus.Visible: visible = true; break; } } if (null != pair.Value) { if (visible) { if (!pair.Value.Visible) { ShowGuide(pair.Key); } if (localData.RefreshPosInTime) { pair.Value.RefreshPos(); } } else if (!visible && pair.Value.Visible) { pair.Value.SetVisible(false); if (null != localData.GuideTargetObj) { gTrigger = localData.GuideTargetObj.GetComponent <GuideTrigger>(); if (null != gTrigger && gTrigger.enabled) { gTrigger.enabled = false; } } } } } } }
private void Awake() { #if !UNITY_EDITOR try { #endif Instance = this; MainCamera.gameObject.AddComponent <CameraController>(); MainCamera.gameObject.AddComponent <CameraShake>(); gameObject.AddComponent <InputManager>(); if (GameSetting.Instance.RenderTextureEnable) { try { var uicam = UIManager.Instance.UICamera; if (null != uicam) { var rtc = uicam.gameObject.GetComponent <RenderTextureCreator>(); if (null == rtc) { rtc = uicam.gameObject.AddComponent <RenderTextureCreator>(); } rtc.enabled = true; rtc.BindCamera(); } else { Logger.Error("cant find UIRoot/Camera"); } } catch (Exception e) { Logger.Error("cant find uicamera"); } } //Scene = gameObject.GetComponent<Scene>(); SceneEffect = gameObject.AddComponent <SceneEffectManager>(); GuideTrigger = gameObject.AddComponent <GuideTrigger>(); mControl = gameObject.AddComponent <GameControl>(); var mTime = Game.Instance.ServerTime; ShadowReceiverLayerMask = LayerMask.GetMask(GAMELAYER.ShadowReceiver, GAMELAYER.Terrain); LoadOver = false; EventDispatcher.Instance.AddEventListener(DungeonCompleteEvent.EVENT_TYPE, OnDungeonComplete); #if !UNITY_EDITOR } catch (Exception ex) { Logger.Error(ex.ToString()); } #endif }
public void RefreshBtnState() { foreach (var btn in NewFuntcionBtn) { if (GuideTrigger.IsFunctionOpen(btn.name)) { btn.LockBtn(false); } else { btn.LockBtn(true); } } }
public bool IsNoticeMainDown() { foreach (var btn in NewFuntcionBtn) { if (GuideTrigger.IsFunctionOpen(btn.name)) { if (btn.name == "BtnEquip" && (PlayerDataManager.Instance.WeakNoticeData.AppendNotice)) { return(true); } if (btn.name == "BtnHnadBook" && (PlayerDataManager.Instance.NoticeData.HandBookTotal)) { return(true); } if (btn.name == "BtnElf" && (PlayerDataManager.Instance.NoticeData.ElfDraw || PlayerDataManager.Instance.WeakNoticeData.ElfTotal)) { return(true); } if (btn.name == "BtnSkill" && (PlayerDataManager.Instance.NoticeData.SkillTotal || PlayerDataManager.Instance.WeakNoticeData.SkillTotal)) { return(true); } if (btn.name == "BtnWing" && (PlayerDataManager.Instance.NoticeData.WingAdvance || PlayerDataManager.Instance.WeakNoticeData.WingTraining)) { return(true); } if (btn.name == "BtnSailingHarbor" && (PlayerDataManager.Instance.NoticeData.SailingNotice)) { return(true); } if (btn.name == "BtnAchievement" && (PlayerDataManager.Instance.NoticeData.HasAchievement)) { return(true); } if (btn.name == "BtnBattleUnion" && (PlayerDataManager.Instance.NoticeData.BattleList)) { return(true); } } } return(false); }
/// <summary> /// 引导UI事件回调 /// </summary> /// <param name="eventType">事件类型</param> /// <param name="data"></param> /// <param name="param"></param> private void GuideTriggerDlg(UIEventType eventType, object data, object param) { switch (eventType) { case UIEventType.Click: if (data is GuideTrigger) { GuideTrigger gTrigger = data as GuideTrigger; if (null != gTrigger && null != gTrigger.TriggerIds) { List <uint> triggerIds = new List <uint>(); triggerIds.AddRange(gTrigger.TriggerIds); GuideDefine.LocalGuideData localData = null; for (int i = 0; i < triggerIds.Count; i++) { if (i == 0) { if (DataManager.Manager <GuideManager>().TryGetGuideLocalData(triggerIds[i], out localData)) { if (null != localData.GuideTargetObj) { GuideTrigger trigger = localData.GuideTargetObj.GetComponent <GuideTrigger>(); if (null != trigger) { GameObject.Destroy(trigger); } //无事件触发,引导完成后删除碰撞器 if (localData.TriggerEventType == GuideDefine.GuideTriggerEventType.None) { if (null != localData.GuideTargetObj.GetComponent <BoxCollider>()) { GameObject.Destroy(localData.GuideTargetObj.GetComponent <BoxCollider>()); } } } } } CompleteGuide(triggerIds[i]); } } } break; } }
/// <summary> /// 引导UI事件回调 /// </summary> /// <param name="eventType">事件类型</param> /// <param name="data"></param> /// <param name="param"></param> private void GuideTriggerDlg(UIEventType eventType, object data, object param) { switch (eventType) { case UIEventType.Click: if (null != m_helpData && null != m_helpData.LocalData) { if (data is GuideTrigger) { GuideTrigger gTrigger = data as GuideTrigger; if (null != gTrigger && null != gTrigger.TriggerIds) { if (null != m_helpData.LocalData.GuideTargetObj) { GuideTriggerData gtData = m_helpData.LocalData.GuideTargetObj.GetComponent <GuideTriggerData>(); if (null == gtData) { gtData = m_helpData.LocalData.GuideTargetObj.AddComponent <GuideTriggerData>(); gtData.IsGuideTrigger = true; } m_helpData.LocalData.GuideTargetObj.SendMessage("OnClick", SendMessageOptions.DontRequireReceiver); if (null != gtData) { GameObject.Destroy(gtData); } } List <uint> triggerIds = new List <uint>(); triggerIds.AddRange(gTrigger.TriggerIds); for (int i = 0; i < triggerIds.Count; i++) { if (m_helpData.LocalData.ID == triggerIds[i]) { CompleteGuide(); } } HideSelf(); } } } break; } }
/// <summary> /// 引导ID /// </summary> /// <param name="guideId"></param> private void ShowGuide(uint guideId) { GuideDefine.LocalGuideData localData = null; if (DataManager.Manager <GuideManager>().TryGetGuideLocalData(guideId, out localData)) { if (null == localData.GuideTargetObj) { return; } PanelType ptype = PanelType.SmartPopUp; UIPanelManager.LocalPanelInfo localInfo = null; if (DataManager.Manager <UIPanelManager>().TryGetLocalPanelInfo(localData.GuideTargetDependPanel, out localInfo)) { ptype = localInfo.PType; } if (IsShowUnconstrainGuide(guideId)) { //如果不可见重新获取当前面板深度 UIUnconstraintGrid showGrid = m_dic_showGuide[guideId]; if (!showGrid.Visible) { showGrid.SetVisible(true); GuideTrigger gTrigger = localData.GuideTargetObj.GetComponent <GuideTrigger>(); if (null != gTrigger && !gTrigger.enabled) { gTrigger.enabled = true; } int maxDepth = DataManager.Manager <UIPanelManager>().GetTargetRootMaxDepth(ptype); showGrid.SetDepth(maxDepth + 1); if (localData.RefreshPosInTime) { showGrid.RefreshPos(); } showGrid.CheckTriggerData(guideId, GuideTriggerDlg); } } else { int maxDepth = DataManager.Manager <UIPanelManager>().GetTargetRootMaxDepth(ptype); UIUnconstraintGrid grid = GetUnconstrainGrid(); if (null != grid) { grid.CacheTransform.gameObject.name = guideId.ToString(); m_dic_showGuide.Add(guideId, grid); } grid.SetData(maxDepth + 1, guideId, GuideTriggerDlg); if (localData.TableData.voiceID != 0) { DataManager.Manager <UIManager>().PlayUIAudioEffect(localData.TableData.voiceID); } } GuideTriggerData gtData = localData.GuideTargetObj.GetComponent <GuideTriggerData>(); if (null == gtData) { gtData = localData.GuideTargetObj.AddComponent <GuideTriggerData>(); } if (null != gtData && !gtData.IsGuideTrigger) { gtData.IsGuideTrigger = true; } } }
public bool SelectTarget(GameObject gameObject, int skill = -1) { //null鍒ゆ柇 if (null == gameObject) { return(false); } //鑾峰緱涓昏鑷繁 var myself = ObjManager.Instance.MyPlayer; if (null == myself) { return(false); } //鐩爣寰楁槸涓猳bj var obj = gameObject.GetComponent <ObjBase>(); if (null == obj) { return(false); } if (skill == -1) { TargetCharacter(obj); } //鍋滄褰撳墠鐨勬寚浠? //Executer.Stop(); //璁$畻鑷繁璺濈鐩爣鐨勮窛绂? var distance = Vector3.Distance(obj.Position, myself.Position); //榛樿鎶€鑳? var skillId = skill; if (skillId == -1) { skillId = PlayerDataManager.Instance.GetNormalSkill(); } if (obj.IsCharacter() && myself.IsMyEnemy(obj as ObjCharacter)) { if (obj.GetObjType() == OBJ.TYPE.NPC || obj.GetObjType() == OBJ.TYPE.RETINUE) { //濡傛灉鏄痭pc var npc = obj as ObjNPC; if (npc == null) { return(false); } if (!npc.CanBeInteractive()) { return(false); } } var character = obj as ObjCharacter; if (character.Dead) { return(false); } //瀵瑰叾閲婃斁鎶€鑳? var data = Table.GetSkill(skillId); //鐩爣绫诲瀷 var targetType = (SkillTargetType)ObjMyPlayer.GetSkillData_Data(data, eModifySkillType.TargetType); //涓嶉渶瑕佺洰鏍囩殑鎶€鑳? if (targetType == SkillTargetType.SELF || targetType == SkillTargetType.CIRCLE || targetType == SkillTargetType.SECTOR || targetType == SkillTargetType.RECT) { //浣跨敤鎶€鑳? return(UseSkill(myself.GetObjId(), skillId, character.GetObjId())); } //闇€瑕佺洰鏍囩殑鎶€鑳? if (targetType == SkillTargetType.SINGLE || targetType == SkillTargetType.TARGET_CIRCLE || targetType == SkillTargetType.TARGET_RECT || targetType == SkillTargetType.TARGET_SECTOR) { var maxSkillDistance = GetSkillReleaseDistance(data); if (maxSkillDistance - 0.5 < 0.0f) { maxSkillDistance = 0.5f; } if (distance > maxSkillDistance - 0.5) { //璺濈涓嶅 var offset = maxSkillDistance - 1.0f; if (offset < 0.0f) { offset = 0.1f; } Executer.PushCommand(new MoveCommand(myself, character.Position, offset)); Executer.PushCommand(new AttackCommand(myself.GetObjId(), skillId, character.GetObjId())); } else { TargetObj = character; PlayerDataManager.Instance.SetSelectTargetData(TargetObj, 3); ObjManager.Instance.MyPlayer.FaceTo(character.Position); return(UseSkill(myself.GetObjId(), skillId, character.GetObjId())); } } else { Logger.Error("Unknow skill target type = {0}", targetType); } } else if (obj.GetObjType() == OBJ.TYPE.NPC) { var npc = obj as ObjNPC; if (!npc.CanBeInteractive()) { return(false); } if (npc.TableNPC.NpcType == (int)eNpcType.PickUpNpc) { if (distance > GameSetting.Instance.MaxDistance_NPC) { var command = new MoveCommand(myself, npc.Position, GameSetting.Instance.MaxDistance_NPC); Executer.PushCommand(command); return(false); } else { { if (!IsInit) { Table.ForeachWarFlag(tb => { WarFlagDic.Add(tb.Id, tb.FlagModel); return(true); }); Table.ForeachLode(tb => { if (tb.Id < 100000) { LodeDic.Add(tb.Id, tb.NpcId); } else if (tb.Id >= 100000 && tb.Id <= 100020)//策划指定墓碑使用此区间 { MonumentDic.Add(tb.Id, tb.NpcId); } return(true); }); IsInit = true; } var npcId = npc.TableNPC.Id; if (WarFlagDic.ContainsValue(npcId)) { //战旗 PlayerDataManager.Instance.HoldLode(npcId); return(false); } else if (LodeDic.ContainsValue(npcId)) { //采矿 PlayerDataManager.Instance.CollectLode(npcId); return(false); } else if (MonumentDic.ContainsValue(npcId)) { //祭拜 PlayerDataManager.Instance.WorshipMonument(npcId); return(false); } } EventDispatcher.Instance.DispatchEvent(new PickUpNpc_Event(npc.GetDataId(), npc.GetObjId())); return(false); } } var npcDataId = npc.GetDataId(); if (npcDataId >= 108 && npcDataId <= 110)//判断是否是排行NPC { EventDispatcher.Instance.DispatchEvent(new OnRankNpcClick_Event(npcDataId)); } myself.StopMove(); if (distance <= GameSetting.Instance.MaxDistance_NPC) { if (MissionManager.Instance.OpenMissionByNpcId(npc.GetDataId(), npc.GetObjId())) { npc.DoDialogue(); //TODO if (myself.IsAutoFight()) { myself.LeaveAutoCombat(); } } } else { var command = new MoveCommand(myself, npc.Position, GameSetting.Instance.MaxDistance_NPC); Executer.PushCommand(command); var command1 = new FuncCommand(() => { if (MissionManager.Instance.OpenMissionByNpcId(npc.GetDataId(), npc.GetObjId())) { npc.DoDialogue(); //TODO if (myself.IsAutoFight()) { myself.LeaveAutoCombat(); } } }); Executer.PushCommand(command1); } } else if (obj.GetObjType() == OBJ.TYPE.DROPITEM) { //濡傛灉鏄帀钀界墿鍝? var dropItem = obj as ObjDropItem; myself.StopMove(); var dis = GameSetting.Instance.MaxDistance_DropItem; if (dropItem.mTableData != null && dropItem.mTableData.Type == 300) { dis = GameUtils.AutoPickUpBuffDistance; } if (distance <= dis) { dropItem.Pickup(); } else { var command = new MoveCommand(myself, dropItem.Position, dis); Executer.PushCommand(command); var command1 = new FuncCommand(() => { if (null != dropItem) { dropItem.Pickup(); } }); Executer.PushCommand(command1); } } else if (obj.GetObjType() == OBJ.TYPE.FAKE_CHARACTER) { if (((ObjFakeCharacter)obj).iType == (int)eFakeCharacterTypeDefine.MieShiFakeCharacterType) { EventDispatcher.Instance.DispatchEvent(new ApplyPortraitAward_Event(obj.GetDataId())); } else { if (((ObjFakeCharacter)obj).iType == (int)OBJ.TYPE.FAKE_FIGHTLEADER) { if (GuideTrigger.IsFunctionOpen("BtnRank")) { var e = new Show_UI_Event(UIConfig.RankUI, new RankArguments { RankId = obj.GetObjId() }); EventDispatcher.Instance.DispatchEvent(e); } else { EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(1736)); } } else { EventDispatcher.Instance.DispatchEvent(new Show_UI_Event(UIConfig.WorshipFrame)); } } } return(false); }
/// <summary> /// 设置非强制引导数据 /// </summary> /// <param name="panelDepath"></param> /// <param name="id"></param> public void SetData(int panelDepth, uint id, UIEventDelegate dlg) { Init(); if (!Visible) { SetVisible(true); } this.m_uint_id = id; GuideDefine.LocalGuideData localGuideData = null; SetDepth(panelDepth); if (DataManager.Manager <GuideManager>().TryGetGuideLocalData(ID, out localGuideData)) { //设置位置 SetPos(out m_v3ContentOffset); //显示内容 UILabel tempLab = null; RefreshHumanImage(ref tempLab); if (null != tempLab) { tempLab.text = localGuideData.Des; } if (null != localGuideData.GuideTargetObj) { m_sourcePos = localGuideData.GuideTargetObj.transform.position; GuideTrigger trigger = localGuideData.GuideTargetObj.GetComponent <GuideTrigger>(); if (null == trigger) { trigger = localGuideData.GuideTargetObj.AddComponent <GuideTrigger>(); trigger.InitTrigger(localGuideData.ID, dlg); } else { trigger.AddTriggerId(localGuideData.ID); } //如果没有事件触发,需要手动添加碰撞器触发引导事件 if (localGuideData.TriggerEventType == GuideDefine.GuideTriggerEventType.None) { BoxCollider boxCollider = localGuideData.GuideTargetObj.GetComponent <BoxCollider>(); if (null == boxCollider) { boxCollider = localGuideData.GuideTargetObj.AddComponent <BoxCollider>(); boxCollider.size = localGuideData.GuideTargetObjLocalBounds.size; boxCollider.center = localGuideData.GuideTargetObjLocalBounds.center; } } } if (null != m_particle) { m_effectRoot.transform.localPosition = Vector3.zero; m_particle.ReleaseParticle(); m_particle.AddParticle(50042, endCallback: OnParticleDispalyEffectComplete); } //if (null != m_particle && !m_bAddEffect) //{ // m_particle.AddParticle(50041); // m_bAddEffect = true; //} SetVisible(false); SetVisible(true); } }
/// <summary> /// 显示引导 /// </summary> /// <param name="data"></param> private void ShowGuide() { Transform ts = null; if (IsDataReady) { GuideDefine.LocalGuideData data = m_helpData.LocalData; if (null == m_helpData.LocalData.GuideTargetObj) { SilentComplete(); } if (!m_helpData.GuideRoot.gameObject.activeSelf) { m_helpData.GuideRoot.gameObject.SetActive(true); } GuideStyleData gstyleData = GuidePanel.GetGuideStyleData(m_helpData); Vector3 angle = Vector3.zero; angle.z = gstyleData.ArrowRotateAngle; UILabel desLab = null; if (null != m_trans_ArrowContent) { m_trans_ArrowContent.localEulerAngles = angle; } if (null != m_trans_PointBoxContent) { m_trans_PointBoxContent.parent = gstyleData.TargetRoot; m_trans_PointBoxContent.localPosition = Vector3.zero; } if (null != m_trans_PBLeftContent) { if (m_trans_PBLeftContent.gameObject.activeSelf == gstyleData.ArrowRight) { m_trans_PBLeftContent.gameObject.SetActive(!gstyleData.ArrowRight); } if (!gstyleData.ArrowRight) { desLab = m_label_GuideLeftContent; } } if (null != m_trans_PBRightContent) { if (m_trans_PBRightContent.gameObject.activeSelf != gstyleData.ArrowRight) { m_trans_PBRightContent.gameObject.SetActive(gstyleData.ArrowRight); } if (gstyleData.ArrowRight) { desLab = m_label_GuideRightContent; } } if (null != desLab) { desLab.text = data.Des; } if (null != data.GuideTargetObj && null != m_helpData.AttachRoot) { //备份目标对象 GameObject cloneTarget = GameObject.Instantiate(data.GuideTargetObj); cloneTarget.name = data.GuideTargetObj.name; cloneTarget.transform.parent = m_helpData.AttachRoot; cloneTarget.transform.localScale = data.GuideTargetObj.transform.localScale; cloneTarget.transform.localPosition = data.GuideTargetObj.transform.localPosition; cloneTarget.transform.localRotation = data.GuideTargetObj.transform.localRotation; cloneTarget.transform.position = data.GuideTargetObj.transform.position; m_helpData.CloneTarget = cloneTarget; //删除UIPlayerTween UIPlayTween[] tws = cloneTarget.GetComponents <UIPlayTween>(); int length = (null != tws) ? tws.Length:0; if (length > 0) { for (int i = 0; i < length; i++) { GameObject.Destroy(tws[i]); } } GuideTrigger trigger = cloneTarget.GetComponent <GuideTrigger>(); if (null == trigger) { trigger = cloneTarget.AddComponent <GuideTrigger>(); } trigger.InitTrigger(data.ID, GuideTriggerDlg); //如果没有事件触发,需要手动添加碰撞器触发引导事件 //if (data.TriggerEventType == GuideDefine.GuideTriggerEventType.None) { BoxCollider boxCollider = cloneTarget.GetComponent <BoxCollider>(); if (null == boxCollider) { boxCollider = cloneTarget.AddComponent <BoxCollider>(); boxCollider.size = data.GuideTargetObjLocalBounds.size; boxCollider.center = data.GuideTargetObjLocalBounds.center; } if (!boxCollider.enabled) { boxCollider.enabled = true; } } } if (null != m_helpData.PointBoxRoot) { if (!m_helpData.PointBoxRoot.gameObject.activeSelf) { m_helpData.PointBoxRoot.gameObject.SetActive(true); } m_helpData.PointBoxRoot.localPosition = gstyleData.TargetPos; } ShowGuideDynamicMask(m_helpData.LocalData.GuideTargetWorldPos, 1); if (null != m_trans_ConstraintAnimContent) { TweenScale tween = m_trans_ConstraintAnimContent.GetComponent <TweenScale>(); if (null != tween) { tween.ResetToBeginning(); tween.enabled = true; } } SetVisible(false); SetVisible(true); } }