Skip to content

Commit

Permalink
Add GamePlayDeckPositions and GamePlayZones
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmfinol committed Jul 24, 2023
1 parent 10c3cb1 commit 7aee88f
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Assets/Plugins/FinolDigital.Cgs.CardGameDef.dll
Git LFS file not shown
3 changes: 3 additions & 0 deletions Assets/Scripts/Cgs/AotTypeEnforcer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public void Awake()
var gameBoardUrl = new GameBoardUrl(string.Empty, new Uri(UnityFileMethods.FilePrefix));
cardGame.GameBoardUrls = new List<GameBoardUrl> {gameBoardUrl};
cardGame.GamePlayDeckName = string.Empty;
cardGame.GamePlayDeckPositions = new List<Float2>();
var gamePlayZone = new GamePlayZone(FacePreference.Any, float2, float2, GamePlayZoneType.Area);
cardGame.GamePlayZones = new List<GamePlayZone> {gamePlayZone};
cardGame.GameStartHandCount = 1;
cardGame.GameStartPointsCount = 1;
cardGame.Name = string.Empty;
Expand Down
33 changes: 29 additions & 4 deletions Assets/Scripts/Cgs/Play/PlayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public Vector2 NewDeckPosition
{
get
{
var allCardStacks = AllCardStacks.ToList();
if (allCardStacks.Count < CardGameManager.Current.GamePlayDeckPositions.Count)
{
var position = CardGameManager.Current.GamePlayDeckPositions[allCardStacks.Count];
return new Vector2(CardGameManager.PixelsPerInch * position.X,
CardGameManager.PixelsPerInch * position.Y);
}

var cardStack = cardStackPrefab.GetComponent<CardStack>();
var cardStackLabelHeight =
((RectTransform) cardStack.deckLabel.transform.parent).rect.height * playArea.CurrentZoom;
Expand All @@ -74,7 +82,7 @@ public Vector2 NewDeckPosition
null, out var nextDeckPosition);

var nextOffset = new Rect(nextDeckPosition, cardSize);
while (AllCardStacks.Any(stack =>
while (allCardStacks.Any(stack =>
(new Rect(stack.transform.localPosition, cardSize)).Overlaps(nextOffset)))
{
nextDeckPosition += Vector2.down * (cardSize.y + cardStackLabelHeight);
Expand Down Expand Up @@ -241,8 +249,18 @@ private void LoadDeck(UnityDeck deck)
var i = 1;
foreach (var (stackName, cards) in extraGroups)
{
var position = newDeckPosition + Vector2.right *
(CardGameManager.PixelsPerInch * i * CardGameManager.Current.CardSize.X + DeckPositionBuffer);
var position = newDeckPosition +
Vector2.right *
(CardGameManager.PixelsPerInch * i * CardGameManager.Current.CardSize.X +
DeckPositionBuffer);

var deckCount = AllCardStacks.ToList().Count;
if (deckCount >= 0 && deckCount < CardGameManager.Current.GamePlayDeckPositions.Count)
{
var targetPosition = CardGameManager.Current.GamePlayDeckPositions[deckCount];
position = CardGameManager.PixelsPerInch * new Vector2(targetPosition.X, targetPosition.Y);
}

CgsNetManager.Instance.LocalPlayer.RequestNewCardStack(stackName, cards.Cast<UnityCard>().Reverse(),
position);
i++;
Expand All @@ -256,12 +274,19 @@ private void LoadDeck(UnityDeck deck)
{
var position = newDeckPosition + Vector2.right *
(CardGameManager.PixelsPerInch * i * CardGameManager.Current.CardSize.X);

var deckCount = AllCardStacks.ToList().Count;
if (deckCount >= 0 && deckCount < CardGameManager.Current.GamePlayDeckPositions.Count)
{
var targetPosition = CardGameManager.Current.GamePlayDeckPositions[deckCount];
position = CardGameManager.PixelsPerInch * new Vector2(targetPosition.X, targetPosition.Y);
}

CreateCardStack(groupName, cards.Cast<UnityCard>().Reverse().ToList(), position);
i++;
}
}


PromptForHand();
}

Expand Down
4 changes: 4 additions & 0 deletions docs/games/grand_archive/grand_archive.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@
"gameStartHandCount": 7,
"playMatImageFileType": "jpg",
"playMatImageUrl": "https://www.cardgamesimulator.com/games/grand_archive/PlayMat.jpg",
"playMatGridCellSize": {
"x": 0,
"y": 0
},
"playMatSize": {
"x": 36.75,
"y": 42.75
Expand Down
15 changes: 8 additions & 7 deletions docs/pages/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ permalink: roadmap.html
- Bug: Sometimes stacks will duplicate the bottom two cards below the stack, creating another stack underneath
- 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: Add restart button in Play Settings Menu
- Game-Play: Contextual green button for default action based on card location
- Game-Play: Face-Up Stacks (Always reveal the top card)
- Game-Play: Rename Stacks
- Game-Creation: Edit Button in Main Menu

## Backlog - 2023 Q3
## Backlog - 2023 Q4
- Game-Play: Add restart button in Play Settings Menu
- Game-Play: Contextual green button for default action based on card location
- Game-Play: Label which player is moving cards
- Game-Play: Support multiple card selection
- Game-Play: Name-Plates indicating player seats
- Game-Play: Custom Tokens
- Game-Play: Rotate Dice
- Game-Play: Face-Up Stacks (Always reveal the top card)
- Game-Play: Prevent player from looking through Stacks in certain situations

## Backlog - 2023 Q4
## Backlog - 2024 Q1
- Game-Play: Cut Stacks
- Game-Play: Counter system for players and cards
- Game-Play: Save/Load Games + Log of all (Player) actions
Expand All @@ -33,7 +34,7 @@ permalink: roadmap.html
- Game-Play: Special action buttons (i.e. button to reset rotation for all cards, button to turn all cards faceup, etc.)
- Game-Play: Move card to zone, stack, or drawer (E)

## Backlog - 2024 Q1
## Backlog - 2024 Q2
- Cards: Support mix of different card sizes in the same game
- Cards: Support more than 1 card face (Dual-Faced Cards)
- Cards: Support multiple card backs
Expand All @@ -43,7 +44,7 @@ permalink: roadmap.html
- Decks: Show error(s) when a card is not found
- Decks: Group cards in Deck Editor

## Backlog - 2024
## Backlog - 2024 Q3
- 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
Expand Down
82 changes: 82 additions & 0 deletions docs/schema/CardGameDef.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,20 @@
"type": "string",
"description": "gamePlayDeckName is the name of the card stack shown when a player loads a deck. If <gamePlayDeckName> is empty, the *Deck:Name* is used."
},
"gamePlayDeckPositions": {
"type": "array",
"description": "Each deck loaded during a game will be loaded to its corresponding position in gamePlayDeckPositions. The first deck loaded will go to the first position, second to second, etc.",
"items": {
"$ref": "#/definitions/Float2"
}
},
"gamePlayZones": {
"type": "array",
"description": "gamePlayZones will appear in the Play Area in Play Mode.",
"items": {
"$ref": "#/definitions/GamePlayZone"
}
},
"gameStartHandCount": {
"type": "integer",
"description": "gameStartHandCount indicates how many cards are automatically dealt from the deck to the hand, when a user loads a deck in Play Mode.",
Expand Down Expand Up @@ -689,6 +703,74 @@
"tap",
"zoom"
]
},
"GamePlayZone": {
"type": "object",
"additionalProperties": false,
"properties": {
"face": {
"description": "When a Card enters the Game Play Zone, the Card will display this face",
"default": "any",
"oneOf": [
{
"$ref": "#/definitions/FacePreference"
}
]
},
"position": {
"description": "Indicates the Game Play Zone's position in inches",
"oneOf": [
{
"$ref": "#/definitions/Float2"
}
]
},
"size": {
"description": "Indicates the Game Play Zone's width and height in inches",
"oneOf": [
{
"$ref": "#/definitions/Float2"
}
]
},
"type": {
"description": "The Game Play Zone type from area, horizontal, or vertical",
"default": "area",
"oneOf": [
{
"$ref": "#/definitions/GamePlayZoneType"
}
]
}
}
},
"FacePreference": {
"type": "string",
"description": "",
"x-enumNames": [
"Any",
"Down",
"Up"
],
"enum": [
"any",
"down",
"up"
]
},
"GamePlayZoneType": {
"type": "string",
"description": "",
"x-enumNames": [
"Area",
"Horizontal",
"Vertical"
],
"enum": [
"area",
"horizontal",
"vertical"
]
}
}
}

0 comments on commit 7aee88f

Please sign in to comment.