/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Damage() { //-------------- if (dead == false) { amountDamage += currentDamage; if (amountDamage > amountLife * 0.75f && runAwayAdditionally == false) { runAway = true; } if (amountDamage > amountLife) { if (Mathf.Sqrt(Class_Controller.SqrMagnitudeToPlayer(thisTransform)) < thisAudioSource.maxDistance) { thisAudioSource.pitch = Random.Range(0.7f, 1.2f); thisAudioSource.panStereo = Random.Range(-0.1f, 0.1f); thisAudioSource.PlayOneShot(soundsFx[Random.Range(2, 5)], Random.Range(0.6f, 1.0f)); } dead = true; speed = 0; aiAgr = attack = contusion = false; Class_AI.amountEnemyAIs -= 1; if (injuredByPlayer == true) { Class_AI.RandomMinerals(thisTransform, true); PlayerPrefs.SetInt("DestroyedEnemies", PlayerPrefs.GetInt("DestroyedEnemies") + 1); } } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void AvoidObstacles() { //-------------- if (obstacleDetourOn == true && lodUpdate1 == false) { if (counter10++ >= 3) { counter10 = 0; if (obstacleDetour == false) { obstacleDetour = Class_AI.ObstacleDetour(thisTransform, localScaleX); } else if (counter11++ >= 2) { counter11 = 0; obstacleDetour = false; sign = (Random.Range(0, 2) - 0.5f) * 2; } } } else if (obstacleDetour == true) { obstacleDetour = false; } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void AttackOnPlayer() { //-------------- if (variableRotation != 10) { variableRotation = 10; } Shooting(distanceToPlayer); counter20++; if (counter20 < counter21) { if (speedBehavior != 1) { speedBehavior = 1; } if (dodge == true) { dodge = false; } thisQuaternion = Quaternion.LookRotation(Class_Controller.playerPosition - thisTransform.position); } else if (counter20 == counter21) { speedBehavior = 1.5f; dodge = true; thisQuaternion = Class_AI.RotationSinus(thisTransform, 500); } else if (counter20 >= counter21 + 11) { speedBehavior = 1; dodge = false; counter20 = 0; counter21 = Random.Range(10, 60); } if (counter23++ > 5) { counter23 = 0; gravityValid = true; } else { gravityValid = false; } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HelpPlayer() { //-------------- if (variableRotation != 2) { variableRotation = 2; } if (playerIsVisible == true) { if (distanceToPlayer < atackDistance2 && distanceToPlayer > atackDistance3 && speed != 5) { speed = 5; } else if (distanceToPlayer < atackDistance3 && distanceToPlayer > 33 && speed != 1) { speed = 1; } else if (distanceToPlayer < 33) { thisAudioSource.pitch = Random.Range(0.7f, 1.0f); thisAudioSource.panStereo = Random.Range(-0.1f, 0.1f); thisAudioSource.PlayOneShot(soundsFx[Random.Range(2, 5)], Random.Range(0.4f, 0.7f)); playerIsVisible = false; if (speed != -3) { speed = -4; } Class_AI.RandomMinerals(thisTransform, true); } } thisQuaternion = Quaternion.LookRotation(Class_Controller.playerPosition - thisTransform.position); if (counter23++ > 5) { counter23 = 0; gravityValid = true; } else { gravityValid = false; } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void SeesEnemiesOrPlayer() { //-------------- if (counter22++ >= 5) { counter22 = 0; distanceToPlayer = Class_Controller.SqrMagnitudeToPlayer(thisTransform); enemiesIsVisible = Class_AI.EnemiesIsVisible(thisTransform, atackDistance0, 14); playerIsVisible = distanceToPlayer < atackDistancePow0 && Class_Interface.maskerEnabled == false && Class_Controller.playerAlive == true; if (Class_Interface.tamingEnabled == false && speedTaming != 1) { speedTaming = 1; } else if (speedTaming != 0.5f) { speedTaming = 0.5f; } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void SeesEnemiesOrPlayer() { //-------------- if (counter22++ >= 5) { counter22 = 0; distanceToPlayer = Class_Controller.SqrMagnitudeToPlayer(thisTransform); enemiesIsVisible = Class_AI.EnemiesIsVisible(thisTransform, atackDistance0, 10); if (counter12++ > 6 && helpPlayerOn == true && playerIsVisible == false && enemiesIsVisible == false && distanceToPlayer < atackDistance2) { counter12 = 0; playerIsVisible = Random.Range(1, helpVariation) == 1; if (playerIsVisible == true) { randomAtackDistance = Random.Range(0.85f, 1.15f); } } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HomePlanet() { //-------------- attack = aiAgr = dodge = false; if (variableRotation != 1) { variableRotation = 1; } //-------------- if (atHomePlanet == false) { homePlanetList = Class_PlanetarySystem.listPlanets; homePlanetListCount = homePlanetList.Count; for (int i = 0; i < homePlanetListCount; i++) { homePlanetTransform = homePlanetList[i].transform; if ((homePlanetTransform.position - thisTransform.position).sqrMagnitude < 90000) { planetPosition = homePlanetTransform.position; homePlanetScaleX = Mathf.Pow(homePlanetTransform.localScale.x * 15, 2); } } counter15 = Random.Range(timeChangeHomeX, timeChangeHomeY); atHomePlanet = planetSelected = true; } else { if (counter14++ > 4) { counter14 = 0; homePlanetList = Class_PlanetarySystem.listPlanets; if (homePlanetListCount > homePlanetList.Count) { planetSelected = false; } homePlanetListCount = homePlanetList.Count; } } //-------------- if (planetSelected == false) { counter15 = Random.Range(timeChangeHomeX, timeChangeHomeY); homePlanetTransform = homePlanetList[Random.Range(0, homePlanetListCount)].transform; planetPosition = homePlanetTransform.position; homePlanetScaleX = Mathf.Pow(homePlanetTransform.localScale.x * 15, 2); planetSelected = planetSelectedLod = true; } else { if (counter13++ > 2) { counter13 = 0; distanceHomePlanet = (planetPosition - thisTransform.position).sqrMagnitude; if (distanceHomePlanet > homePlanetScaleX + 10000) { speed = 14; } else { speed = 7; if (counter15-- <= 0) { planetSelected = false; } } if (distanceHomePlanet > homePlanetScaleX) { if (Random.Range(1, 8) == 1) { thisQuaternion = Class_AI.RotationSinus(thisTransform, 1000); } else { thisQuaternion = Quaternion.LookRotation(planetPosition - thisTransform.position); } gravityValid = false; } else { if (Random.Range(1, 3) == 1) { thisQuaternion = Class_AI.RotationSinus(thisTransform, 1000); } if (counter23++ > 5) { counter23 = 0; gravityValid = true; } else { gravityValid = false; } planetSelectedLod = false; if (runAway == true) { if (counter8++ > 5) { counter8 = 0; runAway = false; runAwayAdditionally = true; if (playerIsVisible == false && enemiesIsVisible == false) { amountDamage = 0; } } } } } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void AttackOnEnemy() { //-------------- if (variableRotation != 10) { variableRotation = 10; } enemies = Class_AI.EnemiesCollidersNearby(thisTransform, atackDistance0, 14); enemiesLength = enemies.Length; if (enemiesLength > 0) { if (counter16-- <= 0) { counter16 = 120; enemyObject = enemies[Random.Range(0, enemiesLength)].gameObject; } else if (enemyObject != null) { enemyPosition = enemyObject.transform.position; Shooting((enemyPosition - thisTransform.position).sqrMagnitude); counter17++; if (counter17 < counter18) { if (speedBehavior != 1) { speedBehavior = 1; } if (dodge == true) { dodge = false; } thisQuaternion = Quaternion.LookRotation(enemyPosition - thisTransform.position); } else if (counter17 == counter18) { speedBehavior = 1.5f; dodge = true; thisQuaternion = Class_AI.RotationSinus(thisTransform, 500); } else if (counter17 >= counter18 + 11) { speedBehavior = 1; dodge = false; counter17 = 0; counter18 = Random.Range(10, 60); } } } else { speed = 5; } if (counter23++ > 5) { counter23 = 0; gravityValid = true; } else { gravityValid = false; } //-------------- }