Ejemplo n.º 1
0
 /// <summary>
 /// 发送消息
 /// </summary>
 /// <param name="channelType">通信协议通道类型</param>
 /// <param name="message">消息对象</param>
 /// <returns>是否发送成功</returns>
 public bool SendMessage(Type channelType, INetworkMessage message)
 {
     if (_protocolChannels.ContainsKey(channelType))
     {
         if (_protocolChannels[channelType].IsNeedConnect)
         {
             if (_protocolChannels[channelType].IsConnect)
             {
                 _protocolChannels[channelType].InjectMessage(_protocolChannels[channelType].EncapsulatedMessage(message));
                 return(true);
             }
             else
             {
                 GlobalTools.LogError("发送消息出错:客户端已断开连接!");
                 return(false);
             }
         }
         else
         {
             _protocolChannels[channelType].InjectMessage(_protocolChannels[channelType].EncapsulatedMessage(message));
             return(true);
         }
     }
     else
     {
         GlobalTools.LogWarning("发送消息出错:" + channelType.FullName + " 未启用或并不是有效的通信协议!");
         return(true);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 与服务器断开连接
        /// </summary>
        /// <param name="channelType">通信协议通道类型</param>
        /// <param name="message">断开连接请求</param>
        public void DisconnectServer(Type channelType, INetworkMessage message)
        {
            if (_protocolChannels.ContainsKey(channelType))
            {
                if (_protocolChannels[channelType].IsNeedConnect)
                {
                    if (!_protocolChannels[channelType].IsConnect)
                    {
                        return;
                    }

                    if (_protocolChannels[channelType].IsDisconnectRequest(message))
                    {
                        SendMessage(channelType, message);
                    }
                    else
                    {
                        GlobalTools.LogWarning("与服务器断开连接出错:发送的消息并不是断开连接的请求!");
                    }
                }
                else
                {
                    GlobalTools.LogWarning("与服务器断开连接出错:" + _protocolChannels[channelType].ToString() + " 不需要与服务器保持连接!");
                }
            }
            else
            {
                GlobalTools.LogWarning("与服务器断开连接出错:" + channelType.FullName + " 未启用或并不是有效的通信协议!");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 连接服务器
        /// </summary>
        /// <param name="channelType">通信协议通道类型</param>
        public void ConnectServer(Type channelType)
        {
            if (_protocolChannels.ContainsKey(channelType))
            {
                if (_protocolChannels[channelType].IsNeedConnect)
                {
                    if (_protocolChannels[channelType].IsConnect)
                    {
                        return;
                    }

                    BeginConnectServerEvent?.Invoke(_protocolChannels[channelType]);

                    Main.Current.StartCoroutine(ConnectServerCoroutine(_protocolChannels[channelType]));
                }
                else
                {
                    GlobalTools.LogWarning("连接服务器出错:" + _protocolChannels[channelType].ToString() + " 不需要与服务器保持连接!");
                }
            }
            else
            {
                GlobalTools.LogWarning("连接服务器出错:" + channelType.FullName + " 未启用或并不是有效的通信协议!");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 屏幕截图
        /// </summary>
        private IEnumerator ScreenShot()
        {
            string path = "";

#if UNITY_ANDROID
            path = "/sdcard/DCIM/ScreenShots/";
#endif

#if UNITY_STANDALONE_WIN || UNITY_EDITOR
            path = Application.dataPath + "/ScreenShots/";
#endif

            if (path != "")
            {
                Main.m_Debug.IsEnableDebugger = false;
                yield return(YieldInstructioner.GetWaitForEndOfFrame());

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                Texture2D texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
                texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
                texture.Apply();
                string name  = "ScreenShotImage_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".png";
                byte[] bytes = texture.EncodeToPNG();
                File.WriteAllBytes(path + name, bytes);
                Main.m_Debug.IsEnableDebugger = true;
            }
            else
            {
                GlobalTools.LogWarning("当前平台不支持截屏!");
                yield return(0);
            }
        }
Ejemplo n.º 5
0
        private void EditModule()
        {
            HTFrameworkModule module       = _settingItems[_currentItem].GetType().GetCustomAttribute <InternalSettingItemAttribute>().Module;
            GameObject        moduleEntity = null;

            switch (module)
            {
            case HTFrameworkModule.AspectTrack:
                moduleEntity = GameObject.Find("HTFramework/AspectTrack");
                break;

            case HTFrameworkModule.Audio:
                moduleEntity = GameObject.Find("HTFramework/Audio");
                break;

            case HTFrameworkModule.Controller:
                moduleEntity = GameObject.Find("HTFramework/Controller");
                break;

            case HTFrameworkModule.WebRequest:
                moduleEntity = GameObject.Find("HTFramework/WebRequest");
                break;
            }

            if (moduleEntity)
            {
                Selection.activeGameObject = moduleEntity;
                EditorGUIUtility.PingObject(moduleEntity);
            }
            else
            {
                GlobalTools.LogWarning("未找到该设置项相关联的模块!");
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 注册状态机
 /// </summary>
 public void RegisterFSM(FSM fsm)
 {
     if (!_fsms.ContainsKey(fsm.Name))
     {
         _fsms.Add(fsm.Name, fsm);
     }
     else
     {
         GlobalTools.LogWarning(string.Format("注册状态机失败:已存在状态机 {0}!", fsm.Name));
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 移除已注册的状态机
 /// </summary>
 public void UnRegisterFSM(FSM fsm)
 {
     if (_fsms.ContainsKey(fsm.Name))
     {
         _fsms.Remove(fsm.Name);
     }
     else
     {
         GlobalTools.LogWarning(string.Format("移除已注册的状态机失败:不存在状态机 {0}!", fsm.Name));
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 获取代理者
 /// </summary>
 /// <param name="realObject">真实对象</param>
 /// <returns>代理者</returns>
 public object GetProxyer(IAspectTrackObject realObject)
 {
     if (_proxys.ContainsKey(realObject))
     {
         return(_proxys[realObject]);
     }
     else
     {
         GlobalTools.LogWarning("获取代理者失败:真实对象 " + realObject.ToString() + " 并不存在代理者!");
         return(null);
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 移除已注册的对象池
 /// </summary>
 public void UnRegisterSpawnPool(string name)
 {
     if (_spawnPools.ContainsKey(name))
     {
         _spawnPools[name].Clear(true);
         _spawnPools.Remove(name);
     }
     else
     {
         GlobalTools.LogWarning("移除对象池失败:不存在对象池 " + name + " !");
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 获取代理对象
 /// </summary>
 /// <typeparam name="T">代理对象类型</typeparam>
 /// <param name="realObject">真实对象</param>
 /// <returns>代理对象</returns>
 public T GetProxyObject <T>(IAspectTrackObject realObject) where T : class, IAspectTrackObject
 {
     if (_proxyObjects.ContainsKey(realObject))
     {
         return(_proxyObjects[realObject] as T);
     }
     else
     {
         GlobalTools.LogWarning("获取代理对象失败:真实对象 " + realObject.ToString() + " 并不存在代理对象!");
         return(null);
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 获取代理者
 /// </summary>
 /// <param name="realObject">真实对象</param>
 /// <returns>代理者</returns>
 public object GetProxyer(IAspectTrackObject realObject)
 {
     if (_proxys.ContainsKey(realObject))
     {
         return(_proxys[realObject]);
     }
     else
     {
         GlobalTools.LogWarning(string.Format("获取代理者失败:真实对象 {0} 并不存在代理者!", realObject));
         return(null);
     }
 }
Ejemplo n.º 12
0
        public sealed override IMessage Invoke(IMessage msg)
        {
            IMethodCallMessage callMsg = msg as IMethodCallMessage;

            bool       isVoid = false;
            MethodInfo info   = callMsg.MethodBase as MethodInfo;

            if (info != null)
            {
                isVoid = (info.ReturnType.Name == VOIDSIGN);
                info   = null;
            }

            object returnValue = null;

            object[] args = OnBeforeInvoke(callMsg.MethodBase, callMsg.Args);

            try
            {
                if (isVoid && IsIntercept(callMsg.MethodBase, args))
                {
                    OnIntercept(callMsg.MethodBase);
                    returnValue = null;
                    return(msg);
                }
                else
                {
                    if (args != null && args.Length == callMsg.ArgCount)
                    {
                        returnValue = callMsg.MethodBase.Invoke(_realObject, args);
                        return(new ReturnMessage(returnValue, args, callMsg.ArgCount - callMsg.InArgCount, callMsg.LogicalCallContext, callMsg));
                    }
                    else
                    {
                        GlobalTools.LogWarning("切面追踪:方法 " + callMsg.MethodBase.Name + " 经过修改后传入的实参与形参数量不匹配!");
                        returnValue = callMsg.MethodBase.Invoke(_realObject, callMsg.Args);
                        return(new ReturnMessage(returnValue, callMsg.Args, callMsg.ArgCount - callMsg.InArgCount, callMsg.LogicalCallContext, callMsg));
                    }
                }
            }
            catch (Exception ex)
            {
                returnValue = null;
                return(new ReturnMessage(ex, callMsg));
            }
            finally
            {
                OnAfterInvoke(callMsg.MethodBase, returnValue);
            }
        }
Ejemplo n.º 13
0
        private static void MeshCombines()
        {
            if (Selection.gameObjects.Length <= 1)
            {
                GlobalTools.LogWarning("请先选中至少2个以上的待合并网格!");
                return;
            }

            GameObject[]      objs      = Selection.gameObjects;
            CombineInstance[] combines  = new CombineInstance[objs.Length];
            List <Material>   materials = new List <Material>();

            for (int i = 0; i < objs.Length; i++)
            {
                EditorUtility.DisplayProgressBar("合并网格", "正在合并网格及纹理......(" + i + "/" + objs.Length + ")", ((float)i) / objs.Length);

                if (!objs[i].GetComponent <MeshRenderer>() || !objs[i].GetComponent <MeshFilter>())
                {
                    continue;
                }

                Material[] mats = objs[i].GetComponent <MeshRenderer>().sharedMaterials;
                for (int j = 0; j < mats.Length; j++)
                {
                    materials.Add(mats[j]);
                }

                combines[i].mesh      = objs[i].GetComponent <MeshFilter>().sharedMesh;
                combines[i].transform = objs[i].transform.localToWorldMatrix;

                objs[i].SetActive(false);
            }

            EditorUtility.DisplayProgressBar("合并网格", "合并完成!", 1.0f);

            GameObject newMesh = new GameObject("CombineMesh");

            newMesh.AddComponent <MeshFilter>();
            newMesh.AddComponent <MeshRenderer>();
            newMesh.GetComponent <MeshFilter>().sharedMesh = new Mesh();
            //false表示合并为子网格列表,多个材质混用时必须这样设置
            newMesh.GetComponent <MeshFilter>().sharedMesh.CombineMeshes(combines, false);
            newMesh.GetComponent <MeshRenderer>().sharedMaterials = materials.ToArray();

            AssetDatabase.CreateAsset(newMesh.GetComponent <MeshFilter>().sharedMesh, "Assets/CombineMesh.asset");
            AssetDatabase.SaveAssets();

            EditorUtility.ClearProgressBar();
        }
Ejemplo n.º 14
0
        protected override void OnBodyGUI()
        {
            base.OnBodyGUI();

            if (EditorBuildSettings.scenes != null && EditorBuildSettings.scenes.Length > 0)
            {
                EditorBuildSettings.scenes = null;
                GlobalTools.LogWarning("只允许构建包含框架主体的场景!如有多场景切换的需求,请将其他场景打入AB包!");
            }

            if (!_isCanBuild)
            {
                BuildButtonMaskGUI();
            }

            _onGUIMethod.Invoke(_buildPlayerWindow, null);

            if (!_isCanBuild)
            {
                BuildButtonMaskGUI();
            }

            GUI.enabled = true;

            if (_isShowBuildABButton)
            {
                if (GUI.Button(new Rect(position.width - 422, position.height - 31, 123, 18), "Build AssetBundles"))
                {
                    AssetBundleBrowserMain.ShowWindow();
                }
            }
            if (GUI.Button(new Rect(position.width - 294, position.height - 31, 52, 18), "Check"))
            {
                CheckResourceMode();
                Check();
            }
            if (GUI.Button(new Rect(position.width - 170, 3, 160, 18), "HTFramework Settings..."))
            {
                Setter setter = GetWindow <Setter>();
                setter.titleContent.image = EditorGUIUtility.IconContent("SettingsIcon").image;
                setter.titleContent.text  = "HTFramework Setter";
                setter.minSize            = new Vector2(640, 580);
                setter.Show();
            }
        }
Ejemplo n.º 15
0
        private static void SetMouseRayUITarget()
        {
            if (Selection.gameObjects.Length <= 0)
            {
                GlobalTools.LogWarning("请先选中场景中的UI对象!");
                return;
            }

            GameObject[] objs = Selection.gameObjects;
            for (int i = 0; i < objs.Length; i++)
            {
                if (!objs[i].GetComponent <MouseRayUITarget>())
                {
                    objs[i].AddComponent <MouseRayUITarget>();
                }
                objs[i].GetComponent <MouseRayUITarget>().Name = objs[i].name;
            }
        }
Ejemplo n.º 16
0
 private static void SetMouseRayUITarget()
 {
     GameObject[] objs = Selection.gameObjects;
     for (int i = 0; i < objs.Length; i++)
     {
         if (!objs[i].GetComponent <Graphic>())
         {
             GlobalTools.LogWarning("对象 " + objs[i].name + " 没有Graphic组件,无法做为可捕获UI目标!");
             continue;
         }
         objs[i].GetComponent <Graphic>().raycastTarget = true;
         if (!objs[i].GetComponent <MouseRayUITarget>())
         {
             objs[i].AddComponent <MouseRayUITarget>();
         }
         objs[i].GetComponent <MouseRayUITarget>().Name = objs[i].name;
     }
 }
Ejemplo n.º 17
0
        protected override void OnBodyGUI()
        {
            base.OnBodyGUI();

            if (EditorBuildSettings.scenes != null && EditorBuildSettings.scenes.Length > 0)
            {
                EditorBuildSettings.scenes = null;
                GlobalTools.LogWarning("只允许构建包含框架主体的场景!如有多场景切换的需求,请将其他场景打入AB包!");
            }

            if (!_isCanBuild)
            {
                BuildButtonMaskGUI();
            }

            _onGUIMethod.Invoke(_buildPlayerWindow, null);

            if (!_isCanBuild)
            {
                BuildButtonMaskGUI();
            }

            GUI.enabled = true;

            if (_isShowBuildABButton)
            {
                if (GUI.Button(new Rect(position.width - 422, position.height - 31, 123, 18), "Build AssetBundles"))
                {
                    AssetBundleBrowserMain.ShowWindow();
                }
            }
            if (GUI.Button(new Rect(position.width - 294, position.height - 31, 52, 18), "Check"))
            {
                CheckResourceMode();
                Check();
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 重新编译任务内容,在更改任务资源 ContentAsset 后,必须重新编译一次才可以开始任务流程
        /// </summary>
        /// <param name="disableTaskIDs">禁用的任务点ID集合(当为null时启用所有任务,禁用的任务不会触发)</param>
        public void RecompileTaskContent(HashSet <string> disableTaskIDs = null)
        {
            if (ContentAsset)
            {
                #region 搜寻任务目标
                _targets.Clear();
                //搜寻框架下所有任务目标
                List <TaskTarget> targetCaches = new List <TaskTarget>();
                Main.Current.transform.GetComponentsInChildren(true, targetCaches);
                for (int i = 0; i < targetCaches.Count; i++)
                {
                    if (!_targets.ContainsKey(targetCaches[i].GUID))
                    {
                        _targets.Add(targetCaches[i].GUID, targetCaches[i]);
                    }
                    else
                    {
                        GlobalTools.LogWarning(string.Format("任务控制者:发现相同GUID的目标!GUID:{0}\r\n目标物体:{1} 和 {2}", targetCaches[i].GUID, _targets[targetCaches[i].GUID].transform.FullName(), targetCaches[i].transform.FullName()));
                    }
                }
                //搜寻场景中所有任务目标
                GameObject[] rootObjs = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
                foreach (GameObject rootObj in rootObjs)
                {
                    targetCaches.Clear();
                    rootObj.transform.GetComponentsInChildren(true, targetCaches);
                    for (int i = 0; i < targetCaches.Count; i++)
                    {
                        if (!_targets.ContainsKey(targetCaches[i].GUID))
                        {
                            _targets.Add(targetCaches[i].GUID, targetCaches[i]);
                        }
                        else
                        {
                            GlobalTools.LogWarning(string.Format("任务控制者:发现相同GUID的目标!GUID:{0}\r\n目标物体:{1} 和 {2}", targetCaches[i].GUID, _targets[targetCaches[i].GUID].transform.FullName(), targetCaches[i].transform.FullName()));
                        }
                    }
                }
                #endregion

                #region 判断任务ID是否重复
                _taskContents.Clear();
                _taskPoints.Clear();
                for (int i = 0; i < ContentAsset.Content.Count; i++)
                {
                    TaskContentBase content = ContentAsset.Content[i];
                    if (_taskContents.ContainsKey(content.GUID))
                    {
                        GlobalTools.LogError(string.Format("任务控制者:发现相同GUID的任务内容!GUID:{0}\r\n任务内容:{1} 和 {2}", content.GUID, _taskContents[content.GUID].Name, content.Name));
                    }
                    else
                    {
                        _taskContents.Add(content.GUID, content);
                    }

                    for (int j = 0; j < content.Points.Count; j++)
                    {
                        TaskPointBase point = content.Points[j];
                        if (_taskPoints.ContainsKey(point.GUID))
                        {
                            GlobalTools.LogError(string.Format("任务控制者:发现相同GUID的任务点!GUID:{0}\r\n任务点:{1} 和 {2}", point.GUID, _taskPoints[point.GUID].Name, point.Name));
                        }
                        else
                        {
                            _taskPoints.Add(point.GUID, point);
                        }

                        if (_taskContents.ContainsKey(point.GUID))
                        {
                            GlobalTools.LogError(string.Format("任务控制者:发现相同GUID的任务内容和任务点!GUID:{0}\r\n任务内容:{1} 任务点:{2}", point.GUID, _taskContents[point.GUID].Name, point.Name));
                        }
                    }
                }
                #endregion

                #region 刷新任务状态
                foreach (var item in _taskContents)
                {
                    item.Value.ReSet();
                }
                foreach (var item in _taskPoints)
                {
                    item.Value.ReSet();
                }

                if (disableTaskIDs != null && disableTaskIDs.Count > 0)
                {
                    foreach (var item in disableTaskIDs)
                    {
                        if (_taskPoints.ContainsKey(item))
                        {
                            _taskPoints[item].IsEnable = false;
                        }
                    }
                }

                _currentContentIndex = 0;
                _currentContent      = null;
                _running             = false;
                #endregion
            }
            else
            {
                throw new HTFrameworkException(HTFrameworkModule.TaskEditor, "任务控制者:重新编译任务失败,任务控制者丢失了任务资源 TaskContentAsset!");
            }
        }
Ejemplo n.º 19
0
 private static void ConsoleDebugLogWarning()
 {
     GlobalTools.LogWarning("Debug.LogWarning!");
 }
Ejemplo n.º 20
0
        private void Start()
        {
            //不支持后期特效
            if (!SystemInfo.supportsImageEffects)
            {
                GlobalTools.LogWarning("HighlightingSystem : Image effects is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持渲染纹理格式
            if (!SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGB32))
            {
                GlobalTools.LogWarning("HighlightingSystem : RenderTextureFormat.ARGB32 is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持Highlighting Stencil着色器
            if (!Shader.Find("Hidden/Highlighted/StencilOpaque").isSupported)
            {
                GlobalTools.LogWarning("HighlightingSystem : HighlightingStencilOpaque shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持Highlighting StencilTransparent着色器
            if (!Shader.Find("Hidden/Highlighted/StencilTransparent").isSupported)
            {
                GlobalTools.LogWarning("HighlightingSystem : HighlightingStencilTransparent shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持Highlighting StencilZ着色器
            if (!Shader.Find("Hidden/Highlighted/StencilOpaqueZ").isSupported)
            {
                GlobalTools.LogWarning("HighlightingSystem : HighlightingStencilOpaqueZ shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持Highlighting StencilTransparentZ着色器
            if (!Shader.Find("Hidden/Highlighted/StencilTransparentZ").isSupported)
            {
                GlobalTools.LogWarning("HighlightingSystem : HighlightingStencilTransparentZ shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持HighlightingBlur着色器
            if (!BlurShader.isSupported)
            {
                GlobalTools.LogWarning("HighlightingSystem : HighlightingBlur shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持HighlightingComposite着色器
            if (!CompositeShader.isSupported)
            {
                GlobalTools.LogWarning("HighlightingSystem : HighlightingComposite shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            BlurMaterial.SetFloat("_Intensity", BlurIntensity);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 重新编译步骤内容
        /// </summary>
        /// <param name="prohibitStepID">禁用的步骤ID列表(当为null时启用所有步骤,禁用的步骤会自动跳过)</param>
        public void RecompileStepContent(HashSet <string> prohibitStepID = null)
        {
            if (ContentAsset)
            {
                //搜寻所有目标
                _targets.Clear();
                GameObject[] rootObjs = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
                foreach (GameObject rootObj in rootObjs)
                {
                    StepTarget[] targets = rootObj.transform.GetComponentsInChildren <StepTarget>(true);
                    foreach (StepTarget target in targets)
                    {
                        if (!_targets.ContainsKey(target.GUID))
                        {
                            _targets.Add(target.GUID, target);
                        }
                        else
                        {
                            GlobalTools.LogWarning(string.Format("发现相同GUID的目标!GUID:{0}\r\n目标物体:{1} 和 {2}", target.GUID, _targets[target.GUID].transform.FullName(), target.transform.FullName()));
                        }
                    }
                }

                //判断步骤ID是否重复
                _stepContentIDs.Clear();
                for (int i = 0; i < ContentAsset.Content.Count; i++)
                {
                    StepContent content = ContentAsset.Content[i];
                    if (_stepContentIDs.ContainsKey(content.GUID))
                    {
                        GlobalTools.LogError(string.Format("发现相同GUID的步骤!GUID:{0}\r\n步骤:{1} 和 {2}", content.GUID, _stepContentIDs[content.GUID].Name, content.Name));
                        return;
                    }
                    else
                    {
                        _stepContentIDs.Add(content.GUID, content);
                    }
                }

                _stepContents.Clear();
                _stepContentEnables.Clear();
                _stepContentIndexs.Clear();
                //启用所有步骤
                if (prohibitStepID == null)
                {
                    for (int i = 0; i < ContentAsset.Content.Count; i++)
                    {
                        StepContent content = ContentAsset.Content[i];
                        if (_targets.ContainsKey(content.TargetGUID))
                        {
                            content.Target = _targets[content.TargetGUID].gameObject;
                        }
                        else
                        {
                            GlobalTools.LogError(string.Format("【步骤:{0}】【{1}】目标没有找到,目标路径:{2}", i, content.Name, content.TargetPath));
                        }

                        for (int j = 0; j < content.Operations.Count; j++)
                        {
                            StepOperation operation = content.Operations[j];
                            if (_targets.ContainsKey(operation.TargetGUID))
                            {
                                operation.Target = _targets[operation.TargetGUID].gameObject;
                            }
                            else
                            {
                                GlobalTools.LogError(string.Format("【步骤:{0}】【操作:{1}】目标没有找到,目标路径:{2}", i, operation.Name, operation.TargetPath));
                            }
                        }

                        _stepContents.Add(content);
                        if (!_stepContentEnables.ContainsKey(content.GUID))
                        {
                            _stepContentEnables.Add(content.GUID, true);
                            _stepContentIndexs.Add(content.GUID, _stepContents.Count - 1);
                        }
                    }
                }
                //禁用 prohibitStepID 指定的步骤
                else
                {
                    for (int i = 0; i < ContentAsset.Content.Count; i++)
                    {
                        StepContent content = ContentAsset.Content[i];
                        if (_targets.ContainsKey(content.TargetGUID))
                        {
                            content.Target = _targets[content.TargetGUID].gameObject;
                        }
                        else
                        {
                            GlobalTools.LogError(string.Format("【步骤:{0}】【{1}】目标没有找到,目标路径:{2}", i, content.Name, content.TargetPath));
                        }

                        for (int j = 0; j < content.Operations.Count; j++)
                        {
                            StepOperation operation = content.Operations[j];
                            if (_targets.ContainsKey(operation.TargetGUID))
                            {
                                operation.Target = _targets[operation.TargetGUID].gameObject;
                            }
                            else
                            {
                                GlobalTools.LogError(string.Format("【步骤:{0}】【操作:{1}】目标没有找到,目标路径:{2}", i, operation.Name, operation.TargetPath));
                            }
                        }

                        _stepContents.Add(content);
                        if (!_stepContentEnables.ContainsKey(content.GUID))
                        {
                            _stepContentEnables.Add(content.GUID, !prohibitStepID.Contains(ContentAsset.Content[i].GUID));
                            _stepContentIndexs.Add(content.GUID, _stepContents.Count - 1);
                        }
                    }
                }

                _currentStep    = 0;
                _currentContent = null;
                _currentTarget  = null;
                _running        = false;
                _executing      = false;

                ClearCustomOrder();
            }
            else
            {
                GlobalTools.LogError("步骤控制器丢失了步骤资源 Step Content Asset!");
            }
        }
 /// <summary>
 /// Immediately restore original materials. Obsolete. Use ReinitMaterials() instead.
 /// </summary>
 public void RestoreMaterials()
 {
     GlobalTools.LogWarning("HighlightingSystem : RestoreMaterials() is obsolete. Please use ReinitMaterials() instead.");
     ReinitMaterials();
 }
Ejemplo n.º 23
0
        internal void Execute()
        {
            switch (OperationType)
            {
            case StepOperationType.Move:
                MoveExecute();
                break;

            case StepOperationType.Rotate:
                RotateExecute();
                break;

            case StepOperationType.Scale:
                ScaleExecute();
                break;

            case StepOperationType.Color:
                ColorExecute();
                break;

            case StepOperationType.Active:
                ActiveExecute();
                break;

            case StepOperationType.Action:
                ActionExecute();
                break;

            case StepOperationType.ActionArgs:
                ActionArgsExecute();
                break;

            case StepOperationType.CameraFollow:
                CameraFollowExecute();
                break;

            case StepOperationType.TextMesh:
                TextMeshExecute();
                break;

            case StepOperationType.Prompt:
                PromptExecute();
                break;

            case StepOperationType.FSM:
                FSMExecute();
                break;

            case StepOperationType.Delay:
                DelayExecute();
                break;

            case StepOperationType.ActiveComponent:
                ActiveComponentExecute();
                break;

            default:
                GlobalTools.LogWarning("步骤控制者:[" + OperationType + " 操作] 没有可以执行的 Execute 定义!");
                break;
            }
        }
Ejemplo n.º 24
0
        internal void OnEditorGUI()
        {
            switch (OperationType)
            {
            case StepOperationType.Move:
                MoveGUI();
                break;

            case StepOperationType.Rotate:
                RotateGUI();
                break;

            case StepOperationType.Scale:
                ScaleGUI();
                break;

            case StepOperationType.Color:
                ColorGUI();
                break;

            case StepOperationType.Active:
                ActiveGUI();
                break;

            case StepOperationType.Action:
                ActionGUI();
                break;

            case StepOperationType.ActionArgs:
                ActionArgsGUI();
                break;

            case StepOperationType.CameraFollow:
                CameraFollowGUI();
                break;

            case StepOperationType.TextMesh:
                TextMeshGUI();
                break;

            case StepOperationType.Prompt:
                PromptGUI();
                break;

            case StepOperationType.FSM:
                FSMGUI();
                break;

            case StepOperationType.Delay:
                DelayGUI();
                break;

            case StepOperationType.ActiveComponent:
                ActiveComponentGUI();
                break;

            default:
                GlobalTools.LogWarning("步骤控制者:[" + OperationType + " 操作] 没有可以执行的 OnEditorGUI 定义!");
                break;
            }
        }
Ejemplo n.º 25
0
        internal void Skip()
        {
            switch (OperationType)
            {
            case StepOperationType.Move:
                MoveSkip();
                break;

            case StepOperationType.Rotate:
                RotateSkip();
                break;

            case StepOperationType.Scale:
                ScaleSkip();
                break;

            case StepOperationType.Color:
                ColorSkip();
                break;

            case StepOperationType.Active:
                ActiveSkip();
                break;

            case StepOperationType.Action:
                ActionSkip();
                break;

            case StepOperationType.ActionArgs:
                ActionArgsSkip();
                break;

            case StepOperationType.CameraFollow:
                CameraFollowSkip();
                break;

            case StepOperationType.TextMesh:
                TextMeshSkip();
                break;

            case StepOperationType.Prompt:
                PromptSkip();
                break;

            case StepOperationType.FSM:
                FSMSkip();
                break;

            case StepOperationType.Delay:
                DelaySkip();
                break;

            case StepOperationType.ActiveComponent:
                ActiveComponentSkip();
                break;

            default:
                GlobalTools.LogWarning("步骤控制者:[" + OperationType + " 操作] 没有可以执行的 Skip 定义!");
                break;
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 重新编译步骤内容
        /// </summary>
        /// <param name="prohibitStepIndex">禁用的步骤索引列表(当为null时启用所有步骤)</param>
        public void RecompileStepContent(List <int> prohibitStepIndex = null)
        {
            if (ContentAsset)
            {
                _targets.Clear();
                GameObject[] rootObjs = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
                foreach (GameObject rootObj in rootObjs)
                {
                    StepTarget[] targets = rootObj.transform.GetComponentsInChildren <StepTarget>(true);
                    foreach (StepTarget target in targets)
                    {
                        if (!_targets.ContainsKey(target.GUID))
                        {
                            _targets.Add(target.GUID, target);
                        }
                        else
                        {
                            GlobalTools.LogWarning("发现相同GUID的目标!GUID:" + target.GUID + "!\r\n目标物体:" + _targets[target.GUID].transform.FullName() + " 和 " + target.transform.FullName());
                        }
                    }
                }

                _stepContents.Clear();
                //启用所有步骤
                if (prohibitStepIndex == null)
                {
                    for (int i = 0; i < ContentAsset.Content.Count; i++)
                    {
                        StepContent content = ContentAsset.Content[i];
                        if (_targets.ContainsKey(content.TargetGUID))
                        {
                            content.Target = _targets[content.TargetGUID].gameObject;
                        }
                        else
                        {
                            GlobalTools.LogError("【步骤:" + (i + 1) + "】【" + content.Name + "】目标没有找到,目标路径:" + content.TargetPath);
                        }

                        for (int j = 0; j < content.Operations.Count; j++)
                        {
                            StepOperation operation = content.Operations[j];
                            if (_targets.ContainsKey(operation.TargetGUID))
                            {
                                operation.Target = _targets[operation.TargetGUID].gameObject;
                            }
                            else
                            {
                                GlobalTools.LogError("【步骤:" + (i + 1) + "】【操作:" + operation.Name + "】目标没有找到,目标路径:" + operation.TargetPath);
                            }
                        }

                        _stepContents.Add(content);
                    }
                }
                //禁用 prohibitStepIndex 指定的步骤
                else
                {
                    for (int i = 0; i < ContentAsset.Content.Count; i++)
                    {
                        if (prohibitStepIndex.Contains(i))
                        {
                            continue;
                        }

                        StepContent content = ContentAsset.Content[i];
                        if (_targets.ContainsKey(content.TargetGUID))
                        {
                            content.Target = _targets[content.TargetGUID].gameObject;
                        }
                        else
                        {
                            GlobalTools.LogError("【步骤:" + (i + 1) + "】【" + content.Name + "】目标没有找到,目标路径:" + content.TargetPath);
                        }

                        for (int j = 0; j < content.Operations.Count; j++)
                        {
                            StepOperation operation = content.Operations[j];
                            if (_targets.ContainsKey(operation.TargetGUID))
                            {
                                operation.Target = _targets[operation.TargetGUID].gameObject;
                            }
                            else
                            {
                                GlobalTools.LogError("【步骤:" + (i + 1) + "】【操作:" + operation.Name + "】目标没有找到,目标路径:" + operation.TargetPath);
                            }
                        }

                        _stepContents.Add(content);
                    }
                }

                _currentStep    = 0;
                _currentContent = null;
                _currentTarget  = null;
                _ongoing        = false;
                _running        = false;

                ClearCustomOrder();
            }
            else
            {
                GlobalTools.LogWarning("步骤控制器丢失了步骤资源 Step Content Asset!");
            }
        }
Ejemplo n.º 27
0
        public void Execute()
        {
            switch (OperationType)
            {
            case StepOperationType.Move:
                MoveExecute();
                break;

            case StepOperationType.Rotate:
                RotateExecute();
                break;

            case StepOperationType.Scale:
                ScaleExecute();
                break;

            case StepOperationType.Color:
                ColorExecute();
                break;

            case StepOperationType.Active:
                ActiveExecute();
                break;

            case StepOperationType.Action:
                ActionExecute();
                break;

            case StepOperationType.ActionArgs:
                ActionArgsExecute();
                break;

            case StepOperationType.CameraFollow:
                CameraFollowExecute();
                break;

            case StepOperationType.TextMesh:
                TextMeshExecute();
                break;

            case StepOperationType.Prompt:
                PromptExecute();
                break;

            case StepOperationType.FSM:
                FSMExecute();
                break;

            case StepOperationType.Delay:
                DelayExecute();
                break;

            case StepOperationType.ActiveComponent:
                ActiveComponentExecute();
                break;

            default:
                GlobalTools.LogWarning(string.Format("[{0}] 没有可以执行的 Execute 定义!", OperationType));
                break;
            }
        }
Ejemplo n.º 28
0
        public void OnEditorGUI()
        {
            switch (OperationType)
            {
            case StepOperationType.Move:
                MoveGUI();
                break;

            case StepOperationType.Rotate:
                RotateGUI();
                break;

            case StepOperationType.Scale:
                ScaleGUI();
                break;

            case StepOperationType.Color:
                ColorGUI();
                break;

            case StepOperationType.Active:
                ActiveGUI();
                break;

            case StepOperationType.Action:
                ActionGUI();
                break;

            case StepOperationType.ActionArgs:
                ActionArgsGUI();
                break;

            case StepOperationType.CameraFollow:
                CameraFollowGUI();
                break;

            case StepOperationType.TextMesh:
                TextMeshGUI();
                break;

            case StepOperationType.Prompt:
                PromptGUI();
                break;

            case StepOperationType.FSM:
                FSMGUI();
                break;

            case StepOperationType.Delay:
                DelayGUI();
                break;

            case StepOperationType.ActiveComponent:
                ActiveComponentGUI();
                break;

            default:
                GlobalTools.LogWarning(string.Format("[{0}] 没有可以执行的 OnEditorGUI 定义!", OperationType));
                break;
            }
        }
Ejemplo n.º 29
0
        public void Skip()
        {
            switch (OperationType)
            {
            case StepOperationType.Move:
                MoveSkip();
                break;

            case StepOperationType.Rotate:
                RotateSkip();
                break;

            case StepOperationType.Scale:
                ScaleSkip();
                break;

            case StepOperationType.Color:
                ColorSkip();
                break;

            case StepOperationType.Active:
                ActiveSkip();
                break;

            case StepOperationType.Action:
                ActionSkip();
                break;

            case StepOperationType.ActionArgs:
                ActionArgsSkip();
                break;

            case StepOperationType.CameraFollow:
                CameraFollowSkip();
                break;

            case StepOperationType.TextMesh:
                TextMeshSkip();
                break;

            case StepOperationType.Prompt:
                PromptSkip();
                break;

            case StepOperationType.FSM:
                FSMSkip();
                break;

            case StepOperationType.Delay:
                DelaySkip();
                break;

            case StepOperationType.ActiveComponent:
                ActiveComponentSkip();
                break;

            default:
                GlobalTools.LogWarning(string.Format("[{0}] 没有可以执行的 Skip 定义!", OperationType));
                break;
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 重新编译步骤内容,在更改步骤资源 ContentAsset 后,必须重新编译一次才可以开始任务流程
        /// </summary>
        /// <param name="disableStepIDs">禁用的步骤ID集合(当为null时启用所有步骤,禁用的步骤会自动跳过)</param>
        public void RecompileStepContent(HashSet <string> disableStepIDs = null)
        {
            if (ContentAsset)
            {
                #region 搜寻步骤目标
                _targets.Clear();
                //搜寻框架下所有步骤目标
                List <StepTarget> targetCaches = new List <StepTarget>();
                Main.Current.transform.GetComponentsInChildren(true, targetCaches);
                for (int i = 0; i < targetCaches.Count; i++)
                {
                    if (!_targets.ContainsKey(targetCaches[i].GUID))
                    {
                        _targets.Add(targetCaches[i].GUID, targetCaches[i]);
                    }
                    else
                    {
                        GlobalTools.LogWarning(string.Format("步骤控制者:发现相同GUID的目标!GUID:{0}\r\n目标物体:{1} 和 {2}", targetCaches[i].GUID, _targets[targetCaches[i].GUID].transform.FullName(), targetCaches[i].transform.FullName()));
                    }
                }
                //搜寻场景中所有步骤目标
                GameObject[] rootObjs = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
                foreach (GameObject rootObj in rootObjs)
                {
                    targetCaches.Clear();
                    rootObj.transform.GetComponentsInChildren(true, targetCaches);
                    for (int i = 0; i < targetCaches.Count; i++)
                    {
                        if (!_targets.ContainsKey(targetCaches[i].GUID))
                        {
                            _targets.Add(targetCaches[i].GUID, targetCaches[i]);
                        }
                        else
                        {
                            GlobalTools.LogWarning(string.Format("步骤控制者:发现相同GUID的目标!GUID:{0}\r\n目标物体:{1} 和 {2}", targetCaches[i].GUID, _targets[targetCaches[i].GUID].transform.FullName(), targetCaches[i].transform.FullName()));
                        }
                    }
                }
                #endregion

                #region 判断步骤ID是否重复
                _stepContentIDs.Clear();
                for (int i = 0; i < ContentAsset.Content.Count; i++)
                {
                    StepContent content = ContentAsset.Content[i];
                    if (_stepContentIDs.ContainsKey(content.GUID))
                    {
                        GlobalTools.LogError(string.Format("步骤控制者:发现相同GUID的步骤!GUID:{0}\r\n步骤:{1} 和 {2}", content.GUID, _stepContentIDs[content.GUID].Name, content.Name));
                    }
                    else
                    {
                        _stepContentIDs.Add(content.GUID, content);
                    }
                }
                #endregion

                #region 生成所有步骤信息
                _stepContents.Clear();
                _stepContentEnables.Clear();
                _stepContentIndexs.Clear();
                //启用所有步骤
                if (disableStepIDs == null || disableStepIDs.Count == 0)
                {
                    for (int i = 0; i < ContentAsset.Content.Count; i++)
                    {
                        StepContent content = ContentAsset.Content[i];
                        if (_targets.ContainsKey(content.TargetGUID))
                        {
                            content.Target = _targets[content.TargetGUID].gameObject;
                        }
                        else
                        {
                            GlobalTools.LogError(string.Format("步骤控制者:【步骤:{0}】【{1}】目标没有找到,目标路径:{2}", i, content.Name, content.TargetPath));
                        }

                        for (int j = 0; j < content.Operations.Count; j++)
                        {
                            StepOperation operation = content.Operations[j];
                            if (_targets.ContainsKey(operation.TargetGUID))
                            {
                                operation.Target = _targets[operation.TargetGUID].gameObject;
                            }
                            else
                            {
                                GlobalTools.LogError(string.Format("步骤控制者:【步骤:{0}】【操作:{1}】目标没有找到,目标路径:{2}", i, operation.Name, operation.TargetPath));
                            }
                        }

                        _stepContents.Add(content);
                        if (!_stepContentEnables.ContainsKey(content.GUID))
                        {
                            _stepContentEnables.Add(content.GUID, true);
                            _stepContentIndexs.Add(content.GUID, _stepContents.Count - 1);
                        }
                    }
                }
                //禁用 disableStepIDs 指定的步骤
                else
                {
                    for (int i = 0; i < ContentAsset.Content.Count; i++)
                    {
                        StepContent content = ContentAsset.Content[i];
                        if (_targets.ContainsKey(content.TargetGUID))
                        {
                            content.Target = _targets[content.TargetGUID].gameObject;
                        }
                        else
                        {
                            GlobalTools.LogError(string.Format("步骤控制者:【步骤:{0}】【{1}】目标没有找到,目标路径:{2}", i, content.Name, content.TargetPath));
                        }

                        for (int j = 0; j < content.Operations.Count; j++)
                        {
                            StepOperation operation = content.Operations[j];
                            if (_targets.ContainsKey(operation.TargetGUID))
                            {
                                operation.Target = _targets[operation.TargetGUID].gameObject;
                            }
                            else
                            {
                                GlobalTools.LogError(string.Format("步骤控制者:【步骤:{0}】【操作:{1}】目标没有找到,目标路径:{2}", i, operation.Name, operation.TargetPath));
                            }
                        }

                        _stepContents.Add(content);
                        if (!_stepContentEnables.ContainsKey(content.GUID))
                        {
                            _stepContentEnables.Add(content.GUID, !disableStepIDs.Contains(content.GUID));
                            _stepContentIndexs.Add(content.GUID, _stepContents.Count - 1);
                        }
                    }
                }

                _currentStepIndex = 0;
                _currentContent   = null;
                _currentTarget    = null;
                _currentHelper    = null;
                _running          = false;
                _pause            = false;
                _executing        = false;

                ClearCustomOrder();
                #endregion
            }
            else
            {
                throw new HTFrameworkException(HTFrameworkModule.StepEditor, "步骤控制者:重新编译步骤失败,步骤控制者丢失了步骤资源 StepContentAsset!");
            }
        }