using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FlowTarget : ViewEntity
{
    //跟随目标
   
    public Transform target2;

    // public float height;

    public float distance;

    public float X;

    public float Y = 0.8F;


    public Transform target1;

    void LateUpdate()
    {

        if (!battleController || !battleController.GameStarted)
            return;        


        if (target2.gameObject.activeSelf) 
        {
            if (target2.transform.position.y >= -1f)
            {
                Vector3 vec3 = new Vector3(target2.position.x + X, target2.transform.position.y + Y, target2.position.z + distance);
                this.transform.position = Vector3.Lerp(transform.position, vec3, 2 * Time.deltaTime);
            }
            else
            {
                Vector3 vec3 = new Vector3(target2.position.x + X, this.transform.position.y, target2.position.z + distance);
            }
        }

        if (target1.gameObject.activeSelf) 
        {
            if (target1.transform.position.y >= -1f)
            {
                Vector3 vec3 = new Vector3(target1.position.x + X, target1.transform.position.y + Y, target1.position.z + distance);
                this.transform.position = Vector3.Lerp(transform.position, vec3, 2 * Time.deltaTime);
            //    Debug.Log("触发。。。。。。。。。");
            }
            else
            {
                Vector3 vec3 = new Vector3(target1.position.x + X, this.transform.position.y, target1.position.z + distance);
            }
        }


   
        if (Input.GetMouseButtonDown(0))
        {
            isdown = false;
        }
        if (Input.GetMouseButtonUp(0))
        {
            isdown = true;
        }
        if (isdown)
        {
            GetComponent<Camera>().fieldOfView += Time.deltaTime * 14f;
            if (GetComponent<Camera>().fieldOfView >= 82F)
            {
                GetComponent<Camera>().fieldOfView = 82F;
              
            }
        }
        else
        {
            GetComponent<Camera>().fieldOfView -= Time.deltaTime * 15f;
            if (GetComponent<Camera>().fieldOfView <= 75F)
            {
                GetComponent<Camera>().fieldOfView = 75F;
            }
        }
    }
    private bool isdown = false;
}
 
