public void OpenUIPanel(UIPanel panelType, bool isMain) { if (isMain && !m_Property.IsMain()) { return; } CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy; //设置输入模式 InputManager.Instance.SceneInputMap = cfgEternityProxy.IsSpace() ? HotKeyMapID.SHIP : HotKeyMapID.HUMAN; object msg = null; if (panelType == UIPanel.RevivePanel) { if (m_ExDataTable.TryGetValue(ExDataType.DeadUIData, out var obj)) { DieExMessage dieExMessage = (DieExMessage)obj; string killerName = "error_name"; if (dieExMessage.KillerId > 0) { killerName = TableUtil.GetNpcName((uint)dieExMessage.KillerId); } else { killerName = dieExMessage.KillerName; } bool isShowHallRelive = false; foreach (var item in dieExMessage.ReliveTypes) { if (item == (short)PlayerReliveType.relive_hall) { isShowHallRelive = true; break; } } m_ExDataTable.Remove(ExDataType.DeadUIData); msg = new ShowRelviePanelNotify() { IsShowHallRelive = isShowHallRelive, Countdown = dieExMessage.Cd, KillerName = killerName }; } } //Debug.LogError("msg:" + JsonUtility.ToJson(msg)); UIManager.Instance.OpenPanel(panelType, msg); //BehaviorManager.Instance.LogFormat(m_Agent, string.Format($"OpenUIPanel panelType:{panelType}")); }
/// <summary> /// 创建时 /// </summary> private void OnTargetCreate(SpacecraftEntity target, RectTransform view) { KHeroType entityType = target.GetHeroType(); if (entityType == KHeroType.htMine) { TMP_Text nameField = view.Find("Name/Name/Label_Name").GetComponent <TMP_Text>(); nameField.text = entityType == KHeroType.htPlayer ? target.GetName() : TableUtil.GetNpcName(target.GetTemplateID()); //血段 m_LineGrid = FindComponent <Transform>(view, "Slider/Image_Bar/LineGrid"); int bloodVolumeLength = m_CfgEternityProxy.GetDoppingBloodVolumeLengthByKey((uint)target.GetTemplateID()) - 1; if (m_OldPrivew != bloodVolumeLength) { m_OldPrivew = bloodVolumeLength; while (m_LineGrid.childCount - 2 < bloodVolumeLength) { Transform lineItem = Object.Instantiate(m_LineGrid.GetChild(1), m_LineGrid); lineItem.gameObject.SetActive(true); } for (int i = bloodVolumeLength + 2; i < m_LineGrid.childCount; i++) { m_LineGrid.GetChild(i).gameObject.SetActive(false); } } } else { //目标名称 TMP_Text nameField = view.Find("Name/Name").GetComponent <TMP_Text>(); nameField.text = entityType == KHeroType.htPlayer ? target.GetName() : TableUtil.GetNpcName(target.GetTemplateID()); //目标图标 Image image = view.Find("Name/Icon/ImageIcon").GetComponent <Image>(); image.gameObject.SetActive(entityType != KHeroType.htPlayer); if (image.gameObject.activeSelf) { Npc entityVO = m_CfgEternityProxy.GetNpcByKey(target.GetTemplateID()); if (entityVO.NameBoardIcon == 0) { image.color = Color.clear; } else { image.color = Color.white; UIUtil.SetIconImage(image, entityVO.NameBoardIcon); } } } }
/// <summary> /// 设置npc模型 /// </summary> /// <param name="tid">模型ID</param> private void ShowNpcModel(int npcid) { Npc npc = m_CfgEternityProxy.GetNpcByKey((uint)npcid); m_NpcName.text = TableUtil.GetNpcName((uint)npcid); m_NpcDesc.text = TableUtil.GetNpcDesc((uint)npcid); m_UI3dImage.gameObject.SetActive(false); CfgEternityProxy cfe = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy; string prefabName = cfe.GetNpcModelByKey((uint)npcid); Model NpcModel = m_CfgEternityProxy.GetModel(npc.Model); Npc3DViewer npc3DViewer = m_UI3dImage.GetComponent <Npc3DViewer>(); if (npc3DViewer == null) { npc3DViewer = m_UI3dImage.gameObject.AddComponent <Npc3DViewer>(); } npc3DViewer.SetModel(prefabName, GetNpcUiPos(NpcModel), GetNpcUiRotation(NpcModel), GetNpcUiScale(NpcModel)); }
/// <summary> /// 更新 /// </summary> protected override void Update() { CfgEternityProxy eternityProxy = Facade.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy; TaskTrackingProxy taskTrackingProxy = Facade.RetrieveProxy(ProxyName.TaskTrackingProxy) as TaskTrackingProxy; if (!IsWatchOrUIInputMode() && !IsDead() && !IsLeaping()) { GameplayProxy gamePlayProxy = Facade.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy; BaseEntity main = gamePlayProxy.GetEntityById <BaseEntity>(gamePlayProxy.GetMainPlayerUID()); List <SpacecraftEntity> humanList = gamePlayProxy.GetEntities <SpacecraftEntity>(KHeroType.htNpc); foreach (SpacecraftEntity entity in humanList) { if (entity.GetHeroType() != KHeroType.htNpc) { continue; } Npc entityVO = eternityProxy.GetNpcByKey(entity.GetTemplateID()); if (entityVO.Display == 0) { continue; } Vector3 titleOffset = entityVO.HeroHeaderLength >= 3 ? new Vector3(entityVO.HeroHeader(0), entityVO.HeroHeader(1), entityVO.HeroHeader(2)) : Vector3.zero; Vector3 targetPosition = entity.transform.position + entity.transform.TransformDirection(titleOffset); //屏幕外忽略 if (!IsInScreen(targetPosition, Camera.main)) { continue; } //太远忽略 float targetDistance = Vector3.Distance(entity.transform.position, main.transform.position) * GameConstant.METRE_PER_UNIT; if (targetDistance >= entityVO.MissionTargetHiddenDistance * GameConstant.METRE_PER_UNIT) { continue; } Vector2 iconPosition; Vector3 screenPosition = Camera.main.WorldToScreenPoint(targetPosition); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_FlagBox, screenPosition, m_CanvasCamera, out iconPosition)) { bool isNew = false; uint entityID = entity.GetUId(); //创建标记 RectTransform flag = m_NpcID2FlagA.ContainsKey(entityID) ? m_NpcID2FlagA[entityID] : null; if (flag == null) { if (m_IdleBox.childCount > 0) { flag = m_IdleBox.GetChild(0).GetComponent <RectTransform>(); flag.gameObject.SetActive(true); flag.SetParent(m_FlagBox); } else { flag = Object.Instantiate(m_FlagTemplate, m_FlagBox); flag.gameObject.SetActive(true); } isNew = true; } m_NpcID2FlagA.Remove(entityID); m_NpcID2FlagB.Add(entityID, flag); //标记坐标 flag.anchoredPosition = new Vector2(iconPosition.x, iconPosition.y); //名称文本 if (isNew) { flag.Find("Name/Label_NPCName").GetComponent <TMP_Text>().text = TableUtil.GetNpcName(entity.GetTemplateID()); Image npcIcon = flag.Find("IconBox/IconScenceNameElement/Image_NpcIcon").GetComponent <Image>(); npcIcon.color = entityVO.NameBoardIcon == 0 ? Color.clear : Color.white; if (entityVO.NameBoardIcon != 0) { UIUtil.SetIconImage(npcIcon, entityVO.NameBoardIcon); } } //任务 TaskTrackingProxy.TrackingInfo tracking = taskTrackingProxy.GetNpcMission(entity.GetUId(), entity.GetTemplateID()); MissionType missionType = tracking != null ? tracking.MissionType : MissionType.None; //任务状态 RectTransform flagIcon = FindComponent <RectTransform>(flag, "IconBox"); RectTransform flagMission = FindComponent <RectTransform>(flag, "MissionBox"); Animator flagMissionAnimator = FindComponent <Animator>(flagMission, "IconMissionElement"); Image flagMissionIcon = FindComponent <Image>(flagMissionAnimator, "Icon").GetComponent <Image>(); UIUtil.SetIconImage(flagMissionIcon, GameConstant.FUNCTION_ICON_ATLAS_ASSETADDRESS, GetMissionIcon(missionType)); flagMission.gameObject.SetActive(missionType != MissionType.None); flagIcon.gameObject.SetActive(!flagMission.gameObject.activeSelf); taskTrackingProxy.SetAreadyAddMissionInfo(entity.GetUId(), entity.GetTemplateID()); flagMissionAnimator.SetBool("Finished", tracking != null && tracking.MissionState == MissionState.Finished); /* * //图标动画 * Animator flagIconAnimator = flag.Find("IconBox").GetComponent<Animator>(); * if (flagIconAnimator != null && flagIconAnimator.runtimeAnimatorController != null && flagIconAnimator.isActiveAndEnabled) * { * flagIconAnimator.ResetTrigger("Open"); * flagIconAnimator.ResetTrigger("Close"); * flagIconAnimator.SetTrigger(targetDistance <= GameConstant.DEFAULT_HUMAN_TITLE_SHOW_RANGE * 2 ? "Open" : "Close"); * } * * //名称动画 * Animator flagTextAnimator = flag.Find("Name").GetComponent<Animator>(); * if (flagTextAnimator != null && flagTextAnimator.runtimeAnimatorController != null && flagTextAnimator.isActiveAndEnabled) * { * flagTextAnimator.ResetTrigger("Open"); * flagTextAnimator.ResetTrigger("Close"); * flagTextAnimator.SetTrigger(targetDistance <= GameConstant.DEFAULT_HUMAN_TITLE_SHOW_RANGE ? "Open" : "Close"); * } */ } } } //回收标记 foreach (var flag in m_NpcID2FlagA) { taskTrackingProxy.SetAreadyAddMissionInfo(flag.Key, 0, true); flag.Value.gameObject.SetActive(false); flag.Value.SetParent(m_IdleBox); } m_NpcID2FlagA.Clear(); //交换缓存 Dictionary <uint, RectTransform> tmp = m_NpcID2FlagA; m_NpcID2FlagA = m_NpcID2FlagB; m_NpcID2FlagB = tmp; }
/// <summary> /// 更新任务列表 /// </summary> private void UpdateMissionList(MissionVO mission, RectTransform view) { TMP_Text rowTitle = view.Find("TitleLine/Label_Name").GetComponent <TMP_Text>(); RectTransform rowBox = view.Find("Content").GetComponent <RectTransform>(); RectTransform rowFinish = view.Find("Label_Finish").GetComponent <RectTransform>(); RectTransform rowTemplate = rowBox.GetChild(0).GetComponent <RectTransform>(); rowTitle.text = TableUtil.GetLanguageString("mission_name_" + mission.Tid); rowBox.gameObject.SetActive(mission.MissionState != MissionState.Finished); rowFinish.gameObject.SetActive(mission.MissionState == MissionState.Finished); CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy; bool finised = true; int index = 0; if (mission.MissionState == MissionState.CanAccept) { string str = string.Empty; if (GetRoleLevel() < mission.MissionConfig.LvLimit) { str = string.Format(TableUtil.GetLanguageString("mission_title_1011"), mission.MissionConfig.LvLimit); } else if (mission.MissionMainConfig.Value.AcceptNpcId > 0) { str = TableUtil.GetNpcName((uint)mission.MissionMainConfig.Value.AcceptNpcId); str = string.Format(TableUtil.GetLanguageString("mission_title_1012"), str); } RectTransform row = index < rowBox.childCount ? rowBox.GetChild(index).GetComponent <RectTransform>() : Object.Instantiate(rowTemplate, rowBox); row.gameObject.SetActive(true); UpdateMissionRow(str, string.Empty, row, true, false, false); finised = false; index++; } else { foreach (KeyValuePair <uint, SortedDictionary <uint, MissionTargetVO> > group in mission.MissionGroupTargetList) { RectTransform row = index < rowBox.childCount ? rowBox.GetChild(index).GetComponent <RectTransform>() : Object.Instantiate(rowTemplate, rowBox); if (index != 0 && !finised) { row.gameObject.SetActive(true); UpdateMissionRow(string.Empty, string.Empty, row, false, true, false); index++; row = index < rowBox.childCount ? rowBox.GetChild(index).GetComponent <RectTransform>() : Object.Instantiate(rowTemplate, rowBox); } bool frist = true; foreach (KeyValuePair <uint, MissionTargetVO> target in group.Value) { if (!target.Value.DoneToFinish) { continue; } row = index < rowBox.childCount ? rowBox.GetChild(index).GetComponent <RectTransform>() : Object.Instantiate(rowTemplate, rowBox); string str = string.Empty; if (target.Value.DoneToFinish) //正常条件 { switch (target.Value.MissionTargetType) { case MissionTargetType.Kill: case MissionTargetType.CollectItem: case MissionTargetType.HaveItem: str = $"[{target.Value.Value}/{target.Value.MissionTargetConfig.Arg2}]"; break; case MissionTargetType.Escort: default: str = target.Value.TargetState == MissionState.Finished ? "[1/1]" : "[0/1]"; break; } if (target.Value.TargetState == MissionState.Failed) { str = TableUtil.GetLanguageString("mission_title_1013"); } } row.gameObject.SetActive(true); row.name = target.Value.Tid + " " + TableUtil.GetMissionTargetDesc(target.Value.Tid); if (target.Value.MissionTargetConfig.Arg4 > 0 && target.Value.Relation != null) { if (target.Value.Relation.MissionTargetType == MissionTargetType.TimeOut) { UpdateMissionRow(TableUtil.GetMissionTargetDesc(target.Value.Tid), str, row, false, false, frist, target.Value.TargetState, (ulong)target.Value.Relation.Value); } } else { UpdateMissionRow(TableUtil.GetMissionTargetDesc(target.Value.Tid), str, row, false, false, frist, target.Value.TargetState); } finised = target.Value.TargetState == MissionState.Finished; index++; frist = false; } } } for (int i = index; i < rowBox.childCount; i++) { rowBox.GetChild(i).gameObject.SetActive(false); } }