Exemplo 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;
            }
        }
    }
Exemplo n.º 2
0
    public void Teleport(string plane, Vector3 pos, Vector3?rotation)
    {
        Vector3 rot = rotation ?? transform.eulerAngles;

        pos.y    = 0;
        navPlane = NavigationPlane.FindPlane(plane);
        NavigationPlane.ValidMove(ref pos, ref navPlane);
        transform.position    = pos;
        transform.eulerAngles = rot;
        targetRotation        = transform.rotation;
    }
    private void OnTouchClick(TouchInput.TouchData touchData)
    {
        if (touchData.DownOverUI || touchData.UpOverUI)
        {
            return;
        }

        Vector2 selectionPoint      = NavigationPlane.RaycastNavPlane2D();
        Entity  newlySelectedEntity = GetFirstSelectedEntity(selectionPoint);

        SetSelection(newlySelectedEntity);
    }
Exemplo n.º 4
0
    // Utilities:

    public static void ApplyUpgrades()
    {
        NavigationPlane store = NavigationPlane.FindPlane("Store_Main");

        if (State.currentGameUpgrade > 6)
        {
            StoreReferances.instance.belt.moveSpeed = new Vector3(2.0f, 0, 0);
            StoreReferances.instance.belt.spawnMin  = 0.75f;
            StoreReferances.instance.belt.spawnMax  = 0.75f;
        }
        else if (State.currentGameUpgrade > 1)
        {
            StoreReferances.instance.belt.moveSpeed = new Vector3(1.0f, 0, 0);
            StoreReferances.instance.belt.spawnMin  = 1.0f;
            StoreReferances.instance.belt.spawnMax  = 3.0f;
        }
        else
        {
            StoreReferances.instance.belt.moveSpeed = new Vector3(0.5f, 0, 0);
            StoreReferances.instance.belt.spawnMin  = 3.0f;
            StoreReferances.instance.belt.spawnMax  = 5.0f;
        }

        StoreReferances.instance.table1.SetActive(State.currentGameUpgrade > 2);
        store.exceptions[1].navigable = !(State.currentGameUpgrade > 2);

        StoreReferances.instance.table2.SetActive(State.currentGameUpgrade > 7);
        store.exceptions[2].navigable = !(State.currentGameUpgrade > 7);

        InteractionCheckout.instances[1].gameObject.SetActive(State.currentGameUpgrade > 4);
        store.exceptions[7].navigable = !(State.currentGameUpgrade > 4);
        store.exceptions[8].navigable = !(State.currentGameUpgrade > 4);
        store.exceptions[9].navigable = !(State.currentGameUpgrade > 4);

        InteractionCheckout.instances[2].gameObject.SetActive(State.currentGameUpgrade > 9);
        store.exceptions[10].navigable = !(State.currentGameUpgrade > 9);
        store.exceptions[11].navigable = !(State.currentGameUpgrade > 9);
        store.exceptions[12].navigable = !(State.currentGameUpgrade > 9);

        if (!StoreReferances.instance.storeTimerOn)
        {
            StoreReferances.instance.storeTimerLeft = (State.currentGameUpgrade > 5) ? 300 : 150;
        }
    }
    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;
    }
Exemplo n.º 6
0
    void Update()
    {
        float speed = 0;

        if (!GameStateManager.IsMenu && GameStateManager.HasFocus)
        {
            Vector3    oldPos        = transform.localPosition;
            Quaternion cameraForward = Quaternion.Euler(0, cam.eulerAngles.y, 0);
            Vector3    moveVector    = cameraForward * new Vector3(Input.GetAxis("Horizontal"), 0,
                                                                   Input.GetAxis("Vertical"));
            if (moveVector.sqrMagnitude > 0.01f)
            {
                speed = moveVector.magnitude;
                if (speed > 1)
                {
                    moveVector /= speed;
                    speed       = 1;
                }
                float accSpeed = moveSpeed;
                if (GameStateManager.State.currentGameUpgrade > 3)
                {
                    accSpeed *= 1.5f;
                }
                Vector3 newPos = transform.localPosition + Time.deltaTime * accSpeed * moveVector;
                NavigationPlane.ValidMove(ref newPos, ref navPlane);
                transform.localPosition = newPos;
                targetRotation          = Quaternion.LookRotation(moveVector);
            }
            transform.localRotation = Quaternion.RotateTowards(transform.localRotation, targetRotation,
                                                               spinSpeed * Time.deltaTime);
        }
        animator.speed = 10.0f * speed;
        Vector3 pos = positionInteraction.localPosition;

        pos.y = offsetYInteraction * (1.0f / cam.up.y);
        positionInteraction.localPosition = pos;
    }
Exemplo n.º 7
0
 void Start()
 {
     cam      = Camera.main.transform;
     navPlane = NavigationPlane.FindPlane(startingPlane);
 }
Exemplo n.º 8
0
    public static bool ValidMove(ref Vector3 pos, ref NavigationPlane plane)
    {
        if (plane.navigable && plane.Contains(pos.x, pos.z))
        {
            bool noExcept = true;
            foreach (Exception e in plane.exceptions)
            {
                if (!e.navigable && plane.ExceptionContains(e, pos.x, pos.z))
                {
                    noExcept = false;
                    break;
                }
            }
            if (noExcept)
            {
                return(true);
            }
        }

        NavigationPlane nPlane = null;

        if (plane.navigable)
        {
            List <NavigationPlane> visitedPlanes = new List <NavigationPlane>();
            nPlane = plane.SearchPlanes(pos.x, pos.z, ref visitedPlanes, 3);
        }
        if (nPlane == null)
        {
            nPlane = plane;
            Vector3 nPos  = plane.NearestPoint(pos);
            float   nDist = (nPos - pos).sqrMagnitude;
            if (!plane.navigable)
            {
                nDist = float.PositiveInfinity;
            }

            foreach (NavigationPlane tPlane in plane.connections)
            {
                if (tPlane.navigable)
                {
                    Vector3 tPos  = tPlane.NearestPoint(pos);
                    float   tDist = (tPos - pos).sqrMagnitude;
                    if (tDist < nDist)
                    {
                        nDist  = tDist;
                        nPos   = tPos;
                        nPlane = tPlane;
                    }
                }
            }

            pos   = nPos;
            plane = nPlane;

            return(false);
        }
        else
        {
            pos   = nPlane.NearestPoint(pos);
            plane = nPlane;
            return(true);
        }
    }