private int ManageImpact(Rigidbody impactingRigidbody, Bullet bulletComponent) { // float damageReceived = 0; // Primero determinamos penetración float penetrationValue = GeneralFunctions.Navy1940PenetrationCalc(impactingRigidbody.mass, bulletComponent.diameter, impactingRigidbody.velocity.magnitude); // float penetrationResult = Mathf.Max(penetrationValue - enemyCollider.armor, 0); // Pasamos en qué proporción ha penetrado if (penetrationResult > 0) { penetrationResult = 1 - (enemyCollider.armor / penetrationValue); // float kineticEnergy = GeneralFunctions.GetBulletKineticEnergy(impactingRigidbody); damageReceived = kineticEnergy * penetrationResult; // if (damageReceived < 1) { carolBaseHelp.TriggerGeneralAdvice("NoPenetration"); } // currentHealthPoints -= damageReceived; } else { carolBaseHelp.TriggerGeneralAdvice("NoPenetration"); impactInfoManager.SendImpactInfo(transform.position, 0, "No Penetration"); } // return((int)damageReceived); }
// void SufferDamage(float impactDamage, float impactAngle) { // Primero chequeamos si hay alguna acción defensiva activa if (robotControl.CurrentActionCharging == ActionCharguing.Defense) { switch (robotControl.ActiveDefenseMode) { case DefenseMode.Spheric: float extraShieldEnergy = robotControl.ChargedAmount * gameManager.playerAttributes.forcePerSecond.CurrentValue; float stoppedDamage = Mathf.Min(impactDamage, extraShieldEnergy); float impactDamageBeforeReduction = impactDamage; impactDamage -= stoppedDamage; // Aplicamos un mini margen para que no se detenga la acción robotControl.ChargedAmount -= (stoppedDamage / gameManager.playerAttributes.forcePerSecond.CurrentValue); // Debug.Log("SD - Impact damage before reduction: " + impactDamageBeforeReduction + ", stopped damage: " + stoppedDamage + ", entering damage: " + impactDamage); break; case DefenseMode.Front: break; } } //float damageToShields = Mathf.Max(impactDamage - shieldAbsortion, 0); currentShield -= impactDamage; DamageType damageType; if (currentShield < 0) { // Recuerda que el escudo perdido sobrante llega como negativo //currentHealth += currentShield; //currentShield = 0; // TODO: Añadir efecto chachi en el HUD currentHealth--; invulnerable = true; //shieldsDepleted = true; damageType = DamageType.Hull; GeneralFunctions.PlaySoundEffect(audioSource, shieldDepletionClip); } else { damageType = DamageType.Shield; } // hud.AddDamageIndicator(impactAngle, damageType); // if (currentHealth <= 0) { currentHealth = 0; // Muerte Debug.Log("YOU DIED, BITCH"); ManageDeath(); } else { //currentShield = gameManager.playerAttributes.maxShield.CurrentValue; //invulnerable = true; // TODO: Crear uno para este caso carolHelp.TriggerGeneralAdvice(""); } }
// protected override void ExecuteCurrentAction(float dt) { // if (player == null) { return; } // Vector3 playerDistanceAndDirection = player.transform.position - headRb.transform.position; Vector2 xZDistanceToPlayerAndDirection = new Vector2(player.transform.position.x - headRb.transform.position.x, player.transform.position.z - headRb.transform.position.z); // Y aquí las específicas de bichos // Primero que el player siga vivo, si no mal switch (bigWormStatus) { case BigWormStatus.GoingToPlayer: headRb.transform.rotation = GeneralFunctions.UpdateRotationInOneAxis(headRb.transform, player.transform.position, rotationSpeed, dt); Move(dt); // if (xZDistanceToPlayerAndDirection.magnitude < minimalXyApproachDistance) { bigWormStatus = BigWormStatus.ApproachingPlayer; Debug.Log("Approaching player"); // TODO: Que Carol de un aviso carolHelp.TriggerGeneralAdvice("DangerIncoming"); } break; case BigWormStatus.ApproachingPlayer: // //float directionAngle = Vector3.SignedAngle(transform.forward, playerDistanceAndDirection.normalized, transform.up); float pureDistance = playerDistanceAndDirection.magnitude; // if (pureDistance < minimalLungeDistance /* && Mathf.Abs(directionAngle) < maxAngleToLunge*/) { //Debug.Log("Direction angle: " + directionAngle); Debug.Log("Performing lunge"); //Lunge(); GeneralFunctions.PlaySoundEffect(audioSource, lungeClip); headRb.transform.LookAt(player.transform); headRb.velocity = headRb.velocity.normalized * lungeSpeed; bigWormStatus = BigWormStatus.Lunging; ApplyGravityOnBodyParts(true); currentTimeToCheckLungeEnd = 0; return; } // headRb.transform.rotation = GeneralFunctions.UpdateRotation(headRb.transform, player.transform.position, rotationSpeed, dt); Move(dt); break; case BigWormStatus.Lunging: // Que la cabeza vaya rotando en la dirección que mira if (headRb.velocity.magnitude >= Mathf.Epsilon) { headRb.transform.LookAt(headRb.transform.position + headRb.velocity); } else { Debug.Log("Returning to ideal height"); bigWormStatus = BigWormStatus.ReturningToIdealHeight; headRb.transform.eulerAngles = new Vector3(90, headRb.transform.eulerAngles.y, headRb.transform.eulerAngles.z); } // currentTimeToCheckLungeEnd += dt; // if (currentTimeToCheckLungeEnd >= minimalTimeToCheckLungeEnd && HeadIsUnderSand()) { Debug.Log("Returning to ideal height"); bigWormStatus = BigWormStatus.ReturningToIdealHeight; //ApplyGravityOnBodyParts(false); // headRb.transform.eulerAngles = new Vector3(90, headRb.transform.eulerAngles.y, headRb.transform.eulerAngles.z); } break; case BigWormStatus.ReturningToIdealHeight: // Move(dt); // if (headRb.transform.position.y <= underSandIdealHeight) { // bigWormStatus = BigWormStatus.GoingToPlayer; // headRb.transform.eulerAngles = new Vector3(0, headRb.transform.eulerAngles.y, headRb.transform.eulerAngles.z); ApplyGravityOnBodyParts(false); } break; } }
/// <summary> /// Activa los enemigos y los coloca donde corresponde /// Puede ser llamado por el boss /// </summary> /// <param name="i"></param> public void ActivateEnemies(int i, Vector3 spawnPoint = new Vector3()) { //Metodo con spawn points EnemyIdentifier enemyIdentifier = enemiesSpawnSettings[i].enemyPrefab.GetComponent <EnemyIdentifier>(); Transform groupSpawn; Vector3 pointForGroupSpawn; // if (spawnPoint != Vector3.zero) { pointForGroupSpawn = spawnPoint; } else if (enemyIdentifier) { EnemyType typeToSpawn = enemyIdentifier.enemyType; groupSpawn = GetRandomSpawmPointNearerThanX(typeToSpawn, farestSpawnDistanceToEpicenter); // Control de errores if (groupSpawn == null) { return; } pointForGroupSpawn = groupSpawn.position; } else { // TODO: Desarrorlo pointForGroupSpawn = epicenterPoint; } // NOTA: Control de error // De primeras no debería haber tamaño de spawn 0 int enemiesToSpawn = (int)GameManager.instance.ApplyDifficultyFactor(enemiesSpawnSettings[i].enemiesToSpawn, 1); Debug.Log("Spawning enemies: " + enemiesSpawnSettings[i].enemiesToSpawn + ", " + enemiesToSpawn); // Aparte, ahora sale todo el grupo o no sale if (/*enemiesSpawnSettings[i].*/ enemiesToSpawn > 0 && /*enemiesSpawnSettings[i].enemiesToSpawn*/ enemiesToSpawn <= enemiesSpawnSettings[i].maxActiveEnemies - activeEnemies[i].Count) { // Si no hay enemigos activos de ese tipo, aviso de Carol if (activeEnemies[i].Count == 0) { carolHelp.TriggerGeneralAdvice("EnemiesIncoming"); } // Primero iniciamos la formación EnemyFormation newEnemyFormation = null; if (enemiesSpawnSettings[i].formationData != null) { // //newEnemyFormation = new EnemyFormation(enemiesSpawnSettings[i].enemiesToSpawn, // enemiesSpawnSettings[i].formationData.formationInfo.formationType, // enemiesSpawnSettings[i].formationData.formationInfo.distanceBetweenMembers); newEnemyFormation = new EnemyFormation(enemiesSpawnSettings[i].formationData.formationInfo, /*enemiesSpawnSettings[i].*/ enemiesToSpawn); // enemyFormations.Add(newEnemyFormation); } // float memberSpawnAngle = 360 / /*enemiesSpawnSettings[i].*/ enemiesToSpawn; float meberSpawnRadius = 10; // Sacamos a los enemigos for (int j = 0; j < /*enemiesSpawnSettings[i].*/ enemiesToSpawn; j++) { // float memberSpawnCoordinates = memberSpawnAngle * j; Vector2 memberSpawnPositionXY = new Vector2(Mathf.Cos(memberSpawnCoordinates) * meberSpawnRadius, Mathf.Sin(memberSpawnCoordinates) * meberSpawnRadius); //Vector3 positionToSpawn = new Vector3(Random.Range(-groupToSpawnSize[i], groupToSpawnSize[i]) + pointForGroupSpawn.x, 1, // Random.Range(-groupToSpawnSize[i], groupToSpawnSize[i]) + pointForGroupSpawn.z); Vector3 positionToSpawn = new Vector3(pointForGroupSpawn.x + memberSpawnPositionXY.x, pointForGroupSpawn.y, pointForGroupSpawn.z + memberSpawnPositionXY.y); // TODO: Chequear cuando esté vacía if (reserveEnemies[i].Count == 0) { Debug.Log("No more enemies in reserve"); continue; } GameObject nextEnemy = reserveEnemies[i][0]; reserveEnemies[i].Remove(nextEnemy); // TODO: Revisar que falla aquí if (nextEnemy.gameObject == null) { Debug.Log(nextEnemy); continue; } // TODO: Revisar lo de la posición al activarlos nextEnemy.SetActive(true); nextEnemy.transform.position = positionToSpawn; EnemyConsistency enemyConsistency = nextEnemy.GetComponent <EnemyConsistency>(); // TODO: Cuando esté bien organizado este paso no debería ahcer falta if (enemyConsistency == null) { enemyConsistency = nextEnemy.GetComponentInChildren <EnemyConsistency>(); } // if (enemyConsistency != null) { enemyConsistency.ManagerIndex = i; enemyConsistency.ResetStatus(); } // Ponemos los bosses de lado de momento if (levelManager.LevelVictoryCondition == VictoryCondition.SlayTheBeast && i == 0) { nextEnemy.transform.Rotate(Vector3.up * -90); } // Y lo añadimos a enemigos activos activeEnemies[i].Add(nextEnemy); // Si he formación lo metemos a ella if (newEnemyFormation != null) { //TODO: Meterlo en la formación EnemyBaseBodyBehaviour behaviour = nextEnemy.GetComponent <EnemyBaseBodyBehaviour>(); // TODO: Arregalro para que no haga falta hacer esto if (behaviour == null) { behaviour = nextEnemy.GetComponentInChildren <EnemyBaseBodyBehaviour>(); } // newEnemyFormation.formationMembers.Add(behaviour); behaviour.enemyFormation = newEnemyFormation; } //GameObject nextEnemy = Instantiate(enemyPrefabsToUse[i], pointForGroupSpawn, Quaternion.identity); } } //else // Debug.Log("Zero enemies to spawn or no more room for enemies"); }
/// <summary> /// Coge un proyectil del pool /// Bullet power en caso de trabajr con una formación /// </summary> /// <param name="bulletPrefab"></param> /// <param name="bulletPower"></param> /// <returns></returns> public GameObject GetBullet(GameObject bulletPrefab, float bulletPower = -1) { // GameObject nextBullet = null; string bulletName = bulletPrefab.name; // for (int i = 0; i < bulletPoolsPerType.Count; i++) { if (bulletPoolsPerType[i].prefabName == bulletName) { // if (bulletPoolsPerType[i].reserveBullets.Count == 0) { Debug.Log("No more bullets available"); return(null); } // TODO: Resetear tiempo de vida nextBullet = bulletPoolsPerType[i].reserveBullets[0]; nextBullet.SetActive(true); Bullet nextBulletScript = nextBullet.GetComponent <Bullet>(); nextBulletScript.CurrentLifeTime = 0; // bulletPoolsPerType[i].reserveBullets.Remove(nextBullet); bulletPoolsPerType[i].activeBullets.Add(nextBullet); // TODO: Manejar aqui el peligro del proyectil con la fuerza de la formación // Si es distinto de -1 es que no tiene un tamaño fijo if (bulletPower != -1) { if (bulletPower > 0.5f) { nextBulletScript.dangerousEnough = true; } else { nextBulletScript.dangerousEnough = false; } } // //if (bulletPoolsPerType[i].dangerousEnough) if (nextBulletScript.dangerousEnough) { nextBulletScript.restarted = true; // TODO: Vamos a trabajar con dos avisos, Peligro y Gran peligro if (bulletPower != -1 && bulletPower < 0.75) { carolHelp.TriggerGeneralAdvice("DangerIncoming"); } else { carolHelp.TriggerGeneralAdvice("GreatDangerIncoming"); } // AddDangerousBulletToList(nextBullet); // TODO: Revisar con esto el problema de unity congelandose al editar prefabs //if (SystemInfo.graphicsDeviceName.Contains("Intel") || SystemInfo.graphicsDeviceName.Contains("Integrated") || SystemInfo.graphicsDeviceName.Contains("0D")) //{ // //Show Debug //} } // continue; } } // return(nextBullet); }