示例#1
0
    void Update()
    {
        float dt = Time.deltaTime;

        transform.Find("PowerUpCircle").transform.Rotate(new Vector3(0, 0, -200 * dt), Space.Self);
        lifeTimeSeconds += dt;
        Shoot();

        if (!inPlayArea)
        {
            if (ofb.IsInCameraArea(transform.position.x, transform.position.y))
            {
                inPlayArea = true;
            }
        }
        if (inPlayArea)
        {
            if (!ofb.IsInPlayArea(transform.position.x, transform.position.y))
            {
                Destroy(gameObject);
            }
        }

        if (hasSpline)
        {
            Vector2 newLocation = spline.NewLocation(lifeTimeSeconds / 5);
            transform.position = new Vector3(newLocation.x, newLocation.y, 0);
        }

        if (selfDestructionActivated)
        {
            timeLeft -= dt;
            if (timeLeft <= 0)
            {
                if (hasPowerUp)
                {
                    DropPowerUp();
                }
                Destroy(gameObject);
            }
        }
    }
    void Update()
    {
        Shoot();

        if (!inPlayArea)
        {
            if (ofb.IsInCameraArea(transform.position.x, transform.position.y))
            {
                inPlayArea = true;
            }
        }

        // Friends who statys next to the player can't be out of bounds
        if (inPlayArea && type == FriendlyType.Temporary)
        {
            if (!ofb.IsInPlayArea(transform.position.x, transform.position.y))
            {
                Destroy(gameObject);
            }
        }
        Blink();
    }