Example #1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (lasttargetTransform != null)
            {
                HighlightableObject targetho = lasttargetTransform.GetComponent <HighlightableObject>();
                targetho.Off();

                if (game_ui_autopos.target_bar != null)
                {
                    game_ui_autopos.hideTargetBar();
                    TargetManger.cancelAutoAttack();
                }
            }
            return;
        }

        TargetingRaycast();
    }
    void Update()
    {
        // Fade in/out constant highlighting with 'Tab' button
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            ho.ConstantSwitch();
        }
        // Turn on/off constant highlighting with 'Q' button
        else if (Input.GetKeyDown(KeyCode.Q))
        {
            ho.ConstantSwitchImmediate();
        }

        // Turn off all highlighting modes with 'Z' button
        if (Input.GetKeyDown(KeyCode.Z))
        {
            ho.Off();
        }

        AfterUpdate();
    }
Example #3
0
 /// <summary>
 /// 关闭高亮效果
 /// </summary>
 public void OffHighLighting()
 {
     _hlObj.Off();
 }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        switch (mouseFlow)
        {
        //for the orthographic
        case 0:
            //right press to log the position now
            if (Input.GetMouseButtonDown(1))
            {
                position       = Input.mousePosition;
                cameraPosition = Camera.main.transform.position;
            }
            //right hold to drag
            if (Input.GetMouseButton(1))
            {
                Vector3 change = new Vector3(Input.mousePosition.x - position.x, 0, Input.mousePosition.y - position.y);
                if (Camera.main.transform.position.y < 4)
                {
                    speed = 0.01f;
                }
                else
                {
                    speed = 0.05f;
                }
                Camera.main.transform.position = change * speed + cameraPosition;
            }
            //zoom in
            if (Input.GetAxis("Mouse ScrollWheel") > 0)
            {
                if (distance > 2.5f)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 2.5f)
                    {
                        distance = 2.5f;
                    }
                }
                else
                {
                    distance = 2.5f;
                }
                theCamera.transform.position = new Vector3(theCamera.transform.position.x, distance, theCamera.transform.position.z);
            }
            //zoom out
            if (Input.GetAxis("Mouse ScrollWheel") < 0)
            {
                if (distance < 50)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 2.5f)
                    {
                        distance = 2.5f;
                    }
                }
                else
                {
                    distance = 50;
                }
                theCamera.transform.position = new Vector3(theCamera.transform.position.x, distance, theCamera.transform.position.z);
            }
            //the ray hit
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
            {
                //for plane
                if (hit.collider.gameObject.name.Contains("lane") || hit.collider.gameObject.name.Contains("board"))
                {
                    if (hited != null)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                    label.GetComponent <Text>().text = "";
                }    //for new hited object, empty the last hited
                else if (hited != hit.collider.gameObject)
                {
                    if (hited != null)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                    hited = hit.collider.gameObject;
                    label.GetComponent <Text>().text = "";
                }    //for hited object now
                else
                {
                    hited = hit.collider.gameObject;
                    if (hited != focusObj)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = true;
                    }
                    label.GetComponent <Text>().text = "The target object is " + hited.name;
                    //left press to focus object
                    if (Input.GetMouseButtonUp(0))
                    {
                        mouseFlow    = 1;
                        focusObj     = hit.collider.gameObject;
                        focusObjName = "The target object is " + focusObj.name;
                        var em = focusObj.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                }
            }
            break;

        //changing to focus object
        case 1:
            switch (cameraButton)
            {
            //look at the target first
            case 0:
                changeTarget = theCamera.transform.DOLookAt(focusObj.transform.position, 0.8f);
                changeTarget.SetAutoKill(false).SetEase(Ease.Linear);
                changeTarget.Play();
                cameraButton = 1;
                break;

            //set path and rotate
            case 1:
                if (changeTarget.IsComplete())
                {
                    //release last one
                    changeTarget.Kill();

                    Vector3[] path = new Vector3[2];
                    path[0] = focusObj.transform.position + new Vector3(0, 2.5f, 5);
                    path[1] = focusObj.transform.position + new Vector3(0, 1.5f, 3);

                    changeTarget = theCamera.transform.DOPath(path, 3, PathType.CatmullRom, PathMode.Full3D, 5, null).SetLookAt(focusObj.transform.position);

                    changeTarget.SetAutoKill(false).SetEase(Ease.Linear);
                    changeTarget.Play();

                    theCamera.transform.DORotate(new Vector3(27, 180, 0), 3).Play();

                    cameraButton = 2;
                    //release
                    Array.Clear(path, 0, path.Length);
                }
                break;

            //when finished change to next situation
            case 2:
                if (changeTarget.IsComplete())
                {
                    //release last one
                    changeTarget.Kill();

                    //prepare
                    Vector2 angles = theCamera.transform.eulerAngles;
                    x = angles.y;
                    y = angles.x;

                    Drawer temp = null;
                    foreach (Drawer drawer in main.drawers)
                    {
                        if (drawer.obj.name == focusObj.name)
                        {
                            temp = drawer;
                        }
                    }
                    temp.isFocus = true;
                    HighlightableObject ho = focusObj.GetComponent <HighlightableObject>();
                    if (ho != null)
                    {
                        ho.ConstantOn(Color.red);
                    }
                    else
                    {
                        Debug.Log("ho is null");
                    }
                    var em = hited.GetComponent <ParticleSystem>().emission;
                    em.enabled = false;
                    em         = focusObj.GetComponent <ParticleSystem>().emission;
                    em.enabled = false;

                    if (GetComponent <Rigidbody>())
                    {
                        GetComponent <Rigidbody>().freezeRotation = true;
                    }
                    distance     = (theCamera.transform.position - focusObj.transform.position).magnitude;
                    mouseFlow    = 2;
                    cameraButton = 0;
                }
                break;

            default:
                break;
            }
            break;

        //focuse rotate
        case 2:
            //right press to drag
            if (Input.GetMouseButton(1))
            {
                if (focusObj)
                {
                    x += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
                    y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
                    y  = ClampAngle(y, yMinLimit, yMaxLimit);
                }
            }
            //zoom in
            if (Input.GetAxis("Mouse ScrollWheel") > 0)
            {
                if (distance > 2.5f)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 2.5f)
                    {
                        distance = 2.5f;
                    }
                }
                else
                {
                    distance = 2.5f;
                }
            }
            //zoom out
            if (Input.GetAxis("Mouse ScrollWheel") < 0)
            {
                if (distance < 50)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 2.5f)
                    {
                        distance = 2.5f;
                    }
                }
                else
                {
                    distance = 50;
                }
            }
            //let camera focus on object
            moveCamera();
            //the ray hit
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
            {
                //for plane
                if (hit.collider.gameObject.name.Contains("lane"))
                {
                    if (hited != null && hited != focusObj)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                    else
                    {
                        var em = focusObj.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                    label.GetComponent <Text>().text = focusObjName;
                }    //for new hited object, empty the last hited
                else if (hited != hit.collider.gameObject)
                {
                    if (hited != null && hited != focusObj)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                    hited = hit.collider.gameObject;
                    label.GetComponent <Text>().text = focusObjName;
                }    //for new hited object
                else
                {
                    hited = hit.collider.gameObject;
                    if (hited != focusObj)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = true;
                    }
                    label.GetComponent <Text>().text = "The target object is " + hited.name;
                    if (Input.GetMouseButtonUp(0))
                    {
                        mouseFlow = 1;
                        Drawer temp = null;
                        foreach (Drawer drawer in main.drawers)
                        {
                            if (drawer.obj.name == focusObj.name)
                            {
                                temp = drawer;
                            }
                        }
                        temp.isFocus = false;
                        HighlightableObject ho = focusObj.GetComponent <HighlightableObject>();
                        if (ho != null)
                        {
                            ho.Off();
                        }
                        else
                        {
                            Debug.Log("ho is null");
                        }
                        //focusObj.GetComponent<MeshRenderer>().material.SetFloat("_GlowStrength", 0);
                        //focusObj.GetComponent<LineRenderer>().material.SetColor("_Color", new Color(0, 97.0f/255.0f, 1, 1));
                        focusObj     = hit.collider.gameObject;
                        focusObjName = "The target object is " + focusObj.name;
                        var em = focusObj.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                }
            }
            break;

        default:
            break;
        }
    }
