/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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 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; } //-------------- }