//int m_num = 1; //初始化 public void Init(GameObject obj) { m_actorObject = obj; //m_ani = m_actorObject.GetComponent<Animation>(); m_actor = (m_actorObject.GetComponent <ActorObj>()); m_transform = m_actorObject.transform; m_animationCurveData = m_actorObject.GetComponent <AnimationCurveData>(); if (m_animationCurveData == null) { //LogMgr.LogError(obj.name + ":缺少动画曲线组件AnimationCurveData,可能将导致异常。美术请检查该模型!!!"); } if (m_actor != null && m_actor != null) { m_curRadius = m_actor.GetColliderRadius(); } else { LogMgr.LogError("Please Check m_actor:" + m_actor + " : " + m_actor); } //如果是PVP状态 if (CoreEntry.gGameMgr.IsPvpState()) { m_curRadius += 1.8f; } }
//位移开始 public bool StartMove(string clipName, Vector3 dstPos, CurveMoveParam param, int uuid) { //m_curveMoveParam = param; m_needMove = false; m_curRadius = m_actor.GetColliderRadius(); //如果是PVP状态 if (CoreEntry.gGameMgr.IsPvpState()) { m_curRadius += 1.8f; } m_MoveDestPos = dstPos; if (MoveToPos(clipName, dstPos)) { m_needMove = true; m_uuid = uuid; return(true); } return(false); }
public override void Init(int resID, int ConfigID, long ServerID, string strEnterAction = "", bool isNpc = false) { m_shadowType = 0; base.Init(resID, ConfigID, ServerID, strEnterAction, isNpc); m_PortalCfg = ConfigManager.Instance.Map.GetPortalConfig(ConfigID); m_IgnoreEnter = false; m_EffectObj = null; if (null != m_PortalCfg) { //碰撞体 SphereCollider collider = gameObject.GetComponent <SphereCollider>(); if (null == collider) { collider = gameObject.AddComponent <SphereCollider>(); } collider.isTrigger = true; collider.center = Vector3.zero; collider.radius = m_PortalCfg.Get <float>("trigger_dist"); //判断是否初始点在检测范围内 ActorObj actor = CoreEntry.gActorMgr.GetActorByServerID(MainRole.Instance.serverID); if (null != actor) { float distance = Vector3.Distance(actor.transform.position, transform.position); float cdRadius = actor.GetColliderRadius(); distance = distance - cdRadius - 0.2f; if (distance <= m_PortalCfg.Get <float>("trigger_dist")) { // m_IgnoreEnter = true; } } //特效 GameObject obj = CoreEntry.gGameObjPoolMgr.Instantiate(m_PortalCfg.Get <string>("pfx"));//(GameObject)Instantiate(CoreEntry.gResLoader.LoadResource(m_PortalCfg.pfx)); if (null != obj) { obj.transform.parent = transform; obj.transform.localPosition = new Vector3(0f, m_PortalCfg.Get <int>("effect_high"), 0f); obj.transform.localScale = Vector3.one; } m_EffectObj = obj; } }
public void Init() { m_gameDataBase = CoreEntry.gGameDBMgr; m_actor = this.gameObject.GetComponent <ActorObj>(); m_BehitState = m_actor.behitState; m_isUseGravity = false; m_gravityMotionType = GravityMotionType.GMT_NONE; m_attackObjForward = Vector3.zero; m_startToSkyPos = Vector3.zero; F_ACCE = 0; nCount = 0; m_curRadius = m_actor.GetColliderRadius(); CancelInvoke("AutoCancelStatic"); CancelInvoke("MoveDistanceEnd"); }
public override void OnEnter(ActorObj actor) { if (actor == null) { return; } //塔不没有受击 bool bChangeColor = true; m_state = ACTOR_STATE.AS_BEHIT; m_actor = actor; m_transform = actor.transform; //if (m_actor != null) //{ // m_actor.m_bIsInAttack = true; //} m_behitParame = m_actor.damageBebitParam; monsterObj = m_actor as MonsterObj; if (monsterObj != null) { if (monsterObj.IsVip) { monsterObj.VipIsUnderAttack(); } } if (CurParam != null && CurParam != null) { m_curSkillID = CurParam.skillID; } //m_GameDataBase = CoreEntry.gGameDBMgr; if (CurParam != null && CurParam.AttackActor != null) { m_attack = CurParam.AttackActor; } m_groundLayerMask = 1 << LayerMask.NameToLayer("ground"); //m_baseTool = CoreEntry.gBaseTool; m_gravityMotionBase = this.gameObject.GetComponent <GravityMotionBase>(); //m_gravityMotionBase.enabled = true; //m_ActionEfxList = new List<EfxAttachAction>(); //修改shader //if (m_actor.ChangeShader("Mobile/BeingHitted")) if (monsterObj && monsterObj.m_bIsTower) { bChangeColor = false; } if (bChangeColor && m_actor.m_bUseBehitColor && m_actor.mActorType == ActorType.AT_MONSTER && m_attack != null && m_attack is PlayerObj) { m_actor.SetBrightenShader(); Invoke("RecoverShader", 0.2f); } // if (m_actor.mActorType == ActorType.AT_BOSS && m_actor.AddShader("DZSMobile/Balloon")) //// if (m_actor.mActorType == ActorType.AT_BOSS && m_actor.ChangeShader("DZSMobile/Balloon")) // { // Invoke("RemoveShader", 0.2f); // } if (m_actor.mActorType == ActorType.AT_BOSS && m_actor.IsInQiJue()) { CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_Boss_QiJue, null); } m_curRadius = m_actor.GetColliderRadius(); //如果浮空,就给浮空处理受击 if (m_gravityMotionBase != null && m_gravityMotionBase.isUseGravityState) { m_gravityMotionBase.DoBehit(); } else { m_bHitBack = false; m_isNonControlProtect = false; isNonControl = false; m_isHitDownState = false; //小怪倒地被击 if (m_gravityMotionBase != null) { m_gravityMotionBase.BreakExitBehitState(); } //面向被击玩家 // if (m_actor.actorCreatureDisplayDesc.chIsBehitNotLookAtTarget == 0) if (m_actor.mActorType != ActorType.AT_LOCAL_PLAYER && m_actor.mActorType != ActorType.AT_MECHANICS && //机械类不转向 m_attack != null && !(m_actor is MonsterObj && !m_actor.bHitTurn)) { //自动释放法宝技能 CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_AutoUseMagicKeySkill, null); //只旋转Y轴 Vector3 lookPos = new Vector3(m_attack.transform.position.x, m_transform.position.y, m_attack.transform.position.z); m_transform.LookAt(lookPos); } DoBehitEx(); } }
protected override void CalculateDamage() { CancelInvoke("CalculateDamage"); //bool isDamageSuccess = false; List <GameObject> targetList = new List <GameObject>(); LuaTable skillDesc = ConfigManager.Instance.Skill.GetSkillConfig(m_skillBase.m_skillID); // 把自己添加进去 targetList.Insert(0, m_skillBase.m_actor.gameObject); //复制目标队列 List <ActorObj> actors = CoreEntry.gActorMgr.GetAllMonsterActors(); GameObject[] objList = new GameObject[actors.Count]; float[] fDisList = new float[objList.Length]; for (int i = 0; i < objList.Length; i++) { objList[i] = actors[i].gameObject; fDisList[i] = Vector3.Distance(m_skillBase.m_actor.transform.position, objList[i].transform.position); } // 按距离排序,否则特效的效果会不好 // 冒泡排序 for (int i = 1; i < objList.Length; i++) { for (int j = objList.Length - 1; j >= i; j--) { if (fDisList[j] < fDisList[j - 1]) { float tmp = fDisList[j - 1]; fDisList[j - 1] = fDisList[j]; fDisList[j] = tmp; GameObject tmpObj = objList[j - 1]; objList[j - 1] = objList[j]; objList[j] = tmpObj; } } } for (int i = 0; i < objList.Length; i++) { GameObject obj = objList[i]; ActorObj actorBase = (obj.GetComponent <ActorObj>()); if (!m_skillBase.m_actor.IsSkillAim((sbyte)m_skillBase.m_skillDesc.Get <int>("faction_limit"), actorBase)) { continue; } //按伤害范围算出受伤害对象,具体有没有伤害,还要看对应的属性(免疫等) bool isSkillSuccess = m_skillMgr.IsSkillDamageRange(skillDesc.Get <int>("effect_1"), targetList[targetList.Count - 1].transform, // 已最后一个受击者为中立 obj.transform, actorBase.GetColliderRadius()); //伤害对象 if (isSkillSuccess) { targetList.Add(obj); } } //是否持续伤害 if (m_oneDamageInfo.isRepeatedly && m_repeateKeep > 0) { Invoke("CalculateDamage", m_oneDamageInfo.damageDiff / m_skillBase.m_speed); --m_repeateKeep; } if (targetList.Count > 1) { //GameObject obj1 = Instantiate(CoreEntry.gResLoader.LoadResource("Effect/scence/fx_shandianlian")) as GameObject;//CoreEntry.gGameObjPoolMgr.InstantiateEffect("Effect/scence/fx_shandianlian"); GameObject obj1 = CoreEntry.gGameObjPoolMgr.InstantiateEffect("Effect/scence/fx_shandianlian"); EfxLightningChain lighting = obj1.GetComponent <EfxLightningChain>(); lighting.Init(this, targetList); SceneEfxPool efx1 = obj1.GetComponent <SceneEfxPool>(); if (efx1 == null) { efx1 = obj1.AddComponent <SceneEfxPool>(); } efx1.Init(Vector3.zero, 2f); } }
void TakeAwayTargets(Vector3 translation) { Vector3 aimPos, wallPos, pos0, dir; List <int> NoUseList = null; if (m_TakeAwayGameObjectMap.Count > 0) { NoUseList = new List <int>(); } if (m_param.bCanNotMoveWhenTakenAway) { bool canMoveTarget = false; Vector3 tmpPos = this.transform.position; if (m_TakeAwayGameObjectMap.Count > 0) { //只有在地面上的位置,才是移动目标的有效位置 if (m_baseTool.IsAboveTheGround(tmpPos)) { canMoveTarget = true; } } if (canMoveTarget) { foreach (int i in m_TakeAwayGameObjectMap.Keys) { ActorObj actorBase = m_TakeAwayGameObjectMap[i].GetComponent <ActorObj>(); if (actorBase != null) { float radius = actorBase.GetColliderRadius(); if (BaseTool.instance.CanMoveToPos(actorBase.transform.position, tmpPos, radius)) { //m_TakeAwayGameObjectMap[i].transform.position = new Vector3(tmpPos.x, m_TakeAwayGameObjectMap[i].transform.position.y, tmpPos.z); BaseTool.SetPosition(m_TakeAwayGameObjectMap[i].transform, tmpPos); } } } } } else { foreach (int i in m_TakeAwayGameObjectMap.Keys) { if (m_TakeAwayGameObjectMap[i] != null) { aimPos = m_TakeAwayGameObjectMap[i].transform.position + translation; wallPos = m_baseTool.GetWallHitPoint(m_TakeAwayGameObjectMap[i].transform.position, aimPos); if (!wallPos.Equals(aimPos)) { // Debug.DrawLine(wallPos, aimPos,Color.cyan); dir = translation; dir.Normalize(); //存在空气墙 //unity的raycast是向下忽略的,所以不能再下边界做判断,给定的时候,往回取一点值 Vector3 wallGroundPos = m_baseTool.GetGroundPoint(wallPos - dir * 0.1f); float distance = Vector3.Distance(m_TakeAwayGameObjectMap[i].transform.position, wallGroundPos); distance -= 0.4f; pos0 = m_TakeAwayGameObjectMap[i].transform.position + translation.normalized * distance; aimPos = m_baseTool.GetGroundPoint(pos0); m_TakeAwayGameObjectMap[i].transform.Translate(aimPos - m_TakeAwayGameObjectMap[i].transform.position, Space.World); NoUseList.Add(i); } else { m_TakeAwayGameObjectMap[i].transform.Translate(translation, Space.World); } } } } if (NoUseList != null) { for (int i = 0; i < NoUseList.Count; ++i) { //清除物件前,恢复动作 ActorObj actorBase = m_TakeAwayGameObjectMap[NoUseList[i]].GetComponent <ActorObj>(); if (actorBase != null) { actorBase.CanCurveMove(); } m_TakeAwayGameObjectMap.Remove(NoUseList[i]); } } }
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 + "毫秒....."); } }
void ApplyForce(ActorObj actor) { Vector3 diff = (transform.position - actor.transform.position); if (actor.CheckIfNotBossOrInQijue()) { if (diff.sqrMagnitude <= radiusSQ) { Vector3 distance = diff.normalized * speed * Time.deltaTime; distance.y = 0; Vector3 dest = actor.transform.position + distance; if (BaseTool.instance.CanMoveToPos(actor.transform.position, dest, actor.GetColliderRadius())) { BaseTool.SetPosition(actor.transform, actor.transform.position + distance); } } } }
protected void NextAim() { hitCount--; if (hitCount <= 0) { AutoEnd(); return; } ActorObj aimActorBase = null; List <ActorObj> AIMList = new List <ActorObj>(); List <ActorObj> noDIZZYList = new List <ActorObj>(); // 下一个目标 //计算伤害 群体 List <ActorObj> actors = CoreEntry.gActorMgr.GetAllMonsterActors(); for (int i = 0; i < actors.Count; i++) { //对IOS出现怪物不动 报错的异常 进行错误处理 if (GameLogicMgr.checkValid(actors[i].gameObject) == false) { continue; } GameObject obj = actors[i].gameObject; ActorObj actorBase = actors[i]; //临时判断 ActorObj castBase = m_param.castObj.GetComponent <ActorObj>(); if (actorBase.mActorType == castBase.mActorType) { continue; } if (actorBase.IsDeath()) { continue; } if (!CoreEntry.gGameMgr.IsPvpState() && !castBase.IsAimActorType(actorBase))//IsAimActorType(actorBase.mActorType)) { continue; } if (obj.transform == m_aimTransform) // 跳过自己 { continue; } // 栅栏怪等建筑物不可以被击退,击飞,聚集,眩晕 //if (actorBase.actorCreatureInfo.behitMoveBase == 0 && actorBase.actorCreatureInfo.behitBackBase == 0 && actorBase.actorCreatureInfo.behitFlyBase == 0) //{ // continue; //} // 距离 if (m_aimTransform == null) { if (!CoreEntry.gBaseTool.IsPointInCircleXZ(m_param.castObj.transform.position, actorBase.transform.position, m_param.TanTanLeDis, actorBase.GetColliderRadius())) { continue; } } else if (!CoreEntry.gBaseTool.IsPointInCircleXZ(m_aimTransform.transform.position, actorBase.transform.position, m_param.TanTanLeDis, actorBase.GetColliderRadius())) { continue; } AIMList.Add(actorBase); if (actorBase.curActorState != ACTOR_STATE.AS_DIZZY) { noDIZZYList.Add(actorBase); } if (aimActorBase == null) { aimActorBase = actorBase; continue; } } // 在没有眩晕的怪之间随机 if (noDIZZYList.Count > 0) { aimActorBase = noDIZZYList[Random.Range(0, noDIZZYList.Count)]; } else // 在眩晕的怪之间随机 if (AIMList.Count > 0) { aimActorBase = AIMList[Random.Range(0, AIMList.Count)]; } if (aimActorBase != null) { m_aimTransform = aimActorBase.transform; if (objEfx != null) { objEfx.SetActive(true); } if (GetComponent <Collider>() != null) { GetComponent <Collider>().enabled = false; GetComponent <Collider>().enabled = true; } } else { AutoEnd(); // 没有目标就消失了 } }