少年修仙传客户端代码仓库
client_linchunjie
2019-05-15 5d6f34baa8b0f80fdc1b9c9c5a4f3d022feb5ea7
Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
9个文件已修改
363 ■■■■■ 已修改文件
Fight/ClientCollectUtility.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/GameActor/Bhv_FindEnemy.cs 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/GameActor/GA_Hero.cs 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/GameActor/GA_NpcCollect.cs 161 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/MapTransferUtility.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/PrepareHandler.cs 160 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/Stage/Dungeon/DungeonStage.cs 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Dungeon/DungeonFairyFeastHintWin.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/MainInterfacePanel/MainButtonMisc.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/ClientCollectUtility.cs
@@ -90,9 +90,12 @@
    public static void Init()
    {
        NPCInteractProcessor.s_NpcInteractEvent -= HandleCallback;
        NPCInteractProcessor.s_NpcInteractEvent += HandleCallback;
        WindowCenter.Instance.windowAfterOpenEvent -= CheckOpenCollectIcon;
        WindowCenter.Instance.windowAfterOpenEvent += CheckOpenCollectIcon;
        WindowCenter.Instance.windowAfterCloseEvent -= CheckCloseCollectIcon;
        WindowCenter.Instance.windowAfterCloseEvent += CheckCloseCollectIcon;
    }
Fight/GameActor/Bhv_FindEnemy.cs
@@ -40,9 +40,7 @@
            return;
        }
        if (_hero.LockTarget != null
            && !(_hero.LockTarget is GA_NpcCollect)
            && !(_hero.LockTarget.ActorInfo.faction == 1))
        if (_hero.LockTarget != null)
        {
            // 判断是否要清空锁定目标
            DoIfClearLockTarget();
Fight/GameActor/GA_Hero.cs
@@ -97,10 +97,14 @@
#if UNITY_EDITOR
            // if (m_LockTarget is GA_Player && value != null && !(value is GA_Player))
            // {
            // if (value != null)
            // {
            //     Debug.LogFormat("更换了锁定目标: {0} ", value.ServerInstID);
            // }
            if (value != null)
            {
                Debug.LogFormat("更换了锁定目标: {0} ", value.ServerInstID);
            }
            else
            {
                Debug.LogFormat("清空了锁定目标: null");
            }
            // }
#endif
            m_LockTarget = value;
@@ -481,7 +485,7 @@
                        if ((SelectTarget == null || SelectTarget is GA_NpcCollect) && SelectTarget != _collect)
                        {
                            SelectTarget = _collect;
                            _collect.Arrive();
                            PrepareHandler.Instance.Arrive(_collect);
                        }
                    }
                }
@@ -499,7 +503,7 @@
                        if (_dist < 6)
                        {
                            SelectTarget = _collect;
                            _collect.Arrive();
                            PrepareHandler.Instance.Arrive(_collect);
                        }
                    }
                }
Fight/GameActor/GA_NpcCollect.cs
@@ -6,10 +6,6 @@
public class GA_NpcCollect : GA_NpcFunc
{
    private static List<uint> m_ArrivedList = new List<uint>();
    public static event UnityAction<uint, int> OnArrive;
    public static event UnityAction<uint, int> OnLeave;
    private bool m_CanCollect = true;
    private bool m_IsMainWinOpen = false;
@@ -153,9 +149,6 @@
        m_IsMainWinOpen = WindowCenter.Instance.IsOpen<MainInterfaceWin>();
        WindowCenter.Instance.windowAfterOpenEvent += CheckOpenCollectIcon;
        WindowCenter.Instance.windowAfterCloseEvent += AfterCloseMainWin;
        if (GeneralDefine.NpcPosOffset.ContainsKey(NpcConfig.NPCID))
        {
            Pos = GeneralDefine.NpcPosOffset[NpcConfig.NPCID];
@@ -168,43 +161,6 @@
            m_Dig = SoMap.CreateImpasse.GeneralCircle(Pos, NpcConfig.ModelRadius);
        }
    }
    private void AfterCloseMainWin(Window obj)
    {
        if (obj is MainInterfaceWin)
        {
            m_IsMainWinOpen = false;
            Leave();
        }
    }
    private void CheckOpenCollectIcon(Window obj)
    {
        if (!m_CanCollect)
        {
            return;
        }
        if (obj is MainInterfaceWin)
        {
            m_IsMainWinOpen = true;
            if (NpcConfig.NPCID != GeneralDefine.GatherSoulDZ)
            {
                GA_Hero _hero = PlayerDatas.Instance.hero;
                if (_hero != null)
                {
                    float _distSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, Pos);
                    if (_distSqrt < Mathf.Pow(NpcConfig.ModelRadius + 0.4f + GeneralDefine.CloseNpcDist, 2))
                    {
                        Arrive();
                    }
                }
            }
        }
    }
    private static bool xmlsCollectFinished = false;