Example #5
0
 void OnMouseExit()
 {
     ho.Off();
 }
Example #6
0
    // Update is called once per frame
    void Update()
    {
        switch (mouseFlow)
        {
        case 0:
            if (Input.GetMouseButtonDown(1))
            {
                position       = Input.mousePosition;
                cameraPosition = Camera.main.transform.position;
            }
            //right hold to drag
            if (Input.GetMouseButton(1))
            {
                Vector3 change = new Vector3(Input.mousePosition.x - position.x, 0, Input.mousePosition.y - position.y);
                if (Camera.main.transform.position.y < 4)
                {
                    speed = 0.01f;
                }
                else
                {
                    speed = 0.05f;
                }
                Camera.main.transform.position = change * speed + cameraPosition;
            }
            //zoom in
            if (Input.GetAxis("Mouse ScrollWheel") > 0)
            {
                if (distance > 3.5f)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 3.5f)
                    {
                        distance = 3.5f;
                    }
                }
                else
                {
                    distance = 3.5f;
                }
                theCamera.transform.position = new Vector3(theCamera.transform.position.x, distance, theCamera.transform.position.z);
            }
            //zoom out
            if (Input.GetAxis("Mouse ScrollWheel") < 0)
            {
                if (distance < 20)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 3.5f)
                    {
                        distance = 3.5f;
                    }
                }
                else
                {
                    distance = 20;
                }
                theCamera.transform.position = new Vector3(theCamera.transform.position.x, distance, theCamera.transform.position.z);
            }

            if (mouseLock)
            {
                //ray test
                ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit))
                {
                    //for monitor
                    if (hit.collider.gameObject.name.Contains("mon"))
                    {
                        if (hited != null && hited != hit.collider.gameObject)
                        {
                            HighlightableObject ho1 = hited.GetComponent <HighlightableObject>();
                            if (ho1 != null)
                            {
                                ho1.Off();
                            }
                            else
                            {
                                Debug.Log("ho1 is null");
                            }
                        }
                        hited = hit.collider.gameObject;

                        if (mainTest.levelNow != 2)
                        {
                            HighlightableObject ho = hit.collider.gameObject.GetComponent <HighlightableObject>();
                            if (ho != null)
                            {
                                ho.ConstantOn(Color.red);
                            }
                            else
                            {
                                Debug.Log("ho is null");
                            }
                        }

                        if (Input.GetMouseButtonUp(0))
                        {
                            if (mainTest.levelNow < 2)
                            {
                                HighlightableObject ho1 = hited.GetComponent <HighlightableObject>();
                                if (ho1 != null)
                                {
                                    ho1.Off();
                                }
                                else
                                {
                                    Debug.Log("ho1 is null");
                                }
                                GameObject tempMonitor = hit.collider.gameObject;
                                string[]   tempString  = tempMonitor.name.Split('r');
                                mainTest.center = Track.world2position(new VecTime(tempMonitor.transform.position, new PTime(0)), mainTest.center, mainTest.map.fullLat, mainTest.map.fullLon);
                                switch (mainTest.levelNow)
                                {
                                case 0:
                                    mainTest.lastLevel_0 = int.Parse(tempString[1]);
                                    break;

                                case 1:
                                    mainTest.lastLevel_1 = int.Parse(tempString[1]);
                                    break;

                                default:
                                    break;
                                }
                                theCamera.transform.position = new Vector3(0, 7, 0);
                                distance  = (theCamera.transform.position - new Vector3(0, 0, 0)).magnitude;
                                mouseLock = false;

                                mainTest.map.zoom += 3;
                                mainTest.levelNow++;
                                for (int i = 0; i < mainTest.monitors.Length; i++)
                                {
                                    mainTest.monitors[i].transform.FindChild("Area").GetComponent <TextMesh>().text = "";
                                }

                                mainTest.flow = 2;
                            }
                        }
                        if (Input.GetKeyDown(KeyCode.Space))
                        {
                            if (mainTest.levelNow > 0)
                            {
                                HighlightableObject ho1 = hited.GetComponent <HighlightableObject>();
                                if (ho1 != null)
                                {
                                    ho1.Off();
                                }
                                else
                                {
                                    Debug.Log("ho1 is null");
                                }
                                mainTest.lastLevel_0         = -1;
                                mainTest.lastLevel_1         = -1;
                                theCamera.transform.position = new Vector3(0, 7, 0);
                                distance = (theCamera.transform.position - new Vector3(0, 0, 0)).magnitude;

                                mouseLock         = false;
                                mainTest.map.zoom = mainTest.basicZoom;
                                mainTest.levelNow = 0;
                                mainTest.center   = new Position(mainTest.avgLat, mainTest.avgLon, new PTime(0));
                                for (int i = 0; i < mainTest.monitors.Length; i++)
                                {
                                    mainTest.monitors[i].transform.FindChild("Area").GetComponent <TextMesh>().text = "";
                                }

                                mainTest.flow = 2;
                            }
                        }
                    }
                }
            }

            break;

        default:
            break;
        }
    }
    public void ClearUnits()
    {
        //Clear all Selected Units
        Debug.Log("Clearing Units");
        if(selectedUnit != null)
        {
            tempRend = selectedUnit.gameObject.GetComponentInChildren<Renderer>();
            //tempRend.material.shader = Shader.Find("Self-Illumin/Bumped Diffuse");

            tempHL = selectedUnit.gameObject.GetComponent<HighlightableObject>();
            tempHL.Off();

            tempUnitControl = (script_2PBot)selectedUnit.GetComponent("script_2PBot");
            tempUnitControl.selected = false;
            tempUnitControl.selectedBy = null;
            tempUnitControl.currentState = 0;
            tempUnitControl.distanceDrawn = false;
            Destroy (tempUnitControl.localMoveDistanceObj);
            selectedUnit = null;
            unitStats = null;
        }
    }
