// 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 SpawnBulletHole(Vector3 point, Vector3 normal, GameObject objectToParent) { // PlayerIntegrity playerIntegrity = objectToParent.GetComponent <PlayerIntegrity>(); // Error control vago if (bulletHolePrefab == null || playerIntegrity != null) { return; } // Decidimos si crear agujero de bala o churrete de sangre EnemyCollider enemyCollider = objectToParent.GetComponent <EnemyCollider>(); WeakPoint weakPoint = objectToParent.GetComponent <WeakPoint>(); GameObject prefabToUse = (enemyCollider != null || weakPoint != null) ? bulletHoleBugPrefab : bulletHolePrefab; // Y lo creamos GameObject newBulletHole = Instantiate(prefabToUse, point, Quaternion.identity); newBulletHole.transform.rotation = Quaternion.LookRotation(newBulletHole.transform.forward, normal); // Lo movemos un pelin para evitar el z clipping newBulletHole.transform.position += newBulletHole.transform.up * 0.01f; newBulletHole.transform.SetParent(objectToParent.transform); }
/// <summary> /// For now is used for weakpoints /// </summary> void EnemyInfoSimple() { // TODO: Sacar distancia float distance = (playerIntegrity.transform.position - EnemyAnalyzer.enemyTransform.position).magnitude; int distanceToShow = (int)distance; GUI.Label(new Rect(Screen.width / 2 + 150, Screen.height / 2, 300, 30), "Distance: " + distanceToShow, guiSkin.label); // Empezamos pintando el marcardor en la posición del enemigo en patnalla Vector3 enemyScreenPosition = Camera.main.WorldToViewportPoint(cameraControl.CurrentTarget.position); //GUI.DrawTexture(new Rect( // enemyScreenPosition.x * Screen.width - 50, // Screen.height - enemyScreenPosition.y * Screen.height - 50, 100, 100), // enemyMarkerTextureRed); GUI.DrawTexture(new Rect( (enemyScreenPosition.x * Screen.width) - 50, Screen.height - (enemyScreenPosition.y * Screen.height) - 50, 100, 100), enemyMarkerTextureRed); // WeakPoint weakPoint = EnemyAnalyzer.enemyTransform.GetComponent <WeakPoint>(); if (weakPoint != null) { // Barra de vida float weakPointHealth = weakPoint.CurrentHealthPoins / weakPoint.maxHealthPoints; weakPointHealth = Mathf.Clamp01(weakPointHealth); GUI.DrawTexture(new Rect(Screen.width / 2 + 150, Screen.height / 2 - 30, weakPointHealth * 100f, 20), enemyHealthTexture); //GUI.Label(new Rect(Screen.width / 2 + 150, Screen.height / 2 - 30, 100f, 20), " " + weakPoint.CurrentHealthPoins); } }
/// <summary> /// Función que te busca puntos debiles /// Devuelve booleano para cuando se necesite como trigger /// TODO: Habrá que hacer que se lo llame en algunas otras situaciones /// </summary> /// <returns></returns> bool SearchForWeakPoint() { // bool anyFound = false; // float detectorRange = 100; // Collider[] hitColliders = Physics.OverlapSphere(player.transform.position, detectorRange); for (int i = 0; i < hitColliders.Length; i++) { WeakPoint weakPoint = hitColliders[i].GetComponent <WeakPoint>(); if (weakPoint != null && weakPoint.active == false && weakPoint.CurrentHealthPoins > 0) { // Lo ponemos como activo para que pueda ser targeteado // TODO: Poner nombre de variable más claro, coño weakPoint.Unveil(); //weakPoint.active = true; anyFound = true; audioObjectManager.CreateAudioObject(weakPointFoundBip, player.transform.position); } } // return(anyFound); }
public void WeakpointHit(WeakPoint weakpointThatWasHit) { numberOfSuspenders -= 1; if (numberOfSuspenders == 0) { ReleaseSuspension(); } }
protected override void HandleWeakPointDamage(WeakPoint weakPoint, int lockOns) { health -= lockOns; highlightController.highlight2(0.2f); if (health <= 0) { activeEnemyControllers.Remove(this); this.movementDirection = Vector2.zero; Destroy(this.gameObject, 0.2f); } }
protected void AddWeakPoint(Vector2 relativePosition, int maxLockOns, bool isActive = true) { WeakPoint newWeakPoint = new WeakPoint(); newWeakPoint.relativePosition = relativePosition; newWeakPoint.position = relativePosition + new Vector2(this.transform.position.x, this.transform.position.y); newWeakPoint.distanceFromPlayer = (newWeakPoint.position - (Vector2)PlayerController.Instance.transform.position).magnitude; newWeakPoint.maxLockOns = maxLockOns; newWeakPoint.isActive = isActive; newWeakPoint.enemyController = this; weakPoints.Add(newWeakPoint); }
//射擊,如果有射到救回傳true //然後直接從裡面去取得敵人扣血 public bool Shoot() { // Reset the timer. timer = 0f; // Play the gun shot audioclip. gunAudio.Play(); // Enable the lights. gunLight.enabled = true; faceLight.enabled = true; // Stop the particles from playing if they were, then start the particles. gunParticles.Stop(); gunParticles.Play(); // Enable the line renderer and set it's first position to be the end of the gun. gunLine.enabled = true; gunLine.SetPosition(0, transform.position); // Set the shootRay so that it starts at the end of the gun and points forward from the barrel. shootRay.origin = transform.position; shootRay.direction = transform.forward; // 如果RayCast有碰到東西 if (Physics.Raycast(shootRay, out shootHit, range, shootableMask)) { //取的敵人的弱點 WeakPoint weakpoint = shootHit.collider.GetComponent <WeakPoint>(); //如果確定有敵人 if (weakpoint != null) { //扣血 //一發子彈扣一滴血 : ) weakpoint.SetDamage(damagePerShot); } //設定射線長度就是在槍到人物,不會超過 //gunLine.SetPosition(1, shootHit.point); gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range); } else { //設定射線最長的長度是這個樣子 gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range); return(false); } return(false); }
// Update is called once per frame void Update() { playerPos = player.transform.position; distance = (transform.position - playerPos).magnitude; if (distance <= distanceToActivate) { if (canAttack == false) { attackTimer += Time.deltaTime; //rotate dragon head if the he is done attacking but not ready to start next attack if (attackTimer >= attackDuration) { anim.SetBool("isOpen", false); WeakPoint.GetComponent <DragonWeakPoint>().Open(false); if (canRotate == true) { lookDirection = playerPos - transform.position; lookRot = Quaternion.LookRotation(lookDirection); lookRot *= Quaternion.Euler(0, 90, 0); gameObject.transform.rotation = lookRot; } } } if (attackTimer >= attackCooldown || canAttack == true) { anim.SetBool("isOpen", true); WeakPoint.GetComponent <DragonWeakPoint>().Open(true); canAttack = true; attackTimer = 0; attackprepTimer += Time.deltaTime; if (attackprepTimer > .8f) { WeakPoint.GetComponent <DragonWeakPoint>().Open(true); Attack(1); attackprepTimer = 0; canAttack = false; } } } }
// Start is called before the first frame update void Start() { m_WeakPoint = GetComponent <WeakPoint>(); }
public void WeakpointHit(WeakPoint weakpointThatWasHit) { this.ReceiveBulletDamage(100); }
//一個點被打掉 //把點清除 void SpotHPzero(WeakPoint weapon) { }
protected abstract void HandleWeakPointDamage(WeakPoint weakPoint, int lockOns);
void GetWeakPoint() { weakPoint = (WeakPoint)Getter.ComponentInChild(this, gameObject, typeof(WeakPoint), 0); }
public void WeakpointHit(WeakPoint weakpointThatWasHit) { print("ITAI!"); }
// protected void GenerateImpact(Collider collider, Vector3 hitPoint, Vector3 hitNormal, float dt = 0) { // transform.position = hitPoint; GameObject particlesToUse = impactParticlesPrefab; AudioClip clipToUse = null; // Chequeamos si ha impactado a un enemigo y aplicamos lo necesario EnemyCollider enemyCollider = collider.GetComponent <EnemyCollider>(); if (enemyCollider != null) { enemyCollider.ReceiveBulletImpact(rb, hitPoint); particlesToUse = impactOnBugParticlesPrefab; clipToUse = impactOnEnemy; // TODO: Buscar otro sitio donde ponerlo // Aquí no suena porque se destruye el objeto //GeneralFunctions.PlaySoundEffect(audioSource, impactOnEnemy); //bulletSoundManager.CreateAudioObject(impactOnEnemy, transform.position); } // Y el player, joputa PlayerIntegrity playerIntegrity = collider.GetComponent <PlayerIntegrity>(); if (playerIntegrity != null) { clipToUse = impactOnPlayer; playerIntegrity.ReceiveImpact(transform.position, gameObject, rb, hitNormal); //GeneralFunctions.PlaySoundEffect(audioSource, impactOnPlayer); //bulletSoundManager.CreateAudioObject(impactOnPlayer, transform.position); // //Rigidbody playerRB = playerIntegrity.gameObject.GetComponent<Rigidbody>(); //playerRB.AddForce(rb.velocity * rb.mass, ForceMode.Impulse); } // Weakpoints // TODO: Gestionarlos mejor WeakPoint weakPoint = collider.GetComponent <WeakPoint>(); if (weakPoint != null) { clipToUse = impactOnEnemy; particlesToUse = impactOnBugParticlesPrefab; weakPoint.ReceiveBulletImpact(rb, this); } // Efecto de sonido if (clipToUse != null) { bulletSoundManager.CreateAudioObject(clipToUse, transform.position, 0.1f); } // Partículas if (particlesToUse != null) { GameObject impactParticles = Instantiate(particlesToUse, hitPoint, Quaternion.identity); SpawnBulletHole(hitPoint, hitNormal, collider.gameObject); Destroy(impactParticles, 2); } // TODO: Ver por qué nos hacía falta esto // Si es explosiva gestionamos la destrucción ahí // Y si es player lo gestionams en player if (explosiveBullet == null && playerIntegrity == null) { //Debug.Log("Not explosive component, destroying object"); // Destroy(gameObject); ReturnBulletToPool(); // TODO: Hcaerlo mas limpio //if(dangerousEnough) // bulletPool.RemoveDangerousBulletFromList(gameObject); } }
public void ApplyAttack(WeakPoint weakPoint, int lockOns) { Debug.Log($"Damaged weak point number {weakPoints.IndexOf(weakPoint)} for {lockOns} damage."); HandleWeakPointDamage(weakPoint, lockOns); }
//某個點被攻擊 //要裝作很痛苦的樣子 void SpotDamage(WeakPoint point) { }