// AffectedByPulseAttack GetElementsOnReachOfPulseAttack(float pulseReach, float pulseRadius) { // AffectedByPulseAttack affectedByPulseAttack = new AffectedByPulseAttack(); // Collider[] collidersOnReach = Physics.OverlapSphere(transform.position, pulseReach); // for (int i = 0; i < collidersOnReach.Length; i++) { //Si no entra en el ángulo, siguiente Vector3 pointFromPlayer = collidersOnReach[i].transform.position - transform.position; if (Vector3.Angle(pointFromPlayer, transform.forward) > pulseRadius) { continue; } // Chequemamos primero por enemy colliders EnemyCollider enemyCollider = collidersOnReach[i].GetComponent <EnemyCollider>(); if (enemyCollider != null) { affectedByPulseAttack.affectedEnemyColliders.Add(enemyCollider); } // Después enemy consistencies EnemyConsistency enemyConsistency = collidersOnReach[i].GetComponent <EnemyConsistency>(); if (enemyConsistency == null) { enemyConsistency = collidersOnReach[i].GetComponentInParent <EnemyConsistency>(); } if (enemyConsistency != null) { affectedByPulseAttack.affectedEnemyConsistencies.Add(enemyConsistency); } // WeakPoint weakPoint = collidersOnReach[i].GetComponent <WeakPoint>(); if (weakPoint != null) { Debug.Log("Adding weakpoint"); affectedByPulseAttack.affectedWeakPoints.Add(weakPoint); } // Terrenos destruibles DestructibleTerrain destructibleTerrain = collidersOnReach[i].GetComponent <DestructibleTerrain>(); if (destructibleTerrain == null) { destructibleTerrain = collidersOnReach[i].GetComponentInParent <DestructibleTerrain>(); } if (destructibleTerrain != null) { affectedByPulseAttack.affectedDestructibleTerrains.Add(destructibleTerrain); } // Y por último rigidbodies // Estos solo deberían entrar en la lista si no ha cuajado arriba Rigidbody rigidbody = collidersOnReach[i].GetComponent <Rigidbody>(); if (rigidbody != null && enemyConsistency == null) { affectedByPulseAttack.affectedRigidbodies.Add(rigidbody); } } return(affectedByPulseAttack); }
// void AlternativePulseAttack() { // TODO: Trabajar estos parámetros float coneRadius = 20.0f; float coneReach = 50.0f; float pulseForceToApply = (gameManager.playerAttributes.forcePerSecond.CurrentValue * chargedAmount); // AffectedByPulseAttack elementsOnReachOfPulseAttack = GetElementsOnReachOfPulseAttack(coneReach, coneRadius); Vector3 pointFromPlayer; // Primero enemy colliders for (int i = 0; i < elementsOnReachOfPulseAttack.affectedEnemyColliders.Count; i++) { pointFromPlayer = elementsOnReachOfPulseAttack.affectedEnemyColliders[i].transform.position - transform.position; elementsOnReachOfPulseAttack.affectedEnemyColliders[i].ReceivePulseDamage(pointFromPlayer.normalized * pulseForceToApply); } // Enemy consistencies for (int i = 0; i < elementsOnReachOfPulseAttack.affectedEnemyConsistencies.Count; i++) { pointFromPlayer = elementsOnReachOfPulseAttack.affectedEnemyConsistencies[i].transform.position - transform.position; elementsOnReachOfPulseAttack.affectedEnemyConsistencies[i].ReceivePulseDamage(pointFromPlayer.normalized * pulseForceToApply); } // Weakpoints for (int i = 0; i < elementsOnReachOfPulseAttack.affectedWeakPoints.Count; i++) { pointFromPlayer = elementsOnReachOfPulseAttack.affectedWeakPoints[i].transform.position - transform.position; elementsOnReachOfPulseAttack.affectedWeakPoints[i].ReceivePulseDamage(pointFromPlayer.normalized * pulseForceToApply); } // Destructible terrains for (int i = 0; i < elementsOnReachOfPulseAttack.affectedDestructibleTerrains.Count; i++) { pointFromPlayer = elementsOnReachOfPulseAttack.affectedDestructibleTerrains[i].transform.position - transform.position; elementsOnReachOfPulseAttack.affectedDestructibleTerrains[i].ReceivePulseImpact(pointFromPlayer.normalized * pulseForceToApply); } // Y rigidbodies for (int i = 0; i < elementsOnReachOfPulseAttack.affectedRigidbodies.Count; i++) { pointFromPlayer = elementsOnReachOfPulseAttack.affectedRigidbodies[i].transform.position - transform.position; elementsOnReachOfPulseAttack.affectedRigidbodies[i].AddForce(pointFromPlayer.normalized * pulseForceToApply, ForceMode.Impulse); } // rb.AddForce(-transform.forward * pulseForceToApply, ForceMode.Impulse); ChangeDampingType(DampingType.ThreeDimensional); // GameObject muzzleParticles = Instantiate(shootParticlePrefab, chargedProyectilePoint.position, chargedProyectilePoint.rotation); muzzleParticles.transform.localScale = Vector3.one * (1 + (chargedAmount * 10)); }