Exemplo n.º 1
0
 /// <summary>
 /// 取消主、子任务间的链接
 /// </summary>
 /// <param name="subTask">子任务</param>
 /// <param name="mainTask">主任务</param>
 private void _CancelMainTask(GKToySubTask subTask, GKToyTask mainTask)
 {
     mainTask.subTasks.Remove(subTask.id);
     subTask.ChangeTaskID(subTask.id);
     foreach (Link link in subTask.links)
     {
         if (CurRenderData.nodeLst.ContainsKey(link.next) && ((GKToyNode)CurRenderData.nodeLst[link.next]).className.Contains("GKToyTaskEditor.GKToySubTask"))
         {
             _CancelMainTask(((GKToySubTask)CurRenderData.nodeLst[link.next]), mainTask);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 添加链接时,添加任务间的关系
 /// </summary>
 /// <param name="srcNode"></param>
 /// <param name="destNode"></param>
 /// <param name="paramKey"></param>
 protected override void _AddLink(GKToyNode srcNode, GKToyNode destNode, string paramKey)
 {
     base._AddLink(srcNode, destNode, paramKey);
     if ("GKToyTaskEditor.GKToyTask" == srcNode.className)
     {
         if ("GKToyTaskEditor.GKToyTask" == destNode.className)
         {
             GKToyTask destTask = (GKToyTask)destNode;
             ((GKToyTask)srcNode).nextTaskIds.Add(destTask.id);
             destTask.preTaskIds.Add(srcNode.id);
             if (1 < destTask.preTaskIds.Count)
             {
                 destTask.preSeperator.Add("&");
             }
         }
         else if (destNode.className.Contains("GKToyTaskEditor.GKToySubTask"))
         {
             _SetMainTask((GKToySubTask)destNode, (GKToyTask)srcNode);
         }
     }
     else if (srcNode.className.Contains("GKToyTaskEditor.GKToySubTask"))
     {
         if ("GKToyTaskEditor.GKToyTask" == destNode.className)
         {
             GKToyTask destTask = (GKToyTask)destNode;
             int       mainId   = ((GKToySubTask)srcNode).mainTask;
             if (CurRenderData.nodeLst.ContainsKey(mainId))
             {
                 ((GKToyTask)CurRenderData.nodeLst[mainId]).nextTaskIds.Add(destTask.id);
                 destTask.preTaskIds.Add(mainId);
                 if (1 < destTask.preTaskIds.Count)
                 {
                     destTask.preSeperator.Add("&");
                 }
             }
         }
         else if (destNode.className.Contains("GKToyTaskEditor.GKToySubTask"))
         {
             int mainId = ((GKToySubTask)srcNode).mainTask;
             if (CurRenderData.nodeLst.ContainsKey(mainId))
             {
                 _SetMainTask((GKToySubTask)destNode, (GKToyTask)CurRenderData.nodeLst[mainId]);
             }
         }
     }
 }
Exemplo n.º 3
0
 protected override void _RemoveNode(GKToyNode node)
 {
     base._RemoveNode(node);
     if ("GKToyTaskEditor.GKToyTask" == node.className)
     {
         GKToyTask taskNode = (GKToyTask)node;
         string    path     = string.Format("{0}/TaskDfg/AcceptDfg_{1}.Asset", ToyMakerBase._defaultOverlordPath, taskNode.TaskID.Value);
         if (File.Exists(path))
         {
             AssetDatabase.DeleteAsset(path);
         }
         path = string.Format("{0}/TaskDfg/SubmitDfg_{1}.Asset", ToyMakerBase._defaultOverlordPath, taskNode.TaskID.Value);
         if (File.Exists(path))
         {
             AssetDatabase.DeleteAsset(path);
         }
         path = string.Format("{0}/TaskDfg/AcceptDfg_{1}.prefab", ToyMakerBase._defaultOverlordPath, taskNode.TaskID.Value);
         if (File.Exists(path))
         {
             AssetDatabase.DeleteAsset(path);
         }
         path = string.Format("{0}/TaskDfg/SubmitDfg_{1}.prefab", ToyMakerBase._defaultOverlordPath, taskNode.TaskID.Value);
         if (File.Exists(path))
         {
             AssetDatabase.DeleteAsset(path);
         }
         AssetDatabase.Refresh();
     }
     else if ("GKToyTaskEditor.GKToySubTaskInteract" == node.className)
     {
         GKToySubTaskInteract taskNode = (GKToySubTaskInteract)node;
         string path = string.Format("{0}/TaskDfg/Interact_{1}.Asset", ToyMakerBase._defaultOverlordPath, taskNode.TargetID.Value);
         if (File.Exists(path))
         {
             AssetDatabase.DeleteAsset(path);
         }
         path = string.Format("{0}/TaskDfg/Interact_{1}.prefab", ToyMakerBase._defaultOverlordPath, taskNode.TargetID.Value);
         if (File.Exists(path))
         {
             AssetDatabase.DeleteAsset(path);
         }
         AssetDatabase.Refresh();
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 给子任务设置主任务节点
 /// </summary>
 /// <param name="subTask">子任务节点</param>
 /// <param name="mainTask">主任务节点,留空则最后一个节点</param>
 /// <returns>子任务编号</returns>
 private void _SetMainTask(GKToySubTask subTask, GKToyTask mainTask)
 {
     if (null != mainTask)
     {
         subTask.subId        = mainTask.subTasks.Count + 1;
         subTask.mainTask     = mainTask.id;
         subTask.initTargetId = mainTask.LiteralId * 10000 + subTask.type * 1000 + subTask.subId;
         subTask.ChangeTaskID(subTask.initTargetId);
         mainTask.subTasks.Add(subTask.id);
     }
     else
     {
         subTask.subId = -1;
     }
     foreach (Link link in subTask.links)
     {
         if (CurRenderData.nodeLst.ContainsKey(link.next) && ((GKToyNode)CurRenderData.nodeLst[link.next]).className.Contains("GKToyTaskEditor.GKToySubTask"))
         {
             _SetMainTask(((GKToySubTask)CurRenderData.nodeLst[link.next]), mainTask);
         }
     }
 }
Exemplo n.º 5
0
 protected override void _CreateNode(GKToyNode node)
 {
     base._CreateNode(node);
     if ("GKToyTaskEditor.GKToyTask" == node.className)
     {
         GKToyTask taskNode = (GKToyTask)node;
         taskNode.initTaskId      = CurRenderData.curLiteralId++;
         taskNode.TaskID          = taskNode.initTaskId;
         taskNode.AcceptDfgObject = _CreateDialogueData(string.Format("{0}/TaskDfg/", ToyMakerBase._defaultOverlordPath), taskNode.TaskID.Value, "AcceptDfg");
         taskNode.SubmitDfgObject = _CreateDialogueData(string.Format("{0}/TaskDfg/", ToyMakerBase._defaultOverlordPath), taskNode.TaskID.Value, "SubmitDfg");
         AssetDatabase.Refresh();
     }
     else if (node.className.Contains("GKToyTaskEditor.GKToySubTask"))
     {
         GKToySubTask taskNode = (GKToySubTask)node;
         if ("GKToyTaskEditor.GKToySubTaskInteract" == node.className)
         {
             ((GKToySubTaskInteract)taskNode).InteractDfgObject = _CreateDialogueData(string.Format("{0}/TaskDfg/", ToyMakerBase._defaultOverlordPath), taskNode.TargetID.Value, "Interact");
             AssetDatabase.Refresh();
         }
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 删除链接时,删除任务间的关系
 /// </summary>
 /// <param name="srcNode"></param>
 /// <param name="destNode"></param>
 protected override void _RemoveLink(GKToyNode srcNode, GKToyNode destNode)
 {
     base._RemoveLink(srcNode, destNode);
     if ("GKToyTaskEditor.GKToyTask" == srcNode.className)
     {
         if ("GKToyTaskEditor.GKToyTask" == destNode.className)
         {
             GKToyTask destTask = (GKToyTask)destNode;
             ((GKToyTask)srcNode).nextTaskIds.Remove(destTask.id);
             int linkId = destTask.preTaskIds.IndexOf(srcNode.id);
             if (0 <= linkId && 0 < destTask.preSeperator.Count)
             {
                 destTask.preTaskIds.RemoveAt(linkId);
                 if (0 == linkId)
                 {
                     destTask.preSeperator.RemoveAt(0);
                 }
                 else
                 {
                     destTask.preSeperator.RemoveAt(linkId - 1);
                 }
             }
         }
         else if (destNode.className.Contains("GKToyTaskEditor.GKToySubTask"))
         {
             _CancelMainTask((GKToySubTask)destNode, (GKToyTask)srcNode);
         }
     }
     else if (srcNode.className.Contains("GKToyTaskEditor.GKToySubTask"))
     {
         if ("GKToyTaskEditor.GKToyTask" == destNode.className)
         {
             GKToyTask destTask = (GKToyTask)destNode;
             int       mainId   = ((GKToySubTask)srcNode).mainTask;
             if (CurRenderData.nodeLst.ContainsKey(mainId))
             {
                 ((GKToyTask)CurRenderData.nodeLst[mainId]).nextTaskIds.Remove(destTask.id);
                 int linkId = destTask.preTaskIds.IndexOf(mainId);
                 if (0 <= linkId && 0 < destTask.preSeperator.Count)
                 {
                     destTask.preTaskIds.RemoveAt(linkId);
                     if (0 == linkId)
                     {
                         destTask.preSeperator.RemoveAt(0);
                     }
                     else
                     {
                         destTask.preSeperator.RemoveAt(linkId - 1);
                     }
                 }
             }
         }
         else if (destNode.className.Contains("GKToyTaskEditor.GKToySubTask"))
         {
             int mainId = ((GKToySubTask)srcNode).mainTask;
             if (CurRenderData.nodeLst.ContainsKey(mainId))
             {
                 _CancelMainTask((GKToySubTask)destNode, (GKToyTask)CurRenderData.nodeLst[mainId]);
             }
         }
     }
 }
Exemplo n.º 7
0
 // 初始化任务数据(不包含核心任务数据).
 public static void InitSubData(GKToyTask task, GKToyData data)
 {
     instance._task     = task;
     instance._data     = data;
     instance.tmpTaskId = task.TaskID.Value;
 }
Exemplo n.º 8
0
        /// <summary>
        /// 在实例中读取带有特定Attribute的属性
        /// </summary>
        /// <param name="obj">读取的实例</param>
        /// <param name="attribute">Attribute</param>
        /// <returns>属性列表</returns>
        protected static List <NodeAttr> _GetFieldsWithAttribute(string id, object obj, Type attribute, GameData taskTextData, List <GKToyData> dfgDatas, GKToyData nodeData)
        {
            if (!obj.GetType().IsClass)
            {
                return(null);
            }
            Type type = obj.GetType();

            object[]        attrs;
            List <NodeAttr> fields = new List <NodeAttr>();

            // 读取所有属性.
            type = obj.GetType();
            List <PropertyInfo> allProperties = new List <PropertyInfo>();

            do
            {
                allProperties.AddRange(type.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly));
                type = type.BaseType;
            } while (null != type || typeof(GKToyNode) == type);
            foreach (PropertyInfo property in allProperties)
            {
                attrs = property.GetCustomAttributes(attribute, true);
                if (0 != attrs.Length)
                {
                    object val      = property.GetValue(obj, null);
                    Type   propType = val.GetType();
                    // 存储译文.
                    if (taskTextProps.Contains(property.Name))
                    {
                        string textId = string.Format("{0}_{1}", property.Name, id);
                        string valStr = _DealWithAttributes(val, propType);
                        // id替换.
                        if (replaceProps.Contains(property.Name))
                        {
                            int start = valStr.IndexOf("[");
                            int end   = valStr.IndexOf("]");
                            if (-1 < start && 0 < end - start - 1)
                            {
                                string       name      = valStr.Substring(start + 1, end - start - 1);
                                PropertyInfo innerPorp = obj.GetType().GetProperty(name);
                                if (null != innerPorp)
                                {
                                    object innerVal  = innerPorp.GetValue(obj, null);
                                    Type   innerType = innerVal.GetType();
                                    valStr = valStr.Replace(name, _DealWithAttributes(innerVal, innerType));
                                }
                            }
                        }
                        fields.Add(new NodeAttr(property.Name, textId));
                        taskTextData.Add(_GenerateTaskTextData(textId, valStr));
                    }
                    else if ("PreTask" == property.Name)
                    {
                        string    valStr = "";
                        GKToyTask task   = (GKToyTask)obj;
                        if (0 < task.preTaskIds.Count)
                        {
                            for (int i = 0; i < task.preTaskIds.Count; ++i)
                            {
                                if (i < task.preSeperator.Count)
                                {
                                    valStr = string.Format("{0}{1}{2}", valStr, ((GKToyTask)nodeData.nodeLst[task.preTaskIds[i]]).TaskID, task.preSeperator[i]);
                                }
                                else
                                {
                                    valStr = string.Format("{0}{1}", valStr, ((GKToyTask)nodeData.nodeLst[task.preTaskIds[i]]).TaskID);
                                }
                            }
                        }
                        fields.Add(new NodeAttr(property.Name, valStr));
                    }
                    else if ("NextTask" == property.Name)
                    {
                        string    valStr    = "";
                        GKToyTask task      = (GKToyTask)obj;
                        bool      seperator = false;
                        if (0 < task.nextTaskIds.Count)
                        {
                            foreach (int next in task.nextTaskIds)
                            {
                                if (seperator)
                                {
                                    valStr = string.Format("{0},{1}", valStr, ((GKToyTask)nodeData.nodeLst[next]).TaskID);
                                }
                                else
                                {
                                    valStr    = string.Format("{0}{1}", valStr, ((GKToyTask)nodeData.nodeLst[next]).TaskID);
                                    seperator = true;
                                }
                            }
                        }
                        fields.Add(new NodeAttr(property.Name, valStr));
                    }
                    // 处理对话.
                    else if (dfgProps.Contains(property.Name))
                    {
                        dfgDatas.Add(((GKToySharedGameObject)val).Value.GetComponent <GKToyBaseOverlord>().internalData.data);
                    }
                    else
                    {
                        attrs = property.GetCustomAttributes(typeof(XmlElementAttribute), true);
                        if (0 != attrs.Length)
                        {
                            fields.Add(new NodeAttr(((XmlElementAttribute)attrs[0]).ElementName, _DealWithAttributes(val, propType)));
                        }
                        else
                        {
                            fields.Add(new NodeAttr(property.Name, _DealWithAttributes(val, propType)));
                        }
                    }
                }
            }
            if (0 == fields.Count)
            {
                return(null);
            }
            else
            {
                return(fields);
            }
        }