예제 #1
0
 /// <summary>
 /// 播放高光
 /// </summary>
 public void PlayHighlight()
 {
     if (_HighlightableObject != null)
     {
         _HighlightableObject.ConstantOn(OuterGlowColor);
     }
 }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        this.is_landing = false;
        HighlightableObject obj = GetComponent <HighlightableObject>();

        obj.ConstantOn(Color.black);
    }
예제 #3
0
 /// <summary>
 /// 显示高亮
 /// </summary>
 /// <param name="flashing">是否为闪烁</param>
 public void SetHighLighting(bool flashing)
 {
     if (flashing)
     {
         //闪烁
         _hlObj.FlashingOn(Color.red, Color.green, 2);
     }
     else
     {
         //常亮
         _hlObj.ConstantOn(Color.black);
     }
 }
예제 #4
0
    /// <summary>
    /// 设置物体是否高亮
    /// </summary>
    /// <param name="isShow"></param>
    private void SetObjectHighing(GameObject obj, bool isShow)
    {
        HighlightableObject hitHighing = obj.GetComponent <HighlightableObject>();

        if (null != hitHighing && isShow)
        {
            hitHighing.ConstantOn();
        }

        if (null != hitHighing && !isShow)
        {
            hitHighing.ConstantOff();
        }
    }
    void HifhLightFunction()
    {
        //循环往复外发光开启(参数为:颜色1,颜色2,切换时间)
        m_ho.FlashingOn(Color.green, Color.blue, 1f);

        //关闭循环往复外发光
        m_ho.FlashingOff();


        //持续外发光开启(参数:颜色)
        m_ho.ConstantOn(Color.yellow);

        //关闭持续外发光
        m_ho.ConstantOff();
    }
    // 移动位置并开启边缘高亮

    public bool movePosition(string tag)
    {
        for (int i = 0; i < rooms.rooms.Count; i++)
        {
            room = (Room)rooms.rooms[i];
            if (room.tag == tag)
            {
                transform.position   = room.pos;
                transform.localScale = room.scale;
                ho.ConstantOn(Color.cyan);
                return(true);
            }
        }
        return(false);
    }
예제 #7
0
    void SetTarget(GameObject go)
    {
        // remove old highlight
        if (_target != null)
        {
            HighlightableObject highlight = _target.GetComponent <HighlightableObject> ();
            if (highlight != null)
            {
                highlight.ConstantOffImmediate();
            }
        }

        if (go == null)
        {
            goX.SetActive(false);
            goY.SetActive(false);
            goZ.SetActive(false);

            _target = null;
        }
        else
        {
            _target = go;
            goX.SetActive(true);
            goY.SetActive(true);
            goZ.SetActive(true);

            transform.position = go.transform.position;

            //goX.transform.SetParent (go.transform);
            goX.transform.up = go.transform.right;

            //goY.transform.SetParent (go.transform);
            goY.transform.up = go.transform.up;

            //goZ.transform.SetParent (go.transform);
            goZ.transform.up = go.transform.forward;

            // add new highlight
            HighlightableObject highlight = go.transform.GetComponent <HighlightableObject>();
            if (highlight == null)
            {
                highlight = go.AddComponent <HighlightableObject> ();
            }
            highlight.ConstantOn(new Color32(255, 100, 0, 255));
        }
    }
예제 #8
0
    void Update()
    {
        // Fade in/out constant highlighting with 'Tab' button
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            //ho.ConstantSwitch();
            ho.ConstantOn(Color.red);
        }
        // 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();
    }
예제 #9
0
 //关于高亮部分
 private void OnMouseEnter()
 {
     m_ho = GetComponent <HighlightableObject>();
     m_ho.ConstantOn(Color.red);
 }
예제 #10
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;
        }
    }
예제 #11
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;
        }
    }
