Пример #1
0
        private ChatItemData GetChatItemDataByBaseNode(BaseNode node)
        {
            ChatItemData itemData = new ChatItemData();

            itemData.m_chatItemID = node.Id;
            for (int i = 0; i < node.Lets.Count; i++)
            {
                if (node.Lets[i].Type == LetTypes.OUTLET)
                {
                    for (int j = 0; j < node.Lets[i].Connections.Count; j++)
                    {
                        Connection con = node.Lets[i].Connections[j];
                        itemData.m_nextChatItemID.Add(con.Inlet.Owner.Id);
                    }
                }
            }
            //itemData.m_nextChatItemID
            if (node is ButtonNode)
            {
                ButtonNode btnNode = node as ButtonNode;
                itemData.m_chatHead     = btnNode.headValue;
                itemData.m_chatContent  = btnNode.contentValue;
                itemData.m_chatPosition = (int)btnNode.m_headPosition;
                itemData.m_chatType     = (int)btnNode.m_nodeType;
                if (btnNode.imgValue_00 != null)
                {
                    itemData.m_chatKeyImages.Add(btnNode.imgValue_00.name + ".png");
                }
                if (btnNode.imgValue_01 != null)
                {
                    itemData.m_chatKeyImages.Add(btnNode.imgValue_01.name + ".png");
                }
                if (btnNode.imgValue_02 != null)
                {
                    itemData.m_chatKeyImages.Add(btnNode.imgValue_02.name + ".png");
                }
                if (btnNode.imgValue_03 != null)
                {
                    itemData.m_chatKeyImages.Add(btnNode.imgValue_03.name + ".png");
                }
            }
            else if (node is ChatOptionContentNode)
            {
                ChatOptionContentNode contentNode = (ChatOptionContentNode)node;
                itemData.m_chatContent = contentNode.contentValue;
            }
            else if (node is ChatOptionNode)
            {
                ChatOptionNode optionNode = (ChatOptionNode)node;
                itemData.m_chatContent = optionNode.tex.name + ".png";
            }
            return(itemData);
        }
Пример #2
0
        private EditorChatItemData GetEditorChatItemDataByBaseNode(BaseNode node)
        {
            EditorChatItemData itemData = new EditorChatItemData();

            itemData.m_chatItemID = node.Id;
            itemData.m_Position   = new EditorVector2(node.Position);
            for (int i = 0; i < node.Lets.Count; i++)
            {
                if (node.Lets[i].Type == LetTypes.OUTLET)
                {
                    for (int j = 0; j < node.Lets[i].Connections.Count; j++)
                    {
                        Connection           con          = node.Lets[i].Connections[j];
                        EditorConnectionData connectPoint = new EditorConnectionData();
                        connectPoint.m_connectPoint = new EditorVector2[con.Points.Length];
                        for (int k = 0; k < con.Points.Length; k++)
                        {
                            connectPoint.m_connectPoint[k] = new EditorVector2(con.Points[k]);
                        }
                        connectPoint.m_nextItemID = con.Inlet.Owner.Id;
                        itemData.m_nextChatItemID.Add(connectPoint);
                    }
                }
            }
            //itemData.m_nextChatItemID
            if (node is ButtonNode)
            {
                ButtonNode btnNode = node as ButtonNode;
                itemData.m_chatHead     = btnNode.headValue;
                itemData.m_chatContent  = btnNode.contentValue;
                itemData.m_chatPosition = (int)btnNode.m_headPosition;
                itemData.m_chatType     = (int)btnNode.m_nodeType;
                if (btnNode.imgValue_00 != null)
                {
                    itemData.m_chatKeyImages.Add(UnityEditor.AssetDatabase.GetAssetPath(btnNode.imgValue_00));
                }
                if (btnNode.imgValue_01 != null)
                {
                    itemData.m_chatKeyImages.Add(UnityEditor.AssetDatabase.GetAssetPath(btnNode.imgValue_01));
                }
                if (btnNode.imgValue_02 != null)
                {
                    itemData.m_chatKeyImages.Add(UnityEditor.AssetDatabase.GetAssetPath(btnNode.imgValue_02));
                }
                if (btnNode.imgValue_03 != null)
                {
                    itemData.m_chatKeyImages.Add(UnityEditor.AssetDatabase.GetAssetPath(btnNode.imgValue_03));
                }
            }
            else if (node is ChatOptionContentNode)
            {
                ChatOptionContentNode contentNode = (ChatOptionContentNode)node;
                itemData.m_chatContent = contentNode.contentValue;
                itemData.m_chatType    = (int)ChatNodeType.Content_Word;
            }
            else if (node is ChatOptionNode)
            {
                ChatOptionNode optionNode = (ChatOptionNode)node;
                itemData.m_chatContent = optionNode.tex.name;
                itemData.m_chatType    = (int)ChatNodeType.Content_Image;
            }
            return(itemData);
        }
Пример #3
0
        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();
        }