Ejemplo n.º 1
0
        public override void Preload(ISkillCellData cellData, SkillBase skillBase)
        {
            //m_dataIndex = param.damageCellIndex;
            m_oneDamageInfo = (OneDamageInfo)cellData;
            m_skillBase     = skillBase;

            GameObject frameStopObj = CoreEntry.gGameObjPoolMgr.InstantiateSkillCell("Skill/Cell/frameStop");

            if (frameStopObj != null)
            {
                frameStopObj.transform.parent = transform;

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

                skillCell.Preload(m_oneDamageInfo.frameStopDesc, m_skillBase);

                m_skillBase.AddSkillCell(frameStopObj);
            }

            if (m_oneDamageInfo.cameraShakeDesc != null)
            {
                GameObject cellObj = CoreEntry.gGameObjPoolMgr.InstantiateSkillCell(m_oneDamageInfo.cameraShakeDesc.prefabPath);
                cellObj.transform.parent = transform;

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

                m_skillBase.AddSkillCell(cellObj);
            }
        }
Ejemplo n.º 2
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 + "毫秒.....");
            }
        }
Ejemplo n.º 3
0
        void Fire()
        {
            CancelInvoke("Fire");

            //屏震    不是主玩家 , 就不震屏幕
            if (m_skillBase != null && m_skillBase.m_actor != null && m_skillBase.m_actor.gameObject != null)
            {
                if (m_skillBase.m_actor.IsMainPlayer() || m_skillBase.m_actor.mActorType == ActorType.AT_BOSS)
                {
                    if (m_fireFlyAttackDesc.cameraShakeDesc != null)
                    {
                        //GameObject cellObj = (GameObject)Object.Instantiate(CoreEntry.gResLoader.LoadResource(m_fireFlyAttackDesc.cameraShakeDesc.prefabPath));//CoreEntry.gGameObjPoolMgr.InstantiateSkillCell(m_fireFlyAttackDesc.cameraShakeDesc.prefabPath);
                        GameObject cellObj = CoreEntry.gGameObjPoolMgr.InstantiateSkillCell(m_fireFlyAttackDesc.cameraShakeDesc.prefabPath);
                        cellObj.transform.parent = transform;

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

                        m_skillBase.AddSkillCell(cellObj);
                    }
                }
            }

            //发射点位置
            Transform flyTransform = null;

            if (m_skillBase != null)
            {
                flyTransform = m_skillBase.FindChildTransform(m_fireFlyAttackDesc.firePos);
            }
            if (flyTransform == null)
            {
                LogMgr.UnityError("FireflyCell没有找到绑定点 \"" + m_fireFlyAttackDesc.firePos + "\"");
                return;
            }
            if (m_skillBase == null)
            {
                return;
            }
            // float diffAngle = 360f / m_fireFlyAttackDesc.bulletNum;
            float diffAngle = m_fireFlyAttackDesc.fAngle;

            for (int i = 0; i < m_fireFlyAttackDesc.bulletNum; ++i)
            {
                //加载子弹
                GameObject objBullet =
                    (GameObject)Instantiate(CoreEntry.gResLoader.LoadResource(m_fireFlyAttackDesc.bulletPrefab));
                if (objBullet == null)
                {
                    return;
                }

                objBullet.transform.position = flyTransform.position;

                Vector3 targetpos = new Vector3(0, 0, 0);

                // 下面这句有时候会造成弓箭兵 射出的箭向后飞,目标错乱
                //ActorObj actorObj = m_skillBase.m_actor.GetAttackObj();
                //if (actorObj == null)
                //    actorObj = m_skillBase.m_hateActor;

                ActorObj actorObj = m_skillBase.GetSelTarget();

                if (actorObj != null && m_fireFlyAttackDesc.bulletNum == 1)
                {
                    //单个目标,指向目标方向
                    //Vector3 aimPos = new Vector3(actorObj.thisGameObject.transform.position.x,
                    //    objBullet.transform.position.y, actorObj.thisGameObject.transform.position.z);

                    //aimPos = Vector3.Normalize(aimPos);

                    //objBullet.transform.LookAt(aimPos);

                    //Vector3 aimPos = new Vector3(actorObj.thisGameObject.transform.position.x,
                    //    objBullet.transform.position.y, actorObj.thisGameObject.transform.position.z);

                    Vector3 aimPos = new Vector3();
                    aimPos   = actorObj.thisGameObject.transform.position;
                    aimPos.y = actorObj.GetBehitEfxPosition().y;

                    Vector3 lookRot = aimPos - flyTransform.position;

                    // 穿透的子弹不需要考虑高度
                    if (m_fireFlyAttackDesc.bThroughFlag)
                    {
                        lookRot.y = 0;  // 设置为0时 高度不同时就打不到了
                    }
                    if (lookRot == Vector3.zero)
                    {
                        return;
                    }
                    lookRot.Normalize();
                    objBullet.transform.rotation = Quaternion.LookRotation(lookRot);

                    targetpos = aimPos;
                }
                else
                {
                    if (i == 0)
                    {
                        //朝向
                        Quaternion rot =
                            Quaternion.Euler(m_transform.rotation.eulerAngles.x,
                                             m_transform.rotation.eulerAngles.y + diffAngle * i, m_transform.rotation.eulerAngles.z);

                        objBullet.transform.rotation = rot;
                    }


                    if (i % 2 == 0)
                    {
                        //朝向
                        Quaternion rot =
                            Quaternion.Euler(m_transform.rotation.eulerAngles.x,
                                             m_transform.rotation.eulerAngles.y + diffAngle * (i + 1) * 0.5f, m_transform.rotation.eulerAngles.z);

                        objBullet.transform.rotation = rot;
                    }
                    else
                    {
                        //朝向
                        Quaternion rot =
                            Quaternion.Euler(m_transform.rotation.eulerAngles.x,
                                             m_transform.rotation.eulerAngles.y - diffAngle * (i + 1) * 0.5f, m_transform.rotation.eulerAngles.z);

                        objBullet.transform.rotation = rot;
                    }
                }

                // 弹弹乐
                TanTanLe tantan = objBullet.GetComponent <TanTanLe>();
                if (tantan != null)
                {
                    BulletParam param = new BulletParam();
                    param.flySpeed            = m_fireFlyAttackDesc.flySpeed;
                    param.flyTime             = m_fireFlyAttackDesc.flyTime;
                    param.skillID             = m_skillBase.m_skillID;
                    param.castObj             = m_skillBase.m_actor.thisGameObject;
                    param.damageActorTypeList = m_fireFlyAttackDesc.aimActorTypeList;

                    param.bThroughFlag  = m_fireFlyAttackDesc.bThroughFlag;
                    param.projectile    = m_fireFlyAttackDesc.projectile;
                    param.TanTanLeCount = m_fireFlyAttackDesc.TanTanLeCount;
                    param.TanTanLeDis   = m_fireFlyAttackDesc.TanTanLeDis;
                    param.dizzyTime     = m_fireFlyAttackDesc.dizzyTime;

                    param.targetpos = targetpos;
                    if (m_skillBase != null && m_skillBase.m_actor != null)
                    {
                        ActorObj actorobj = m_skillBase.m_hitActor;
                        if (actorobj != null)
                        {
                            param.aimTransform = actorobj.transform;
                        }
                        else
                        {
                            actorObj = m_skillBase.m_actor.GetAttackObj();
                            if (actorObj == null)
                            {
                                actorObj = m_skillBase.m_hitActor;
                            }
                            if (actorobj != null)
                            {
                                param.aimTransform = actorobj.transform;
                            }
                            {
                                ActorObj gameobj = m_skillBase.GetSelTarget();
                                if (gameobj != null)
                                {
                                    param.aimTransform = gameobj.transform;
                                }
                            }
                        }
                    }
                    tantan.Init(param);
                }
                else // 子弹
                {
                    Bullet      bullet = objBullet.GetComponent <Bullet>();
                    BulletParam param  = new BulletParam();

                    param.m_skillBase = m_skillBase;

                    param.flySpeed            = m_fireFlyAttackDesc.flySpeed;
                    param.flyTime             = m_fireFlyAttackDesc.flyTime;
                    param.skillID             = m_skillBase.m_skillID;
                    param.castObj             = m_skillBase.m_actor.thisGameObject;
                    param.damageActorTypeList = m_fireFlyAttackDesc.aimActorTypeList;

                    param.bThroughFlag              = m_fireFlyAttackDesc.bThroughFlag;
                    param.projectile                = m_fireFlyAttackDesc.projectile;
                    param.targetpos                 = targetpos;
                    param.bTakeAwayTarget           = m_fireFlyAttackDesc.bTakeAwayTarget;
                    param.disappearWhenTouchWall    = m_fireFlyAttackDesc.disappearWhenTouchWall;
                    param.bCanNotMoveWhenTakenAway  = m_fireFlyAttackDesc.bCanNotMoveWhenTakenAway;
                    param.bTraceTarget              = m_fireFlyAttackDesc.bTraceTarget;
                    param.bAttachToSkill            = m_fireFlyAttackDesc.bAttachToSkill;
                    param.bAttackMoreThanOnce       = m_fireFlyAttackDesc.bAttackMoreThanOnce;
                    param.bEndTheSkillWhenDisappear = m_fireFlyAttackDesc.bEndTheSkillWhenDisappear;
                    bullet.Init(param);
                }
            }
        }