// Start is called before the first frame update
    void Start()
    {
        Player = GameObject.FindGameObjectWithTag("Player");
        Enemy  = transform.root.gameObject;

        animator = Enemy.GetComponent <Animator>();

        Canvas = GameObject.FindGameObjectWithTag("Canvas");

        PSButton  = Canvas.transform.Find("PistolShootButton").Find("PSButton");
        lbbScript = PSButton.GetComponent <LiveBulletOnButton>();

        Camera   = GameObject.FindGameObjectWithTag("MainCamera");
        lbScript = Camera.GetComponent <LiveBullet>();

        agent = Enemy.GetComponent <NavMeshAgent>();

        foundPlayer   = false;
        warningPlayer = false;

        SetDestinationRandomly();

        randomCountD1 = Random.Range(2f, 4f);   //Battle時に移動する時間
        randomCountD2 = Random.Range(2f, 5f);   //Battle時にアイドルする時間

        randomCountF1 = Random.Range(2f, 4f);   //発砲時のインターバル
        randomCountF2 = Random.Range(1f, 2.5f); //発砲時間

        audioSources = transform.GetComponents <AudioSource>();

        gocScript = GameObject.FindGameObjectWithTag("Goal").GetComponent <GoalObjectController>();
    }
    // Start is called before the first frame update
    void Start()
    {
        MainCamera = GameObject.Find("MainCamera");
        lbScript   = MainCamera.GetComponent <LiveBullet>();

        Reload      = GameObject.Find("Reload");
        reloadImage = Reload.GetComponent <Image>();

        finishReload = true;

        PistolReadySlider = GameObject.Find("PistolReadySlider");
        prsSlider         = PistolReadySlider.GetComponent <Slider>();
    }
    int layerMask       = ~(1 << 9) & ~(1 << 2);//layer"Player"と"Ignoreraycast"以外に当たる("Playerには当たらない")
    // Start is called before the first frame update
    void Start()
    {
        MainCamera = GameObject.FindGameObjectWithTag("MainCamera");
        lbScript   = MainCamera.transform.GetComponent <LiveBullet>();

        rigidBody = gameObject.transform.GetComponent <Rigidbody>();

        initialPos = transform.position;

        if (lbScript.bulletRaycast)
        {
            BulletDirection = (lbScript.bulletHitInfo.point - transform.position).normalized;
        }
        else if (!lbScript.bulletRaycast)
        {
            Vector3 endOfBulletRaycast = MainCamera.transform.position + (MainCamera.transform.forward * lbScript.bulletRange);
            BulletDirection = (endOfBulletRaycast - transform.position).normalized;
        }

        transform.LookAt(transform.position + BulletDirection);

        earlyHitRaycast = Physics.Raycast(transform.position, BulletDirection, out earlyHitInfo, earlyHitRange, layerMask);
    }