Exemple #1
0
 public void Select(RaycastTarget target)
 {
     OnFillEnd.Invoke();
     if (target != null)
     {
         target.OnFillEnd.Invoke();
     }
 }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     if (dragging)
     {
         Vector3 target = RaycastTarget.Cast(Input.mousePosition);
         draggingObject.transform.position = new Vector3(target.x, target.y, draggingObject.transform.position.z);
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonUp("Build"))
     {
         Vector3 target = RaycastTarget.Cast(Input.mousePosition);
         target += new Vector3(0f, 1f, 0f);
         Instantiate(block, RoundVector(target), Quaternion.identity);
     }
 }
Exemple #4
0
 public void StartFill(RaycastTarget target)
 {
     //Chama os eventos quando a barra começa a carregar
     if (target != null)
     {
         target.OnStartLoad.Invoke();
     }
     OnStartLoad.Invoke();
     //Chama a co-rotina para iniciar o carregamento da barra
     if (UseTimer)
     {
         FillCoroutine = StartCoroutine(Filling(target));
     }
 }
Exemple #5
0
 IEnumerator Filling(RaycastTarget target)
 {
     //Carregar a barra circular no tempo determinado
     loadFillAmount = 0;
     while (loadFillAmount < 1)
     {
         loadFillAmount      += Time.deltaTime / LoadFillTime;
         RadialBar.fillAmount = loadFillAmount;
         yield return(new WaitForEndOfFrame());
     }
     loadFillAmount = 1;
     //Chama os eventos quando a barra terminar de carregar
     Select(target);
 }
Exemple #6
0
    private Vector3 _TryGetRaycastHit(Vector2 touch, RaycastTarget target)
    {
        var hit        = new RaycastHit();
        var ray        = _attachedCamera.ScreenPointToRay(touch);
        var didFindHit = false;

        switch (target)
        {
        case RaycastTarget.Ground:
            didFindHit = Physics.Raycast(ray, out hit, MaxRaycastDistance, _layerMaskGroundCollider);
            break;
        }
        return(didFindHit ? hit.point : _positiveInfinity);
    }
Exemple #7
0
 public void ResetFill(RaycastTarget target)
 {
     //Chama os eventos quando deixa de carregar a barra
     if (target != null)
     {
         target.OnExitRaycast.Invoke();
     }
     OnExitRaycast.Invoke();
     //Reinicia a barra de carregamento
     //Para a co-rotina de carregamento da barra
     RadialBar.fillAmount = 0;
     if (FillCoroutine != null)
     {
         StopCoroutine(FillCoroutine);
     }
 }
Exemple #8
0
    public void OnPointerUp(PointerEventData eventData)
    {
        RaycastTarget workerPool = GetDropTarget(WORKER_POOL);

        if (workerPool != null)
        {
            Debug.Log("dropped Worker!");
            _moveMessage.To = workerPool.Id;
            GameMessage.Send <WorkerMoveMessage>(_moveMessage);
        }
        else
        {
            _goTransform.position = _originalPosition;
        }

        _image.raycastTarget = true;
        _isDragging          = false;
    }
Exemple #9
0
    void Update()
    {
        //Raycast a partir desse objeto camera,
        //na direção que o usuário está olhando
        Ray        ray = new Ray(transform.position, transform.forward);
        RaycastHit hit;

        if (controller.ControllerIsConnected)
        {
            Vector3 worldStartPoint = controller.ControllerWorldPosition;
            Vector3 worldEndPoint   = controller.WorldEndPoint;

            // Create new ray
            ray = controller.ControllerRay;
            Physics.Raycast(ray, out hit);

            controller.line.enabled = controller.ShowLine;
            if (controller.ShowLine && controller.line != null)
            {
                controller.line.SetPosition(0, worldStartPoint);
                if (hit.collider != null)
                {
                    worldEndPoint = hit.point;
                }
                controller.line.SetPosition(1, worldEndPoint);
            }
        }

        Physics.Raycast(ray, out hit);
        //Verifica o objeto que raycast colide
        if (hit.collider != null)
        {
            //Verifica se o raycast mudou o objeto alvo
            if (ActualTarget != hit.collider.gameObject)
            {
                ActualTarget = hit.collider.gameObject;
                //Verifica se tem um componente RaycastTarget nesse objeto
                if (ActualTarget.GetComponent <RaycastTarget>() != null)
                {
                    ActualTargetEvents = ActualTarget.GetComponent <RaycastTarget>();
                }
                else
                {
                    ActualTargetEvents = null;
                }
                //Inicia o evento de carregamento da barra circular
                CircleScript.StartFill(ActualTargetEvents);
            }
            //Ajusta a posição, tamanho e rotação da mira
            // a partir do ponto de colisão do raycast
            reticle.position   = hit.point;
            reticle.localScale = startScale * hit.distance;
            reticle.rotation   = Quaternion.FromToRotation(Vector3.forward, hit.normal);
            if (Input.GetMouseButton(0))
            {
                CircleScript.Select(ActualTargetEvents);
            }

            //Se não estiver olhando para nenhum objeto
        }
        else
        {
            ActualTarget = null;
            //Chama o evento de parar o carregamento da barra circular
            CircleScript.ResetFill(ActualTargetEvents);
            //Ajusta a posição, tamanho e rotação da mira
            // em relação à distancia máxima
            reticle.position   = ray.GetPoint(MaxDistanceReticle);
            reticle.localScale = startScale * MaxDistanceReticle;
            reticle.rotation   = Quaternion.FromToRotation(Vector3.forward, ray.direction);
        }
    }
    private bool _TryGetRaycastHit(Vector2 touch, out RaycastHit hit, RaycastTarget target)
    {
        Ray ray = MainCamera.ScreenPointToRay(touch);

        return(Physics.Raycast(ray, out hit, 1000, (target == RaycastTarget.BASE_ITEM) ? _layerMaskBaseItemCollider : _layerMaskGroundCollider));
    }
Exemple #11
0
        private bool TryGetRaycastHit(Vector2 touch, out RaycastHit hit, RaycastTarget target)
        {
            Ray ray = MainCamera.ScreenPointToRay(touch);

            return(Physics.Raycast(ray, out hit, 1000, (target == RaycastTarget.FunctionBlock) ? _MaskBlockCollider : _MaskGroundCollider));
        }