Пример #1
0
    // Update is called once per frame
    void Update()
    {
        Vector3 position = player.transform.position;
        float   distance = Vector3.Distance(position, transform.position);



        //Move();

        Move();
        //if (Vector3.Distance(transform.position, source) >= 2)
        //{
        //    Debug.Log("起作业");
        //    right = false; up = false; down = false; left = false;
        //    gridMove = false;
        //    Vec.PositionInt(transform);
        //}


        if (isChase)
        {
            this.GetComponent <NavMeshAgent2D>().enabled = true;
            if (isProbe)
            {
                if (distance < (ProbeDistance / 2) * Math.Sqrt(2) * 2)
                {
                    if (canFire && isBullet)
                    {
                        StartCoroutine(Attack());
                    }
                }
            }
            else
            {
                if (canFire && isBullet)
                {
                    StartCoroutine(Attack());
                }
            }
        }
        else
        {
            if (canFire && isBullet && !player.GetComponent <Player>().isHidden)
            {
                StartCoroutine(Attack());
            }
            if (!player.GetComponent <Player>().isHidden)
            {
                this.GetComponent <NavMeshAgent2D>().enabled = false;
                Patrol();
            }
        }


        if (life <= 0 & flag)
        {
            flag = false;
            StartCoroutine(camerashake.Shake(.25f, .4f));
            StartCoroutine(changeColor.Colored());
            Invoke("Die", .3f);
        }
    }