Пример #1
0
    void Update()
    {
        if (!Assault && _assaultStarted)
        {
            OnAssaultEnded();
            _assaultStarted = false;
        }

        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, UnitsLayer))
            {
                if (Selected != null)
                    Selected.SetInfoVisibility(false);

                var collider = hit.collider;
                Selected = collider.GetComponent<Soldier>();
                Selected.SetInfoVisibility(true);
            }
            else if (!Assault && Selected != null && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, CoversLayer))
            {
                var collider = hit.collider;
                StartMovingSoldier(Selected.transform, collider.gameObject);
            }
        }
    }