Пример #1
0
    void CastRay()
    {
        /* int targetLayer = 1 << layerMask;
         * if (hitEveryOtherLayer) {
         *   targetLayer = ~layerMask;
         * }*/
        int        targetLayer = layerMask;
        RaycastHit hit;

        if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit, 100, targetLayer))
        {
            //Debug.Log ("Hit something!");
            targetAgent.SetDestination(hit.point);
            startMoveEvent.Invoke(targetAgent, hit.point);
            if (clickToMoveObject != null)
            {
                clickToMoveObject.GetComponent <Animator> ().SetBool("Active", true);
                clickToMoveObject.SetActive(true);
                clickToMoveObject.transform.position = hit.point;
            }
            //Invoke ("LateStartMove", 0.1f);
            isMoving = true;
        }
        else
        {
            if (clickToMoveFailedObject != null)
            {
                //clickToMoveFailedObject.GetComponent<Animator> ().SetBool ("Active", true);
                clickToMoveFailedObject.SetActive(true);
                clickToMoveFailedObject.transform.position = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition);
                //clickToMoveFailedObject.transform.position = new Vector3 (clickToMoveFailedObject.transform.position.x, clickToMoveFailedObject.transform.transform.position.y, 0f);
                Invoke("DisableClickLocation", 0.5f);
            }
            //Debug.Log ("hit nothing!");
        }
    }
Пример #2
0
 public void OnStartMove()
 {
     StartMove?.Invoke();
 }
Пример #3
0
 protected void OnStartMove()
 {
     StartMove?.Invoke();
 }