// Use this for initialization protected virtual void Start() { impactInfoManager = FindObjectOfType <ImpactInfoManager>(); //currentChasisHealth = maxChasisHealth; //currentHealth = maxHealth + (maxHealth / 10 * GameManager.instance.difficultyFactor); currentHealth = (int)GameManager.instance.ApplyDifficultyFactor(maxHealth, 10); // levelManager = FindObjectOfType <ProvLevelManager>(); enemyManager = FindObjectOfType <EnemyManager>(); springCamera = FindObjectOfType <SpringCamera>(); //if(levelManager) // bodyBehaviour = GetComponent <EnemyBaseBodyBehaviour>(); // De momento para klos voladores mas que nada rb = GetComponent <Rigidbody>(); // Caso del gusano grande, debería coger el de la cabeza //if (rb == null) // rb = GetComponentInChildren<Rigidbody>(); // audioSource = GetComponent <AudioSource>(); // if (bodyColliders.Length == 0) { bodyColliders = GetComponentsInChildren <EnemyCollider>(); } // Chequeo extra para el gusano grande //if(bodyColliders == null || bodyColliders.Length == 0) // bodyColliders = transform.parent.GetComponentsInChildren<EnemyCollider>(); // Debug.Log(gameObject.name + ", " + bodyColliders + ", " + bodyColliders.Length); // DetermineIfMultipart(); }
// public Vector3 GetFormationPlaceInWorld(EnemyBaseBodyBehaviour behaviour) { // //Debug.Log("Debugging leader: " + FormationLeader); // Ñapa if (!FormationLeader) { return(Vector3.zero); } // int formationIndex = formationMembers.IndexOf(behaviour); Vector3 placeInWorld = FormationLeader.transform.TransformPoint(positions[formationIndex]); return(placeInWorld); }
// Start is called before the first frame update void Start() { // Cogemos el componente cuerpo del padre if (transform.parent != null) { //body = transform.parent.GetComponent<EnemyConsistency>(); body = transform.GetComponentInParent <EnemyConsistency>(); } // Para casos en los que el body solo tiene un collider // y por tanto lo lleva integrado if (body == null) { body = GetComponent <EnemyConsistency>(); } // Intento extra para gusano garnde if (body == null) { body = transform.parent.GetComponentInChildren <EnemyConsistency>(); } // if (body != null) { bodyBehaviour = body.GetComponent <EnemyBaseBodyBehaviour>(); } // //bodyRb = body.GetComponent<Rigidbody>(); // GetOriginalColors(); // Si no hay efecto adicional asignado no tiene sentido poner vida aparte if (onDamage != AdditionalEffectOnDamage.None) { currentLocationHealth = maxLocationHealth; } }
// public int GetIndexInFormation(EnemyBaseBodyBehaviour behaviour) { return(formationMembers.IndexOf(behaviour)); }
// public void LeaveFormation(EnemyBaseBodyBehaviour behaviour) { formationMembers.Remove(behaviour); }
/// <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"); }
// //void Mark // void MarkEnemiesOnScreen() { // TODO: Hacerlo con Targeteable // TODO: Cogerlo por refencia del manager apropiado cuando lo tengamos listo Targeteable[] enemies = FindObjectsOfType <Targeteable>(); if (enemies.Length == 0) { return; } // for (int i = 0; i < enemies.Length; i++) { // if (!enemies[i].active) { continue; } // if (!enemies[i].markWhenNotTargeted && enemies[i] != EnemyAnalyzer.targeteable) { continue; } // Distancia al centro de pantalla Vector3 posInScreen = Camera.main.WorldToViewportPoint(enemies[i].transform.position); bool inScreen = posInScreen.x >= 0 && posInScreen.x <= 1 && posInScreen.y >= 0 && posInScreen.y <= 1 && posInScreen.z > 0; // if (inScreen) { // // EnemyIdentifier enemyIdentifier = enemies[i].GetComponentInParent<EnemyIdentifier>(); EnemyBaseBodyBehaviour behaviour = enemies[i].GetComponentInParent <EnemyBaseBodyBehaviour>(); Texture textureToUse = enemyInScreenTextures[0]; if (behaviour != null && behaviour.enemyFormation != null) { float formationStrength = behaviour.enemyFormation.FormationStrength; if (formationStrength >= 0.75f) { textureToUse = enemyInScreenTextures[3]; } else if (formationStrength >= 0.5f) { textureToUse = enemyInScreenTextures[2]; } else if (formationStrength >= 0.25f) { textureToUse = enemyInScreenTextures[1]; } } else { textureToUse = enemyInScreenTextures[3]; } GUI.DrawTexture(new Rect( posInScreen.x * Screen.width - 15, Screen.height - posInScreen.y * Screen.height - 50, 30, 30), textureToUse); //enemyInScreenTextures[(int)enemyIdentifier.enemyType]); //GUI.DrawTexture(new Rect( // posInScreen.x * Screen.width - 15, // Screen.height - posInScreen.y * Screen.height - 15, 30, 30), // circleTexture); } } }