예제 #1
0
    private void LateUpdate()
    {
        var tileUnderMouse = GetTileUnderMouse();

        if (Input.GetKeyDown(MoveKey))
        {
            SetCurrentActionToMove.InvokeSafe();
        }

        if (Input.GetKeyDown(PrimaryAttackKey))
        {
            SetCurrentActionToAttack.InvokeSafe();
        }

        if (Input.GetKeyDown(ContinueKey))
        {
            Continue.InvokeSafe();
        }

        if (Input.GetKeyDown(UndoKey))
        {
            Undo.InvokeSafe();
        }

        if (tileUnderMouse != null)
        {
            if (Input.GetKeyDown(SpawnDefaultUnitKey))
            {
                SpawnDefaultUnit.InvokeSafe(tileUnderMouse);
            }

            if (Input.GetKeyDown(PreviewKey))
            {
                PreviewAction?.Invoke(tileUnderMouse);
            }

            if (Input.GetMouseButtonDown(0))
            {
                Select.InvokeSafe(tileUnderMouse);
            }

            if (Input.GetMouseButtonDown(1))
            {
                CommitCurrentAction.InvokeSafe(tileUnderMouse);
            }

            if (Input.GetKeyDown(KeyCode.K))
            {
                Kill?.Invoke(tileUnderMouse);
            }
        }

        if (tileUnderMouse != _lastTileUnderMouse)
        {
            HoveredTileChanged?.Invoke(tileUnderMouse);
        }

        _lastTileUnderMouse = tileUnderMouse;
    }