@@ -256,18 +212,11 @@
                if (_distSqrt < Mathf.Pow(NpcConfig.ModelRadius + 0.4f + GeneralDefine.CloseNpcDist, 2))
                {
                    Arrive();
                    PrepareHandler.Instance.Arrive(this);
                }
                else
                {
                    if (m_ArrivedList.Contains(ServerInstID))
                    {
                        if (OnLeave != null)
                        {
                            OnLeave(ServerInstID, NpcConfig.NPCID);
                        }
                        m_ArrivedList.Remove(ServerInstID);
                    }
                    PrepareHandler.Instance.Leave(this);
                }
            }
        }
@@ -282,8 +231,6 @@
    public override void OnClick()
    {
        base.OnClick();
        if (!GeneralDefine.SpecialNpcIDs.Contains(NpcConfig.NPCID)// 不是特殊npc
         && !m_CanCollect)
        {
@@ -295,13 +242,22 @@
            return;
        }
        if (!m_ArrivedList.Contains(ServerInstID))
        GA_Hero _hero = PlayerDatas.Instance.hero;
        if (_hero == null)
        {
            if (OnArrive != null)
            {
                OnArrive(ServerInstID, NpcConfig.NPCID);
            }
            m_ArrivedList.Add(ServerInstID);
            return;
        }
        _hero.LockTarget = this;
        _hero.SelectTarget = this;
        float _chkDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, Pos);
        // 这里判断是否要走向此对象
        if (_chkDistSqrt > 4)
        {
            _hero.MoveToPosition(Pos, 1f);
        }
    }
@@ -310,20 +266,6 @@
        if (NpcConfig.NPCID != GeneralDefine.GatherSoulDZ)
        {
            base.HandleOnClick();
        }
        else
        {
            var _hero = PlayerDatas.Instance.hero;
            if (_hero != null)
            {
                float _distSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, Pos);
                if (_distSqrt < Mathf.Pow(NpcConfig.ModelRadius + 0.4f + GeneralDefine.CloseNpcDist, 2))
                {
                    Arrive();
                }
            }
        }
    }
@@ -356,17 +298,7 @@
            ModelCenter.Instance.GetModel<FairyLeagueModel>().CrystalBelongChangeEvent -= CrystalBelongChangeEvent;
        }
        if (m_ArrivedList.Contains(ServerInstID))
        {
            if (OnLeave != null)
            {
                OnLeave(ServerInstID, NpcConfig.NPCID);
            }
            m_ArrivedList.Remove(ServerInstID);
        }
        WindowCenter.Instance.windowAfterOpenEvent -= CheckOpenCollectIcon;
        WindowCenter.Instance.windowAfterCloseEvent -= AfterCloseMainWin;
        PrepareHandler.Instance.Leave(this);
    }
    public override bool CanBeSelected()
@@ -420,11 +352,7 @@
        }
        else
        {
            if (NpcConfig.NPCID == GeneralDefine.GatherSoulDZ)// 聚魂副本
            {
                m_CanCollect = true;
            }
            else if (ModelCenter.Instance.GetModel<HazyGrassModel>().IsInDungeon)
            if (ModelCenter.Instance.GetModel<HazyGrassModel>().IsInDungeon)
            {
                m_CanCollect = true;
            }
@@ -434,30 +362,15 @@
                m_CanCollect = _model.IsGather(NpcConfig.NPCID);
            }
        }
        if (!m_CanCollect)
        {
            if (m_ArrivedList.Contains(ServerInstID))
            {
                if (OnLeave != null)
                {
                    OnLeave(ServerInstID, NpcConfig.NPCID);
                }
                m_ArrivedList.Remove(ServerInstID);
            }
        }
        PrepareHandler.Instance.Leave(this);
    }
    public override void OnUnSelect()
    {
        base.OnUnSelect();
        if (m_ArrivedList.Contains(ServerInstID))
        {
            if (OnLeave != null)
            {
                OnLeave(ServerInstID, NpcConfig.NPCID);
            }
            m_ArrivedList.Remove(ServerInstID);
        }
        PrepareHandler.Instance.Leave(this);
        if (NpcConfig.NPCID == GeneralDefine.GatherSoulDZ)
        {
@@ -506,32 +419,4 @@
        }
    }
    public void Arrive()
    {
        if (!m_CanCollect)
        {
            return;
        }
        if (!m_ArrivedList.Contains(ServerInstID))
        {
            if (OnArrive != null)
            {
                OnArrive(ServerInstID, NpcConfig.NPCID);
            }
            m_ArrivedList.Add(ServerInstID);
        }
    }
    public void Leave()
    {
        if (m_ArrivedList.Contains(ServerInstID))
        {
            if (OnLeave != null)
            {
                OnLeave(ServerInstID, NpcConfig.NPCID);
            }
            m_ArrivedList.Remove(ServerInstID);
        }
    }
}
Fight/MapTransferUtility.cs
@@ -859,7 +859,7 @@
                    GA_NpcCollect _collect = npc as GA_NpcCollect;
                    if (_collect != null)
                    {
                        _collect.Arrive();
                        PrepareHandler.Instance.Arrive(_collect);
                    }
                }
                else
