少年修仙传客户端代码仓库
client_linchunjie
2019-05-16 ae91293b91cb5ed6458e18f0fe9be876796193f3
6803 【前端】【2.0】坐骑、灵宠开启自动激活
1个文件已修改
35 ■■■■■ 已修改文件
System/Mount/MountModel.cs 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Mount/MountModel.cs
@@ -54,6 +54,7 @@
    public List<int> ListEffectSkill = new List<int>();
    private int HorseDanExp = 0;//坐骑丹经验
    private int autoActiveHorseId = 0;
    private bool hasSendAutoActive = false;
    PackModel _playerPack;
    PackModel playerPack {
        get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
@@ -138,6 +139,7 @@
    public void OnBeforePlayerDataInitialize()
    {
        IsOk = false;
        hasSendAutoActive = false;
        _HorseIDNow = string.Empty;
        HorseIDNow = 0;
        _DicHorse.Clear();
@@ -292,6 +294,12 @@
            }
            MountChangeRedPoint();
            MountDanRed();
            var config = HorseConfig.Get(autoActiveHorseId);
            if (config != null && id == config.UnlockItemID)
            {
                TryAutoActiveHorse();
            }
        }
    }
@@ -299,27 +307,26 @@
    {
        if (funcId == (int)FuncOpenEnum.Mounts)
        {
            if (IsOk && FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Mounts))
            {
                Clock.AlarmAfter(0.5f, () =>
                {
                    TryAutoActiveHorse();
                });
            }
            TryAutoActiveHorse();
        }
    }
    private void TryAutoActiveHorse()
    {
        var horseConfig = HorseConfig.Get(autoActiveHorseId);
        if (horseConfig != null)
        if (IsOk && FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Mounts)
            && !_DicHorse.ContainsKey(autoActiveHorseId) && !hasSendAutoActive)
        {
            var itemCount = playerPack.GetItemCountByID(PackType.Item, horseConfig.UnlockItemID);
            if (itemCount >= horseConfig.UnlockItemCnt)
            var horseConfig = HorseConfig.Get(autoActiveHorseId);
            if (horseConfig != null)
            {
                var pak = new CA501_tagPlayerActivateHorse();
                pak.HorseID = (uint)autoActiveHorseId;
                GameNetSystem.Instance.SendInfo(pak);
                var itemCount = playerPack.GetItemCountByID(PackType.Item, horseConfig.UnlockItemID);
                if (itemCount >= horseConfig.UnlockItemCnt)
                {
                    hasSendAutoActive = true;
                    var pak = new CA501_tagPlayerActivateHorse();
                    pak.HorseID = (uint)autoActiveHorseId;
                    GameNetSystem.Instance.SendInfo(pak);
                }
            }
        }
    }