void OnTriggerEnter(Collider other) { if (0 != (attackLayer.value & (1 << other.gameObject.layer))) { SkEntity hitEntity = other.gameObject.GetComponentInParent <SkEntity>(); if (null == hitEntity || hitEntity == m_SkEntity) { return; } PEDefenceTrigger hitTrigger = other.GetComponent <PEDefenceTrigger>(); if (null != hitTrigger) { if (!m_HitTriggers.Contains(hitTrigger) && !m_EffectedTriggers.Contains(hitTrigger)) { if (CheckHit(hitTrigger)) { m_EffectedTriggers.Add(hitTrigger); } else { m_HitTriggers.Add(hitTrigger); } } } else { OnHitCollider(other); } } }
void OnHitTrigger(PEDefenceTrigger hitTrigger, PECapsuleHitResult result) { if (hitTrigger.transform.IsChildOf(motionMgr.transform)) { return; } animScaleStartTime = Time.time; // PESkEntity skEntity = hitTrigger.GetComponentInParent<PESkEntity>(); }
void OnTriggerExit(Collider other) { if (0 != (attackLayer.value & (1 << other.gameObject.layer))) { PEDefenceTrigger hitTrigger = other.GetComponent <PEDefenceTrigger>(); if (null != hitTrigger) { m_HitTriggers.Remove(hitTrigger); } } }
void OnHit(PEDefenceTrigger defenceTrigger, PECapsuleHitResult result) { if (null != m_PEEntity && m_PEEntity.IsDeath()) { return; } if (null != defenceTrigger) { SkEntity hitEntity = defenceTrigger.GetComponentInParent <SkEntity>(); bool isTerrain = PETools.PEUtil.IsVoxelOrBlock45(hitEntity); if (isTerrain || PETools.PEUtil.CanDamage(m_SkEntity, hitEntity)) { if (null != onHitSkEntity) { onHitSkEntity(hitEntity); } } else { return; } } if (null != onHitTrigger) { onHitTrigger(defenceTrigger, result); } if (null != m_SkEntity) { m_SkEntity.CollisionCheck(result); } if (null != m_PEEntity) { m_PEEntity.SendMsg(EMsg.Battle_AttackHit, result); } #if UNITY_EDITOR if (showDebugInfo) { DrawArrow arrow = new DrawArrow(); arrow.pos = result.hitPos; arrow.rot = Quaternion.LookRotation(result.hitDir); hitResults.Add(arrow); } #endif }
public void Reset() { modelController = PEUtil.GetCmpt <PEModelController>(transform); ragdollController = PEUtil.GetCmpt <PERagdollController>(transform); ikArray = PEUtil.GetCmpts <IK>(transform); ikFlashLight = PEUtil.GetCmpt <IKFlashLight>(transform); fbbik = PEUtil.GetCmpt <FullBodyBipedIK>(transform); grounderFBBIK = PEUtil.GetCmpt <GrounderFBBIK>(transform); humanPhyCtrl = PEUtil.GetCmpt <HumanPhyCtrl>(transform); ikAimCtrl = PEUtil.GetCmpt <IKAimCtrl>(transform); ikAnimEffectCtrl = PEUtil.GetCmpt <IKAnimEffectCtrl>(transform); ikDrive = PEUtil.GetCmpt <IKDrive>(transform); defenceTrigger = PEUtil.GetCmpt <PEDefenceTrigger>(transform); pathFinder = PEUtil.GetCmpt <PEPathfinder>(transform); motor = PEUtil.GetCmpt <PEMotor>(transform); steerAgent = PEUtil.GetCmpt <Steer3D.SteerAgent>(transform); animFollow_AF = PEUtil.GetCmpt <AnimFollow_AF>(transform); beatParam = PEUtil.GetCmpt <BeatParam>(transform); moveParam = PEUtil.GetCmpt <MoveParam>(transform); barrelController = PEUtil.GetCmpt <PEBarrelController>(transform); billBoard = PEUtil.GetCmpt <BillBoard>(transform); armorBones = PEUtil.GetCmpt <ArmorBones>(transform); visions = PEUtil.GetCmpts <PEVision>(transform); hears = PEUtil.GetCmpts <PEHearing>(transform); native = PEUtil.GetCmpt <PENative>(transform); monster = PEUtil.GetCmpt <PEMonster>(transform); if (null != modelController) { modelController.ResetModelInfo(); } if (null != animFollow_AF) { animFollow_AF.ResetModelInfo(); } if (null != ragdollController) { ragdollController.ResetRagdoll(); } }
public void SyncBone(PEDefenceTrigger other) { if (null == other) { return; } modelRoot = other.modelRoot; centerBone = other.centerBone; for (int i = 0; i < defenceParts.Length; i++) { for (int j = 0; j < other.defenceParts.Length; j++) { if (defenceParts[i].name == other.defenceParts[j].name) { defenceParts[i].capsule.trans = other.defenceParts[j].capsule.trans; } } } UpdateInfo(); }
bool CheckHit(PEDefenceTrigger defenceTrigger) { defenceTrigger.UpdateInfo(); PECapsuleHitResult mostCross = null; for (int i = 0; i < attackParts.Length; i++) { if (attackParts[i].capsule.enable) { for (int j = 0; j < defenceTrigger.defenceParts.Length; j++) { if (defenceTrigger.defenceParts[j].capsule.enable) { PECapsuleHitResult result; if (attackParts[i].capsule.CheckCollision(defenceTrigger.defenceParts[j].capsule, out result)) { result.selfAttackForm = attackParts[i].attackForm; result.hitDefenceType = defenceTrigger.defenceParts[j].defenceType; result.damageScale = defenceTrigger.defenceParts[j].damageScale; if (null == mostCross || mostCross.distance < result.distance) { mostCross = result; } } } } } } if (null != mostCross) { OnHit(defenceTrigger, mostCross); return(true); } return(false); }
void ChangeAttackTarget() { m_AttackTargetDir = Vector3.zero; if (null != ikCmpt && null != trans) { Vector3 checkCenterPos = trans.position + m_AttackHeight * Vector3.up; if (firstPersonAttack) { m_AttackTargetDir = Vector3.Normalize(ikCmpt.aimTargetPos - PETools.PEUtil.MainCamTransform.position); } else { float minDis = 100f; List <ViewCmpt> viewCmpts = new List <ViewCmpt>(); Collider[] findCols = Physics.OverlapSphere(checkCenterPos, m_AttackChecRange, m_AttackLayer.value); Vector3 attackDirH = m_AttackDir; attackDirH.y = 0; int selfPlayerID = Mathf.RoundToInt(motionMgr.Entity.GetAttribute(AttribType.DefaultPlayerID)); foreach (Collider col in findCols) { BiologyViewCmpt findView = col.GetComponentInParent <BiologyViewCmpt>(); if (null != findView && viewCmpt != findView && !viewCmpts.Contains(findView)) { viewCmpts.Add(findView); if (findView.IsRagdoll) { continue; } if (!ForceSetting.Instance.Conflict(selfPlayerID, Mathf.RoundToInt(findView.Entity.GetAttribute(AttribType.DefaultPlayerID)))) { continue; } PEDefenceTrigger defencetrigger = col.GetComponent <PEDefenceTrigger>(); if (null == defencetrigger) { Transform centerTrans = findView.centerTransform; Vector3 dir = centerTrans.position - checkCenterPos; float dis = dir.magnitude; dir.y = 0; if (null != centerTrans && dis < minDis && Vector3.Angle(dir, attackDirH) < m_LockMaxAngle) { minDis = dis; m_AttackTargetDir = Vector3.Normalize(centerTrans.position - checkCenterPos); } } else { PECapsuleHitResult result; if (defencetrigger.GetClosest(checkCenterPos, m_AttackChecRange, out result)) { Vector3 dir = result.hitPos - checkCenterPos; float dis = dir.magnitude; Vector3 dirH = dir; dirH.y = 0; if (dis < minDis && Vector3.Angle(dirH, attackDirH) < m_LockMaxAngle) { float angle = Vector3.Angle(dir, attackDirH); if (angle < m_LockMaxAngle) { m_AttackTargetDir = dir.normalized; } else { m_AttackTargetDir = Vector3.Slerp(attackDirH.normalized, dir.normalized, m_LockMaxAngle / angle); } } } } } } } ikCmpt.aimActive = Vector3.zero != m_AttackTargetDir; if (ikCmpt.aimActive && null != ikCmpt.m_IKAimCtrl) { ikCmpt.m_IKAimCtrl.StartSyncAimAxie(); } } }
protected IEnumerator ProcPostBoneLoad() { //biologyViewRoot.gameObject.SetActive (false); if (monoPhyCtrl == null) { monoPhyCtrl = biologyViewRoot.humanPhyCtrl; } if (monoIKAimCtrl == null) { monoIKAimCtrl = biologyViewRoot.ikAimCtrl; } if (monoIKAnimCtrl == null) { monoIKAnimCtrl = biologyViewRoot.ikAnimEffectCtrl; } if (monoModelCtrlr == null) { monoModelCtrlr = biologyViewRoot.modelController; } if (monoRagdollCtrlr == null) { monoRagdollCtrlr = biologyViewRoot.ragdollController; } if (monoDefenceTrigger == null) { monoDefenceTrigger = biologyViewRoot.defenceTrigger; } m_MeshBuildEnd = false; if (monoRagdollCtrlr != null) { monoRagdollCtrlr.SetHandler(this); //EMsg.View_Ragdoll_Build } // Collider ignore and other if (monoModelCtrlr != null) { SetupMaterials(mColorID, GetModelName()); if (Entity.proto == EEntityProto.Monster && Entity.Race == ERace.Mankind) { monoModelCtrlr.gameObject.layer = Layer.AIPlayer; } PEUtil.IgnoreCollision(monoModelCtrlr.colliders, monoModelCtrlr.colliders); if (monoRagdollCtrlr != null) { PEUtil.IgnoreCollision(monoModelCtrlr.colliders, monoRagdollCtrlr.colliders); } } BuildOutCollider(biologyViewRoot.gameObject); if (Entity.IsDeath()) { OnDeath(null, null); } else if (monoModelCtrlr != null) { monoModelCtrlr.ActivateDeathMode(false); } HideView(0.01f); if (Entity.Id == 9008) { ActivatePhysics(m_PhyActive); } DoActivateInjured(); yield return(0); if (null == biologyViewRoot) { yield break; } // Proc Mesh if (_coroutineMeshProc != null) { yield return(biologyViewRoot.StartCoroutine(_coroutineMeshProc())); } m_MeshBuildEnd = true; if (null == biologyViewRoot) { yield break; } if (null == Entity) { yield break; } // Send Msg if (monoModelCtrlr != null) { Profiler.BeginSample("EMsg.View_Model_Build"); Entity.SendMsg(EMsg.View_Model_Build, monoModelCtrlr.gameObject, biologyViewRoot); Profiler.EndSample(); yield return(0); } if (null == biologyViewRoot) { yield break; } if (null == Entity) { yield break; } Profiler.BeginSample("EMsg.View_Prefab_Build"); Entity.SendMsg(EMsg.View_Prefab_Build, this, biologyViewRoot); Profiler.EndSample(); yield return(0); if (null == biologyViewRoot) { yield break; } //biologyViewRoot.gameObject.SetActive (true); biologyViewRoot.StartCoroutine(FadeInDelay(0.01f, 3.0f)); // Note: prev version use this Monobehavior(NOT ROOT) to start Coroutine }