Пример #1
0
    private void ModeNormalBehaviour()
    {
        //Handle all non event, and non gui UI elements here
        hoverOver = HoverOver.Land;
        InteractionState interactionState = InteractionState.Nothing;

        //Are we hovering over the GUI or the main screen?
        if (Input.mousePosition.x < Screen.width - m_GuiWidth)
        {
            //We're over the main screen, let's raycast
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, Mathf.Infinity, ~(1 << 16)))
            {
                currentObject = hit.collider.gameObject;
                switch (hit.collider.gameObject.layer)
                {
                case 8:
                    //Friendly unit
                    hoverOver = HoverOver.FriendlyUnit;
                    break;

                case 9:
                    //Enemy Unit
                    hoverOver = HoverOver.EnemyUnit;
                    break;

                case 11:
                case 17:
                    //Terrain or shroud
                    hoverOver = HoverOver.Land;
                    break;

                case 12:
                    //Friendly Building
                    hoverOver = HoverOver.FriendlyBuilding;
                    break;

                case 13:
                    //Enemy building
                    hoverOver = HoverOver.EnemyBuilding;
                    break;
                }
            }
        }
        else
        {
            //Mouse is over GUI
            hoverOver = HoverOver.Menu;
        }

        if (hoverOver == HoverOver.Menu || m_SelectedManager.ActiveObjectsCount() == 0 || m_GuiManager.GetSupportSelected != 0)
        {
            //Nothing orderable Selected or mouse is over menu or support is selected
            CalculateInteraction(hoverOver, ref interactionState);
        }
        else if (m_SelectedManager.ActiveObjectsCount() == 1)
        {
            //One object selected
            CalculateInteraction(m_SelectedManager.FirstActiveObject(), hoverOver, ref interactionState);
        }
        else
        {
            //Multiple objects selected, need to find which order takes precedence
            CalculateInteraction(m_SelectedManager.ActiveObjectList(), hoverOver, ref interactionState);
        }

        //Tell the cursor manager to update itself based on the interactionstate
        CursorManager.main.UpdateCursor(interactionState);
    }