| using UnityEngine;  | 
| #if UNITY_EDITOR  | 
| using UnityEditor;  | 
| #endif  | 
| using System.Collections.Generic;  | 
| using System.Text;  | 
| using vnxbqy.UI;  | 
|   | 
| public class RuntimeLogUtility : MonoBehaviour  | 
| {  | 
|     private static string LS_Key_ForceAutoFight = "LS_Key_ForceAutoFight";  | 
|     public static bool TEST_CLIENT_PVP = false;  | 
|     public static bool TEST_CLIENT_PVP_AI = true;  | 
|     public static bool s_BattleLog = false;  | 
|     public static bool s_MoveLog = false;  | 
|     public static bool s_ForceOneEnemy = false;  | 
|     public static bool s_PerpetualAttack = true;  | 
|     public static bool s_UseKeyBoardCastSkill = false;  | 
|     public static bool s_LogMoveDistance = false;  | 
|     public static bool s_SkillEffectLog = false;  | 
|     public static bool s_ShowMapLine = false;  | 
|     public static bool s_ShowZZAtkValue = false;  | 
|     public static bool s_ForceSupperHit = false;  | 
|     public static bool s_ForceLuckHit = false;  | 
|     public static bool s_LogProcessInfo = false;  | 
|     public static bool s_forceAutoFight  | 
|     {  | 
|         get  | 
|         {  | 
| #if UNITY_EDITOR  | 
|             return EditorPrefs.GetBool("LS_Key_ForceAutoFight", true);  | 
| #else  | 
|             return true;  | 
| #endif  | 
|         }  | 
|   | 
|         set  | 
|         {  | 
| #if UNITY_EDITOR  | 
|             EditorPrefs.SetBool("LS_Key_ForceAutoFight", value);  | 
| #endif  | 
|         }  | 
|     }  | 
|     public static string s_LogPath;  | 
|     static readonly Dictionary<uint, StringBuilder> s_LogDict = new Dictionary<uint, StringBuilder>();  | 
|     static readonly List<string> s_LogList = new List<string>();  | 
|   | 
|     public static bool s_HurtValueLog = false;  | 
|   | 
|     public static UnityEngine.AI.NavMeshObstacle obstacle;  | 
|     public static SFXController sfx;  | 
|   | 
|     public static void ClearLogs()  | 
|     {  | 
|         s_LogDict.Clear();  | 
|         s_LogList.Clear();  | 
|     }  | 
|   | 
|     public static void AddLog_Blue(string info, uint objId = 0)  | 
|     {  | 
|         string _content;  | 
|         if (s_BattleLog)  | 
|         {  | 
|             _content = string.Format("<color=blue>{0}</color>", info);  | 
|             string _strTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");  | 
|             Debug.Log(string.Format("[{0}] {1}", _strTime, _content));  | 
|         }  | 
|         _content = string.Format("<font size=\"2\" color=\"blue\">{0}</font>", info);  | 
|         AddLog(_content, objId);  | 
|     }  | 
|   | 
|     public static void AddLog_Green(string info, uint objId = 0)  | 
|     {  | 
|         string _content;  | 
|         if (s_BattleLog)  | 
|         {  | 
|             _content = string.Format("<color=green>{0}</color>", info);  | 
|             string _strTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");  | 
|             Debug.Log(string.Format("[{0}] {1}", _strTime, _content));  | 
|         }  | 
|         _content = string.Format("<font size=\"2\" color=\"green\">{0}</font>", info);  | 
|         AddLog(_content, objId);  | 
|     }  | 
|   | 
|     public static void AddLog_Red(string info, uint objId = 0)  | 
|     {  | 
|         string _content;  | 
|         if (s_BattleLog)  | 
|         {  | 
|             _content = string.Format("<color=red>{0}</color>", info);  | 
|             string _strTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");  | 
|             Debug.Log(string.Format("[{0}] {1}", _strTime, _content));  | 
|         }  | 
|         _content = string.Format("<font size=\"2\" color=\"red\">{0}</font>", info);  | 
|         AddLog(_content, objId);  | 
|     }  | 
|   | 
|     public static void AddLog_Black(string info, uint objId = 0)  | 
|     {  | 
|         if (s_BattleLog)  | 
|         {  | 
|             string _strTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");  | 
|             Debug.Log(string.Format("[{0}] {1}", _strTime, info));  | 
|         }  | 
|         string _content = string.Format("<font size=\"2\" color=\"black\">{0}</font>", info);  | 
|         AddLog(_content, objId);  | 
|     }  | 
|   | 
|     public static void AddLog(string info, uint objId = 0, bool force = false)  | 
|     {  | 
|         if (!s_BattleLog && !s_MoveLog && !force)  | 
|         {  | 
|             return;  | 
|         }  | 
|   | 
|         string _strTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");  | 
|         string _content = string.Format("[{0}] {1}<br />", _strTime, info);  | 
|   | 
|         s_LogList.Add(_content);  | 
|   | 
|         if (objId == 0)  | 
|         {  | 
|             foreach (var _objId in s_LogDict.Keys)  | 
|             {  | 
|                 s_LogDict[_objId].Append(_content);  | 
|             }  | 
|         }  | 
|         else  | 
|         {  | 
|             if (s_LogDict.ContainsKey(objId) == false)  | 
|             {  | 
|                 s_LogDict.Add(objId, new StringBuilder());  | 
|             }  | 
|   | 
|             s_LogDict[objId].Append(_content);  | 
|         }  | 
|     }  | 
|   | 
|     public static void SaveNpcLog()  | 
|     {  | 
|         s_LogPath = Application.dataPath.Substring(0, 3) + "unit3D_Logs/";  | 
|         if (System.IO.Directory.Exists(s_LogPath) == false)  | 
|         {  | 
|             System.IO.Directory.CreateDirectory(s_LogPath);  | 
|         }  | 
|   | 
|         string _strTime = System.DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff");  | 
|         string _path = string.Empty;  | 
|   | 
|         foreach (var _objId in s_LogDict.Keys)  | 
|         {  | 
|             _path = s_LogPath + _objId;  | 
|             if (System.IO.Directory.Exists(_path) == false)  | 
|             {  | 
|                 System.IO.Directory.CreateDirectory(_path);  | 
|             }  | 
|   | 
|             _path = string.Format(s_LogPath + "{0}/{1}.html", _objId, _strTime);  | 
|   | 
|             using (System.IO.StreamWriter _writer = new System.IO.StreamWriter(_path))  | 
|             {  | 
|                 _writer.Write(s_LogDict[_objId].ToString());  | 
|             }  | 
|         }  | 
|   | 
|         s_LogDict.Clear();  | 
|   | 
|         _path = string.Format(s_LogPath + "Log_{0}.html", _strTime);  | 
|   | 
|         StringBuilder _stringBuilder = new StringBuilder();  | 
|         for (int i = 0; i < s_LogList.Count; ++i)  | 
|         {  | 
|             _stringBuilder.Append(s_LogList[i]);  | 
|         }  | 
|   | 
|         using (System.IO.StreamWriter _writer = new System.IO.StreamWriter(_path))  | 
|         {  | 
|             _writer.Write(_stringBuilder.ToString());  | 
|         }  | 
|   | 
|         s_LogList.Clear();  | 
|     }  | 
| }  | 
|   | 
| #if UNITY_EDITOR  | 
| [CustomEditor(typeof(RuntimeLogUtility))]  | 
| public class RuntimeLogUtilityEditor : Editor  | 
| {  | 
|     private Vector3 _navChkPos;  | 
|     private int _param1;  | 
|     private int _param2;  | 
|     private Vector2 _start;  | 
|     private Vector2 _end;  | 
|     private Vector3 _start3;  | 
|     private Vector3 _end3;  | 
|     private int _triggerID = 11204008;  | 
|     private int _clientNpcSID;  | 
|   | 
|     public override void OnInspectorGUI()  | 
|     {  | 
|         GUILayout.Space(5);  | 
|   | 
|         EditorGUILayout.BeginHorizontal();  | 
|         _triggerID = EditorGUILayout.IntField("触发器ID", _triggerID);  | 
|         if (GUILayout.Button("触发客户端触发器"))  | 
|         {  | 
|             // ClientSceneManager.Instance.TriggerTest(_triggerID);  | 
|             // GA_NpcFunc.SetNpcFuncVisible(10104003, true);  | 
|             // Vector3 ppp;  | 
|             // if (ClientSceneManager.Instance.AAA(PlayerDatas.Instance.hero.Pos, new Vector3(6, 0, 39.5f), out ppp))  | 
|             // {  | 
|             //     Debug.Log("最终....PPP: " + ppp);  | 
|             // }  | 
|             // for (int i = 0; i < 10; ++i)  | 
|             // {  | 
|             //     ClientDropItemUtility.Instance.DropInShortTime(PlayerDatas.Instance.hero.Pos, 10427);  | 
|             // }  | 
|             PlayerDatas.Instance.hero.Play(GAStaticDefine.State_IdleHash);  | 
|         }  | 
|         EditorGUILayout.EndHorizontal();  | 
|   | 
|         _start3 = EditorGUILayout.Vector3Field("起点: ", _start3);  | 
|         _end3 = EditorGUILayout.Vector3Field("终点: ", _end3);  | 
|   | 
|         if (GUILayout.Button("测试寻路"))  | 
|         {  | 
|             // Debug.Log(PathFinder.WalkAble(_start3, _end3));  | 
|             // MapTransferUtility.Instance.MoveToNPC(10904012);  | 
|             // MapTransferUtility.Instance.MoveToLocalMapPosition(new Vector2(_end3.x, _end3.z));  | 
|             MapTransferUtility.Instance.MoveToNPC(_triggerID);  | 
|         }  | 
|   | 
|         EditorGUILayout.LabelField("Log存储路径", RuntimeLogUtility.s_LogPath);  | 
|   | 
|         if (GUILayout.Button("保存Log"))  | 
|         {  | 
|             RuntimeLogUtility.SaveNpcLog();  | 
|         }  | 
|         if (GUILayout.Button("清空Log"))  | 
|         {  | 
|             RuntimeLogUtility.ClearLogs();  | 
|         }  | 
|   | 
|         RuntimeLogUtility.s_BattleLog = EditorGUILayout.Toggle("战斗过程的Log输出", RuntimeLogUtility.s_BattleLog);  | 
|         RuntimeLogUtility.s_MoveLog = EditorGUILayout.Toggle("移动过程的Log输出", RuntimeLogUtility.s_MoveLog);  | 
|         RuntimeLogUtility.s_ForceOneEnemy = EditorGUILayout.Toggle("强制只攻击一个目标对象", RuntimeLogUtility.s_ForceOneEnemy);  | 
|         RuntimeLogUtility.s_PerpetualAttack = EditorGUILayout.Toggle("执行攻击至死逻辑", RuntimeLogUtility.s_PerpetualAttack);  | 
|         RuntimeLogUtility.s_UseKeyBoardCastSkill = EditorGUILayout.Toggle("使用键盘释放技能", RuntimeLogUtility.s_UseKeyBoardCastSkill);  | 
|         RuntimeLogUtility.s_forceAutoFight = EditorGUILayout.Toggle("是否强制开启AI", RuntimeLogUtility.s_forceAutoFight);  | 
|         RuntimeLogUtility.s_SkillEffectLog = EditorGUILayout.Toggle("技能效果log输出", RuntimeLogUtility.s_SkillEffectLog);  | 
|         RuntimeLogUtility.s_LogMoveDistance = EditorGUILayout.Toggle("位移距离Log输出", RuntimeLogUtility.s_LogMoveDistance);  | 
|         RuntimeLogUtility.s_ShowMapLine = EditorGUILayout.Toggle("显示地图网格", RuntimeLogUtility.s_ShowMapLine);  | 
|         RuntimeLogUtility.s_ShowZZAtkValue = EditorGUILayout.Toggle("显示助战伤害", RuntimeLogUtility.s_ShowZZAtkValue);  | 
|         RuntimeLogUtility.TEST_CLIENT_PVP = EditorGUILayout.Toggle("模拟客户端PVP状态", RuntimeLogUtility.TEST_CLIENT_PVP);  | 
|         RuntimeLogUtility.TEST_CLIENT_PVP_AI = EditorGUILayout.Toggle("模拟客户端PVP的AI状态", RuntimeLogUtility.TEST_CLIENT_PVP_AI);  | 
|         RuntimeLogUtility.s_ForceSupperHit = EditorGUILayout.Toggle("强制暴击", RuntimeLogUtility.s_ForceSupperHit);  | 
|         RuntimeLogUtility.s_ForceLuckHit = EditorGUILayout.Toggle("强制会心一击", RuntimeLogUtility.s_ForceLuckHit);  | 
|         RuntimeLogUtility.s_LogProcessInfo = EditorGUILayout.Toggle("输出AI流程控制", RuntimeLogUtility.s_LogProcessInfo);  | 
|   | 
|   | 
|         _triggerID = EditorGUILayout.IntField("NPCID", _triggerID);  | 
|         if (GUILayout.Button("创建PVP敌方"))  | 
|         {  | 
|             PersonalEnemy.Create((uint)_triggerID, E_ActorGroup.Enemy, PlayerDatas.Instance.hero.Pos);  | 
|   | 
|             // BossShowModel.Instance.Start(PlayerDatas.Instance.baseData.MapID, 10103001);  | 
|             // ClientDropItemUtility.Instance.Drop(PlayerDatas.Instance.hero.Pos,  | 
|             //                                     new int[] { 5006, 5301, 5410, 5505, 10543, 1043050,  | 
|             //                                                 5301, 5410, 5505, 10543, 1043050,  | 
|             //                                                 5301, 5410, 5505, 10543, 1043050});  | 
|   | 
|             // var _npc = GAMgr.Instance.ReqClntFightNpc<GA_NpcClientFightBoss>(10103001, E_ActorGroup.Enemy);  | 
|   | 
|             // GActorPlayerBase.PlayerInfo _playerInfo = new GActorPlayerBase.PlayerInfo();  | 
|             // _playerInfo.maxHp = (uint)PlayerDatas.Instance.extersion.MaxMP;  | 
|             // _playerInfo.hp = _playerInfo.maxHp;  | 
|             // _playerInfo.level = 200;  | 
|             // _playerInfo.job = 1;  | 
|             // _playerInfo.name = "机器人";  | 
|   | 
|             // _playerInfo.itemDatas = new GActorPlayerBase.CEquipInfo[4];  | 
|   | 
|             // // 10484, 10481, 10482, 3713  | 
|             // _playerInfo.itemDatas[0] = new GActorPlayerBase.CEquipInfo  | 
|             // {  | 
|             //     id = 10484,  | 
|             //     place = (int)RoleEquipType.Clothes  | 
|             // };  | 
|             // _playerInfo.itemDatas[1] = new GActorPlayerBase.CEquipInfo  | 
|             // {  | 
|             //     id = 10481,  | 
|             //     place = (int)RoleEquipType.Weapon  | 
|             // };  | 
|             // _playerInfo.itemDatas[2] = new GActorPlayerBase.CEquipInfo  | 
|             // {  | 
|             //     id = 10482,  | 
|             //     place = (int)RoleEquipType.Weapon2  | 
|             // };  | 
|             // _playerInfo.itemDatas[3] = new GActorPlayerBase.CEquipInfo  | 
|             // {  | 
|             //     id = 3713,  | 
|             //     place = (int)RoleEquipType.Wing  | 
|             // };  | 
|   | 
|             // GAMgr.Instance.ReqClntPlayer<GA_PVPClientPlayer>(_playerInfo, E_ActorGroup.Player);  | 
|             // AdventureStage.Instance.Enter();  | 
|         }  | 
|   | 
|         if (GUILayout.Button("重置PVP敌方"))  | 
|         {  | 
|             // GA_PVPClientPlayer.Reset();  | 
|             // AdventureStage.Instance.Exit();  | 
|             ClientSceneManager.Instance.ExitClientFightMode();  | 
|         }  | 
|         EditorGUILayout.BeginHorizontal();  | 
|         _clientNpcSID = EditorGUILayout.IntField("NPC SID", _clientNpcSID);  | 
|   | 
|         if (GUILayout.Button("显示NPC信息"))  | 
|         {  | 
|             var _npc = GAMgr.Instance.GetBySID((uint)_clientNpcSID) as GActorNpcFight;  | 
|             if (_npc != null)  | 
|             {  | 
|                 Debug.LogFormat("{0} => 血量: {1}/{2}, 攻击: {3}-{4}, 防御: {5}",  | 
|                 _clientNpcSID,  | 
|                 _npc.ActorInfo.RealHp,  | 
|                 _npc.ActorInfo.RealMaxHp,  | 
|                 _npc.NpcConfig.MinAtk,  | 
|                 _npc.NpcConfig.MaxAtk,  | 
|                 _npc.NpcConfig.Def);  | 
|             }  | 
|         }  | 
|         EditorGUILayout.EndHorizontal();  | 
|   | 
|         _navChkPos = EditorGUILayout.Vector3Field("检测点", _navChkPos);  | 
|   | 
|         if (GUILayout.Button("检测"))  | 
|         {  | 
|             Vector3 _position = Vector3.zero;  | 
|             if (GActor.TryGetValidPos(_navChkPos, ref _position))  | 
|             {  | 
|                 Debug.Log("正常点........: " + _position);  | 
|             }  | 
|             else  | 
|             {  | 
|                 Debug.Log("障碍点........");  | 
|             }  | 
|         }  | 
|   | 
|         _param2 = EditorGUILayout.IntField("param2", _param2);  | 
|   | 
|         _start = EditorGUILayout.Vector2Field("开始点", _start);  | 
|         _end = EditorGUILayout.Vector2Field("结束点", _end);  | 
|         _param1 = EditorGUILayout.IntField("角度", _param1);  | 
|   | 
|         if (GUILayout.Button("创建障碍点"))  | 
|         {  | 
|             if (RuntimeLogUtility.obstacle)  | 
|             {  | 
|                 DestroyImmediate(RuntimeLogUtility.obstacle.gameObject);  | 
|             }  | 
|             if (RuntimeLogUtility.sfx)  | 
|             {  | 
|                 SFXPlayUtility.Instance.Release(RuntimeLogUtility.sfx);  | 
|             }  | 
|   | 
|             RuntimeLogUtility.obstacle = SoMap.CreateImpasse.General(new Vector3(_start.x, 0, _start.y),  | 
|                 new Vector3(_end.x, 0, _end.y), _param1);  | 
|             var _pos = RuntimeLogUtility.obstacle.transform.position;  | 
|             var _y = 0f;  | 
|             if (CollisionUtility.TryGetGroundHeight(_pos, out _y))  | 
|             {  | 
|                 _pos.y = _y;  | 
|             }  | 
|             float _scale = 1;  | 
|             _scale = RuntimeLogUtility.obstacle.transform.localScale.x * 0.25f;  | 
|             RuntimeLogUtility.sfx = SFXPlayUtility.Instance.PlayWithEulerAngle(1040, _pos, RuntimeLogUtility.obstacle.transform.eulerAngles);  | 
|             RuntimeLogUtility.sfx.duration = 0;  | 
|             RuntimeLogUtility.sfx.transform.localScale = new Vector3(_scale, 1, 1);  | 
|         }  | 
|   | 
|         if (GUILayout.Button("清除障碍点"))  | 
|         {  | 
|             if (RuntimeLogUtility.obstacle)  | 
|             {  | 
|                 DestroyImmediate(RuntimeLogUtility.obstacle.gameObject);  | 
|             }  | 
|             if (RuntimeLogUtility.sfx)  | 
|             {  | 
|                 SFXPlayUtility.Instance.Release(RuntimeLogUtility.sfx);  | 
|             }  | 
|         }  | 
|   | 
|         if (GUILayout.Button("直接重连"))  | 
|         {  | 
|             GameNetSystem.Instance.Reconnect();  | 
|         }  | 
|   | 
|         if (GUILayout.Button("GC.Collect()"))  | 
|         {  | 
|             System.GC.Collect();  | 
|         }  | 
|   | 
|         if (GUILayout.Button("Resources.UnloadUnusedAssets"))  | 
|         {  | 
|             Resources.UnloadUnusedAssets();  | 
|         }  | 
|   | 
|         if (GUILayout.Button("上马/下马"))  | 
|         {  | 
|             if (PlayerDatas.Instance.hero != null)  | 
|             {  | 
|                 DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(PlayerDatas.Instance.hero.MovingState != E_MovingState.Ride);  | 
|             }  | 
|         }  | 
|   | 
|         if (GUILayout.Button("采集"))  | 
|         {  | 
|             GA_Hero _hero = PlayerDatas.Instance.hero;  | 
|             if (_hero != null)  | 
|             {  | 
|                 if (_hero.IsCollect())  | 
|                 {  | 
|                     _hero.Idle();  | 
|                 }  | 
|                 else if (_hero.IsIdle())  | 
|                 {  | 
|                     _hero.Collect();  | 
|                 }  | 
|             }  | 
|         }  | 
|   | 
|         GUILayout.Space(10);  | 
|   | 
|         EditorGUILayout.LabelField("# 玩家当前信息 #");  | 
|   | 
|         if (PlayerDatas.Instance.hero != null)  | 
|         {  | 
|             GA_Hero _hero = PlayerDatas.Instance.hero;  | 
|             if (_hero.SkillMgr.CurCastSkill != null)  | 
|             {  | 
|                 int _curSkillID = _hero.SkillMgr.CurCastSkill.id;  | 
|                 bool _isCompelete = _hero.SkillMgr.CurCastSkill.SkillCompelete;  | 
|                 bool _isXuli = _hero.SkillMgr.CurCastSkill.SkillPreparing;  | 
|                 string _content = string.Format("ID: {0}, 蓄力:{2}, 完成: {1}", _curSkillID, _isCompelete, _isXuli);  | 
|                 EditorGUILayout.LabelField("技能信息", _content);  | 
|             }  | 
|   | 
|             EditorGUILayout.IntField("当前主角AI执行状态值: ", HeroAI_Base.stopReason);  | 
|             EditorGUILayout.TextField("队伍ID", _hero.ActorInfo.teamID.ToString());  | 
|             EditorGUILayout.TextField("是否处于地图切换", GA_Hero.s_MapSwitching.ToString());  | 
|             EditorGUILayout.TextField("当前身体状态", _hero.MovingState.ToString());  | 
|             EditorGUILayout.TextField("当前行为状态", _hero.State.ToString());  | 
|             EditorGUILayout.TextField("当前AI状态", _hero.aiHandler.currentType.ToString());  | 
|             EditorGUILayout.TextField("是否死亡", _hero.ActorInfo.serverDie.ToString());  | 
|   | 
|             if (_hero.SelectTarget != null)  | 
|             {  | 
|                 EditorGUILayout.TextField("当前选择目标", _hero.SelectTarget.ServerInstID.ToString());  | 
|             }  | 
|             if (_hero.LockTarget != null)  | 
|             {  | 
|                 EditorGUILayout.TextField("当前锁定目标", _hero.LockTarget.ServerInstID.ToString());  | 
|             }  | 
|   | 
|             for (MapArea.E_Type i = MapArea.E_Type.RebornSafe; i <= MapArea.E_Type.Boss; i = (MapArea.E_Type)((int)i << 1))  | 
|             {  | 
|                 bool _isIn = MapArea.IsInMapArea(_hero.CurMapArea, i);  | 
|                 EditorGUILayout.Toggle(i.ToString(), _isIn);  | 
|             }  | 
|         }  | 
|     }  | 
| }  | 
| #endif |