Exemplo n.º 1
0
    void Awake()
    {
        addPanelButton.onClick.AddListener(OnAddPanelButtonClick);
        Util.FindIfNotSet(this, ref cursorManager);

        centerButton.onClick.AddListener(panelManager.ZoomOutToAllPanels);
        organizePanelsButton.onClick.AddListener(() => panelManager.SetOrganizedPanels(true));

        cardDetail              = Instantiate(cardDetailPrefab, null);
        cardDetail.onTrashCard += (unassignedModel, assignedModel) =>
        {
            UnassignCard(assignedModel);
        };
        cardDetail.onCodeCard += (card, assignment, container) =>
        {
            if (!card.IsValid())
            {
                return;
            }
            if (card.IsBuiltin())
            {
                // Builtin card. Create a custom copy of it and change the assignment to
                // refer to the copy instead.
                ICardModel cardCustomCopy = card.MakeCopy();
                int        index          = container.deck.GetModel().GetIndexOf(assignment);
                container.deck.AcceptCard(cardCustomCopy, index, assignment.GetProperties());
                // Remove the old assignment
                assignment.Unassign();

                // Maybe open the code editor for the custom copy
                onCodeRequest?.Invoke(cardCustomCopy.GetUri());
            }
            else
            {
                onCodeRequest?.Invoke(card.GetUri());
            }
        };
        cardDetail.onPreviewCard += (card) =>
        {
            onCodeRequest?.Invoke(card.GetUri());
        };
        closeButton.onClick.AddListener(() =>
        {
            onCloseRequest?.Invoke();
        });
    }