예제 #12
0
    void dealWithDrawers(bool isSlider)
    {
        foreach (Drawer drawer in drawers)
        {
            if (hSliderValue < drawer.WfirstPosition.time.totalTime)
            {
                drawer.obj.SetActive(false);
            }
            else if (hSliderValue < drawer.WlastPosition.time.totalTime)
            {
                if (isSlider)
                {
                    drawer.tweener.Goto(Drawer.getDuration(drawer.WfirstPosition.time.totalTime, hSliderValue), false);
                }
                else
                {
                    drawer.tweener.PlayForward();
                }
                drawer.obj.SetActive(true);
                if (drawer.isFocus)
                {
                    drawer.obj.transform.position = drawer.myPosition + Drawer.objFocus;
                    HighlightableObject ho = drawer.obj.GetComponent <HighlightableObject>();
                    if (ho != null)
                    {
                        ho.ConstantOn(Color.red);
                    }
                    else
                    {
                        Debug.Log("ho is null");
                    }
                }
                else
                {
                    drawer.obj.transform.position = drawer.myPosition;
                }
                //?
                if (drawer.isCompanion)
                {
                    foreach (Transform child in drawer.obj.transform)
                    {
                        if (child.name.Contains("line"))
                        {
                            child.GetComponent <LineRenderer>().SetVertexCount(0);
                        }
                    }
                }
                drawer.drawLine(isPlaying);
            }
            else
            {
                drawer.obj.SetActive(false);
            }

            //for companion
            if (drawer.isCompanion)
            {
                if (drawer.moveTimes.ContainsKey(((int)hSliderValue / 60)))
                {
                    drawer.obj.GetComponent <Renderer>().material.mainTexture = companionTexture;
                    drawer.obj.transform.FindChild("board").GetComponent <Renderer>().material.mainTexture = boardCompanionTexture;
                }
                else
                {
                    drawer.obj.GetComponent <Renderer>().material.mainTexture = normalTexture;
                    drawer.obj.transform.FindChild("board").GetComponent <Renderer>().material.mainTexture = boardNormalTexture;
                }
            }
        }
    }
