Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        // if this attack is happening
        if (active)
        {
            // what direction are we moving
            if (movingRight)
            {
                //have we passed our destination point?
                if (transform.position.x >= lowRight.position.x)
                {
                    // stop attack and move to next
                    active = false;
                    manager.NextAttack();
                }
            }
            else
            {
                if (transform.position.x <= lowLeft.position.x)
                {
                    active = false;
                    manager.NextAttack();
                }
            }

            // decrement time till next shot fired
            timeTillNextFire -= Time.deltaTime;
            if (timeTillNextFire <= 0)
            {
                Fire();
            }
        }
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (active)
     {
         // if we have passed the end point
         if (transform.position.y < bottom.position.y)
         {
             // end attack and move to next one
             active = false;
             manager.NextAttack();
         }
     }
 }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        // if we are moving
        if (active)
        {
            // check our direction
            if (movingRight)
            {
                // check if we have passed the pivot point and need to reverse direction
                if (pivoted)
                {
                    // if we have passed the finish poin
                    if (transform.position.x > outRight.position.x)
                    {
                        // reset variables
                        active  = false;
                        pivoted = false;
                        // tell the manager to start the next attack
                        manager.NextAttack();
                    }
                }
                else
                {
                    // check if we have reached the pivot point
                    if (transform.position.x > inRight.position.x)
                    {
                        // set pivot to true and change direction variable
                        pivoted     = true;
                        movingRight = false;
                    }
                }
            }
            else
            {
                if (pivoted)
                {
                    if (transform.position.x < outLeft.position.x)
                    {
                        active  = false;
                        pivoted = false;
                        manager.NextAttack();
                    }
                }
                else
                {
                    if (transform.position.x < inLeft.position.x)
                    {
                        pivoted     = true;
                        movingRight = true;
                    }
                }
            }

            // decrement the timer till the next time a projectile should be fired
            timeTillNextFire -= Time.deltaTime;
            // check if it is time to fire a bullet
            if (timeTillNextFire <= 0)
            {
                Fire();
            }
        }
    }