Esempio n. 1
0
    void GetBuildingFromMouse()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100.0f, layer))
            {
                building = hit.collider.GetComponent <BuildingBase>();
                if (building != null && building != currentlySelected)
                {
                    PlayerTypes pt = building.PlayerType;
                    if (pt == PlayerTypes.humanPlayer)
                    {
                        building.EnableMenu();
                        currentlySelected = building;
                    }
                }
            }
        }
    }