Esempio n. 1
0
    public override void OnDrag(PointerEventData eventData)
    {
        if (PlayerCombatController.Instance.OurTurn == false)
        {
            return;
        }

        if (CameraHelper.IsMouseOverUI())
        {
            _pointReticleObject.transform.position = Vector3.up * 1000;
        }
        else
        {
            Vector3 navPlanePoint = NavigationPlane.RaycastNavPlane();

            _pointReticleObject.transform.position = _targetPosition = navPlanePoint;

            List <Entity> nearbyEntities = SelectionController.Instance.GetEntitiesWithinRadius(navPlanePoint, 35f);

            if (nearbyEntities.Count > 0)
            {
                _targetEntity = nearbyEntities[0];
                _pointReticleObject.transform.position = _targetEntity.transform.position;
            }
            else
            {
                _targetEntity = null;
            }
        }
    }
    public void OnDrag(PointerEventData eventData)
    {
        if (PlayerCombatController.Instance.OurTurn == false || PlayerCombatController.Instance.FocusedShip != ShipController)
        {
            return;
        }

        Vector3 navPlanePoint = NavigationPlane.RaycastNavPlane();

        _flightPath = PathUtils.GetBezierCurve(transform.position, transform.position + transform.forward * _forwardHandleOffset, navPlanePoint, 12);
        _flightPathRenderer.positionCount = 12;
        _flightPathRenderer.SetPositions(_flightPath.curve);

        _forwardHandleOffset = _flightPath.Length() / 2f;
        Vector3 _flightPathEndDirection = PathUtils.GetDirectionOnBezierCurve(_flightPath.Start, _flightPath.Mid, _flightPath.End, 1f);

        _isFlightPathValid = _flightPath.Length() <= _maxFlightDistancePerTurn && Vector3.Angle(transform.forward, _flightPathEndDirection) <= _maxAngleDeltaPerTurn;

        _flightPathRenderer.material = _isFlightPathValid ? _validFlightPathMaterial : _invalidFlightPathMaterial;

        _ghostShipGO.transform.position = _flightPath.End;
        _ghostShipGO.transform.forward  = _flightPathEndDirection;
    }