Ejemplo n.º 1
0
        bool mHideEffect        = false;                                                                                                          // 是否隐藏子弹特效

        /// <summary>
        /// 初始化
        /// </summary>
        public bool Init()
        {
            m_SkillInfo = DBSkillSev.Instance.GetSkillInfo(SkillID);
            m_SubEmitId = (ulong)(((ulong)ActorID << 32 & 0xffffffff00000000) | ((ulong)SkillID << 16 & 0xffffffffffff0000));  // 暂时使用技能ID和角色ID来进行组合
            if (m_SkillInfo != null && m_SkillInfo.BulletId != 0)
            {
                m_BulletInfo = DBBulletTrace.GetInstance().GetBulletInfo(m_SkillInfo.BulletId);
                if (m_BulletInfo != null)
                {
                    if (HitPlayers.Count > 0)
                    {
                        uint  hit_player_id = HitPlayers[0];
                        Actor src_player    = ActorManager.Instance.GetPlayer(ActorID);
                        Actor hitPlayer     = ActorManager.Instance.GetPlayer(hit_player_id);

                        if (src_player == null || hitPlayer == null || src_player.GetActorMono() == null || hitPlayer.GetActorMono() == null)
                        {
                            return(false);
                        }

                        ActorMono src_actormono = src_player.GetActorMono();
                        ActorMono hit_actormono = hitPlayer.GetActorMono();

                        BulletTrackInstance sub_bullet_trace = new xc.BulletTrackInstance(m_BulletInfo, m_SkillInfo, 0);
                        m_TraceInsts.Add(sub_bullet_trace);

                        // 开启新的BulletTrackInstance
                        mHideEffect = ShieldManager.Instance.IsHideBulletEffect(src_player, hitPlayer);
                        sub_bullet_trace.Do(m_SubEmitId, src_actormono, hit_actormono, mHideEffect, src_player.transform.position, src_player.transform.rotation, src_player.transform.forward, OnHit);

                        // 将伤害信息添加到新创建的SkillAttackInstance列表中
                        SkillAttackInstance attack_inst = EffectManager.GetInstance().GetAttackInstance(m_SubEmitId);
                        if (attack_inst != null)
                        {
                            Damage dmgInfo = null;
                            if (m_DamageInfos.TryGetValue(hit_player_id, out dmgInfo))
                            {
                                attack_inst.AddHurtInfo(dmgInfo);
                            }
                        }

                        m_HitEmits[hit_player_id] = new HitCacheInfo(m_SubEmitId);
                        m_SubEmitId++;

                        mLastThunderPlayer = hit_player_id;
                        HitPlayers.RemoveAt(0);
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 当命中一个角色后的回调
        /// </summary>
        /// <param name="sub_inst"></param>
        void OnHit(SkillAttackInstance sub_inst)
        {
            if (m_BulletInfo != null)
            {
                if (HitPlayers.Count > 0)
                {
                    uint  hit_player_id = HitPlayers[0];
                    Actor src_player    = ActorManager.Instance.GetPlayer(mLastThunderPlayer);
                    Actor hitPlayer     = ActorManager.Instance.GetPlayer(hit_player_id);

                    if (src_player == null || hitPlayer == null || src_player.GetActorMono() == null || hitPlayer.GetActorMono() == null)
                    {
                        GameDebug.Log("player is null");
                    }
                    else
                    {
                        BulletTrackInstance sub_bullet_trace = new xc.BulletTrackInstance(m_BulletInfo, m_SkillInfo, 0);
                        m_TraceInsts.Add(sub_bullet_trace);

                        // 开启新的BulletTrackInstance
                        sub_bullet_trace.Do(m_SubEmitId, src_player.GetActorMono(), hitPlayer.GetActorMono(), mHideEffect, src_player.transform.position, src_player.transform.rotation, src_player.transform.forward, OnHit);

                        // 将伤害信息添加到新创建的SkillAttackInstance列表中
                        SkillAttackInstance attack_inst = EffectManager.GetInstance().GetAttackInstance(m_SubEmitId);
                        if (attack_inst != null)
                        {
                            Damage dmgInfo = null;
                            if (m_DamageInfos.TryGetValue(hit_player_id, out dmgInfo))
                            {
                                attack_inst.AddHurtInfo(dmgInfo);
                            }
                        }

                        m_HitEmits[hit_player_id] = new HitCacheInfo(m_SubEmitId);
                        m_SubEmitId++;
                    }

                    mLastThunderPlayer = hit_player_id;
                    HitPlayers.RemoveAt(0);
                }
                else// 此时表示闪电链的攻击结束了
                {
                    Destroy();
                }
            }
        }