IEnumerator CheckObject() { while (!this.canLauchAxe) { yield return(new WaitForEndOfFrame()); bool check = true; bool objetFind = false; Collider[] col = Physics.OverlapCapsule(this.pointOneAxeLaunch.position, this.pointTwoAxeLaunch.position, axeRadiusLaunchCheck, ~ignoreLayerMask); Vector3 dir = myGuardian.transform.position - this.transform.position; if (col != null && check && !objetFind) { for (int i = 0; i < col.Length; i++) { GuardianTraining g = col[i].GetComponent <GuardianTraining>(); PillierTraining p = col[i].GetComponent <PillierTraining>(); if (g != null) { if (g != myGuardian && g != lastGuardian)//&& !g.IsStuned) { if (!g.IsStuned && !g.IsDie && !g.IsInvinsible) { lastGuardian = g; if (!this.BackToBucheron) { dir = -dir; } //dir.y = 0; g.SetStun(dir.normalized, forcePush); objetFind = true; /////Son collisionPlayer.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(transform.position)); collisionPlayer.start(); /////Son GameObject go = Instantiate(contactParticulePrefab, this.transform.position, Quaternion.LookRotation(-dir, Vector3.up)); Destroy(go, 1f); check = false; } } } else if (p != null && this.canDestroyPillier) { p.DestroyPillier(); /////Son collisionDecor.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(transform.position)); collisionDecor.start(); /////Son objetFind = true; check = false; } else { /////Son collisionDecor.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(transform.position)); collisionDecor.start(); /////Son objetFind = true; check = false; } } } if (objetFind) { //ActiveBackToBucheron(); this.axeLaunchTimer = 1f; } } yield break; }
/*GuardianTraining currentEnemyGuardian = null; * * public IEnumerator LaunchMeleeAttack() * { * this.IsFusRoDah = true; * StartCoroutine(this.StopMeleeAttack()); * yield return new WaitForEndOfFrame(); * while (this.IsFusRoDah) * { * yield return new WaitForSeconds(12.0f/60.0f); * MeleeAttack(); * } * * this.IsFusRoDah = false; * yield break; * } * * private void MeleeAttack() * { * Collider[] col = Physics.OverlapSphere(this.meleeHitPosition.position, this.detectionHitRadius, this.meleeHitCheckLayerMask); * * if (col != null) * { * for (int i = 0; i < col.Length; i++) * { * Pillier pillier = col[i].GetComponent<Pillier>(); * * if (!this.IsStuned) * { * if (pillier != null) * { * Debug.Log("Pillier hit"); * pillier.DestroyPillier(); * i = col.Length; * return; * } * } * * if (this.IsStuned) * { * this.IsFusRoDah = false; * } * } * } * } * * IEnumerator StopMeleeAttack() * { * yield return new WaitForSeconds(this.durationMeleeAttack); * this.IsFusRoDah = false; * this.IsCooldown = true; * currentEnemyGuardian = null; * SetCooldown(); * yield break; * } */ #endregion #region FusRoDa public void FusRoDa() { this.IsFusRoDah = true; switch (mode) { case FusRoDaMode.Cone: Vector3 position = this.transform.position + (this.CameraRef.rotation * Vector3.forward * (this.distanceCheck / 2)); Vector3 direction = this.cameraRef.rotation * Vector3.forward; ParticleSystem frdParticleSystem = Instantiate(this.fusRoDaFeedback, this.transform.position, this.cameraRef.rotation); ParticleSystem.ShapeModule shape = frdParticleSystem.shape; shape.length = this.distanceCheck; shape.angle = this.angleMaxToCheckCone; Collider[] guardianColliders = Physics.OverlapSphere(position, fusDetectionRadius, this.fusRoDahLayerMask); if (guardianColliders.Length > 0) { foreach (var guard in guardianColliders) { float distance = Vector3.Distance(this.transform.position, guard.transform.position); float angle = Vector3.Angle(this.transform.forward, guard.transform.position - this.transform.position); if (angle <= this.angleMaxToCheckCone && distance <= this.distanceCheck) { if (!Physics.Raycast(this.transform.position, guard.transform.position - this.transform.position, distance, ~this.fusIgnoreLayerMask)) { float force = this.forcePush; force = force * (1 - ((Vector3.Distance(this.transform.position, guard.transform.position)) / this.distanceCheck) / this.diviseurDistance); GuardianTraining guardian = guard.GetComponent <GuardianTraining>(); if (guardian != null && guardian != this) { guardian.SetStun(direction.normalized, force); } } } } StartCoroutine(CoolDownFus()); Destroy(frdParticleSystem.gameObject, 0.8f); } break; case FusRoDaMode.Laser: this.pointStartLaser.rotation = cameraRef.rotation; this.pointEndLaser.localPosition = new Vector3(this.pointEndLaser.localPosition.x, this.pointEndLaser.localPosition.y, this.distanceCheck); ParticleSystem frParticleSystem = Instantiate(this.fusRoDaFeedback, this.startPointFus.position, this.cameraRef.rotation); ParticleSystem.ShapeModule shpe = frParticleSystem.shape; shpe.length = this.distanceCheck; shpe.angle = 0f; shpe.radius = this.fusDetectionRadius; Collider[] laserCol = Physics.OverlapCapsule(this.pointStartLaser.position, this.pointEndLaser.position, this.fusDetectionRadius, this.fusRoDahLayerMask); Vector3 dir = this.cameraRef.rotation * Vector3.forward; if (laserCol.Length > 0) { foreach (var guard in laserCol) { float distance = Vector3.Distance(this.startPointFus.position, guard.transform.position); //float angle = Vector3.Angle(this.transform.forward, guard.transform.position - this.transform.position); if (distance <= this.distanceCheck) { if (!Physics.Raycast(this.startPointFus.position, guard.transform.position - this.transform.position, distance, ~this.fusIgnoreLayerMask)) { float force = this.forcePush; force = force * (1 - ((Vector3.Distance(this.startPointFus.position, guard.transform.position)) / this.distanceCheck) / this.diviseurDistance); GuardianTraining guardian = guard.GetComponent <GuardianTraining>(); if (guardian != null && guardian != this) { guardian.SetStun(dir.normalized, force); } } } } StartCoroutine(CoolDownFus()); Destroy(frParticleSystem.gameObject, 0.8f); } break; } }