Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement drag and drop mechanic for a card #51

Merged
merged 9 commits into from
Jan 2, 2021
Merged

Conversation

OriginalUtkin
Copy link
Owner

@OriginalUtkin OriginalUtkin commented Dec 31, 2020

In that MR I'd like to introduce drag and drop mechanic for manipulating with cards.

Before: Previously we had all callbacks are defined in the Main.cs and manipulating (set and call) via delegates. That lead to a lot of dependencies that are sent through the code and required to pass additional parameters during the initialisation + define it in the places (see Main.cs where it doesn't suit logically).

Now: Since SimpleCard card script is responsible for card visualisation (contains face prefab, card position on scene, etc.) we could say that it is the perfect place to define how card GUI representation should interact with mouse cursor. Since GUI is responsible for manipulating with an object, we also need to define how this object will be handed by others when mouse button will be up and card will be dropped to other object. For that purpose I've implemented the IInteractable interface that define method for receiving any type of object that is inherited from MonoBehavior. For now, only PlayerBattlefield implements this interface. The main point is that each object that could communicate with an another should implement this interface. In that case, caller side won't know any implementation details but only that object under selected one is able to handle it.

Assets/Scripts/Card/SimpleCard.cs Outdated Show resolved Hide resolved
Assets/Scripts/Card/SimpleCard.cs Outdated Show resolved Hide resolved
Assets/Scripts/Card/SimpleCard.cs Outdated Show resolved Hide resolved
Assets/Scripts/Card/SimpleCard.cs Outdated Show resolved Hide resolved
Assets/Scripts/Card/SimpleCard.cs Outdated Show resolved Hide resolved
Assets/Scripts/GameProcess/Main.cs Outdated Show resolved Hide resolved
Assets/Scripts/GameProcess/PlayerBattlefield.cs Outdated Show resolved Hide resolved
Assets/Scripts/GameProcess/PlayerBattlefield.cs Outdated Show resolved Hide resolved
Assets/Scripts/Interfaces/Interactable.cs Outdated Show resolved Hide resolved
@certator certator merged commit 7416c92 into master Jan 2, 2021
This was referenced Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants