Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        Vector3 mousePos = Input.mousePosition;

        //float x=mousePos.x/Screen.width;
        //float y=mousePos.y/Screen.height;
        //Vector3 pos=new Vector3(x, y, 100);
        //cursorT.position=pos;

        if (UIRect.IsCursorOnUI(mousePos))
        {
            //cursor.texture=pointer;
            currentTexture = pointer;
        }
        else
        {
            Ray        ray = Camera.main.ScreenPointToRay(mousePos);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, Mathf.Infinity))
            {
                if (hit.collider.gameObject.layer == LayerManager.LayerCreep())
                {
                    if (GameControl.selectedTower != null)
                    {
                        //cursor.texture=hostile;
                        currentTexture = hostile;
                    }
                }
                else if (hit.collider.gameObject.layer == LayerManager.LayerCreepF())
                {
                    if (GameControl.selectedTower != null)
                    {
                        //cursor.texture=hostile;
                        currentTexture = hostile;
                    }
                }
                else if (hit.collider.gameObject.layer == LayerManager.LayerTower())
                {
                    //cursor.texture=friendly;
                    currentTexture = friendly;
                }
                else
                {
                    //cursor.texture=pointer;
                    currentTexture = pointer;
                }
            }
        }
    }