少年修仙传客户端代码仓库
Hale Cai
2019-08-19 46c2ad259fd3e1cb0a470396339b281f2e56278b
382 前期虚假玩家
4个文件已修改
9个文件已添加
692 ■■■■■ 已修改文件
Core/GameEngine/Model/TelPartialConfig/PartialEquipSuitConfig.cs 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/FakePlayer.meta 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/FakePlayer/FakePlayerController.cs 218 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/FakePlayer/FakePlayerController.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/FakePlayer/FakePlayerManager.cs 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/FakePlayer/FakePlayerManager.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/FakePlayer/GA_FakePlayer.cs 150 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/FakePlayer/GA_FakePlayer.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/FakePlayer/PartialMapnpcConfig.cs 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/FakePlayer/PartialMapnpcConfig.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/GameActor/GAMgr.cs 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/Stage/Dungeon/DungeonStage.cs 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Utility/EnumHelper.cs 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/TelPartialConfig/PartialEquipSuitConfig.cs
@@ -1,42 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Snxxz.UI;
public partial class EquipSuitConfig : IConfigPostProcess
{
    static Dictionary<int, List<EquipSuitConfig>> equipSuitConfigs = new Dictionary<int, List<EquipSuitConfig>>();
    static Dictionary<int, string> equipSuitNames = new Dictionary<int, string>();
    public void OnConfigParseCompleted()
    {
        var key = suiteID * 100 + suiteCnt;
        if (!equipSuitConfigs.ContainsKey(key))
        {
            equipSuitConfigs[key] = new List<EquipSuitConfig>();
        }
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Snxxz.UI;
public partial class EquipSuitConfig : IConfigPostProcess
{
    static Dictionary<int, List<EquipSuitConfig>> equipSuitConfigs = new Dictionary<int, List<EquipSuitConfig>>();
    static Dictionary<int, string> equipSuitNames = new Dictionary<int, string>();
    public void OnConfigParseCompleted()
    {
        var key = suiteID * 100 + suiteCnt;
        if (!equipSuitConfigs.ContainsKey(key))
        {
            equipSuitConfigs[key] = new List<EquipSuitConfig>();
        }
        if (!equipSuitNames.ContainsKey(suiteID))
        {
            equipSuitNames[suiteID] = name;
        }
        equipSuitConfigs[key].Add(this);
    }
    public static List<EquipSuitConfig> GetConfigs(int job, int level, EquipSuitType type)
    {
        var key = (job * 100 + level) * 100 + (int)type;
        if (equipSuitConfigs.ContainsKey(key))
        {
            return equipSuitConfigs[key];
        }
        else
        {
            return null;
        }
    }
        }
        equipSuitConfigs[key].Add(this);
    }
    public static List<EquipSuitConfig> GetConfigs(int job, int level, EquipSuitType type)
    {
        var key = (job * 100 + level) * 100 + (int)type;
        if (equipSuitConfigs.ContainsKey(key))
        {
            return equipSuitConfigs[key];
        }
        else
        {
            return null;
        }
    }
    public static string GetEquipSuitName(int suitId)
    {
        if (equipSuitNames.ContainsKey(suitId))
@@ -44,7 +44,7 @@
            return equipSuitNames[suitId];
        }
        return string.Empty;
    }
}
    }
}
Fight/FakePlayer.meta
New file
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f5c12a3c917131a41b140b07d5c9d404
folderAsset: yes
timeCreated: 1566114223
licenseType: Free
DefaultImporter:
  userData:
  assetBundleName:
  assetBundleVariant:
