private void CreateConnectLine(EditorChatData chatData) { for (int i = 0; i < chatData.m_chat.Count; i++) { Outlet outlet = (Outlet)m_nodes[i].Lets[1]; EditorChatItemData chatItemData = chatData.m_chat[i]; for (int j = 0; j < chatItemData.m_nextChatItemID.Count; j++) { for (int k = 0; k < m_nodes.Count; k++) { if (m_nodes[k].Id == chatItemData.m_nextChatItemID[j].m_nextItemID) { Inlet inlet = (Inlet)m_nodes[k].Lets[0]; EditorVector2[] editorVec = chatItemData.m_nextChatItemID[j].m_connectPoint; List <Vector2> linePoints = new List <Vector2>(); for (int m = editorVec.Length - 1; m >= 0; m--) { linePoints.Add(new Vector2(editorVec[m].x, editorVec[m].y)); } Connection connection = new Connection(inlet, outlet, linePoints); inlet.Connections.Add(connection); outlet.Connections.Add(connection); break; } } //m_nodes[i].Lets //Connection connection = new Connection((Inlet)inlet, (Outlet)outlet, m_livePoints); //inlet.Connections.Add(connection); //outlet.Connections.Add(connection); } } }
private EditorChatData GetEditorChatDataByNodes(List <BaseNode> nodes, string BG, int chatID) { EditorChatData chatData = new EditorChatData(); chatData.m_chatBG = BG; chatData.m_chatID = chatID; for (int i = 0; i < nodes.Count; i++) { EditorChatItemData itemData = GetEditorChatItemDataByBaseNode(nodes[i]); chatData.m_chat.Add(itemData); } return(chatData); }
public void SaveEditorChatData(List <BaseNode> nodes, string BG, int chatID, string describe) { //bool needAdd = true; EditorChatData chatData = GetEditorChatDataByNodes(nodes, BG, chatID); chatData.m_describe = describe; if (editorChatGroup.m_chats.ContainsKey(chatID)) { editorChatGroup.m_chats[chatID] = chatData; } else { editorChatGroup.m_chats.Add(chatID, chatData); } string chatContent = fastJSON.JSON.ToJSON(editorChatGroup); CreateJson(EDITORPATH, chatContent); }
public void CreateChatNodeByEditorData(EditorChatData chatData) { OnDestroy(); Clear(); m_bgImg = null; if (!string.IsNullOrEmpty(chatData.m_chatBG)) { m_bgImg = AssetDatabase.LoadAssetAtPath <Texture>(chatData.m_chatBG); } m_describeLab = chatData.m_describe; chatID = chatData.m_chatID; for (int i = 0; i < chatData.m_chat.Count; i++) { EditorChatItemData chatItemData = chatData.m_chat[i]; System.Type type = typeof(ButtonNode); ChatNodeType nodeType = (ChatNodeType)chatItemData.m_chatType; if (nodeType == ChatNodeType.Content_Image) { type = typeof(ChatOptionNode); ChatOptionNode optionNode = CreateNode(new Vector2(chatItemData.m_Position.x, chatItemData.m_Position.y), type, chatItemData.m_chatItemID) as ChatOptionNode; if (!string.IsNullOrEmpty(chatItemData.m_chatContent)) { optionNode.tex = AssetDatabase.LoadAssetAtPath <Texture>(chatItemData.m_chatContent); } } else if (nodeType == ChatNodeType.Content_Word) { type = typeof(ChatOptionContentNode); ChatOptionContentNode contentNode = CreateNode(new Vector2(chatItemData.m_Position.x, chatItemData.m_Position.y), type, chatItemData.m_chatItemID) as ChatOptionContentNode; contentNode.contentValue = chatItemData.m_chatContent; } else { ButtonNode btnNode = CreateNode(new Vector2(chatItemData.m_Position.x, chatItemData.m_Position.y), type, chatItemData.m_chatItemID) as ButtonNode; btnNode.m_headPosition = (ChatHeadPosition)chatItemData.m_chatPosition; btnNode.m_nodeType = (ChatNodeType)chatItemData.m_chatType; btnNode.contentValue = chatItemData.m_chatContent; btnNode.headValue = chatItemData.m_chatHead; if (chatItemData.m_chatKeyImages.Count >= 1) { btnNode.imgValue_00 = AssetDatabase.LoadAssetAtPath <Texture>(chatItemData.m_chatKeyImages[0]); } if (chatItemData.m_chatKeyImages.Count >= 2) { btnNode.imgValue_01 = AssetDatabase.LoadAssetAtPath <Texture>(chatItemData.m_chatKeyImages[1]); } if (chatItemData.m_chatKeyImages.Count >= 3) { btnNode.imgValue_02 = AssetDatabase.LoadAssetAtPath <Texture>(chatItemData.m_chatKeyImages[2]); } if (chatItemData.m_chatKeyImages.Count >= 4) { btnNode.imgValue_03 = AssetDatabase.LoadAssetAtPath <Texture>(chatItemData.m_chatKeyImages[3]); } } } CreateConnectLine(chatData); Repaint(); }