Example #1
0
    protected override void Update()
    {
        if (!stop)
        {
            gun.StopFire();
            float distance = speed * Time.deltaTime;

            // 如果距离目标点足够近
            if ((transform.position - TargetPosition).sqrMagnitude < (distance * distance))
            {
                stop = true;
                transform.position = TargetPosition;
                gun.StartFire();
            }
            else
            {
                // 向玩家移动
                transform.Translate(MovingDirection * distance, Space.World);
            }
        }

        if (shootingWarning != null && gun.CooldownPercentage < 0.4f)
        {
            shootingWarning.StartFlash();
        }
        else
        {
            shootingWarning.StopFlash();
        }
    }