Fight/FakePlayer/FakePlayerController.cs
New file
@@ -0,0 +1,218 @@
using System.Collections.Generic;
using UnityEngine;
public class FakePlayerController
{
    public enum E_BehaviourType
    {
        MoveBeTweenNpc,
        MaxType,
        Fight
    }
    public struct FakePlayerData
    {
        public int job;
        public string name;
        public int clothes;
        public int weapon;
        public int sedcondary;
        public E_BehaviourType behaviourType;
    }
    private float m_Duration;
    public bool IsDone;
    private GA_FakePlayer m_Player;
    private int currentMoveToNpc = 0;
    public E_BehaviourType BehaviourType { get; private set; }
    public float m_WaitingTime = 0;
    public float m_RandomIdelTime = 0;
    private float m_DurationEscapeTime;
    public void Init(FakePlayerData data)
    {
        IsDone = false;
        var _playerData = new GActorPlayerBase.PlayerInfo();
        _playerData.name = data.name;
        _playerData.job = (byte)data.job;
        var _equipList = new List<GActorPlayerBase.CEquipInfo>();
        if (ItemConfig.Has(data.clothes))
        {
            _equipList.Add(new GActorPlayerBase.CEquipInfo()
            {
                id = data.clothes,
                place = ItemConfig.Get(data.clothes).EquipPlace
            });
        }
        if (ItemConfig.Has(data.weapon))
        {
            _equipList.Add(new GActorPlayerBase.CEquipInfo()
            {
                id = data.clothes,
                place = ItemConfig.Get(data.clothes).EquipPlace
            });
        }
        if (ItemConfig.Has(data.sedcondary))
        {
            _equipList.Add(new GActorPlayerBase.CEquipInfo()
            {
                id = data.clothes,
                place = ItemConfig.Get(data.clothes).EquipPlace
            });
        }
        _playerData.itemDatas = _equipList.ToArray();
        _equipList.Clear();
        _equipList = null;
        m_DurationEscapeTime = 0;
        m_Duration = FakePlayerManager.EachPlayerLastTime;
        BehaviourType = data.behaviourType;
        currentMoveToNpc = 0;
        // 从已经刷出的NPC中随机出生位置
        Vector3 _bornPos = GetRandomNpcPosition();
        if (_bornPos == Vector3.zero)
        {
            // 如果没有已经刷出的,从该地图的所有npc中取最近的
            _bornPos = GetCloserNpcPosition();
        }
        if (_bornPos == Vector3.zero)
        {
            _bornPos = FakePlayerManager.LastStandPos;
        }
        var _randomDir = new Vector3(Random.Range(-.5f, .5f), 0, Random.Range(-.5f, .5f));
        _bornPos = _bornPos + _randomDir;
        GActor.TryGetValidPos(_bornPos, ref _bornPos);
        m_Player = GAMgr.Instance.ReqClntPlayer<GA_FakePlayer>(_playerData, E_ActorGroup.Player);
        m_Player.InitBornPos((ushort)(_bornPos.x * 2), (ushort)(_bornPos.z * 2));
    }
    public void UnInit()
    {
        if (m_Player != null)
        {
            GAMgr.Instance.Release(m_Player);
            m_Player = null;
        }
    }
    private byte m_Step = 0;
    public void Update()
    {
        if (BehaviourType == E_BehaviourType.MoveBeTweenNpc)
        {
            if (m_Player != null)
            {
                switch (m_Step)
                {
                    case 0:
                        if (m_Player.IsIdle())
                        {
                            m_WaitingTime = Time.time + Random.Range(3f, 5f);
                            m_Step = 1;
                        }
                        else
                        {
                            m_Step = 2;
                        }
                        break;
                    case 1:// 等待站立的随机时间结束
                        if (Time.time > m_WaitingTime)
                        {
                            var _nextPosition = GetRandomNpcPosition();
                            if (_nextPosition == Vector3.zero)
                            {
                                _nextPosition = GetCloserNpcPosition();
                            }
                            if (_nextPosition == Vector3.zero)
                            {
                                m_Step = 0;
                            }
                            else
                            {
                                m_Player.MoveToPosition(_nextPosition, 1);
                                m_Step = 2;
                            }
                        }
                        break;
                    case 2:
                        if (m_Player.IsIdle())
                        {
                            m_Step = 0;
                        }
                        break;
                }
            }
        }
        m_DurationEscapeTime += Time.deltaTime;
        if(m_DurationEscapeTime > m_Duration)
        {
            IsDone = true;
        }
    }
    private Vector3 GetNextNpcPosition()
    {
        var _list = GAMgr.Instance.GetTypeList(E_ActorClassType.NpcFunc);
        if (_list == null || _list.Count == 0)
        {
            return Vector3.zero;
        }
        GActorNpcNoFight _npc;
        for (int i = 0; i < _list.Count; ++i)
        {
            _npc = _list[i] as GActorNpcNoFight;
            if (_npc == null
             || _npc.NpcConfig.NPCID == currentMoveToNpc)
            {
                continue;
            }
            currentMoveToNpc = _npc.NpcConfig.NPCID;
            return _npc.Pos;
        }
        return Vector3.zero;
    }
    private Vector3 GetRandomNpcPosition()
    {
        var _list = GAMgr.Instance.GetTypeList(E_ActorClassType.NpcFunc);
        if (_list == null || _list.Count == 0)
        {
            return Vector3.zero;
        }
        var _random = Random.Range(0, _list.Count - 1);
        return _list[_random].Pos;
    }
    private Vector3 GetCloserNpcPosition()
    {
        var _mapID = PlayerDatas.Instance.baseData.MapID;
        var _mapNpcs = mapnpcConfig.GetNpcList(_mapID);
        var _list = new List<int>(_mapNpcs.Keys);
        _list.Sort((n1, n2) =>
        {
            var _d1 = MathUtility.DistanceSqrtXZ(PlayerDatas.Instance.hero.Pos,
                _mapNpcs[n1]);
            var _d2 = MathUtility.DistanceSqrtXZ(PlayerDatas.Instance.hero.Pos,
                _mapNpcs[n1]);
            return _d2 < _d1 ? -1 : 1;
        });
        for (int i = 0; i < _list.Count; ++i)
        {
            if (_list[i] != currentMoveToNpc)
            {
                currentMoveToNpc = _list[i];
                return _mapNpcs[_list[i]];
            }
        }
        return Vector3.zero;
    }
}
Fight/FakePlayer/FakePlayerController.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a7b3f8ba99dc62944bc12214a8f253e2
timeCreated: 1566114246
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Fight/FakePlayer/FakePlayerManager.cs
New file
@@ -0,0 +1,122 @@
using System.Collections.Generic;
using UnityEngine;
public class FakePlayerManager
{
    public static bool Start = false;
    public static Vector3 LastStandPos;
    public static int LastFindNPC;
    // 等级限制
    private static int m_LevelLimit = 70;
    // 创建间隔
    private static float m_CraeteInterval = 5f;
    // 计算创建间隔
    private static float m_CraeteCalcTime = 0;
    // 最大的玩家数量
    private static int m_MaxPlayerCount = 10;
    // 每个的持续时间
    public static float EachPlayerLastTime = 30f;
    // 装备配置
    // 境界 | 职业 | [衣服,武器,副手]
    private static List<Dictionary<int, List<int>>> m_Equip = new List<Dictionary<int, List<int>>>()
    {
        new Dictionary<int, List<int>>()
        {
            { 1,new List<int>(){1011040,1011010, 1011020} },
            { 2,new List<int>(){2011040,2011010, 2011020} }
        }
    };
    private static List<FakePlayerController> m_ControllerList = new List<FakePlayerController>();
    public static void Update()
    {
        if (!Start)
        {
            return;
        }
        if (AdventureStage.Instance.IsInAdventureStage)
        {
            return;
        }
        for (int i = m_ControllerList.Count - 1; i >= 0; --i)
        {
            if (m_ControllerList[i] == null)
            {
                continue;
            }
            m_ControllerList[i].Update();
            if (m_ControllerList[i].IsDone)
            {
                m_ControllerList[i].UnInit();
                m_ControllerList.RemoveAt(i);
            }
        }
        if (PlayerDatas.Instance.baseData.LV > m_LevelLimit)
        {
            return;
        }
        if (Time.time - m_CraeteCalcTime < m_CraeteInterval)
        {
            return;
        }
        m_CraeteCalcTime = Time.time;
        int _curPlayerCount = 0;
        var _playerList = GAMgr.Instance.GetTypeList(E_ActorClassType.Player);
        if (_playerList != null)
        {
            _curPlayerCount = _playerList.Count;
        }
        _playerList = GAMgr.Instance.GetTypeList(E_ActorClassType.FakePlayer);
        if (_playerList != null)
        {
            _curPlayerCount += _playerList.Count;
        }
        if (_curPlayerCount >= m_MaxPlayerCount)
        {
            return;
        }
        int _ranJob = Random.Range(1, 3);
        // 随机类型
        int _ran = Random.Range(0, (int)(FakePlayerController.E_BehaviourType.MaxType));
        var _controller = new FakePlayerController();
        _controller.Init(new FakePlayerController.FakePlayerData()
        {
            job = _ranJob,
            name = StringUtility.Contact(RandomNameConfig.GetFirstName(_ranJob), RandomNameConfig.GetSecondName(_ranJob)),
            clothes = m_Equip[PlayerDatas.Instance.baseData.realmLevel][_ranJob][0],
            weapon = m_Equip[PlayerDatas.Instance.baseData.realmLevel][_ranJob][1],
            sedcondary = m_Equip[PlayerDatas.Instance.baseData.realmLevel][_ranJob][2],
            behaviourType = (FakePlayerController.E_BehaviourType)_ran
        });
        m_ControllerList.Add(_controller);
    }
    public static void UnInit()
    {
        for (int i = m_ControllerList.Count - 1; i >= 0; --i)
        {
            if (m_ControllerList[i] == null)
            {
                continue;
            }
            m_ControllerList[i].UnInit();
        }
        m_ControllerList.Clear();
    }
}
Fight/FakePlayer/FakePlayerManager.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7ade948ffbaaee549986f3d4d07d4c7d
timeCreated: 1566113840
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Fight/FakePlayer/GA_FakePlayer.cs
New file
@@ -0,0 +1,150 @@
using Snxxz.UI;
using UnityEngine;
public class GA_FakePlayer : GActorPlayerBase
{
    private PlayerInfo m_PlayerInfo;
    public void Init(uint serverInstID, uint clientInstID, PlayerInfo info, E_ActorGroup group)
    {
        m_PlayerInfo = info;
        Init(serverInstID, clientInstID, group, null);
    }
    protected sealed override void OnInit(GameNetPackBasic package)
    {
        base.OnInit(package);
        if (m_PlayerInfo == null)
        {
            return;
        }
        JobSetup = JobSetupConfig.Get(m_PlayerInfo.job);
        ActorInfo.moveSpeed = 3;
        ActorInfo.atkSpeed = 1;
        CEquipInfo _itemInfo;
        if (m_PlayerInfo.itemDatas != null)
        {
            // 因为衣服是所有装备的父节点, 需要预先处理衣服
            for (int i = 0; i < m_PlayerInfo.itemDatas.Length; ++i)
            {
                _itemInfo = m_PlayerInfo.itemDatas[i];
                if (_itemInfo.place == (int)RoleEquipType.Clothes)
                {
                    SwitchClothes((uint)_itemInfo.id);
                    break;
                }
            }
            if (ClothesItemID == 0 || ClothesItemID == uint.MaxValue)
            {
                SwitchClothes(0);
            }
            if (m_PlayerInfo.itemDatas != null)
            {
                for (int i = 0; i < m_PlayerInfo.itemDatas.Length; ++i)
                {
                    _itemInfo = m_PlayerInfo.itemDatas[i];
                    if (_itemInfo.place == (int)RoleEquipType.Weapon)
                    {
                        SwitchWeapon((uint)_itemInfo.id);
                    }
                    else if (_itemInfo.place == (int)RoleEquipType.Weapon2)
                    {
                        SwitchSecondary((uint)_itemInfo.id);
                    }
                }
            }
            if (WeaponItemID == 0 || WeaponItemID == uint.MaxValue)
            {
                SwitchWeapon(0);
            }
        }
        ActorInfo.LV = m_PlayerInfo.level == 0 ? (ushort)1 : m_PlayerInfo.level;
        ActorInfo.Job = m_PlayerInfo.job;
        ActorInfo.PlayerName = m_PlayerInfo.name;
        ActorInfo.Hp = m_PlayerInfo.hp == 0 ? 1 : m_PlayerInfo.hp;
        ActorInfo.MaxHp = m_PlayerInfo.maxHp == 0 ? 1 : m_PlayerInfo.maxHp;
        RequestName();
    }
    public override void RequestName()
    {
        ReleaseName();
        if (MovingState == E_MovingState.Ride)
        {
            m_HeadUpName = HeadUpName.RequireHeadUpName(HeadUpName.Pattern.Player, MP_Name1, 0, CameraController.Instance.CameraObject);
        }
        else
        {
            m_HeadUpName = HeadUpName.RequireHeadUpName(HeadUpName.Pattern.Player, MP_Name, 0, CameraController.Instance.CameraObject);
        }
        m_HeadUpName.SetPlayerInfo(new HeadUpName.PlayerInfo()
        {
            realm = ActorInfo.realm,
            title = ActorInfo.titleID,
            name = ActorInfo.PlayerName,
            alliance = ActorInfo.familyName,
        });
    }
    protected override void OnPutonClothes(uint clothesItemID, GameObject clothed)
    {
        clothed.layer = LayerUtility.Player;
        SkinnedMeshRenderer _renderer = clothed.GetComponentInChildren<SkinnedMeshRenderer>();
        _renderer.gameObject.SetLayer(LayerUtility.Player, false);
    }
    protected override void OnPutonSecondary(uint secondaryItemID, GameObject secondary)
    {
        Renderer _renderer = secondary.GetComponentInChildren<Renderer>();
        if (_renderer)
        {
            _renderer.gameObject.SetLayer(LayerUtility.Player, false);
        }
    }
    protected override void OnPutonWeapon(uint weaponItemID, GameObject weapon)
    {
        Renderer _renderer = weapon.GetComponentInChildren<Renderer>();
        _renderer.gameObject.SetLayer(LayerUtility.Player, false);
    }
    protected override void OnPutonWing(uint wingItemID, GameObject wing)
    {
        SkinnedMeshRenderer _renderer = wing.GetComponentInChildren<SkinnedMeshRenderer>();
        _renderer.gameObject.SetLayer(LayerUtility.Player, false);
    }
    public override void SyncSuitEffect(bool onOrOff = true)
    {
    }
    protected override void OnSwitchHorse(uint horseID, GameObject horse)
    {
    }
    public override void Destroy()
    {
    }
    public override void OnHorse(byte upOrDown) { }
    public override void RefreshLifeBar(ulong value) { }
    public override bool CanAtked()
    {
        return false;
    }
}
Fight/FakePlayer/GA_FakePlayer.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f8213530f9ceb394faf0fa92757db57a
timeCreated: 1566139751
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Fight/FakePlayer/PartialMapnpcConfig.cs
New file
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using UnityEngine;
public partial class mapnpcConfig : IConfigPostProcess
{
    static Dictionary<int, Dictionary<int, Vector3>> mapNpcIDict = new Dictionary<int, Dictionary<int, Vector3>>();
    public void OnConfigParseCompleted()
    {
        if (!mapNpcIDict.ContainsKey(MapID))
        {
            mapNpcIDict.Add(MapID, new Dictionary<int, Vector3>());
        }
        Vector3 _npcPos = GAStaticDefine.GetClientPostionFromHex(HexPosNPCRefreshAreaChaseArea);
        if (!mapNpcIDict[MapID].ContainsKey(NPCID) && NPCType == (int)E_NpcType.Func)
        {
            mapNpcIDict[MapID].Add(NPCID, _npcPos);
        }
    }
    public static Dictionary<int, Vector3> GetNpcList(int mapID)
    {
        if (!mapNpcIDict.ContainsKey(mapID))
        {
            return null;
        }
        return mapNpcIDict[mapID];
    }
}
Fight/FakePlayer/PartialMapnpcConfig.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 65f0c5aca7046df4c8e6675e4956bbad
timeCreated: 1566179236
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Fight/GameActor/GAMgr.cs
@@ -776,6 +776,21 @@
                BuildManagerRelation(_actor, _actorClassType);
            }
        }
        else if ((E_ActorClassType)_actorClassType == E_ActorClassType.FakePlayer)
        {
            _actor = GetPoolActor(_actorClassType) as GA_FakePlayer;
            if (_actor == null)
            {
                _actor = new GA_FakePlayer();
            }
            if (_actor != null)
            {
                (_actor as GA_FakePlayer).Init(serverInstID, m_ClientId.Request(), info, group);
                BuildManagerRelation(_actor, _actorClassType);
            }
        }
        else
        {
            _actor = GetPoolActor(_actorClassType) as GA_PlayerClient;
@@ -1418,6 +1433,10 @@
        {
            return (byte)E_ActorClassType.NpcClientCollect;
        }
        else if (_type == typeof(GA_FakePlayer))
        {
            return (byte)E_ActorClassType.FakePlayer;
        }
        return (byte)E_ActorClassType.UnDefine;
    }
Fight/Stage/Dungeon/DungeonStage.cs
@@ -113,6 +113,17 @@
        GA_Hero.s_Flying = false;
        GA_Hero.s_MapSwitching = false;
        if (CurrentMapType == MapType.OpenCountry
        && !ClientDungeonStageUtility.isClientDungeon)
        {
            FakePlayerManager.Start = true;
        }
        else
        {
            FakePlayerManager.Start = false;
        }
    }
    public override void UnInitialize()
@@ -154,6 +165,7 @@
            AdventureStage.Instance.Exit();
        }
        FakePlayerManager.UnInit();
        PersonalEnemy.ReleaseAll();
        ClientSceneManager.Instance.UnInit();
        ClientCollectUtility.UnInit();
@@ -180,6 +192,7 @@
        ClientCollectUtility.Update();
        FakePlayerManager.Update();
        // if (PreFightMission.Instance.IsFinished() == false)
        // {
        //     PreFightMission.Instance.Update();
Utility/EnumHelper.cs
@@ -24,6 +24,7 @@
    PlayerSgzcRobot,
    PVPClientPlayer,
    NpcClientCollect,
    FakePlayer,
}
[XLua.LuaCallCSharp]