少年修仙传客户端代码仓库
lcy
3 天以前 6d8908e1fcfb62e174d1fa60eb6aa31f65dff3e1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
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