Fight/PrepareHandler.cs
@@ -1,5 +1,8 @@
using UnityEngine;
using Snxxz.UI;
using System.Collections.Generic;
using UnityEngine.Events;
using System;
[XLua.LuaCallCSharp]
public class PrepareHandler : Singleton<PrepareHandler>
@@ -34,6 +37,163 @@
        pstMax,
    }
    public List<GA_NpcCollect> m_ArriveList = new List<GA_NpcCollect>();
    public UnityAction<uint, int> OnShowCollectIcon;
    public UnityAction<uint, int> OnHideCollectIcon;
    public void Init()
    {
        NPCInteractProcessor.s_NpcInteractEvent -= HandleCallback;
        NPCInteractProcessor.s_NpcInteractEvent += HandleCallback;
        WindowCenter.Instance.windowAfterOpenEvent -= CheckOpenCollectIcon;
        WindowCenter.Instance.windowAfterOpenEvent += CheckOpenCollectIcon;
        WindowCenter.Instance.windowAfterCloseEvent -= CheckCloseCollectIcon;
        WindowCenter.Instance.windowAfterCloseEvent += CheckCloseCollectIcon;
    }
    private void CheckCloseCollectIcon(Window obj)
    {
        if (obj is MainInterfaceWin)
        {
            if (OnHideCollectIcon != null)
            {
                OnHideCollectIcon(0, 0);
            }
        }
    }
    private void CheckOpenCollectIcon(Window obj)
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
        if (_hero == null)
        {
            return;
        }
        if (obj is MainInterfaceWin)
        {
            if (m_ArriveList.Count > 0)
            {
                if (OnShowCollectIcon != null)
                {
                    var _collect = _hero.SelectTarget as GA_NpcCollect;
                    if (_collect == null)
                    {
                        _collect = m_ArriveList[0];
                    }
                    OnShowCollectIcon(_collect.ServerInstID, _collect.NpcConfig.NPCID);
                }
            }
        }
    }
    private void HandleCallback(E_NpcType type, int npcID, uint sid)
    {
        var _target = GAMgr.Instance.GetBySID(sid);
        if (!(_target is GA_NpcCollect))
        {
            return;
        }
        var _hero = PlayerDatas.Instance.hero;
        if (_hero != null)
        {
            var _npc = _hero.SelectTarget as GA_NpcCollect;
            var _checkDis = 0f;
            if (_npc == null)
            {
                var _list = GAMgr.Instance.GetTypeList(E_ActorClassType.NpcCollect);
                if (_list != null)
                {
                    _list.Sort((a1, a2) =>
                    {
                        var _d1 = MathUtility.DistanceSqrtXZ(a1.Pos, _hero.Pos);
                        var _d2 = MathUtility.DistanceSqrtXZ(a2.Pos, _hero.Pos);
                        if (_d1 > _d2)
                        {
                            return 1;
                        }
                        else if (_d1 < _d2)
                        {
                            return -1;
                        }
                        return 0;
                    });
                    foreach (var _a in _list)
                    {
                        if (!(_a is GA_NpcCollect))
                        {
                            continue;
                        }
                        _npc = _a as GA_NpcCollect;
                        break;
                    }
                }
            }
            if (_npc != null)
            {
                if (_hero.SelectTarget == null)
                {
                    _hero.SelectTarget = _npc;
                }
                _checkDis = MathUtility.DistanceSqrtXZ(_hero.Pos, _npc.Pos);
                if (_checkDis < 4f)
                {
                    if (OnShowCollectIcon != null)
                    {
                        OnShowCollectIcon(_npc.ServerInstID, _npc.NpcConfig.NPCID);
                    }
                    var _dir = MathUtility.ForwardXZ(_npc.Pos, _hero.Pos);
                    _hero.Forward = _dir;
                }
                else
                {
                    _hero.MoveToPosition(_npc.Pos, 2f);
                }
            }
        }
    }
    public void Arrive(GA_NpcCollect npc)
    {
        if (!m_ArriveList.Contains(npc))
        {
            if (m_ArriveList.Count == 0)
            {
                if (OnShowCollectIcon != null)
                {
                    OnShowCollectIcon(npc.ServerInstID, npc.NpcConfig.NPCID);
                }
            }
            m_ArriveList.Add(npc);
        }
    }
    public void Leave(GA_NpcCollect npc)
    {
        if (m_ArriveList.Contains(npc))
        {
            m_ArriveList.Remove(npc);
            if (m_ArriveList.Count == 0)
            {
                if (OnHideCollectIcon != null)
                {
                    OnHideCollectIcon(npc.ServerInstID, npc.NpcConfig.NPCID);
                }
            }
        }
    }
    public void ServerPrepareStart(H0812_tagBeginPrepare h0812)
    {
        // 做一些清理或者重置工作
Fight/Stage/Dungeon/DungeonStage.cs
@@ -112,6 +112,7 @@
        ClientSceneManager.Instance.Init();
        ClientCollectUtility.Init();
        PrepareHandler.Instance.Init();
        GA_Hero.s_MapSwitching = false;
    }
