Exemplo n.º 1
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    // 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();
    }
Exemplo n.º 2
0
    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;
        }
    }
Exemplo n.º 3
0
    private void SetStartDodgingFlying()
    {
        // set altitude
        enemyFlyingComponent.SetDesAlt(StartDodgingAlt());
        // set direction
        enemyFlyingComponent.SetDesDir(FlyTowardsPlayer());
        // set speed
        enemyFlyingComponent.SetDesSpeed(DodgingSpeed());

        currentEnemyAction = EEnemyAction.currentlyDodging;
    }
Exemplo n.º 4
0
 private void RunningAwayCountDown()
 {
     if (runawayDeltaTime >= runawayTime)
     {
         currentEnemyAction = EEnemyAction.neutralFlying;
         runawayDeltaTime   = 0f;
     }
     else
     {
         runawayDeltaTime += Time.deltaTime;
     }
 }
Exemplo n.º 5
0
 public void SetDodging(EDodgeType dodgeType, GameObject dodgingObject, bool startDodging)
 {
     this.dodgeType         = dodgeType;
     currentlyDodgingObject = dodgingObject;
     if (startDodging)
     {
         currentEnemyAction = EEnemyAction.startDodging;
     }
     else
     {
         currentEnemyAction = EEnemyAction.neutralFlying;
     }
 }
Exemplo n.º 6
0
    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}");
            }
        }
    }
Exemplo n.º 7
0
 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;
     }
 }