Exemplo n.º 1
0
    private void OnTriggerEnter(Collider other)
    {
        //1号设备
        if (other.gameObject.name == "target1")
        {
            m_Nav           = m_ObjControl.m_Nav[0];
            m_Agent         = m_ObjControl.m_Agent[0];
            m_Agent.enabled = false;
            m_Nav.m_isFirst = false;
            m_Nav.enabled   = false;
            //m_Player.transform.position = new Vector3(0f, 8f, 11.67f);
            //m_Player.transform.rotation = Quaternion.Euler(-90, 0, 0);
            //m_Player.transform.localScale = new Vector3(1, 1, 1);
            //m_PlayerCamera.transform.localPosition = new Vector3(-4.426f, -3.03f, 4.9f);
            //m_PlayerCamera.transform.localEulerAngles = new Vector3(-34f, 135f, 60f);
            m_ObjControl.m_BoxCollider1[0].SetActive(false);
            m_ObjControl.m_BoxCollider1[1].SetActive(false);
            m_ObjControl.m_Shebei[0].SetActive(false);
            m_CameraControl.m_Camera[4].SetActive(true);
            //0.3f,19.8f,4.3f
            m_CameraControl.m_Camera[4].transform.position         = new Vector3(1.5f, 23f, 8.6f);
            m_CameraControl.m_Camera[4].transform.localEulerAngles = new Vector3(74f, 0, 0);
            m_ObjControl.m_ShebeiDown[0].SetActive(true);
            m_ObjControl.m_ShebeiDown[0].SetActive(true);
        }
        //2号设备
        if (other.gameObject.name == "target")
        {
            m_Nav           = m_ObjControl.m_Nav[1];
            m_Agent         = m_ObjControl.m_Agent[1];
            m_Agent.enabled = false;
            m_Nav.m_isFirst = false;
            m_Nav.enabled   = false;
            //m_Player.transform.position = new Vector3(5.601f, 11.07f, 12.236f);
            //m_Player.transform.rotation = Quaternion.Euler(-90, 0, 0);
            //m_PlayerCamera.transform.localPosition = new Vector3(3f, 1f, 2f);
            //m_PlayerCamera.transform.localRotation = Quaternion.Euler(21f, -120f, -100f);
            m_ObjControl.m_BoxCollider2[0].SetActive(false);
            m_ObjControl.m_BoxCollider2[1].SetActive(false);
            m_ObjControl.m_Shebei[1].SetActive(false);
            m_CameraControl.m_Camera[4].SetActive(true);
            m_CameraControl.m_Camera[4].transform.position         = new Vector3(2.335106f, 19.57973f, 13.63064f);
            m_CameraControl.m_Camera[4].transform.localEulerAngles = new Vector3(36.6f, 96.6f, 0);
            m_ObjControl.m_ShebeiDown[1].SetActive(true);
            m_ObjControl.m_ShebeiDown[1].SetActive(true);
        }
        //1号设备
        if (shebei == SheBei.shebei1)
        {
            switch (other.gameObject.name)
            {
            case "target1-1":
                m_Nav.m_Target = m_Target[0];
                break;

            case "target1-1 (1)":
                m_Nav.m_Target = m_Target[1];
                break;

            case "target1-1 (2)":
                m_Nav.m_Target = m_Target[2];
                break;

            case "target1-1 (3)":
                m_Nav.m_Target = m_Target[3];
                break;

            default:
                break;
            }
        }
    }
