Enemies perform all their possible actions in a single frame?

When trying to make enemies that did more than constantly face the player, move forward, and randomly shoot, I ran into a problem: When I run the game, my FPS drops dramatically and the enemy fires an enormous quantity of bullets at once. On the Unity Forum, I was told that the sequence would have to be in Function Update(), but it seems to me that would make the enemy try to perform all the actions requested in a single frame, so I tried to correct that by creating a simple counter to call only one option at a time. Can anyone explain to me how to properly script these actions? I'm not necessarily looking to create an enemy that has a variety of responses. I'm mostly looking for a way to implement a simple, repeating pattern of actions.

My code so far:

var speed = 10;
var shipcontrol = 0;
var minspeed = 2.5;
speed *= Random.value;
speed += minspeed;
var shipTarget : Transform;

function Update () {
    if (Time.timeScale > 0) {
        if (transform.position.y == 0) {
            if (shipcontrol >= 3) {
                shipWait(2);
                shipcontrol +=1;
            }
            if (shipcontrol == 2) {
                moveTo(Vector3(10,0,10));
                shipcontrol +=1;
            }
            if (shipcontrol == 1) {
                moveTowardPlayer(shipTarget);
                shipcontrol +=1;
            }
            if (shipcontrol == 0) {
                fire(shipTarget);
                shipcontrol +=1;
            }
}
    }
}

function shipWait (waitTime : float) {
    yield WaitForSeconds(Random.value * waitTime);
}

function moveTo (targetlocation : Vector3) {
    transform.LookAt(targetlocation);
    transform.position = Vector3(Mathf.Lerp(transform.position.x, targetlocation.x, speed*Time.deltaTime), 0, Mathf.Lerp(transform.position.z, targetlocation.z, speed*Time.deltaTime));
}

function moveTowardPlayer (target : Transform) {
    facePlayer(shipTarget);
    moveTo (shipTarget.position);
}

function facePlayer (target : Transform) {
        if (shipTarget) {
        // Look at and dampen the rotation
        var rotation = Quaternion.LookRotation(shipTarget.position - transform.position);
        transform.rotation = Quaternion.Lerp(transform.rotation, rotation, Time.deltaTime);
    }
}

function fire (shootTarget : Transform) {
    facePlayer(shootTarget);
    gameObject.SendMessage("Shoot", SendMessageOptions.DontRequireReceiver);
}

I'm afraid that the answer to your question is much more complex than you realize. There are many types of programming patterns used to implement agent control. Each has its strengths and weaknesses. All can be implemented in Unity.

The method that most people start with is the finite state machine (FSM). It involves defining states (which implement the desired behavior) and controlling transitions between the states.

Try a web search for "state design pattern" or "finite state machine". Here are a couple links that my be useful to beginners:

AI-Junkie

AI-Depot

The answer to your question lies in understanding the concepts behind encapsulating behaviors and transitions. FSM's tend to encapsulate them in classes. But once you understand the concepts you should be able to implement a simplified state machine. Here is a pseudo-code example of one method of simplification. (Which you will likely outgrow quickly.)

function Update () {
    // Very little decisionmaking should occur in the update.
    if (Time.timeScale > 0) {
        switch (state)  // An enum variable indicating current state.
        {
        case WAITING:
            ShipWait();
        case SEEKING:
            SeekTarget();
        case ATTACKING:
            AttackTarget();
        }
    }
}

// Encapulate actions in various high level functions.
// Often, you'll want to also have separate functions for
// the transitions.  E.g. TransitionWaitToSeek();

function ShipWait()
{
    // Wait.
    // Detect if waiting is complete and transition to next
    // state.
}

function SeekTarget()
{
    // Rotate and move toward target.
    // Detect if at desired target.  If so, transition to next state.
}

function AttackTarget()
{
    // Attack the target.
    // Detect when complete and transition to next state.
    // Might use a shared timer function to attack for a specific 
    // length of time.
}