Esempio n. 1
0
    void HandleTargetReticle()
    {
        if (GameplayController.GameIsStopped)
        {
            TargetingReticleInstance.Hide();
            return;
        }

        Ray          pointerRay = PointerCamera.ScreenPointToRay(Input.mousePosition);
        RaycastHit2D hit        = Physics2D.Raycast(pointerRay.origin, pointerRay.direction, float.MaxValue, ReactorLayerMask);

        if (hit.collider != null)
        {
            Reactor hitReactor = hit.collider.GetComponentInParent <Reactor>();
            TargetingReticleInstance.MoveToReactor(hitReactor);
            HoveredReactor = hitReactor;
            hitReactor.BeingHovered(SelectedResource);
            return;
        }

        if (HoveredReactor != null)
        {
            HoveredReactor.EndHovered();
            TargetingReticleInstance.Hide();
            HoveredReactor = null;
        }
        else
        {
            TargetingReticleInstance.Hide();
        }
    }