Exemplo n.º 2
0
    private void Update()
    {
        //重新开始
        if (Input.GetKeyDown(KeyCode.F1))
        {
            Button_OnClick_Restart();
        }


        if (m_isFrist)
        {
            if (m_RayControl.m_ID == 1)
            {
                //获取到寻路
                m_Nav                = m_ObjControl.m_Nav[0];
                m_NavMeshAgent       = m_ObjControl.m_Agent[0];
                m_Nav.enabled        = false;
                m_NavMeshAgent.speed = 0;
                m_isFrist            = false;
            }
            if (m_RayControl.m_ID == 2)
            {
                //获取到寻路
                m_Nav                = m_ObjControl.m_Nav[1];
                m_NavMeshAgent       = m_ObjControl.m_Agent[1];
                m_Nav.enabled        = false;
                m_NavMeshAgent.speed = 0;
                m_isFrist            = false;
            }
        }

        //搜索路径
        if (m_TimeControl == TimeControl.RegionSearch)
        {
            m_UIControl.m_TextObj.SetActive(true);

            m_TimeDis += Time.deltaTime * m_Speed;
            m_TimeAdd += Time.deltaTime * m_Speed;
            if (m_TimeDis > 2)
            {
                m_Text.text = "正在建立搜索区域" + ".";
            }
            if (m_TimeDis > 3)
            {
                m_Text.text = "正在建立搜索区域" + "..";
            }
            if (m_TimeDis > 4)
            {
                m_Text.text = "正在建立搜索区域" + "...";
            }
            if (m_TimeDis > 5)
            {
                m_Text.text = "正在建立搜索区域" + "....";
                m_TimeDis   = 0;
            }
            if (m_TimeAdd > 7)
            {
                m_Text.text = "<color=green>建立搜索区域完毕</color>";
                m_FloorObj.SetActive(true);
            }
            if (m_TimeAdd > 10)
            {
                m_TimeControl = TimeControl.GetPath;
                m_TimeAdd     = 0;
            }
        }
        //计算路径
        if (m_TimeControl == TimeControl.GetPath)
        {
            m_TimeAdd += Time.deltaTime * m_Speed;
            m_TimeDis += Time.deltaTime * m_Speed;

            if (m_TimeDis > 0)
            {
                m_Text.text = "正在计算路线" + ".";
            }
            if (m_TimeDis > 3)
            {
                m_Text.text = "正在计算路线" + ".." + "\n" + "正在计算进入角度.." + "\n" + "<color=green>绿色</color>为可进入,<color=red>红色</color>为不可进入..";
            }
            if (m_TimeDis > 4)
            {
                m_Text.text = "正在计算路线" + "..." + "\n" + "正在计算进入角度..." + "\n" + "<color=green>绿色</color>为可进入,<color=red>红色</color>为不可进入...";
            }
            if (m_TimeDis > 5)
            {
                m_Text.text = "正在计算路线" + "...." + "\n" + "正在计算进入角度...." + "\n" + "<color=green>绿色</color>为可进入,<color=red>红色</color>为不可进入....";
                m_TimeDis   = 3;
            }
            //设备1
            if (m_RayControl.m_ID == 1)
            {
                //判断什么时间到达什么门
                if (m_TimeAdd > 2)
                {
                    //启用3号摄像头
                    m_CameraControl.Button_OnClick_Camera03_On();
                    //1号门  第一个角度
                    Camera_Control(1, 1);
                }
                if (m_TimeAdd > 4)
                {
                    //第二个角度
                    Camera_Control(1, 2);
                }
                if (m_TimeAdd > 6)
                {
                    //第三个角度
                    Camera_Control(1, 3);
                }
                if (m_TimeAdd > 8)
                {
                    //第四个角度
                    Camera_Control(1, 4);
                }
                if (m_TimeAdd > 10)
                {
                    //第五个角度
                    Camera_Control(1, 5);
                }
                //2号门
                if (m_TimeAdd > 12)
                {
                    Camera_Control(2, 1);
                }
                if (m_TimeAdd > 14)
                {
                    Camera_Control(2, 2);
                }
                if (m_TimeAdd > 16)
                {
                    Camera_Control(2, 3);
                }
                if (m_TimeAdd > 18)
                {
                    Camera_Control(2, 4);
                }
                //3号门
                if (m_TimeAdd > 20)
                {
                    Camera_Control(3, 1);
                }
                if (m_TimeAdd > 22)
                {
                    Camera_Control(3, 2);
                }
                if (m_TimeAdd > 24)
                {
                    Camera_Control(3, 3);
                }
                if (m_TimeAdd > 26)
                {
                    Camera_Control(3, 4);
                }
                if (m_TimeAdd > 28)
                {
                    Camera_Control(3, 5);
                }
                //演示完毕
                if (m_TimeAdd > 30)
                {
                    m_Text.text = "<color=green>计算完毕</color>";
                    //2号设备
                    m_ObjControl.m_TestObj[0].SetActive(false);
                    m_CameraControl.Button_OnClick_MainCamera();
                    m_FloorObj.SetActive(false);
                    m_TimeAdd = 0;

                    m_NavMeshAgent.speed = 0;
                    m_TimeControl        = TimeControl.ObstaclesAvoid;
                }
            }
            //设备2
            if (m_RayControl.m_ID == 2)
            {
                //判断什么时间到达什么门
                if (m_TimeAdd > 2)
                {
                    //启用3号摄像头
                    m_CameraControl.Button_OnClick_Camera03_On();
                    //1号门  第一个角度
                    Camera_Control(1, 1);
                }
                if (m_TimeAdd > 4)
                {
                    //第二个角度
                    Camera_Control(1, 2);
                }
                if (m_TimeAdd > 6)
                {
                    //第三个角度
                    Camera_Control(1, 3);
                }
                if (m_TimeAdd > 8)
                {
                    //第四个角度
                    Camera_Control(1, 4);
                }
                if (m_TimeAdd > 10)
                {
                    //第五个角度
                    Camera_Control(1, 5);
                }
                //2号门
                if (m_TimeAdd > 12)
                {
                    Camera_Control(2, 1);
                }
                if (m_TimeAdd > 14)
                {
                    Camera_Control(2, 2);
                }
                if (m_TimeAdd > 16)
                {
                    Camera_Control(2, 3);
                }
                if (m_TimeAdd > 18)
                {
                    Camera_Control(2, 4);
                }
                if (m_TimeAdd > 20)
                {
                    Camera_Control(2, 5);
                }
                //演示完毕
                if (m_TimeAdd > 22)
                {
                    m_Text.text = "<color=green>计算完毕</color>";
                    //2号设备
                    m_ObjControl.m_TestObj[1].SetActive(false);
                    m_CameraControl.Button_OnClick_MainCamera();
                    m_FloorObj.SetActive(false);
                    m_TimeAdd            = 0;
                    m_NavMeshAgent.speed = 0;
                    m_TimeControl        = TimeControl.ObstaclesAvoid;
                }
            }
        }
        //障碍躲避
        if (m_TimeControl == TimeControl.ObstaclesAvoid)
        {
            m_TimeAdd += Time.deltaTime * m_Speed;
            m_TimeDis += Time.deltaTime * m_Speed;
            m_CameraControl.Button_OnClick_Camera03_On();
            if (m_RayControl.m_ID == 1)
            {
                m_CameraControl.m_Camera[3].transform.position         = new Vector3(50.11f, 4.45f, -14.96477f);
                m_CameraControl.m_Camera[3].transform.localEulerAngles = new Vector3(42.32f, -94.331f, 0);
            }
            if (m_RayControl.m_ID == 2)
            {
                m_CameraControl.m_Camera[3].transform.position         = new Vector3(-20.32f, 8.82f, -47f);
                m_CameraControl.m_Camera[3].transform.localEulerAngles = new Vector3(47f, 0, 0);
            }
            if (m_TimeDis > 2)
            {
                m_Text.text = "正在创建障碍躲避检测光圈" + ".";
            }
            if (m_TimeDis > 3)
            {
                m_Text.text = "正在创建障碍躲避检测光圈" + "..";
            }
            if (m_TimeDis > 4)
            {
                m_Text.text = "正在创建障碍躲避检测光圈" + "...";
            }
            if (m_TimeDis > 5)
            {
                m_Text.text = "正在创建障碍躲避检测光圈" + "....";
                m_TimeDis   = 0;
            }
            if (m_TimeAdd > 7)
            {
                m_Text.text = "<color=green>创建完毕</color>";
                if (m_RayControl.m_ID == 1)
                {
                    for (int i = 0; i < m_ObjControl.m_BoxCollider1.Length; i++)
                    {
                        m_ObjControl.m_BoxCollider1[i].SetActive(true);
                    }
                }
                if (m_RayControl.m_ID == 2)
                {
                    for (int i = 0; i < m_ObjControl.m_BoxCollider2.Length; i++)
                    {
                        m_ObjControl.m_BoxCollider2[i].SetActive(true);
                    }
                }
            }
            if (m_TimeAdd > 10)
            {
                m_TimeAdd     = 0;
                m_TimeControl = TimeControl.PathFinding;
                m_CameraControl.Button_OnClick_MainCamera();
            }
        }
        //自动寻路
        if (m_TimeControl == TimeControl.PathFinding)
        {
            m_TimeAdd += Time.deltaTime * m_Speed;
            if (m_TimeAdd > 3)
            {
                m_Nav.enabled        = true;
                m_Text.text          = "正在寻路...";
                m_NavMeshAgent.speed = 3.5f;
            }
            if (m_TimeAdd > 4)
            {
                if (m_RayControl.m_ID == 1)
                {
                    m_CameraControl.Button_OnClick_Camera01_On();
                }
                if (m_RayControl.m_ID == 2)
                {
                    m_CameraControl.Button_OnClick_Camera02_On();
                }
                m_Text.text = "";
            }
        }
    }
Exemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     m_Nav = m_ObjControl.m_Nav[0];
 }