Esempio n. 1
0
        protected virtual void CalculateDamage()
        {
            // System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            //  sw.Start();
            CancelInvoke("CalculateDamage");

            bool isDamageSuccess = false;

            LuaTable skillDesc = ConfigManager.Instance.Skill.GetSkillConfig(m_skillBase.m_skillID);

            if (skillDesc == null)
            {
                return;
            }

            if (m_skillMgr.m_bShowSkillScope)
            {
                Vector3 pos = m_skillBase.m_actor.transform.position;
                if (null == m_SkillScope)
                {
                    if (m_skillBase.m_actor.mActorType == ActorType.AT_LOCAL_PLAYER || m_skillBase.m_actor.mActorType == ActorType.AT_BOSS)
                    {
                        if (DamageTypeID.DTID_FUN == m_oneDamageInfo.type)
                        {
                            if (m_oneDamageInfo.damageNode.funDamage.angle >= 360)
                            {
                                m_SkillScope = WarningDecel.CreateSectorDecal("Effect/skill/remain/fx_yujing_yuan", pos,
                                                                              m_oneDamageInfo.damageNode.funDamage.radius * 2, m_oneDamageInfo.damageNode.funDamage.angle);
                            }
                            else
                            {
                                m_SkillScope = WarningDecel.CreateSectorDecal("Effect/skill/remain/fx_yujing_shanxing", pos,
                                                                              m_oneDamageInfo.damageNode.funDamage.radius * 2, m_oneDamageInfo.damageNode.funDamage.angle);
                            }


                            if (m_oneDamageInfo.damageNode.funDamage.angle < 360)
                            {
                                float   ActorAngle = 0.0f;
                                Vector3 ActorAxis  = Vector3.zero;
                                m_skillBase.m_actor.transform.rotation.ToAngleAxis(out ActorAngle, out ActorAxis);
                                if (m_SkillScope != null)
                                {
                                    float angle = Mathf.Acos(Vector3.Dot(m_skillBase.m_actor.transform.forward.normalized, new Vector3(1.0f, 0f, 0f))) * Mathf.Rad2Deg;
                                    if (ActorAngle >= 90 && ActorAngle <= 270)
                                    {
                                        m_SkillScope.transform.RotateAround(pos, Vector3.up, angle);
                                    }
                                    else
                                    {
                                        m_SkillScope.transform.RotateAround(pos, Vector3.up, -angle);
                                    }
                                }

                                //LogMgr.UnityLog("angle="+angle.ToString());


                                // m_SkillScope.transform.position += m_SkillScope.transform.up * 0.1f;
                            }
                        }
                        else if (DamageTypeID.DTID_RECT == m_oneDamageInfo.type)
                        {
                            m_SkillScope = WarningDecel.CreateRectangleDecal("Effect/skill/remain/fx_yujing_changfang", pos,
                                                                             m_oneDamageInfo.damageNode.rectDamage.width, m_oneDamageInfo.damageNode.rectDamage.length);
                            if (m_SkillScope != null)
                            {
                                m_SkillScope.transform.rotation  = m_skillBase.m_actor.transform.rotation;
                                m_SkillScope.transform.position += m_oneDamageInfo.damageNode.rectDamage.length / 2 * m_skillBase.m_actor.transform.forward;
                            }
                        }
                    }
                    //Invoke("HideSkillScope", m_oneDamageInfo.hitTime);
                }
            }

            //单体伤害
            if (!m_bIsAoe)
            {
                ActorObj targetObj = m_skillBase.m_actor.GetSelTarget();

                if (targetObj != null && m_skillBase.m_actor.IsSkillAim((sbyte)m_skillBase.m_skillDesc.Get <int>("faction_limit"), targetObj))
                {
                    ActorObj actorBase = targetObj;

                    //按伤害范围算出受伤害对象,具体有没有伤害,还要看对应的属性(免疫等)
                    bool isSkillSuccess = m_skillMgr.IsSkillDamageRange(skillDesc.Get <int>("effect_1"), m_transform,
                                                                        targetObj.transform, actorBase.GetColliderRadius());

                    //伤害对象
                    if (isSkillSuccess)
                    {
                        isDamageSuccess = true;

                        //纠正被击表现
                        DamageParam damageParam = new DamageParam();
                        damageParam.skillID = m_skillBase.m_skillID;
                        //damageParam.attackObj = m_skillBase.m_castOwnObj;
                        damageParam.attackActor = m_skillBase.m_actor;

                        //damageParam.behitObj = attackObj.gameObject;
                        damageParam.behitActor = actorBase;
                        damageParam.IsClient   = true;

                        damageParam.weight            = m_oneDamageInfo.resetSkillWeight;
                        damageParam.isNotUseCurveMove = m_oneDamageInfo.isNotUseCurveMove;

                        CoreEntry.gSkillMgr.OnSkillDamage(damageParam);

                        //是否有眩晕效果
                        if (m_oneDamageInfo.dizzyParamDesc != null)
                        {
                            DizzyParam param = new DizzyParam();
                            param.keepTime = m_oneDamageInfo.dizzyParamDesc.keepTime;

                            actorBase.OnEnterDizzy(param);
                        }
                    }
                }
            }
            else
            {
                //计算伤害  群体
                if (m_skillBase.m_actor == null)
                {
                    return;
                }

                ActorObj actor = null;

                for (int k = 0; k < m_skillBase.m_actor.m_TargetList.Count; ++k)
                {
                    actor = CoreEntry.gActorMgr.GetActorByServerID(m_skillBase.m_actor.m_TargetList[k]);

                    if (ArenaMgr.Instance.IsArenaFight)
                    {
                        actor = CoreEntry.gActorMgr.GetPlayerActorByServerID(m_skillBase.m_actor.m_TargetList[k]);
                    }

                    if (actor == null)
                    {
                        continue;
                    }

                    //对IOS出现怪物不动 报错的异常  进行错误处理
                    if (GameLogicMgr.checkValid(actor.gameObject) == false)
                    {
                        continue;
                    }

                    {
                        isDamageSuccess = true;

                        //纠正被击表现
                        DamageParam damageParam = new DamageParam();
                        damageParam.skillID = m_skillBase.m_skillID;
                        // damageParam.attackObj = m_skillBase.m_castOwnObj;
                        damageParam.attackActor = m_skillBase.m_actor;
                        // damageParam.behitObj = obj.gameObject;
                        damageParam.behitActor        = actor;
                        damageParam.weight            = m_oneDamageInfo.resetSkillWeight;
                        damageParam.isNotUseCurveMove = m_oneDamageInfo.isNotUseCurveMove;

                        damageParam.IsClient = true;

                        CoreEntry.gSkillMgr.OnSkillDamage(damageParam);

                        //是否有眩晕效果
                        if (m_oneDamageInfo.dizzyParamDesc != null)
                        {
                            DizzyParam param = new DizzyParam();
                            param.keepTime = m_oneDamageInfo.dizzyParamDesc.keepTime;

                            actor.OnEnterDizzy(param);
                        }

                        if (isDamageSuccess && actor.mActorType == ActorType.AT_BOSS && m_skillBase.m_actor.IsMainPlayer())
                        {
                            m_isHadLoadFrameStop = true;

                            //顿帧
                            if (m_oneDamageInfo.frameStopDesc != null)
                            {
                                //GameObject frameStopObj = Instantiate(
                                //    CoreEntry.gResLoader.LoadResource(m_oneDamageInfo.frameStopDesc.prefabPath)) as GameObject;
                                GameObject frameStopObj = CoreEntry.gGameObjPoolMgr.InstantiateSkillCell(m_oneDamageInfo.frameStopDesc.prefabPath);

                                ISkillCell skillCell = frameStopObj.GetComponent <ISkillCell>();
                                if (skillCell)
                                {
                                    skillCell.Init(m_oneDamageInfo.frameStopDesc, m_skillBase, actor);
                                    m_skillBase.AddSkillCell(frameStopObj);
                                }
                                else
                                {
                                    //没有skillcell说明,坏掉了马上清理掉
                                    Destroy(frameStopObj);
                                }
                            }
                        }
                    }
                }
            }


            LuaTable skill_action = CoreEntry.gSkillMgr.GetSkillActon(m_skillBase.m_skillID);


            string remanEfx = null;

            if (skill_action != null)
            {
                remanEfx = skill_action.Get <string>("remain");
            }


            //地表残留
            if (remanEfx.Length > 0 && m_oneDamageInfo.m_bUseRemain)
            {
                //GameObject efxObj = (GameObject)Object.Instantiate(CoreEntry.gResLoader.LoadResource(remanEfx));//CoreEntry.gGameObjPoolMgr.InstantiateEffect(remanEfx);
                GameObject efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect(remanEfx);


                if (efxObj == null)
                {
                    //efxObj = (GameObject)Object.Instantiate(CoreEntry.gResLoader.LoadResource(remanEfx));//CoreEntry.gGameObjPoolMgr.InstantiateEffect(remanEfx);
                    efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect(remanEfx);
                }


                //yy 特效和模型按等比例缩放
                //if (m_skillBase.m_actor.actorCreatureDisplayDesc.sacle > 1.0f)
                //{
                //    ParticleScaler ScaleComponet = efxObj.GetComponent<ParticleScaler>();
                //    if (ScaleComponet == null)
                //        ScaleComponet = efxObj.AddComponent<ParticleScaler>();

                //    ScaleComponet.particleScale = m_skillBase.m_actor.actorCreatureDisplayDesc.sacle;

                //}


                float maxEfxTime = 0;

                if (efxObj)
                {
                    NcCurveAnimation[] efxAnimations = efxObj.GetComponentsInChildren <NcCurveAnimation>();
                    for (int i = 0; i < efxAnimations.Length; ++i)
                    {
                        // efxAnimations[i].m_fDelayTime /= m_speed;
                        // efxAnimations[i].m_fDurationTime /= m_speed;

                        float efxTime = efxAnimations[i].m_fDelayTime + efxAnimations[i].m_fDurationTime;
                        if (efxTime > maxEfxTime)
                        {
                            maxEfxTime = efxTime;
                        }
                    }
                }

                if (skill_action != null)
                {
                    if (skill_action.Get <float>("skillEfxLength") > 0)
                    {
                        maxEfxTime = skill_action.Get <float>("skillEfxLength");
                    }

                    //特效存在时间
                    if (maxEfxTime <= 0.001)
                    {
                        maxEfxTime = m_skillBase.m_actor.GetActionLength(skill_action.Get <string>("animation"));
                    }
                }


                EfxAttachActionPool efx = efxObj.GetComponent <EfxAttachActionPool>();
                if (efx == null)
                {
                    efx = efxObj.AddComponent <EfxAttachActionPool>();
                }

                //yy test

                efx.InitRemain(m_skillBase.m_actor.transform, maxEfxTime, false);


                m_RemainEfx = efx;
            }



            //场景物件,主角破坏
            if (m_skillBase.m_actor.mActorType == ActorType.AT_LOCAL_PLAYER)
            {
                GameObject[] brokedObjs = CoreEntry.gSceneMgr.brokedObjArray;
                for (int i = 0; i < brokedObjs.Length; ++i)
                {
                    if (brokedObjs[i] == null)
                    {
                        continue;
                    }

                    bool isSkillSuccess = m_skillMgr.IsSkillDamageRange(skillDesc.Get <int>("effect_1"), m_transform, brokedObjs[i].transform, 0.5f);

                    //伤害对象
                    if (isSkillSuccess)
                    {
                        Broked broked = brokedObjs[i].GetComponent <Broked>();
                        int    weight = 3;//m_skillBase.m_skillDesc.weight;
                        if (m_oneDamageInfo.resetSkillWeight > 0)
                        {
                            weight = m_oneDamageInfo.resetSkillWeight;
                        }

                        broked.DoBroked(m_skillBase.m_actor.thisGameObject, weight);
                    }
                }
            }

            //if (isDamageSuccess && !m_isHadLoadFrameStop)
            //{
            //    m_isHadLoadFrameStop = true;

            //    //顿帧
            //    if (m_oneDamageInfo.frameStopDesc != null)
            //    {
            //        GameObject frameStopObj = Instantiate(
            //            CoreEntry.gResLoader.LoadResource(m_oneDamageInfo.frameStopDesc.prefabPath)) as GameObject;

            //        ISkillCell skillCell = frameStopObj.GetComponent<ISkillCell>();

            //        skillCell.Init(m_oneDamageInfo.frameStopDesc,m_skillBase.m_actor);

            //        m_skillBase.AddSkillCell(frameStopObj);
            //    }

            //}

            //屏震    不是主玩家 , 就不震屏幕
            if (m_skillBase.m_actor.IsMainPlayer() || m_skillBase.m_actor.mActorType == ActorType.AT_BOSS)
            {
                if (m_oneDamageInfo.cameraShakeDesc != null)
                {
                    if (m_oneDamageInfo.cameraShakeDesc.activeWhenHit == false ||
                        (m_oneDamageInfo.cameraShakeDesc.activeWhenHit == true && isDamageSuccess == true)
                        )
                    {
                        //GameObject cellObj = Instantiate(
                        //    CoreEntry.gResLoader.LoadResource(m_oneDamageInfo.cameraShakeDesc.prefabPath)) as GameObject;

                        GameObject cellObj = CoreEntry.gGameObjPoolMgr.InstantiateSkillCell(m_oneDamageInfo.cameraShakeDesc.prefabPath);
                        cellObj.transform.parent = transform;

                        // m_oneDamageInfo.cameraShakeDesc.playTime = m_oneDamageInfo.hitTime;

                        ISkillCell skillCell = cellObj.GetComponent <ISkillCell>();
                        skillCell.Init(m_oneDamageInfo.cameraShakeDesc, m_skillBase);

                        m_skillBase.AddSkillCell(cellObj);
                    }
                }
            }



            //是否持续伤害
            if (m_oneDamageInfo.isRepeatedly && m_repeateKeep > 0)
            {
                Invoke("CalculateDamage", m_oneDamageInfo.damageDiff / m_skillBase.m_speed);
                --m_repeateKeep;
            }

            // sw.Stop();
            if (m_skillBase.m_actor.IsLocalPlayer())
            {
                // Debug.LogError("3....." + sw.ElapsedMilliseconds + "毫秒.....");
            }
        }