Example #8
0
 public void HideLight()
 {
     mSelected = false;
     mHighlightableObjecto.Off();
 }
    // Update is called once per frame
    void Update()
    {
        switch (mouseFlow)
        {
        //for the orthographic
        case 0:
            if (Input.GetMouseButtonDown(1))
            {
                position       = Input.mousePosition;
                cameraPosition = Camera.main.transform.position;
            }
            //right hold to drag
            if (Input.GetMouseButton(1))
            {
                Vector3 change = new Vector3(Input.mousePosition.x - position.x, 0, Input.mousePosition.y - position.y);
                if (Camera.main.transform.position.y < 4)
                {
                    speed = 0.01f;
                }
                else
                {
                    speed = 0.05f;
                }
                Camera.main.transform.position = change * speed + cameraPosition;
            }
            //zoom in
            if (Input.GetAxis("Mouse ScrollWheel") > 0)
            {
                if (distance > 3.5f)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 3.5f)
                    {
                        distance = 3.5f;
                    }
                }
                else
                {
                    distance = 3.5f;
                }
                theCamera.transform.position = new Vector3(theCamera.transform.position.x, distance, theCamera.transform.position.z);
            }
            //zoom out
            if (Input.GetAxis("Mouse ScrollWheel") < 0)
            {
                if (distance < 20)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 3.5f)
                    {
                        distance = 3.5f;
                    }
                }
                else
                {
                    distance = 20;
                }
                theCamera.transform.position = new Vector3(theCamera.transform.position.x, distance, theCamera.transform.position.z);
            }

            if (mouseLock)
            {
                //ray test
                ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit))
                {
                    //for monitor
                    if (hit.collider.gameObject.name.Contains("mon"))
                    {
                        if (hited != null && hited != hit.collider.gameObject)
                        {
                            HighlightableObject ho1 = hited.GetComponent <HighlightableObject>();
                            if (ho1 != null)
                            {
                                ho1.Off();
                            }
                            else
                            {
                                Debug.Log("ho1 is null");
                            }
                        }
                        hited = hit.collider.gameObject;

                        if (main.levelNow != 2)
                        {
                            HighlightableObject ho = hit.collider.gameObject.GetComponent <HighlightableObject>();
                            if (ho != null)
                            {
                                ho.ConstantOn(Color.red);
                            }
                            else
                            {
                                Debug.Log("ho is null");
                            }
                        }

                        if (Input.GetMouseButtonUp(0))
                        {
                            if (main.levelNow < 2)
                            {
                                HighlightableObject ho1 = hited.GetComponent <HighlightableObject>();
                                if (ho1 != null)
                                {
                                    ho1.Off();
                                }
                                else
                                {
                                    Debug.Log("ho1 is null");
                                }
                                GameObject tempMonitor = hit.collider.gameObject;
                                string[]   tempString  = tempMonitor.name.Split('r');
                                main.center = Track.world2position(new VecTime(tempMonitor.transform.position, new PTime(0)), main.center, main.map.fullLat, main.map.fullLon);
                                switch (main.levelNow)
                                {
                                case 0:
                                    main.lastLevel_0 = int.Parse(tempString[1]);
                                    break;

                                case 1:
                                    main.lastLevel_1 = int.Parse(tempString[1]);
                                    break;

                                default:
                                    break;
                                }
                                theCamera.transform.position = new Vector3(0, 7, 0);
                                distance  = (theCamera.transform.position - new Vector3(0, 0, 0)).magnitude;
                                mouseLock = false;

                                main.map.zoom += 3;
                                main.levelNow++;
                                for (int i = 0; i < main.monitors.Length; i++)
                                {
                                    main.monitors[i].transform.FindChild("Area").GetComponent <TextMesh>().text = "";
                                }

                                main.Mflow = 0;
                            }
                        }
                        if (Input.GetKeyDown(KeyCode.Space))
                        {
                            if (main.levelNow > 0)
                            {
                                HighlightableObject ho1 = hited.GetComponent <HighlightableObject>();
                                if (ho1 != null)
                                {
                                    ho1.Off();
                                }
                                else
                                {
                                    Debug.Log("ho1 is null");
                                }
                                main.lastLevel_0             = -1;
                                main.lastLevel_1             = -1;
                                theCamera.transform.position = new Vector3(0, 7, 0);
                                distance = (theCamera.transform.position - new Vector3(0, 0, 0)).magnitude;

                                mouseLock     = false;
                                main.map.zoom = main.basicZoom;
                                main.levelNow = 0;
                                main.center   = new Position(main.avgLat, main.avgLon, new PTime(0));
                                for (int i = 0; i < main.monitors.Length; i++)
                                {
                                    main.monitors[i].transform.FindChild("Area").GetComponent <TextMesh>().text = "";
                                }

                                main.Mflow = 0;
                            }
                        }
                    }
                }
            }
            break;

        case 1:
            //right press to log the position now
            if (Input.GetMouseButtonDown(1))
            {
                position       = Input.mousePosition;
                cameraPosition = Camera.main.transform.position;
            }
            //right hold to drag
            if (Input.GetMouseButton(1))
            {
                Vector3 change = new Vector3(Input.mousePosition.x - position.x, 0, Input.mousePosition.y - position.y);
                if (Camera.main.transform.position.y < 4)
                {
                    speed = 0.01f;
                }
                else
                {
                    speed = 0.05f;
                }
                Camera.main.transform.position = change * speed + cameraPosition;
            }
            //zoom in
            if (Input.GetAxis("Mouse ScrollWheel") > 0)
            {
                if (distance > 2.5f)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 2.5f)
                    {
                        distance = 2.5f;
                    }
                }
                else
                {
                    distance = 2.5f;
                }
                theCamera.transform.position = new Vector3(theCamera.transform.position.x, distance, theCamera.transform.position.z);
            }
            //zoom out
            if (Input.GetAxis("Mouse ScrollWheel") < 0)
            {
                if (distance < 50)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 2.5f)
                    {
                        distance = 2.5f;
                    }
                }
                else
                {
                    distance = 50;
                }
                theCamera.transform.position = new Vector3(theCamera.transform.position.x, distance, theCamera.transform.position.z);
            }
            //for back to the first time
            if (Input.GetKeyDown(KeyCode.Space))
            {
                main.drawers.Clear();
                label.GetComponent <Text>().text = "";
                foreach (Transform child in main.drawTracks.transform)
                {
                    Destroy(child.gameObject);
                }
                main.monitor_parent.SetActive(true);
                main.lastLevel_0             = -1;
                main.lastLevel_1             = -1;
                main.lastLevel_2             = -1;
                theCamera.transform.position = new Vector3(0, 40, 0);
                theCamera.transform.rotation = Quaternion.Euler(new Vector3(90, 180, 0));
                distance      = (theCamera.transform.position - new Vector3(0, 0, 0)).magnitude;
                mouseLock     = false;
                main.map.zoom = main.basicZoom;
                main.levelNow = 0;
                main.center   = new Position(main.avgLat, main.avgLon, new PTime(0));


                mouseFlow = 0;
                main.flow = 1;
                break;
            }
            //the ray hit
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
            {
                //for plane
                if (hit.collider.gameObject.name.Contains("lane") || hit.collider.gameObject.name.Contains("board"))
                {
                    if (hited != null)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                    label.GetComponent <Text>().text = "";
                }    //for new hited object, empty the last hited
                else if (hited != hit.collider.gameObject)
                {
                    if (hited != null)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                    hited = hit.collider.gameObject;
                    label.GetComponent <Text>().text = "";
                }    //for hited object now
                else
                {
                    hited = hit.collider.gameObject;
                    if (hited != focusObj)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = true;
                    }
                    label.GetComponent <Text>().text = "The target object is " + hited.name;
                    //left press to focus object
                    if (Input.GetMouseButtonUp(0))
                    {
                        mouseFlow    = 2;
                        focusObj     = hit.collider.gameObject;
                        focusObjName = "The target object is " + focusObj.name;
                        var em = focusObj.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                }
            }
            break;

        //changing to focus object
        case 2:
            switch (cameraButton)
            {
            //look at the target first
            case 0:
                changeTarget = theCamera.transform.DOLookAt(focusObj.transform.position, 0.8f);
                changeTarget.SetAutoKill(false).SetEase(Ease.Linear);
                changeTarget.Play();
                cameraButton = 1;
                break;

            //set path and rotate
            case 1:
                if (changeTarget.IsComplete())
                {
                    //release last one
                    changeTarget.Kill();

                    Vector3[] path = new Vector3[2];
                    path[0] = focusObj.transform.position + new Vector3(0, 2.5f, 5);
                    path[1] = focusObj.transform.position + new Vector3(0, 1.5f, 3);

                    changeTarget = theCamera.transform.DOPath(path, 3, PathType.CatmullRom, PathMode.Full3D, 5, null).SetLookAt(focusObj.transform.position);

                    changeTarget.SetAutoKill(false).SetEase(Ease.Linear);
                    changeTarget.Play();

                    theCamera.transform.DORotate(new Vector3(27, 180, 0), 3).Play();

                    cameraButton = 2;
                    //release
                    Array.Clear(path, 0, path.Length);
                }
                break;

            //when finished change to next situation
            case 2:
                if (changeTarget.IsComplete())
                {
                    //release last one
                    changeTarget.Kill();

                    //prepare
                    Vector2 angles = theCamera.transform.eulerAngles;
                    x = angles.y;
                    y = angles.x;

                    Drawer temp = null;
                    foreach (Drawer drawer in main.drawers)
                    {
                        if (drawer.obj.name == focusObj.name)
                        {
                            temp = drawer;
                        }
                    }
                    temp.isFocus = true;
                    HighlightableObject ho = focusObj.GetComponent <HighlightableObject>();
                    if (ho != null)
                    {
                        ho.ConstantOn(Color.red);
                    }
                    else
                    {
                        Debug.Log("ho is null");
                    }
                    var em = hited.GetComponent <ParticleSystem>().emission;
                    em.enabled = false;
                    em         = focusObj.GetComponent <ParticleSystem>().emission;
                    em.enabled = false;

                    if (GetComponent <Rigidbody>())
                    {
                        GetComponent <Rigidbody>().freezeRotation = true;
                    }
                    distance     = (theCamera.transform.position - focusObj.transform.position).magnitude;
                    mouseFlow    = 3;
                    cameraButton = 0;
                }
                break;

            default:
                break;
            }
            break;

        //focuse rotate
        case 3:
            //right press to drag
            if (Input.GetMouseButton(1))
            {
                if (focusObj)
                {
                    x += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
                    y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
                    y  = ClampAngle(y, yMinLimit, yMaxLimit);
                }
            }
            //zoom in
            if (Input.GetAxis("Mouse ScrollWheel") > 0)
            {
                if (distance > 2.5f)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 2.5f)
                    {
                        distance = 2.5f;
                    }
                }
                else
                {
                    distance = 2.5f;
                }
            }
            //zoom out
            if (Input.GetAxis("Mouse ScrollWheel") < 0)
            {
                if (distance < 50)
                {
                    if (distance > 4)
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
                    }
                    else
                    {
                        distance -= Input.GetAxis("Mouse ScrollWheel") * 2;
                    }

                    if (distance < 2.5f)
                    {
                        distance = 2.5f;
                    }
                }
                else
                {
                    distance = 50;
                }
            }
            //let camera focus on object
            moveCamera();
            //for back to the first time
            if (Input.GetKeyDown(KeyCode.Space))
            {
                main.drawers.Clear();
                main.tracks.Clear();
                foreach (Transform child in main.drawTracks.transform)
                {
                    Destroy(child.gameObject);
                }
                label.GetComponent <Text>().text = "";
                main.monitor_parent.SetActive(true);
                main.lastLevel_0             = -1;
                main.lastLevel_1             = -1;
                main.lastLevel_2             = -1;
                theCamera.transform.position = new Vector3(0, 40, 0);
                theCamera.transform.rotation = Quaternion.Euler(new Vector3(90, 180, 0));
                distance      = (theCamera.transform.position - new Vector3(0, 0, 0)).magnitude;
                mouseLock     = false;
                main.map.zoom = main.basicZoom;
                main.levelNow = 0;
                main.center   = new Position(main.avgLat, main.avgLon, new PTime(0));


                mouseFlow = 0;
                main.flow = 1;
                break;
            }
            //the ray hit
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
            {
                //for plane
                if (hit.collider.gameObject.name.Contains("lane"))
                {
                    if (hited != null && hited != focusObj)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                    else
                    {
                        var em = focusObj.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                    label.GetComponent <Text>().text = focusObjName;
                }    //for new hited object, empty the last hited
                else if (hited != hit.collider.gameObject)
                {
                    if (hited != null && hited != focusObj)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                    hited = hit.collider.gameObject;
                    label.GetComponent <Text>().text = focusObjName;
                }    //for new hited object
                else
                {
                    hited = hit.collider.gameObject;
                    if (hited != focusObj)
                    {
                        var em = hited.GetComponent <ParticleSystem>().emission;
                        em.enabled = true;
                    }
                    label.GetComponent <Text>().text = "The target object is " + hited.name;
                    if (Input.GetMouseButtonUp(0))
                    {
                        mouseFlow = 1;
                        Drawer temp = null;
                        foreach (Drawer drawer in main.drawers)
                        {
                            if (drawer.obj.name == focusObj.name)
                            {
                                temp = drawer;
                            }
                        }
                        temp.isFocus = false;
                        HighlightableObject ho = focusObj.GetComponent <HighlightableObject>();
                        if (ho != null)
                        {
                            ho.Off();
                        }
                        else
                        {
                            Debug.Log("ho is null");
                        }
                        //focusObj.GetComponent<MeshRenderer>().material.SetFloat("_GlowStrength", 0);
                        //focusObj.GetComponent<LineRenderer>().material.SetColor("_Color", new Color(0, 97.0f/255.0f, 1, 1));
                        focusObj     = hit.collider.gameObject;
                        focusObjName = "The target object is " + focusObj.name;
                        var em = focusObj.GetComponent <ParticleSystem>().emission;
                        em.enabled = false;
                    }
                }
            }
            break;

        default:
            break;
        }
    }