Skip to content

Commit

Permalink
Work on card zones
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmfinol committed Aug 2, 2023
1 parent 9b09084 commit 4071e6c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
24 changes: 23 additions & 1 deletion Assets/Scenes/PlayGame.unity

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions Assets/Scripts/Cgs/CardGameView/Multiplayer/CardZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

using System.Collections.Generic;
using Cgs.CardGameView.Multiplayer;
using Cgs.UI.ScrollRects;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
Expand All @@ -23,7 +23,7 @@ public enum CardZoneType
Area
}

public class CardZone : CgsNetPlayable, IPointerEnterHandler, IPointerExitHandler
public class CardZone : CgsNetPlayable
{
public CardZoneType type;
public bool allowsFlip;
Expand All @@ -43,14 +43,21 @@ protected override void OnPointerEnterPlayable(PointerEventData eventData)
if (cardModel != null && (type != CardZoneType.Area || cardModel.transform.parent != transform) &&
!cardModel.IsStatic)
cardModel.PlaceHolderCardZone = this;

if (type == CardZoneType.Area && scrollRectContainer is RotateZoomableScrollRect scrollRect)
scrollRect.OnPointerEnter(eventData);
}

protected override void OnPointerExitPlayable(PointerEventData eventData)
{
var cardModel = CardModel.GetPointerDrag(eventData);
if (cardModel != null && cardModel.PlaceHolderCardZone == this)
cardModel.PlaceHolderCardZone = null;

OnLayout?.Invoke();

if (type == CardZoneType.Area && scrollRectContainer is RotateZoomableScrollRect scrollRect)
scrollRect.OnPointerExit(eventData);
}

protected override void OnPointerDownPlayable(PointerEventData eventData)
Expand All @@ -75,17 +82,20 @@ protected override void OnDeselectPlayable(BaseEventData eventData)

protected override void OnBeginDragPlayable(PointerEventData eventData)
{
// Nothing
if (type == CardZoneType.Area && scrollRectContainer is RotateZoomableScrollRect scrollRect)
scrollRect.OnBeginDrag(eventData);
}

protected override void OnDragPlayable(PointerEventData eventData)
{
// Nothing
if (type == CardZoneType.Area && scrollRectContainer is RotateZoomableScrollRect scrollRect)
scrollRect.OnDrag(eventData);
}

protected override void OnEndDragPlayable(PointerEventData eventData)
{
// Nothing
if (type == CardZoneType.Area && scrollRectContainer is RotateZoomableScrollRect scrollRect)
scrollRect.OnEndDrag(eventData);
}

protected override void PostDragPlayable(PointerEventData eventData)
Expand Down
1 change: 0 additions & 1 deletion Assets/Scripts/Cgs/Play/Multiplayer/CgsNetPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Cgs.CardGameView;
using Cgs.CardGameView.Multiplayer;
using Cgs.Play.Drawer;
using FinolDigital.Cgs.CardGameDef;
Expand Down

0 comments on commit 4071e6c

Please sign in to comment.