Esempio n. 2
0
        //触发器
        public virtual void OnTriggerEnter(Collider other)
        {
            if (bAutoEnd)
            {
                return;
            }

            int groundLayer = LayerMask.NameToLayer("ground");

            //碰到地面就消失
            if (IsRunning && other.gameObject.layer == groundLayer)
            {
                AutoEnd(other.gameObject.transform);
                return;
            }

            if (m_param.disappearWhenTouchWall)
            {
                int wallLayer = LayerMask.NameToLayer("wall");

                //被带走的,碰到墙壁就消失
                if (other.gameObject.layer == wallLayer)
                {
                    AutoEnd(other.gameObject.transform);
                    return;
                }
            }

            bool bIsMonster = false;

            ActorObj actorBase = other.transform.root.gameObject.GetComponent <ActorObj>();

            if (actorBase == null)
            {
                actorBase  = other.transform.gameObject.GetComponent <ActorObj>();
                bIsMonster = true;
            }

            if (actorBase == null)
            {
                //判断是否是破碎物体
                if ((other.gameObject.CompareTag("broked") || other.gameObject.layer == 13) && m_param.m_skillBase.m_actor.mActorType == ActorType.AT_LOCAL_PLAYER)
                {
                    GameObject[] brokedObjs = CoreEntry.gSceneMgr.brokedObjArray;
                    for (int i = 0; i < brokedObjs.Length; ++i)
                    {
                        if (brokedObjs[i] == null)
                        {
                            continue;
                        }

                        //伤害对象

                        Broked broked = brokedObjs[i].GetComponent <Broked>();
                        int    weight = 0; //m_param.m_skillBase.m_skillDesc.weight;
                        broked.DoBroked(m_param.m_skillBase.m_actor.thisGameObject, weight);
                    }


                    if (!m_param.bThroughFlag)
                    {
                        AutoEnd( );
                    }
                }

                return;
            }

            //临时判断
            ActorObj castBase = m_param.castObj.GetComponent <ActorObj>();

            //if (actorBase.mActorType == castBase.mActorType)
            //{
            //    return;
            //}


            if (!castBase.IsAimActorType(actorBase))//IsAimActorType(actorBase.mActorType))
            {
                return;
            }


            if (m_param.bAttackMoreThanOnce == false)
            {
                //增加个判断,判断是不是受过此子弹技能的伤害
                for (int i = 0; i < m_param.m_skillBase.m_AttackList.Count; i++)
                {
                    if (actorBase.entityid == m_param.m_skillBase.m_AttackList[i].entityid)
                    {
                        return;
                    }
                }
            }

            // m_param.m_skillBase.m_AttackList.Find(actorBase);

            //增加到攻击列表
            m_param.m_skillBase.m_AttackList.Add(actorBase);


            //纠正被击表现
            DamageParam damageParam = new DamageParam();

            damageParam.skillID     = m_param.skillID;
            damageParam.attackActor = castBase;// m_param.castObj;

            if (bIsMonster)
            {
                damageParam.behitActor = actorBase;
            }
            else
            {
                damageParam.behitActor = actorBase;
            }

            CoreEntry.gSkillMgr.OnSkillDamage(damageParam);

            m_baseTool = CoreEntry.gBaseTool;

            //是否被带走
            if (m_param.bTakeAwayTarget)
            {
                bool shouldTakeAway = true;
                if (actorBase != null)
                {
                    //boss在气绝状态下才能被带走
                    if (actorBase.CheckIfBossNotQiJue())
                    {
                        shouldTakeAway = false;
                    }

                    //无敌状态不被带走
                    if (actorBase.IsRecoverHealth)
                    {
                        shouldTakeAway = false;
                    }
                }

                if (shouldTakeAway)
                {
                    SetTakeAwayTarget(damageParam, bIsMonster);
                }
            }

            if (!m_param.bThroughFlag)
            {
                AutoEnd( );
            }
        }
