From dfb77360ce5ce34a9705cb02e71e1692356337ce Mon Sep 17 00:00:00 2001 From: David Finol Date: Mon, 13 Nov 2023 17:02:01 -0600 Subject: [PATCH 1/5] Minor fixes --- Assets/Scripts/Cgs/CardGameManager.cs | 3 ++- Assets/Scripts/Cgs/Tags.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Cgs/CardGameManager.cs b/Assets/Scripts/Cgs/CardGameManager.cs index e06143cb..10705c49 100644 --- a/Assets/Scripts/Cgs/CardGameManager.cs +++ b/Assets/Scripts/Cgs/CardGameManager.cs @@ -622,7 +622,8 @@ private IEnumerator Start() yield return null; Debug.Log("CardGameManager::Start:GameReady"); - GameReady(); + if (Current == null || Current == UnityCardGame.UnityInvalid || Current.Id.equals(Tags.StandardPlayingCardsDirectoryName)) + GameReady(); } #endif diff --git a/Assets/Scripts/Cgs/Tags.cs b/Assets/Scripts/Cgs/Tags.cs index 71dd65c7..31117302 100644 --- a/Assets/Scripts/Cgs/Tags.cs +++ b/Assets/Scripts/Cgs/Tags.cs @@ -12,6 +12,6 @@ public static class Tags public const string CgsWebsite = "https://www.cardgamesimulator.com/"; public const string StandardPlayingCardsDirectoryName = "Standard Playing Cards@www.cardgamesimulator.com"; - public const string CgsGamesListUrl = "https://cgs.games/link"; + public const string CgsGamesListUrl = "https://cgs.games/"; } } From 5ad8e33ec0b35a7b63cdceb47dc5f5d79abb2acc Mon Sep 17 00:00:00 2001 From: David Finol Date: Mon, 13 Nov 2023 18:31:51 -0600 Subject: [PATCH 2/5] Fix case --- Assets/Scripts/Cgs/CardGameManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/Cgs/CardGameManager.cs b/Assets/Scripts/Cgs/CardGameManager.cs index 10705c49..692efb63 100644 --- a/Assets/Scripts/Cgs/CardGameManager.cs +++ b/Assets/Scripts/Cgs/CardGameManager.cs @@ -622,7 +622,7 @@ private IEnumerator Start() yield return null; Debug.Log("CardGameManager::Start:GameReady"); - if (Current == null || Current == UnityCardGame.UnityInvalid || Current.Id.equals(Tags.StandardPlayingCardsDirectoryName)) + if (Current == null || Current == UnityCardGame.UnityInvalid || Current.Id.Equals(Tags.StandardPlayingCardsDirectoryName)) GameReady(); } #endif From 4574b3810bb3fcdc096734bc3fed331028a2cd69 Mon Sep 17 00:00:00 2001 From: David Finol Date: Wed, 15 Nov 2023 09:01:17 -0600 Subject: [PATCH 3/5] Set default zoom to min zoom --- Assets/Scripts/Cgs/Play/PlayController.cs | 2 +- Assets/Scripts/Cgs/UI/ScrollRects/RotateZoomableScrollRect.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Cgs/Play/PlayController.cs b/Assets/Scripts/Cgs/Play/PlayController.cs index 767691e8..dc5e2281 100644 --- a/Assets/Scripts/Cgs/Play/PlayController.cs +++ b/Assets/Scripts/Cgs/Play/PlayController.cs @@ -33,7 +33,7 @@ public class PlayController : MonoBehaviour, ICardDropHandler public const string RestartPrompt = "Restart?"; public const string DefaultStackName = "Stack"; - private const float DefaultZoom = 0.75f; + private const float DefaultZoom = 0.5f; private const float PlayAreaBuffer = 8; private const float DeckPositionBuffer = 50; diff --git a/Assets/Scripts/Cgs/UI/ScrollRects/RotateZoomableScrollRect.cs b/Assets/Scripts/Cgs/UI/ScrollRects/RotateZoomableScrollRect.cs index 64e57842..61299477 100644 --- a/Assets/Scripts/Cgs/UI/ScrollRects/RotateZoomableScrollRect.cs +++ b/Assets/Scripts/Cgs/UI/ScrollRects/RotateZoomableScrollRect.cs @@ -15,7 +15,7 @@ public class RotateZoomableScrollRect : ScrollRect, IPointerEnterHandler, IPoint { private const float MinRotation = -180; // Also in PlayMatRotation slider private const float MaxRotation = 180; // Also in PlayMatRotation slider - public const float MinZoom = 0.5f; // Also in PlayMatZoom slider + private const float MinZoom = 0.5f; // Also in PlayMatZoom slider private const float MaxZoom = 1.5f; // Also in PlayMatZoom slider private const float MouseRotationSensitivity = 360; private const float ZoomLerpSpeed = 7.5f; From 2c00cfe4eeb9e3d43755a8434f9f257d2a40d4dd Mon Sep 17 00:00:00 2001 From: David Finol Date: Wed, 22 Nov 2023 09:32:30 -0600 Subject: [PATCH 4/5] CGS Games List --- Assets/Scripts/Cgs/Tags.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/Cgs/Tags.cs b/Assets/Scripts/Cgs/Tags.cs index 31117302..7b578ee3 100644 --- a/Assets/Scripts/Cgs/Tags.cs +++ b/Assets/Scripts/Cgs/Tags.cs @@ -12,6 +12,6 @@ public static class Tags public const string CgsWebsite = "https://www.cardgamesimulator.com/"; public const string StandardPlayingCardsDirectoryName = "Standard Playing Cards@www.cardgamesimulator.com"; - public const string CgsGamesListUrl = "https://cgs.games/"; + public const string CgsGamesListUrl = "https://cgs.games/list"; } } From b196ff250530b8a87f97d98c75cfc6a878f2f0e0 Mon Sep 17 00:00:00 2001 From: David Finol Date: Fri, 24 Nov 2023 14:50:41 -0600 Subject: [PATCH 5/5] Add stack dropping --- .../Multiplayer/Card Stack.prefab | 69 ++++++++++++++++++- .../CardGameView/Multiplayer/Token.prefab | 33 +++++---- .../Cgs/CardGameView/Multiplayer/CardModel.cs | 14 ++-- .../Cgs/CardGameView/Multiplayer/CardStack.cs | 35 ++++++++-- .../Multiplayer/CgsNetPlayable.cs | 13 ++-- .../Scripts/Cgs/CardGameView/StackDropArea.cs | 29 ++++++++ .../Cgs/CardGameView/StackDropArea.cs.meta | 11 +++ .../Cgs/CardGameView/Viewer/StackViewer.cs | 2 +- .../Cgs/Play/Multiplayer/CgsNetPlayer.cs | 2 +- docs/pages/roadmap.md | 34 ++++----- 10 files changed, 189 insertions(+), 53 deletions(-) create mode 100644 Assets/Scripts/Cgs/CardGameView/StackDropArea.cs create mode 100644 Assets/Scripts/Cgs/CardGameView/StackDropArea.cs.meta diff --git a/Assets/Prefabs/CardGameView/Multiplayer/Card Stack.prefab b/Assets/Prefabs/CardGameView/Multiplayer/Card Stack.prefab index 4c8e4a0a..344562a8 100644 --- a/Assets/Prefabs/CardGameView/Multiplayer/Card Stack.prefab +++ b/Assets/Prefabs/CardGameView/Multiplayer/Card Stack.prefab @@ -11,8 +11,10 @@ GameObject: - component: {fileID: 4087591186767669377} - component: {fileID: 4087591186767669386} - component: {fileID: 4087591186767669389} + - component: {fileID: -3975936145322606666} - component: {fileID: 1400919328307714973} - component: {fileID: 4087591186767669391} + - component: {fileID: -8089532940468131473} - component: {fileID: 4087591186767669390} - component: {fileID: 2811030240499207137} - component: {fileID: 2513898200185063189} @@ -39,7 +41,6 @@ RectTransform: - {fileID: 205211813261613510} - {fileID: 3318835810310926618} m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -84,6 +85,18 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 1 +--- !u!225 &-3975936145322606666 +CanvasGroup: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4087591186767669376} + m_Enabled: 1 + m_Alpha: 1 + m_Interactable: 1 + m_BlocksRaycasts: 1 + m_IgnoreParentGroups: 0 --- !u!114 &1400919328307714973 MonoBehaviour: m_ObjectHideFlags: 0 @@ -112,6 +125,18 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: isBlocker: 0 +--- !u!114 &-8089532940468131473 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4087591186767669376} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7686d93302c464c49b89ebc85cf35224, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!114 &4087591186767669390 MonoBehaviour: m_ObjectHideFlags: 0 @@ -142,6 +167,25 @@ BoxCollider2D: m_Enabled: 1 m_Density: 1 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 m_IsTrigger: 1 m_UsedByEffector: 0 m_UsedByComposite: 0 @@ -175,6 +219,12 @@ Rigidbody2D: m_AngularDrag: 0.05 m_GravityScale: 1 m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 m_Interpolate: 0 m_SleepingMode: 1 m_CollisionDetection: 0 @@ -193,6 +243,10 @@ MonoBehaviour: m_EditorClassIdentifier: GlobalObjectIdHash: 951099334 AlwaysReplicateAsRoot: 0 + SynchronizeTransform: 1 + ActiveSceneSynchronization: 0 + SceneMigrationSynchronization: 1 + SpawnWithObservers: 1 DontDestroyWithOwner: 1 AutoObjectParentSync: 0 --- !u!1 &7768493091142720168 @@ -226,7 +280,6 @@ RectTransform: - {fileID: 3318835810156797752} - {fileID: 3318835808615085628} m_Father: {fileID: 4087591186767669377} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} @@ -238,6 +291,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: + serializedVersion: 3 m_TransformParent: {fileID: 4087591186767669377} m_Modifications: - target: {fileID: 1636166841839465175, guid: eb9a84c1b0b6d25479b907acb118cde9, @@ -361,6 +415,9 @@ PrefabInstance: value: 0 objectReference: {fileID: 0} m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: eb9a84c1b0b6d25479b907acb118cde9, type: 3} --- !u!224 &3318835810310926618 stripped RectTransform: @@ -385,6 +442,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: + serializedVersion: 3 m_TransformParent: {fileID: 205211813261613510} m_Modifications: - target: {fileID: 1636166841839465175, guid: eb9a84c1b0b6d25479b907acb118cde9, @@ -508,6 +566,9 @@ PrefabInstance: value: Deck Label objectReference: {fileID: 0} m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: eb9a84c1b0b6d25479b907acb118cde9, type: 3} --- !u!224 &3318835810156797752 stripped RectTransform: @@ -532,6 +593,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: + serializedVersion: 3 m_TransformParent: {fileID: 205211813261613510} m_Modifications: - target: {fileID: 1636166841839465175, guid: eb9a84c1b0b6d25479b907acb118cde9, @@ -655,6 +717,9 @@ PrefabInstance: value: Count Label objectReference: {fileID: 0} m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: eb9a84c1b0b6d25479b907acb118cde9, type: 3} --- !u!224 &3318835808615085628 stripped RectTransform: diff --git a/Assets/Prefabs/CardGameView/Multiplayer/Token.prefab b/Assets/Prefabs/CardGameView/Multiplayer/Token.prefab index 7ce8aaec..6d9ad7e1 100644 --- a/Assets/Prefabs/CardGameView/Multiplayer/Token.prefab +++ b/Assets/Prefabs/CardGameView/Multiplayer/Token.prefab @@ -11,9 +11,9 @@ GameObject: - component: {fileID: 81248678858698834} - component: {fileID: 4728627613952560980} - component: {fileID: 8080477713170359516} + - component: {fileID: -1703201769562250438} - component: {fileID: 5112060449121573889} - component: {fileID: -6009252998721899997} - - component: {fileID: -1703201769562250438} m_Layer: 5 m_Name: Token m_TagString: Untagged @@ -34,7 +34,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -79,7 +78,7 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 1 ---- !u!114 &5112060449121573889 +--- !u!114 &-1703201769562250438 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -88,10 +87,13 @@ MonoBehaviour: m_GameObject: {fileID: 5127053305123712531} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: abe5a9f80e90af144a558538ecc9f00c, type: 3} + m_Script: {fileID: 11500000, guid: e19747de3f5aca642ab2be37e372fb86, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &-6009252998721899997 + m_EffectColor: {r: 0, g: 0, b: 0, a: 1} + m_EffectDistance: {x: 0, y: 0} + m_UseGraphicAlpha: 1 +--- !u!114 &5112060449121573889 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -100,14 +102,10 @@ MonoBehaviour: m_GameObject: {fileID: 5127053305123712531} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} + m_Script: {fileID: 11500000, guid: abe5a9f80e90af144a558538ecc9f00c, type: 3} m_Name: m_EditorClassIdentifier: - GlobalObjectIdHash: 951099334 - AlwaysReplicateAsRoot: 0 - DontDestroyWithOwner: 1 - AutoObjectParentSync: 0 ---- !u!114 &-1703201769562250438 +--- !u!114 &-6009252998721899997 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -116,9 +114,14 @@ MonoBehaviour: m_GameObject: {fileID: 5127053305123712531} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e19747de3f5aca642ab2be37e372fb86, type: 3} + m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} m_Name: m_EditorClassIdentifier: - m_EffectColor: {r: 0, g: 0, b: 0, a: 1} - m_EffectDistance: {x: 0, y: 0} - m_UseGraphicAlpha: 1 + GlobalObjectIdHash: 951099334 + AlwaysReplicateAsRoot: 0 + SynchronizeTransform: 1 + ActiveSceneSynchronization: 0 + SceneMigrationSynchronization: 1 + SpawnWithObservers: 1 + DontDestroyWithOwner: 1 + AutoObjectParentSync: 0 diff --git a/Assets/Scripts/Cgs/CardGameView/Multiplayer/CardModel.cs b/Assets/Scripts/Cgs/CardGameView/Multiplayer/CardModel.cs index 173bc3a3..db2b09a9 100644 --- a/Assets/Scripts/Cgs/CardGameView/Multiplayer/CardModel.cs +++ b/Assets/Scripts/Cgs/CardGameView/Multiplayer/CardModel.cs @@ -20,7 +20,7 @@ namespace Cgs.CardGameView.Multiplayer { - public class CardModel : CgsNetPlayable, ICardDisplay, ICardDropHandler + public class CardModel : CgsNetPlayable, ICardDisplay, ICardDropHandler, IStackDropHandler { public const string DropErrorMessage = "Error: Card dropped on Card outside of play area!"; @@ -148,9 +148,6 @@ private void SetIsNameVisible(bool value) private Image View => _view ??= GetComponent(); private Image _view; - private CanvasGroup Visibility => _visibility ??= GetComponent(); - private CanvasGroup _visibility; - public override void OnNetworkSpawn() { PlayController.SetPlayActions(this); @@ -175,6 +172,9 @@ protected override void OnStartPlayable() var cardDropArea = gameObject.GetOrAddComponent(); cardDropArea.isBlocker = true; cardDropArea.DropHandler = this; + + var stackDropArea = gameObject.GetOrAddComponent(); + stackDropArea.DropHandler = this; } var cardSize = new Vector2(CardGameManager.Current.CardSize.X, CardGameManager.Current.CardSize.Y); @@ -325,6 +325,12 @@ public void OnDrop(CardModel cardModel) Discard(); } + public void OnDrop(CardStack cardStack) + { + cardStack.RequestInsert(0, Id); + Discard(); + } + public static CardModel CreateDrag(PointerEventData eventData, GameObject gameObject, Transform transform, UnityCard value, bool isFacedown, CardZone placeHolderCardZone = null) { diff --git a/Assets/Scripts/Cgs/CardGameView/Multiplayer/CardStack.cs b/Assets/Scripts/Cgs/CardGameView/Multiplayer/CardStack.cs index a28ef353..4e203721 100644 --- a/Assets/Scripts/Cgs/CardGameView/Multiplayer/CardStack.cs +++ b/Assets/Scripts/Cgs/CardGameView/Multiplayer/CardStack.cs @@ -43,7 +43,7 @@ public static void Shuffle(this IList list) } [RequireComponent(typeof(CardDropArea))] - public class CardStack : CgsNetPlayable, ICardDisplay, ICardDropHandler + public class CardStack : CgsNetPlayable, ICardDisplay, ICardDropHandler, IStackDropHandler { private const float DragHoldTime = 0.5f; public const string ShuffleText = "Shuffled!"; @@ -61,6 +61,12 @@ public class CardStack : CgsNetPlayable, ICardDisplay, ICardDropHandler CurrentPointerEventData.button != PointerEventData.InputButton.Right || PointerPositions.Count > 1; + private bool IsDraggingStack => HoldTime >= DragHoldTime || CurrentPointerEventData is + {button: PointerEventData.InputButton.Middle}; + + protected override bool IsProcessingSecondaryDragAction => + !IsDraggingStack && base.IsProcessingSecondaryDragAction; + public GameObject stackViewerPrefab; public GameObject cardModelPrefab; @@ -152,6 +158,7 @@ protected override void OnStartPlayable() { ParentToPlayAreaContent(); GetComponent().DropHandler = this; + GetComponent().DropHandler = this; var rectTransform = (RectTransform) transform; var cardSize = new Vector2(CardGameManager.Current.CardSize.X, CardGameManager.Current.CardSize.Y); @@ -240,6 +247,12 @@ protected override void OnEndDragPlayable(PointerEventData eventData) { if (!IsDraggingCard && !LacksOwnership) ActOnDrag(); + Visibility.blocksRaycasts = true; + } + + public static CardStack GetPointerDrag(PointerEventData eventData) + { + return eventData.pointerDrag == null ? null : eventData.pointerDrag.GetComponent(); } private void DragCard(PointerEventData eventData) @@ -295,7 +308,7 @@ private void OnCardsUpdated(NetworkListEvent changeEvent) } if (changeEvent.Type.Equals(NetworkListEvent.EventType.Insert) && - changeEvent.Index == _cardIds.Count -1) + changeEvent.Index == _cardIds.Count - 1) { if (CardGameManager.Current.Cards.TryGetValue(_cardIds[^2], out var previous)) previous.UnregisterDisplay(this); @@ -312,13 +325,25 @@ private void OnCardsUpdated(NetworkListEvent changeEvent) public void OnDrop(CardModel cardModel) { cardModel.PlaceHolderCardZone = null; + RequestInsert(Cards.Count, cardModel.Id); + } + + public void OnDrop(CardStack cardStack) + { + for (var i = _cardIds.Count - 1; i >= 0; i--) + cardStack.RequestInsert(0, _cardIds[i]); + RequestDelete(); + } + + public void RequestInsert(int index, string cardId) + { if (LacksOwnership) - CgsNetManager.Instance.LocalPlayer.RequestInsert(gameObject, Cards.Count, cardModel.Id); + CgsNetManager.Instance.LocalPlayer.RequestInsert(gameObject, index, cardId); else - Insert(Cards.Count, cardModel.Id); + OwnerInsert(index, cardId); } - public void Insert(int index, string cardId) + public void OwnerInsert(int index, string cardId) { Debug.Log($"CardStack: {name} insert {cardId} at {index} of {_cardIds.Count}"); _cardIds.Insert(index, cardId); diff --git a/Assets/Scripts/Cgs/CardGameView/Multiplayer/CgsNetPlayable.cs b/Assets/Scripts/Cgs/CardGameView/Multiplayer/CgsNetPlayable.cs index 1330e060..a833ad94 100644 --- a/Assets/Scripts/Cgs/CardGameView/Multiplayer/CgsNetPlayable.cs +++ b/Assets/Scripts/Cgs/CardGameView/Multiplayer/CgsNetPlayable.cs @@ -54,7 +54,7 @@ public class CgsNetPlayable : NetworkBehaviour, IPointerEnterHandler, IPointerEx private NetworkObject _networkObject; - protected bool IsProcessingSecondaryDragAction => PointerDragOffsets.Count > 1 || CurrentPointerEventData is + protected virtual bool IsProcessingSecondaryDragAction => PointerDragOffsets.Count > 1 || CurrentPointerEventData is {button: PointerEventData.InputButton.Middle or PointerEventData.InputButton.Right}; public Vector2 Position @@ -101,6 +101,9 @@ public Quaternion Rotation public virtual string ViewValue => ""; + protected CanvasGroup Visibility => _visibility ??= gameObject.GetOrAddComponent(); + private CanvasGroup _visibility; + public HighlightMode HighlightMode { get => _highlightMode; @@ -173,7 +176,7 @@ private void Start() private void Update() { - if (PointerPositions.Count > 0 && !DidDrag) + if (PointerPositions.Count > 0 && !DidDrag && !Input.GetMouseButton(1)) HoldTime += Time.deltaTime; else HoldTime = 0; @@ -340,6 +343,7 @@ protected virtual void OnEndDragPlayable(PointerEventData eventData) { if (!LacksOwnership) ActOnDrag(); + Visibility.blocksRaycasts = true; } protected virtual void PostDragPlayable(PointerEventData eventData) @@ -362,6 +366,7 @@ protected void RemovePointer(PointerEventData eventData) protected virtual void ActOnDrag() { + Visibility.blocksRaycasts = false; UpdatePosition(); if (IsProcessingSecondaryDragAction) Rotate(); @@ -369,13 +374,11 @@ protected virtual void ActOnDrag() protected virtual void UpdatePosition() { - #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR if (IsProcessingSecondaryDragAction) return; #else - if (Input.GetMouseButton(1) || Input.GetMouseButtonUp(1) || Input.GetMouseButton(2) || - Input.GetMouseButtonUp(2)) + if (Input.GetMouseButton(1) || Input.GetMouseButtonUp(1)) return; #endif diff --git a/Assets/Scripts/Cgs/CardGameView/StackDropArea.cs b/Assets/Scripts/Cgs/CardGameView/StackDropArea.cs new file mode 100644 index 00000000..16ffdf5d --- /dev/null +++ b/Assets/Scripts/Cgs/CardGameView/StackDropArea.cs @@ -0,0 +1,29 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +using Cgs.CardGameView.Multiplayer; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Cgs.CardGameView +{ + public interface IStackDropHandler + { + void OnDrop(CardStack cardStack); + } + + public class StackDropArea : MonoBehaviour, IDropHandler + { + public IStackDropHandler DropHandler { get; set; } + + public void OnDrop(PointerEventData eventData) + { + var cardStack = CardStack.GetPointerDrag(eventData); + if (cardStack == null) + return; + + DropHandler.OnDrop(cardStack); + } + } +} diff --git a/Assets/Scripts/Cgs/CardGameView/StackDropArea.cs.meta b/Assets/Scripts/Cgs/CardGameView/StackDropArea.cs.meta new file mode 100644 index 00000000..a04acf4a --- /dev/null +++ b/Assets/Scripts/Cgs/CardGameView/StackDropArea.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7686d93302c464c49b89ebc85cf35224 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Cgs/CardGameView/Viewer/StackViewer.cs b/Assets/Scripts/Cgs/CardGameView/Viewer/StackViewer.cs index b8c76a89..aaa8bffd 100644 --- a/Assets/Scripts/Cgs/CardGameView/Viewer/StackViewer.cs +++ b/Assets/Scripts/Cgs/CardGameView/Viewer/StackViewer.cs @@ -158,7 +158,7 @@ private void OnAddCardModel(CardZone cardZone, CardModel cardModel) if (CgsNetManager.Instance.IsOnline) CgsNetManager.Instance.LocalPlayer.RequestInsert(_cardStack.gameObject, cardIndex, cardModel.Id); else - _cardStack.Insert(cardIndex, cardModel.Id); + _cardStack.OwnerInsert(cardIndex, cardModel.Id); } private void OnRemoveCardModel(CardZone cardZone, CardModel cardModel) diff --git a/Assets/Scripts/Cgs/Play/Multiplayer/CgsNetPlayer.cs b/Assets/Scripts/Cgs/Play/Multiplayer/CgsNetPlayer.cs index 290fd678..9000cd32 100644 --- a/Assets/Scripts/Cgs/Play/Multiplayer/CgsNetPlayer.cs +++ b/Assets/Scripts/Cgs/Play/Multiplayer/CgsNetPlayer.cs @@ -346,7 +346,7 @@ private void InsertServerRpc(NetworkObjectReference stack, int index, string car { Debug.Log($"[CgsNet Player] Insert {cardId} at {index}!"); var cardStack = ((NetworkObject) stack).GetComponent(); - cardStack.Insert(index, cardId); + cardStack.OwnerInsert(index, cardId); } public void RequestRemoveAt(GameObject stack, int index) diff --git a/docs/pages/roadmap.md b/docs/pages/roadmap.md index 91f667ef..6639fe4d 100644 --- a/docs/pages/roadmap.md +++ b/docs/pages/roadmap.md @@ -4,40 +4,36 @@ permalink: roadmap.html # Roadmap -## What's New - v1.95 -- Minor Bug Fixes +## What's New - v1.96 +- Game-Play: Drop Stack on top of Cards or other Stacks ## Active Sprint - Bug-Fix: Apply rotation when spawning players objects -- Game-Play: Combine Stacks when dropped on each other -- Game-Play: Put Card on bottom of Stack when Stack is dropped on Card -- Game-Play: Rename Stacks +- Game-Play: Group dice onto cards (Dice drop target) +- Game-Play: Special action buttons (i.e. button to reset rotation for all cards, button to turn all cards faceup, etc.) +- Game-Play: Contextual green button for default action based on card location +- Game-Play: Right-click on playable for context menu ## Backlog - 2023 Q4 -- Game-Creation: Edit Button in Games Management Menu -- Game-Play: Cards you receive at the beginning of the game can be defined by default -- Game-Play: Contextual green button for default action based on card location -- Game-Play: Custom Tokens +- Game-Play: Name-Plates indicating player seats - Game-Play: Label which player is moving cards +- Game-Play: Rename Stacks +- Game-Play: Custom Tokens +- Game-Play: gamePlayDefaultDecks and gamePlayDefaultCards - Game-Play: Support multiple card selection -- Game-Play: Name-Plates indicating player seats ## Backlog - 2024 Q1 -- Cards: Ability to resize card preview image +- Game-Creation: Edit Button in Games Management Menu - Cards: Support multiple card backs - Cards: Support more than 1 card face (Dual-Faced Cards) - Cards: Support mix of different card sizes in the same game -- Game-Play: gamePlayDefaultDecks and gamePlayDefaultCards - Game-Play: Counter system for players and cards - Game-Play: Save/Load Sessions + Log of all (Player) actions - Game-Play: Cut/Copy/Paste Cards - Game-Play: Undo with Ctrl-Z ## Backlog - 2024 Q2 -- Game-Play: Right-click on playable for context menu -- Game-Play: Special action buttons (i.e. button to reset rotation for all cards, button to turn all cards faceup, etc.) - Game-Play: Apply permissions for each other's decks/stacks/cards, shuffling, moving, deleting, viewing facedown, etc -- Game-Play: Cut Stacks - Game-Play: Move card to zone, stack, or drawer (E) - Game-Play: Add restart button in Play Settings Menu - Decks: Support organizing decks into folders @@ -54,11 +50,9 @@ permalink: roadmap.html - Cards Explorer & Deck Editor: Add sorting + Sort Menu - Game-Play: Support multiple playmats - Game-Play: Setup gamepad and keyboard shortcuts/hotkeys for Game-Play and Settings -- Games: Ability to re-skin CGS per game, changing the look of the buttons, background, scroll bar, etc -- Integration: Private Lobbies & Deep links to join multiplayer rooms -- Platforms: Productionize WebGL version by enabling Multiplayer and Developer Mode - Platforms: Full controller support (Steam) -- Integration: Database for user-created card games, with in-app automation to upload and download from this database (Steam Workshop?) +- Integration: Private Lobbies & Deep links to join multiplayer rooms +- Platforms: Add Multiplayer and Developer Mode to Web browser - Accessibility: Tutorial Video for How-To-Play - 0:00 Intro (Name/Website) - 0:00 Playing Solo (Single-player/Goldfishing) @@ -69,7 +63,7 @@ permalink: roadmap.html - 0:00 Settings/Contact - CGS Website: https://www.cardgamesimulator.com/ - Accessibility: Tutorial Video for How-To-Create-And-Share -- Game-Play: Tournament Support (PoQ?) +- Games: Ability to re-skin CGS per game, changing the look of the buttons, background, scroll bar, etc - Dev option (GUI): Create a default 'Setup' for more complicated card games. For example games that use multiple decks, counters, tokens etc that are always placed on the table when a game begins. The game dev should be able to put all of this down on the 'table' so that all future players will just be able to play when launching a game without manual setup.