System/Dungeon/DungeonFairyFeastHintWin.cs
@@ -60,8 +60,8 @@
            nearNpc = false;
            Select(0);
            model.updateMissionEvent += UpdateMissionEvent;
            GA_NpcCollect.OnArrive += OnArriveCollectNPC;
            GA_NpcCollect.OnLeave += OnLeaveCollectNpc;
            PrepareHandler.Instance.OnShowCollectIcon += OnArriveCollectNPC;
            PrepareHandler.Instance.OnHideCollectIcon += OnLeaveCollectNpc;
            GlobalTimeEvent.Instance.secondEvent += SecondEvent;
            DisplayTransmit();
            DisplayGotoFeast();
@@ -76,8 +76,8 @@
        protected override void OnPreClose()
        {
            model.updateMissionEvent -= UpdateMissionEvent;
            GA_NpcCollect.OnArrive -= OnArriveCollectNPC;
            GA_NpcCollect.OnLeave -= OnLeaveCollectNpc;
            PrepareHandler.Instance.OnShowCollectIcon -= OnArriveCollectNPC;
            PrepareHandler.Instance.OnHideCollectIcon -= OnLeaveCollectNpc;
            GlobalTimeEvent.Instance.secondEvent -= SecondEvent;
        }
System/MainInterfacePanel/MainButtonMisc.cs
@@ -64,8 +64,8 @@
            OSEnvelopeModel.OSRedEnvelopeInfoEnvent += OnRedBagGet;
            RedpointCenter.Instance.redpointValueChangeEvent += RedpointValueChangeEvent;
            PlayerDatas.Instance.playerDataRefreshEvent += Updatefighting;
            GA_NpcCollect.OnArrive += OnArriveCollectNPC;
            GA_NpcCollect.OnLeave += OnLeaveCollectNpc;
            PrepareHandler.Instance.OnShowCollectIcon += OnArriveCollectNPC;
            PrepareHandler.Instance.OnHideCollectIcon += OnLeaveCollectNpc;
            ClientCollectUtility.OnShowCollectIcon += OnArriveCollectNPC;
            ClientCollectUtility.OnHideCollectIcon += OnLeaveCollectNpc;
            wishModel.UpdateWishAwardEvent += UpdateWishAwardImag;
@@ -90,8 +90,8 @@
            OSEnvelopeModel.OSRedEnvelopeInfoEnvent -= OnRedBagGet;
            RedpointCenter.Instance.redpointValueChangeEvent -= RedpointValueChangeEvent;
            PlayerDatas.Instance.playerDataRefreshEvent -= Updatefighting;
            GA_NpcCollect.OnArrive -= OnArriveCollectNPC;
            GA_NpcCollect.OnLeave -= OnLeaveCollectNpc;
            PrepareHandler.Instance.OnShowCollectIcon -= OnArriveCollectNPC;
            PrepareHandler.Instance.OnHideCollectIcon -= OnLeaveCollectNpc;
            ClientCollectUtility.OnShowCollectIcon -= OnArriveCollectNPC;
            ClientCollectUtility.OnHideCollectIcon -= OnLeaveCollectNpc;
            wishModel.UpdateWishAwardEvent -= UpdateWishAwardImag;