Esempio n. 3
0
        void CalculateDamage()
        {
            CancelInvoke("CalculateDamage");

            OneCurveDamageInfo curveInfo = m_curveDamageCellDesc.curveDamageInfoList[m_curIndex];

            //旋转偏移
            m_transform.Rotate(Vector3.up, curveInfo.offsetAngle * Mathf.Deg2Rad);

            //debug
#if UNITY_EDITOR
            GameObject efxObj = Instantiate(
                CoreEntry.gResLoader.LoadResource("Skill/Cube")) as GameObject;
            efxObj.transform.position = m_transform.position;
            efxObj.transform.rotation = m_transform.rotation;
            efxObj.name = m_curIndex.ToString();

            SceneEfx efx = efxObj.AddComponent <SceneEfx>();
            efx.Init(m_transform.position, 5);
#endif

            //计算伤害monster
            System.Collections.Generic.List <ActorObj> actors = CoreEntry.gActorMgr.GetAllMonsterActors();
            foreach (ActorObj obj in actors)
            {
                //对IOS出现怪物不动 报错的异常  进行错误处理
                if (GameLogicMgr.checkValid(obj.gameObject) == false)
                {
                    continue;
                }
                ActorObj actorBase = obj;

                //临时判断
                if (actorBase.mActorType == m_skillBase.m_actor.mActorType)
                {
                    continue;
                }


                if (!CoreEntry.gGameMgr.IsPvpState() && !m_skillBase.m_actor.IsAimActorType(actorBase))
                {
                    continue;
                }

                bool isSkillSuccess = BaseTool.instance.IsPointInRectangleXZ(m_transform.position,
                                                                             m_transform.rotation.eulerAngles, curveInfo.damageLength,
                                                                             curveInfo.damageWidth, obj.transform.position);

                //伤害对象
                if (isSkillSuccess)
                {
                    //纠正被击表现
                    DamageParam damageParam = new DamageParam();
                    damageParam.skillID     = m_skillBase.m_skillID;
                    damageParam.attackActor = m_skillBase.m_actor;
                    damageParam.behitActor  = actorBase;

                    CoreEntry.gSkillMgr.OnSkillDamage(damageParam);
                }
            }

            //场景物件,主角破坏
            if (m_skillBase.m_actor.mActorType == ActorType.AT_LOCAL_PLAYER)
            {
                GameObject[] brokedObjs = CoreEntry.gSceneMgr.brokedObjArray;
                for (int i = 0; i < brokedObjs.Length; ++i)
                {
                    bool isSkillSuccess = BaseTool.instance.IsPointInRectangleXZ(m_transform.position,
                                                                                 m_transform.rotation.eulerAngles, curveInfo.damageLength,
                                                                                 curveInfo.damageWidth, brokedObjs[i].transform.position);

                    //伤害对象
                    if (isSkillSuccess)
                    {
                        Broked broked = brokedObjs[i].GetComponent <Broked>();
                        int    weight = 3;//m_skillBase.m_skillDesc.weight;

                        broked.DoBroked(m_skillBase.m_actor.thisGameObject, weight);
                    }
                }
            }

            if (m_curIndex < m_curveDamageCellDesc.curveDamageInfoList.Count - 1)
            {
                m_curIndex++;

                //设置位置
                m_transform.position += m_transform.forward.normalized * curveInfo.length;

                Invoke("CalculateDamage", m_curveDamageCellDesc.curveDamageInfoList[m_curIndex].hitTime);
            }
        }