using Games.GlobeDefine; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using GCGame.Table; public class MarryInteractionPanelCtr : MonoBehaviour { public static MarryInteractionPanelCtr Instance; private void Awake() { Instance = this; } private void OnDestroy() { Instance = null; } public UICameraTexture cameraTextureA; public UICameraTexture cameraTextureB; public UIContainerBase itemContianer; private int _CurSelectType = 1; //结婚 private void OnEnable() { StartCoroutine(InitPage()); } IEnumerator InitPage() { yield return new WaitForEndOfFrame(); //caneraTexture yield return StartCoroutine(InitCamerTexture()); List idList = new List(); foreach(var tab in TableManager.GetInteractionNode()) { if(tab.Value.InteractiveType == _CurSelectType) idList.Add(tab.Key); } itemContianer.InitContentItem(idList); ReqInteractionState(); yield break; } IEnumerator InitCamerTexture() { yield return new WaitForEndOfFrame(); var profession = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession; Tab_SystemParam systemParamTab = null; if (profession == (int)CharacterDefine.PROFESSION.LIUSHAN || profession == (int)CharacterDefine.PROFESSION.TIANJI) { systemParamTab = TableManager.GetSystemParamByID(17, 0); } else { systemParamTab = TableManager.GetSystemParamByID(18, 0); } if (systemParamTab == null) { cameraTextureA.gameObject.SetActive(false); cameraTextureB.gameObject.SetActive(false); yield break; } cameraTextureA.gameObject.SetActive(true); cameraTextureB.gameObject.SetActive(true); var charModelIdA = systemParamTab.StringValue.Split('|')[0]; var charModelIdB = systemParamTab.StringValue.Split('|')[1]; var charModelA = TableManager.GetCharModelByID(int.Parse(charModelIdA), 0); var charModelB = TableManager.GetCharModelByID(int.Parse(charModelIdB), 0); if (charModelA == null || charModelB == null) { yield break; } cameraTextureA.InitModelPath(charModelA.ResPath, charModelA, LoadAssetBundle.BUNDLE_PATH_MODEL, true); cameraTextureB.InitModelPath(charModelB.ResPath, charModelB, LoadAssetBundle.BUNDLE_PATH_MODEL, true); yield break; } public void ReqInteractionState() { ReqInteraction req = new ReqInteraction(); req._type = _CurSelectType; req.SendMsg(); } public void OnPacket(RetInteractionState packet) { itemContianer.ForeachActiveItem(item => { for (int index = 0; index < packet._itemStateList.Count; index++) { if (item.interactionNodeId == packet._itemStateList[index]._nodeId) { item.RefreshMarryInteractionItemState(packet._itemStateList[index]._state); break; } } }); } public void OnTalkBtnClick() { var interactionSummaryTab = TableManager.GetInteractionSummaryByID(_CurSelectType, 0); if (interactionSummaryTab == null) return; var _clickWait = interactionSummaryTab.CD; if (GlobalData._InteractionLastMessageTime == 0) //第一次点击 { GlobalData._InteractionLastMessageTime = Time.realtimeSinceStartup; } else //第二次判断时差 { if (Time.realtimeSinceStartup - GlobalData._InteractionLastMessageTime >= _clickWait) { GlobalData._InteractionLastMessageTime = Time.realtimeSinceStartup; } else { GUIData.AddNotifyData("#{1076}"); return; } } ReqInteractionPublishInfo req = new ReqInteractionPublishInfo(); req._type = _CurSelectType; req._strIndex = 1; req.SendMsg(); } private const int marryNpcAutosearchId = 9008; public void OnGoForMarryBtnClick() { Tab_AutoSearch autoSearch = TableManager.GetAutoSearchByID(marryNpcAutosearchId, 0); if (autoSearch == null) { return; } Vector3 pos = new Vector3(); pos.x = autoSearch.X; pos.z = autoSearch.Z; int sceneId = autoSearch.DstSceneID; AutoSearchPoint targetPoint = new AutoSearchPoint(sceneId, pos.x, pos.z); if (GameManager.gameManager && GameManager.gameManager.AutoSearch) { GameManager.gameManager.AutoSearch.BuildPath(targetPoint); Tab_RoleBaseAttr RoleBase = TableManager.GetRoleBaseAttrByID(autoSearch.DataId, 0); if (null != RoleBase && null != GameManager.gameManager.AutoSearch.Path) { GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = RoleBase.Name; GameManager.gameManager.AutoSearch.Path.autoSearchRadius = RoleBase.DialogRadius; } } UIManager.CloseUI(UIInfo.InteractionPanel); } }