少年修仙传客户端代码仓库
client_Hale
2019-04-16 e8fef6c83238990fc56000a439a17b7df3704af3
Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
6个文件已修改
369 ■■■■■ 已修改文件
System/HazyRegion/ClientHazyGrassStage.cs 308 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/HazyRegion/HazyDemonKingModel.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/HazyRegion/HazyGrassDungeonWin.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/HazyRegion/HazyRegionIncidentBehaviour.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/HazyRegion/HazyRegionModel.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/ItemTip/EquipTipUtility.cs 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/HazyRegion/ClientHazyGrassStage.cs
@@ -1,166 +1,218 @@
using System;
using Snxxz.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Snxxz.UI
using UnityEngine;
public class ClientHazyGrassStage : DungeonStage
{
    public class ClientHazyGrassStage : DungeonStage
    static readonly Vector3 PlayerBornPosition1 = new Vector3(17.25f, 5.12f, 3.70f);
    static readonly Vector3 PlayerBornPosition2 = new Vector3(17.25f, 5.12f, 3.70f);
    static List<HazyMapNpcScriptableObject.NpcInfo> s_NpcInfos = new List<HazyMapNpcScriptableObject.NpcInfo>();
    static Dictionary<Vector3, GA_NpcClientCollect> s_CollectNpcs = new Dictionary<Vector3, GA_NpcClientCollect>();
    static Dictionary<uint, Vector3> s_Sid2NpcPos = new Dictionary<uint, Vector3>();
    static Dictionary<uint, int> s_Sid2NpcIds = new Dictionary<uint, int>();
    static List<GA_NpcClientFightNorm> s_ClientFightNpcs = new List<GA_NpcClientFightNorm>();
    static int grassRefreshCount = 0;
    bool mapLoadFinish = false;
    bool initedFightNpc = false;
    HazyRegionIncidentType incidentType;
    HazyGrassModel model { get { return ModelCenter.Instance.GetModel<HazyGrassModel>(); } }
    HazyRegionModel hazyRegionModel { get { return ModelCenter.Instance.GetModel<HazyRegionModel>(); } }
    public override void Initialize()
    {
        static readonly Vector3 PlayerBornPosition = new Vector3(17.25f, 5.12f, 3.70f);
        base.Initialize();
        static List<HazyMapNpcScriptableObject.NpcInfo> s_NpcInfos = new List<HazyMapNpcScriptableObject.NpcInfo>();
        static Dictionary<Vector3, GA_NpcClientCollect> s_CollectNpcs = new Dictionary<Vector3, GA_NpcClientCollect>();
        static Dictionary<uint, Vector3> s_Sid2NpcPos = new Dictionary<uint, Vector3>();
        static Dictionary<uint, int> s_Sid2NpcIds = new Dictionary<uint, int>();
        s_NpcInfos.Clear();
        s_Sid2NpcIds.Clear();
        s_Sid2NpcPos.Clear();
        static int grassRefreshCount = 0;
        mapLoadFinish = false;
        initedFightNpc = false;
        bool mapLoadFinish = false;
        grassRefreshCount = 0;
        HazyGrassModel model { get { return ModelCenter.Instance.GetModel<HazyGrassModel>(); } }
        public override void Initialize()
        var config = HazyRegionConfig.Get(hazyRegionModel.processingIncidentId);
        if (config != null)
        {
            base.Initialize();
            s_NpcInfos.Clear();
            s_Sid2NpcIds.Clear();
            s_Sid2NpcPos.Clear();
            mapLoadFinish = false;
            grassRefreshCount = 0;
            UnloadAllNpc();
            GA_NpcClientCollect.OnCollectFinished += OnCollectFinished;
            incidentType = (HazyRegionIncidentType)config.incidentType;
        }
        protected override void OnStageLoadFinish()
        UnloadAllNpc();
        GA_NpcClientCollect.OnCollectFinished += OnCollectFinished;
    }
    protected override void OnStageLoadFinish()
    {
        base.OnStageLoadFinish();
        mapLoadFinish = true;
        model.RefreshGrassBornTime(TimeUtility.ServerNow);
        InitialPlayer();
        InitializeNpc();
        initedFightNpc = true;
    }
    protected override void OnUpdate()
    {
        base.OnUpdate();
        if (mapLoadFinish)
        {
            base.OnStageLoadFinish();
            mapLoadFinish = true;
            model.RefreshGrassBornTime(TimeUtility.ServerNow);
            InitialPlayer();
            InitializeNpc();
        }
        protected override void OnUpdate()
        {
            base.OnUpdate();
            if (mapLoadFinish)
            var used = Mathf.Max(0, (int)(TimeUtility.ServerNow - model.grassBornTime).TotalSeconds);
            var count = used / model.grassRefreshSeconds;
            if (count != grassRefreshCount)
            {
                var used = Mathf.Max(0, (int)(TimeUtility.ServerNow - model.grassBornTime).TotalSeconds);
                var count = used / model.grassRefreshSeconds;
                if (count != grassRefreshCount)
                {
                    RebornCollectedNpc();
                    grassRefreshCount = count;
                }
            }
        }
        public override void UnInitialize()
        {
            base.UnInitialize();
            UnloadAllNpc();
            GA_NpcClientCollect.OnCollectFinished -= OnCollectFinished;
        }
        private void OnCollectFinished(uint _sid)
        {
            if (s_Sid2NpcIds.ContainsKey(_sid))
            {
                var npcId = s_Sid2NpcIds[_sid];
                Debug.Log("采集了Npc:--" + npcId);
            }
            if (s_Sid2NpcPos.ContainsKey(_sid))
            {
                var pos = s_Sid2NpcPos[_sid];
                if (s_CollectNpcs.ContainsKey(pos))
                {
                    s_CollectNpcs.Remove(pos);
                }
            }
        }
        void InitializeNpc()
        {
            s_NpcInfos.Clear();
            var config = ScriptableObjectLoader.LoadSoHazyMapNpc(ClientDungeonStageUtility.clientMapId);
            var npcInfos = config.GetAllNpcInfos();
            if (npcInfos != null)
            {
                s_NpcInfos.AddRange(npcInfos);
                RebornCollectedNpc();
                grassRefreshCount = count;
            }
        }
    }
        void InitialPlayer()
    public override void UnInitialize()
    {
        base.UnInitialize();
        UnloadAllNpc();
        GA_NpcClientCollect.OnCollectFinished -= OnCollectFinished;
    }
    private void OnCollectFinished(uint _sid)
    {
        if (s_Sid2NpcIds.ContainsKey(_sid))
        {
            var hero = PlayerDatas.Instance.hero;
            hero.Pos = PlayerBornPosition;
            CameraController.Instance.Apply();
            var npcId = s_Sid2NpcIds[_sid];
            Debug.Log("采集了Npc:--" + npcId);
        }
        void RebornCollectedNpc()
        if (s_Sid2NpcPos.ContainsKey(_sid))
        {
            foreach (var npcInfo in s_NpcInfos)
            var pos = s_Sid2NpcPos[_sid];
            if (s_CollectNpcs.ContainsKey(pos))
            {
                switch (npcInfo.npcType)
                {
                    case E_NpcType.Collect:
                        GA_NpcClientCollect _npc = null;
                        if (!s_CollectNpcs.TryGetValue(npcInfo.position, out _npc)
                            || _npc == null || _npc.ActorInfo.serverDie)
                s_CollectNpcs.Remove(pos);
            }
        }
    }
    void InitializeNpc()
    {
        s_NpcInfos.Clear();
        var config = ScriptableObjectLoader.LoadSoHazyMapNpc(ClientDungeonStageUtility.clientMapId);
        var npcInfos = config.GetAllNpcInfos();
        if (npcInfos != null)
        {
            s_NpcInfos.AddRange(npcInfos);
            RebornCollectedNpc();
        }
    }
    void InitialPlayer()
    {
        var hero = PlayerDatas.Instance.hero;
        if (incidentType == HazyRegionIncidentType.ReikiGrass)
        {
            hero.Pos = PlayerBornPosition1;
        }
        else if (incidentType == HazyRegionIncidentType.FairyGrass)
        {
            hero.Pos = PlayerBornPosition2;
        }
        CameraController.Instance.Apply();
    }
    void RebornCollectedNpc()
    {
        foreach (var npcInfo in s_NpcInfos)
        {
            switch (npcInfo.npcType)
            {
                case E_NpcType.Collect:
                    GA_NpcClientCollect _npc = null;
                    if (!s_CollectNpcs.TryGetValue(npcInfo.position, out _npc)
                        || _npc == null || _npc.ActorInfo.serverDie)
                    {
                        _npc = GAMgr.Instance.ReqClntNoFightNpc<GA_NpcClientCollect>((uint)npcInfo.npcId,
                            E_ActorGroup.FuncNpc);
                        if (_npc != null)
                        {
                            _npc = GAMgr.Instance.ReqClntNoFightNpc<GA_NpcClientCollect>((uint)npcInfo.npcId,
                                E_ActorGroup.FuncNpc);
                            if (_npc != null)
                            {
                                _npc.Pos = npcInfo.position;
                                s_CollectNpcs[npcInfo.position] = _npc;
                            _npc.Pos = npcInfo.position;
                            s_CollectNpcs[npcInfo.position] = _npc;
                                s_Sid2NpcIds[_npc.ServerInstID] = npcInfo.npcId;
                                s_Sid2NpcPos[_npc.ServerInstID] = npcInfo.position;
                            }
                            s_Sid2NpcIds[_npc.ServerInstID] = npcInfo.npcId;
                            s_Sid2NpcPos[_npc.ServerInstID] = npcInfo.position;
                        }
                        break;
                }
                    }
                    break;
                case E_NpcType.Fight:
                    if (!initedFightNpc)
                    {
                        var fightNpc = GAMgr.Instance.ReqClntFightNpc<GA_NpcClientFightNorm>((uint)npcInfo.npcId,
                             E_ActorGroup.Enemy);
                        if (fightNpc != null)
                        {
                            fightNpc.Pos = npcInfo.position;
                            fightNpc.OnAttacked -= OnAttackNpc;
                            fightNpc.OnAttacked += OnAttackNpc;
                        }
                        s_ClientFightNpcs.Add(fightNpc);
                    }
                    break;
            }
        }
    }
    private void OnAttackNpc()
    {
        Debug.Log("攻击了宝箱怪");
    }
    void UnloadAllNpc()
    {
        foreach (var _npc in s_CollectNpcs.Values)
        {
            if (_npc != null)
            {
                _npc.KillerServerInstID = PlayerDatas.Instance.PlayerId;
                _npc.ActorInfo.serverDie = true;
                GAMgr.Instance.ServerDie(_npc.ServerInstID);
                GAMgr.Instance.Release(_npc);
            }
        }
        void UnloadAllNpc()
        foreach (var _npc in s_ClientFightNpcs)
        {
            foreach (var _npc in s_CollectNpcs.Values)
            if (_npc != null)
            {
                if (_npc != null)
                {
                    _npc.KillerServerInstID = PlayerDatas.Instance.PlayerId;
                    _npc.ActorInfo.serverDie = true;
                    GAMgr.Instance.ServerDie(_npc.ServerInstID);
                    GAMgr.Instance.Release(_npc);
                }
                _npc.OnAttacked -= OnAttackNpc;
                _npc.ActorInfo.serverDie = true;
                GAMgr.Instance.ServerDie(_npc.ServerInstID);
                GAMgr.Instance.Release(_npc);
            }
            s_CollectNpcs.Clear();
        }
        s_ClientFightNpcs.Clear();
        s_CollectNpcs.Clear();
    }
#if UNITY_EDITOR
        private void OnGUI()
    private void OnGUI()
    {
        if (GUILayout.Button("Exit"))
        {
            if (GUILayout.Button("Exit"))
            {
                model.RequestExitClientDungeon();
            }
            model.RequestExitClientDungeon();
        }
#endif
    }
}
#endif
}
System/HazyRegion/HazyDemonKingModel.cs
@@ -159,7 +159,7 @@
            var configs = HazyRegionConfig.GetValues();
            foreach (var config in configs)
            {
                if (config.incidentType == (int)HazyRegionIncidentType.Boss
                if (config.incidentType == (int)HazyRegionIncidentType.DemonKing
                    && config.dungeonId == mapId)
                {
                    return true;
System/HazyRegion/HazyGrassDungeonWin.cs
@@ -20,6 +20,9 @@
        [SerializeField] Text m_BasicGrassRefreshTime;
        [SerializeField] Text m_FairyGrassRefreshTime;
        [SerializeField] Transform m_ContainerCollectSucc;
        [SerializeField] Text m_GainRemind;
        DungeonModel model { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
        HazyRegionModel hazyRegionModel { get { return ModelCenter.Instance.GetModel<HazyRegionModel>(); } }
        HazyGrassModel hazyGrassModel { get { return ModelCenter.Instance.GetModel<HazyGrassModel>(); } }
@@ -34,6 +37,8 @@
        protected override void OnPreOpen()
        {
            m_ContainerCollectSucc.gameObject.SetActive(false);
            Display();
            GlobalTimeEvent.Instance.secondEvent += PerSecond;
System/HazyRegion/HazyRegionIncidentBehaviour.cs
@@ -69,7 +69,7 @@
        void DisplayBase()
        {
            var config = HazyRegionConfig.Get(incidentId);
            m_DepletionPoint.text = string.Format("消耗体力: ", config.point);
            m_DepletionPoint.text = string.Format("消耗体力: {0}", config.point);
            m_IncidentTitle.text = config.name;
            m_Icon.SetSprite(config.PortraitID);
            m_Icon.SetNativeSize();
@@ -99,9 +99,9 @@
        void DisplayBoss()
        {
            m_ContainerBoss.gameObject.SetActive(incidentType == HazyRegionIncidentType.Boss);
            m_ContainerBoss.gameObject.SetActive(incidentType == HazyRegionIncidentType.DemonKing);
            var config = HazyRegionConfig.Get(incidentId);
            if (incidentType == HazyRegionIncidentType.Boss)
            if (incidentType == HazyRegionIncidentType.DemonKing)
            {
                var npcConfig = NPCConfig.Get(config.npcId);
                m_BossName.text = npcConfig.charName;
System/HazyRegion/HazyRegionModel.cs
@@ -360,7 +360,7 @@
                        }
                    }
                    break;
                case HazyRegionIncidentType.Boss:
                case HazyRegionIncidentType.DemonKing:
                    if (InFakeHazyRegion)
                    {
                        hazyDemonKingModel.RequestEnterClientDungeon();
@@ -517,7 +517,7 @@
        Adventure,
        Precious,
        FairyGrass,
        Boss,
        DemonKing,
        ReikiGrass,
    }
}
System/ItemTip/EquipTipUtility.cs
@@ -231,7 +231,7 @@
                legendProperty = GetLegendProperty(guid),
                skillInfo = GetSkillInfo(item.itemId),
                suitInfo = GetSuitInfo(guid),
                starInfo = GetStarInfo(item.itemId),
                starInfo = GetStarInfo(guid),
                strengthenProperty = GetStrengthenProperty(guid),
                gemInfo = GetGemInfo(guid),
@@ -392,7 +392,7 @@
                levelLimit = item.isAuction ? 0 : item.config.UseLV,
                realmLimit = item.isAuction ? 0 : item.config.RealmLimit,
                star = isEquiped ? star : -1,
                strengthenLevel = Mathf.Min(placeStrengthenLevel, maxStrengthenLevel)
                strengthenLevel = isEquiped ? Mathf.Min(placeStrengthenLevel, maxStrengthenLevel) : 0
            };
            return baseInfo;
@@ -608,7 +608,30 @@
            var starInfo = new StarInfo();
            starInfo.equipPosition = new Int2(config.LV, config.EquipPlace);
            starInfo.maxLevel = EquipStarModel.GetMaxStarLevel(config.ItemColor, config.LV);
            starInfo.starLevel = starModel.GetStarLevel(new Int2(config.LV, config.EquipPlace));
            starInfo.starLevel = 0;
            return starInfo;
        }
        private static StarInfo GetStarInfo(string guid)
        {
            var item = packModel.GetItemByGuid(guid);
            if (item == null)
            {
                return default(StarInfo);
            }
            if (!EquipModel.IsRealmEquip(item.config.EquipPlace))
            {
                return default(StarInfo);
            }
            var starInfo = new StarInfo();
            var equipPosition = new Int2(item.config.LV, item.config.EquipPlace);
            var equiped = equipModel.GetEquip(equipPosition) == guid;
            starInfo.equipPosition = equipPosition;
            starInfo.maxLevel = EquipStarModel.GetMaxStarLevel(item.config.ItemColor, item.config.LV);
            starInfo.starLevel = equiped ? starModel.GetStarLevel(equipPosition) : 0;
            return starInfo;
        }
@@ -623,6 +646,12 @@
            var level = item.config.LV;
            var place = item.config.EquipPlace;
            var equiped = equipModel.GetEquip(new Int2(level, place)) == guid;
            if (!equiped)
            {
                return default(StrengthenProperty);
            }
            var data = new StrengthenProperty();
            var strengthenLevel = strengthenModel.GetStrengthLevel(level, place);
@@ -658,8 +687,8 @@
            var level = item.config.LV;
            var place = item.config.EquipPlace;
            var gemInfo = new GemInfo();
            var gemInfo = new GemInfo();
            var maxStar = EquipStarModel.GetMaxStarLevel(item.config.ItemColor, item.config.LV);
            gemInfo.activeStates = new Dictionary<int, bool>();
            for (int i = 0; i < 4; i++)
@@ -692,8 +721,13 @@
            }
            var equipPosition = new Int2(item.config.LV, item.config.EquipPlace);
            var trainProperty = new TrainProperty();
            var equiped = equipModel.GetEquip(equipPosition) == guid;
            if (!equiped)
            {
                return default(TrainProperty);
            }
            var trainProperty = new TrainProperty();
            var star = Mathf.Min(EquipStarModel.GetMaxStarLevel(item.config.ItemColor, item.config.LV), starModel.GetEquipStarLevel(equipPosition));
            var type = EquipTrainModel.GetTrainType(equipPosition.y);
            var maxConfig = WashLevelMaxConfig.Get(type, star);