Exemplo n.º 1
0
    public void OnEndDrag(PointerEventData eventData)
    {
        Debug.Log($"End Drag {eventData.position}");

        if (buildingPreviewInstance == null)
        {
            return;
        }

        Ray ray = mainCamera.ScreenPointToRay(eventData.position);

        if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, floorMask))
        {
            player.CmdTryPlaceBuilding(building.GetId(), hit.point);
        }

        Destroy(buildingPreviewInstance);
    }
Exemplo n.º 2
0
    private void TryPutBuilding()
    {
        var ray = mainCamera.ScreenPointToRay(Mouse.current.position.ReadValue());

        if (Physics.Raycast(ray, out var hit, Mathf.Infinity, floorMask))
        {
            player.CmdTryPlaceBuilding(building.ID, hit.point);
            Destroy(buildingPrevievInstance);
        }
    }
Exemplo n.º 3
0
    public void OnPointerUp(PointerEventData eventData)
    {
        if (buildingPreviewInstance == null)
        {
            return;
        }
        Ray ray = mainCamera.ScreenPointToRay(Mouse.current.position.ReadValue());

        if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, floorMask))
        {
            player.CmdTryPlaceBuilding(building.GetId(), hit.point);
        }

        Destroy(buildingPreviewInstance);
    }
Exemplo n.º 4
0
    public void OnPointerUp(PointerEventData eventData)
    {
        //If We Arent Dragging, We Release Mouse Button
        if (buildingPreviewInstance == null)
        {
            return;
        }

        Ray ray = mainCamera.ScreenPointToRay(Mouse.current.position.ReadValue());

        //Place Building At Hit Position
        if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, groundMask))
        {
            player.CmdTryPlaceBuilding(building.GetId(), hit.point);
        }

        Destroy(buildingPreviewInstance);
    }
Exemplo n.º 5
0
    public void OnPointerUp(PointerEventData eventData)
    {
        //If the building preview instance is not null. Raycast to mouse position, Place building, Destroy preview instance.
        if (buildingPreviewInstance == null)
        {
            return;
        }

        Ray ray = mainCamera.ScreenPointToRay(Mouse.current.position.ReadValue());

        if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, floorMask))
        {
            //Place building
            player.CmdTryPlaceBuilding(hit.point, building.GetId());
        }

        //Released destroy preview INSTANCE
        Destroy(buildingPreviewInstance);
    }
Exemplo n.º 6
0
    public void OnPointerUp(PointerEventData eventData)
    {
        // not dragging
        if (buildingPreviewInstance == null)
        {
            return;
        }

        // WHAT WAS PRESSED?
        if (!MUtils.WasAHit(out RaycastHit hit, floorMask))
        {
            return;
        }

        // PLACE BUILDING
        player.CmdTryPlaceBuilding(building.GetId(), hit.point);

        Destroy(buildingPreviewInstance);
    }