Пример #1
0
    private void InputUpdate()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            if (_target == null)
            {
                return;
            }

            _isAttack = true;

            SendAttackUnitViews sendAttackUnitViews = new SendAttackUnitViews();
            sendAttackUnitViews.SendAttackUnit(_netObject.Id, _target.GetComponent <NetObject>().Id);
        }

        if (Input.GetMouseButtonDown(0))
        {
            if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }

            RaycastHit hit;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100))
            {
                if (!BattleManager.Instance.SessionStarted)
                {
                    transform.position = new Vector3(hit.point.x, hit.point.y + 0.5f, hit.point.z);

                    SetUnitPositionView setUnitPositionView = new SetUnitPositionView();
                    setUnitPositionView.SetPosition(_netObject.Id, transform.position);
                }

                if (hit.collider.tag == "Player")
                {
                    if (!hit.collider.gameObject.GetComponent <NetObject>().IsMine)
                    {
                        SendAttackUnitViews sendAttackUnitViews = new SendAttackUnitViews();
                        sendAttackUnitViews.SendAttackUnit(_netObject.Id, hit.collider.gameObject.GetComponent <NetObject>().Id);
                        return;
                    }
                }

                _isAttack = false;
                _netObject.SendNewDestination(hit.point);
            }
        }
    }