//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Start is called before the first frame update void Start() { enemyFlyingComponent = this.GetComponent <Flying>(); playerTransform = GameObject.FindWithTag("Player").transform; playerFlyingComponent = GameObject.FindWithTag("PilotStation").GetComponent <Flying>(); currentEnemyAction = EEnemyAction.neutralFlying; SetEnemysCurrentAction(); CheckEnemysCurrentAction(); }
private void CheckParallelism() { int offset = 5; if (currentEnemyAction == EEnemyAction.startParallelMovement && playerFlyingComponent.currentDir - offset <= enemyFlyingComponent.currentDir && enemyFlyingComponent.currentDir <= playerFlyingComponent.currentDir + offset && playerFlyingComponent.currentAltitude - offset <= enemyFlyingComponent.currentAltitude && enemyFlyingComponent.currentAltitude <= playerFlyingComponent.currentAltitude + offset) { currentEnemyAction = EEnemyAction.currentlyParallelToPlayer; } }
private void SetStartDodgingFlying() { // set altitude enemyFlyingComponent.SetDesAlt(StartDodgingAlt()); // set direction enemyFlyingComponent.SetDesDir(FlyTowardsPlayer()); // set speed enemyFlyingComponent.SetDesSpeed(DodgingSpeed()); currentEnemyAction = EEnemyAction.currentlyDodging; }
private void RunningAwayCountDown() { if (runawayDeltaTime >= runawayTime) { currentEnemyAction = EEnemyAction.neutralFlying; runawayDeltaTime = 0f; } else { runawayDeltaTime += Time.deltaTime; } }
public void SetDodging(EDodgeType dodgeType, GameObject dodgingObject, bool startDodging) { this.dodgeType = dodgeType; currentlyDodgingObject = dodgingObject; if (startDodging) { currentEnemyAction = EEnemyAction.startDodging; } else { currentEnemyAction = EEnemyAction.neutralFlying; } }
private void ParallelismCountDown() { if (currentEnemyAction == EEnemyAction.currentlyParallelToPlayer) { if (swoopDeltaTime >= swoopInTime) { currentEnemyAction = EEnemyAction.runningAwayFromPlayer; runawayTime = Random.Range(runawayTimeRange.x, runawayTimeRange.y); swoopDeltaTime = 0f; setRunaway = true; } else { swoopDeltaTime += Time.deltaTime; //Debug.Log($"{this.transform.name} is now parallel to player, {swoopDeltaTime} : {swoopInTime}"); } } }
private void SetEnemysCurrentAction() { // if dodging if (currentEnemyAction == EEnemyAction.startDodging || currentEnemyAction == EEnemyAction.currentlyDodging || currentEnemyAction == EEnemyAction.startParallelMovement || currentEnemyAction == EEnemyAction.currentlyParallelToPlayer || currentEnemyAction == EEnemyAction.runningAwayFromPlayer) { // do nothing, just don't do any other action either } // if within parallel distance else if (Mathf.Abs(Vector3.Distance(playerTransform.position, this.transform.position)) <= parallelDistance) { currentEnemyAction = EEnemyAction.startParallelMovement; setSwoop = true; } else { currentEnemyAction = EEnemyAction.neutralFlying; } }