예제 #13
0
    // Update is called once per frame
    void Update()
    {
        //If it's my turn
        if (isMyTurn)
        {
            //And we LEFT click
            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                mousePosUp = Input.mousePosition;
                mouseXUp = mousePosUp.x;
                mouseYUp = mousePosUp.y;
                leftUpRay = mainCam.ScreenPointToRay(new Vector3(mouseXUp, mouseYUp, 0));
                Debug.DrawRay (leftUpRay.origin, leftUpRay.direction * 800, Color.yellow);

                //And that click is on a
                if (Physics.Raycast(leftUpRay, out leftUpHit, 800, nonTileMask))
                {
                    mouse3DHitUp = leftUpHit.point;
                    publicLeftHit = leftUpHit.point;
                    Debug.Log(leftUpHit.collider.gameObject.name);

                    GameObject tempHit = leftUpHit.transform.gameObject;
                    script_2PBot tempBot = tempHit.transform.gameObject.GetComponent<script_2PBot>();

                    //Game object on the "Child" layer
                    if (tempHit.gameObject.tag == "Child")
                    {
                        if (selectedUnit != null)
                        {
                            if (tempUnitControl.targetMover.target != null)
                            {
                                //Deselect All Units
                                selectedUnit.transform.position = startPos;

                                //Disable the Unit's Movement
                                tempUnitControl = (script_2PBot)selectedUnit.GetComponent("script_2PBot");
                                tempUnitControl.selected = false;
                                tempUnitControl.selectedBy = null;
                                tempUnitControl.currentState = 0;
                                tempUnitControl.targetMover.target.transform.position = selectedUnit.transform.position;

                                //Reset our variables
                                movingUnit = false;
                            }

                            ClearUnits();
                        }

                        //If this is OUR unit and not the enemy's
                        if (gameManager.player1Turn)
                        {
                            if (tempBot.player1Unit == true)
                            {
                                //Select Unit
                                selectedUnit = tempHit;
                                targetScript.selectedUnit = selectedUnit;
                                unitStats = selectedUnit.GetComponent<UnitStats>();
                                tempUnitControl = (script_2PBot)tempHit.GetComponent("script_2PBot");
                                tempUnitControl.targetMover.target.transform.position = selectedUnit.transform.position;
                                tempUnitControl.selected = true;
                                tempUnitControl.selectedBy = this.gameObject;
                                //tempUnitControl.currentState = 1;

                                //Hi-light the unit
                                tempRend = tempHit.gameObject.GetComponentInChildren<Renderer>();
                                //tempRend.material.shader = hiLightShader;

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

                                //Get the unit's Starting Position
                                startPos = tempHit.gameObject.transform.position;
                                if (tempUnitControl.canMove)
                                {
                                    movingUnit = true;
                                }
                                showAttack = false;
                            }
                            else //This is the enemy's unit
                            {
                                Debug.Log("Enemy Unit hit.");

        //								if (movingUnit)
        //								{
        //									showAttack = true;
        //									tempUnitControl.botAI.target.position = tempHit.transform.position;
        //								}
                                //else
                                //{
                                    selectedUnit = tempHit;
                                    targetScript.selectedUnit = selectedUnit;
                                    unitStats = selectedUnit.GetComponent<UnitStats>();
                                    tempUnitControl = (script_2PBot)tempHit.GetComponent("script_2PBot");
                                    Debug.Log("Selecting unit.");
                                    tempUnitControl.selected = true;
                                    tempUnitControl.currentState = 0;

                                    tempUnitControl.selectedBy = this.gameObject;

                                    tempRend = tempHit.gameObject.GetComponentInChildren<Renderer>();
                                    //tempRend.material.shader = enemyShader;

                                    tempHL = selectedUnit.gameObject.GetComponent<HighlightableObject>();
                                    tempHL.ConstantOn(Color.red);
                                //}
                            }
                        }
                        else if (gameManager.player2Turn)
                        {
                            if (tempBot.player2Unit == true)
                            {
                                //Select Unit
                                selectedUnit = tempHit;
                                targetScript.selectedUnit = selectedUnit;
                                unitStats = selectedUnit.GetComponent<UnitStats>();
                                tempUnitControl = (script_2PBot)tempHit.GetComponent("script_2PBot");
                                tempUnitControl.targetMover.target.transform.position = selectedUnit.transform.position;
                                tempUnitControl.selected = true;
                                tempUnitControl.selectedBy = this.gameObject;
                                //tempUnitControl.currentState = 1;

                                //Hi-light the unit
                                tempRend = tempHit.gameObject.GetComponentInChildren<Renderer>();
                                //tempRend.material.shader = hiLightShader;

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

                                //Get the unit's Starting Position
                                startPos = tempHit.gameObject.transform.position;
                                if (tempUnitControl.canMove)
                                {
                                    movingUnit = true;
                                }
                                showAttack = false;
                            }
                            else //This is the enemy's unit
                            {
                                Debug.Log("Enemy Unit hit.");
        //								if (movingUnit)
        //								{
        //									showAttack = true;
        //									tempUnitControl.botAI.target.position = tempHit.transform.position;
        //								}
        //								else
        //								{
                                    selectedUnit = tempHit;
                                    targetScript.selectedUnit = selectedUnit;
                                    unitStats = selectedUnit.GetComponent<UnitStats>();
                                    tempUnitControl = (script_2PBot)tempHit.GetComponent("script_2PBot");
                                    tempUnitControl.selected = true;
                                    tempUnitControl.selectedBy = this.gameObject;
                                    tempUnitControl.currentState = 0;

                                    tempRend = tempHit.gameObject.GetComponentInChildren<Renderer>();
                                    //tempRend.material.shader = enemyShader;

                                    Debug.Log("Highlighting");
                                    tempHL = selectedUnit.gameObject.GetComponent<HighlightableObject>();
                                    tempHL.ConstantOn(Color.red);
                                //}
                            }
                        }
                    }
                    else // This is not a unit, so clear everything
                    {
                        Debug.Log("Clearing All");
                        if (GUIUtility.hotControl == 0)
                        {
                            //Send the unit back to the starting spot
                            if (selectedUnit != null)
                            {
                                if (tempUnitControl.selectedBy == tempUnitControl.ourPlayer)
                                {
                                    selectedUnit.transform.position = startPos;
                                }

                                //Disable the Unit's Movement
                                tempUnitControl = (script_2PBot)selectedUnit.GetComponent("script_2PBot");
                                tempUnitControl.selected = true;
                                tempUnitControl.currentState = 0;

                                //Reset our variables
                                movingUnit = false;
                                showAttack = false;
                                ClearUnits();
                            }
                        }
                    }
                }
            }

            //If we RIGHT click
            if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                mousePosUp = Input.mousePosition;
                mouseXUp = mousePosUp.x;
                mouseYUp = mousePosUp.y;
                leftUpRay = mainCam.ScreenPointToRay(new Vector3(mouseXUp, mouseYUp, 0));
                Debug.DrawRay (leftUpRay.origin, leftUpRay.direction * 800, Color.yellow);

                //And that click is on a
                if (Physics.Raycast(leftUpRay, out leftUpHit, 800))
                {
                    mouse3DHitUp = leftUpHit.point;
                    publicLeftHit = leftUpHit.point;
                    Debug.Log(leftUpHit.collider.gameObject.name);

                    GameObject tempHit = leftUpHit.transform.gameObject;
                    script_2PBot tempBot = tempHit.transform.gameObject.GetComponent<script_2PBot>();

                    //we hit a unit
                    if (tempHit.gameObject.tag == "Child")
                    {
                        //we have a unit selected
                        if (selectedUnit != null)
                        {
                            //we are a jock
                            if (playerType == PlayerType.Jock)
                            {
                                //we selected a nerd
                                if (tempHit.gameObject.name.Contains("Nerd"))
                                {
                                    //our selected unit is a jock
                                    if (selectedUnit.gameObject.name.Contains("Jock"))
                                    {
                                        Debug.Log("Nerd Hit");
                                        targetEnemy = tempHit.gameObject;

                                        if (Vector3.Distance(selectedUnit.gameObject.transform.position, targetEnemy.transform.position) < tempUnitControl.remainingDistance)
                                        {
                                            if (tempUnitControl.canAttack)
                                            {
                                                tempUnitControl.selected = true;
                                                tempUnitControl.currentState = 1;

                                                //Get the unit's Starting Position
                                                startPos = tempHit.gameObject.transform.position;

                                                tempUnitControl.targetMover.target.transform.position = targetEnemy.transform.position;
                                                attackMode = true;
                                                AkSoundEngine.PostEvent("Play_AttackSelect", this.gameObject);
                                                AkSoundEngine.PostEvent("Set_State_Attack", this.gameObject);
                                                Destroy(tempUnitControl.localMoveDistanceObj);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (playerType == PlayerType.Nerd)
                            {
                                if (tempHit.gameObject.name.Contains("Jock"))
                                {
                                    if (selectedUnit.gameObject.name.Contains("Nerd"))
                                    {
                                        Debug.Log("Jock Hit");
                                        targetEnemy = tempHit.gameObject;

                                        if (Vector3.Distance(selectedUnit.gameObject.transform.position, targetEnemy.transform.position) < tempUnitControl.remainingDistance)
                                        {
                                            if (tempUnitControl.canAttack)
                                            {
                                                tempUnitControl.selected = true;
                                                tempUnitControl.currentState = 1;

                                                //Get the unit's Starting Position
                                                startPos = tempHit.gameObject.transform.position;

                                                tempUnitControl.targetMover.target.transform.position = targetEnemy.transform.position;
                                                attackMode = true;
                                                AkSoundEngine.PostEvent("Play_AttackSelect", this.gameObject);
                                                AkSoundEngine.PostEvent("Set_State_Attack", this.gameObject);
                                                Destroy(tempUnitControl.localMoveDistanceObj);
                                            }
                                        }
                                    }
                                }
                            }
                        }

                    }
                }

            } //End of Right Click

            if (attackMode)
            {
                if (selectedUnit != null)
                {
                    float distance = Vector3.Distance(selectedUnit.gameObject.transform.position, targetEnemy.gameObject.transform.position);

                    if (distance < unitStats.AtkRng)
                    {
                        script_2PBot botScript = selectedUnit.gameObject.GetComponent<script_2PBot>();

                        if (botScript.canAttack)
                        {
                            Vector3 spawnSpot = new Vector3(targetEnemy.transform.position.x, targetEnemy.transform.position.y + 3, targetEnemy.transform.position.z);
                            Instantiate(attackEffect, spawnSpot, Quaternion.identity);
                            tempUnitControl.targetMover.target.transform.position = selectedUnit.transform.position;
                            tempUnitControl.currentState = 0;
                            Debug.Log("Attacking!!!!");
                            UnitStats enemyScript = targetEnemy.gameObject.GetComponent<UnitStats>();
                            enemyScript.CurrentHealth -= unitStats.AtkDmg;
                            attackMode = false;
                            movingUnit = false;
                            botScript.currentState = 0;
                            botScript.canAttack = false;
                            ClearUnits();
                        }

                    }
                }
            }

            if (movingUnit)
            {
                if (movesRemaining > 0)
                {
                    if (Input.GetKeyDown(KeyCode.Space))
                    {
                        if (Vector3.Distance(selectedUnit.transform.position, startPos) > 1)
                        {
                            movesRemaining--;
                        }

                        //Disable the Unit's Movement
                        tempUnitControl = (script_2PBot)selectedUnit.GetComponent("script_2PBot");
                        tempUnitControl.selected = true;
                        tempUnitControl.currentState = 0;

                        if (Vector3.Distance(tempUnitControl.targetSpot, tempUnitControl.spotPos) < tempUnitControl.remainingDistance)
                        {
                            Vector3 newPos = new Vector3(tempUnitControl.targetMover.target.transform.position.x, tempUnitControl.gameObject.transform.position.y, tempUnitControl.targetMover.target.transform.position.z);
                            tempUnitControl.gameObject.transform.position = newPos;
                        }

                        //Reset our variables
                        movingUnit = false;
                        tempUnitControl.canMove = false;
                        ClearUnits();
                        AkSoundEngine.PostEvent("Play_Confirm", this.gameObject);
                    }
                }
            }

            //Constant Update for Highlighting
            mousePosUp = Input.mousePosition;
            mouseXUp = mousePosUp.x;
            mouseYUp = mousePosUp.y;
            leftUpRay = mainCam.ScreenPointToRay(new Vector3(mouseXUp, mouseYUp, 0));
            Debug.DrawRay (leftUpRay.origin, leftUpRay.direction * 800, Color.yellow);

            //And that click is on a
            if (Physics.Raycast(leftUpRay, out leftUpHit, 800))
            {
                mouse3DHitUp = leftUpHit.point;
                publicLeftHit = leftUpHit.point;
                //Debug.Log(leftUpHit.collider.gameObject.name);

                GameObject tempHit = leftUpHit.transform.gameObject;
                script_2PBot tempBot = tempHit.transform.gameObject.GetComponent<script_2PBot>();

                //Game object on the "Child" layer
                if (tempHit.gameObject.tag == "Child")
                {
                    if (playerType == PlayerType.Nerd)
                    {
                        if (tempHit.gameObject.name.Contains("Nerd"))
                        {
                            tempHL = tempHit.gameObject.GetComponent<HighlightableObject>();
                            tempHL.On(highlightColor);
                        }

                        if (tempHit.gameObject.name.Contains("Jock"))
                        {
                            tempHL = tempHit.gameObject.GetComponent<HighlightableObject>();
                            tempHL.On(Color.red);
                        }
                    }

                    if (playerType == PlayerType.Jock)
                    {
                        if (tempHit.gameObject.name.Contains("Jock"))
                        {
                            tempHL = tempHit.gameObject.GetComponent<HighlightableObject>();
                            tempHL.On(highlightColor);
                        }

                        if (tempHit.gameObject.name.Contains("Nerd"))
                        {
                            tempHL = tempHit.gameObject.GetComponent<HighlightableObject>();
                            tempHL.On(Color.red);
                        }
                    }
                }
            }
        }
    }
    // 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;
        }
    }
예제 #15
0
 void OnMouseOver()
 {
     mho.ConstantOn(Color.red);
 }