public void Bent(List<GameObject> cards, Transform parent) { if (cards == null || cards.Count < 1) return; var fullAngle = -bentAngle; var anglePerCard = fullAngle / cards.Count; var firstAngle = Utilities.CalcFirstAngle(fullAngle); //var handWidth = CalcHandWidth(cards.Count); var handWidth = Utilities.CalcAreaWidth(cards.Count, cardWidth, spacing); var offsetX = pivot.position.x - handWidth / 2; for (var i = 0; i < cards.Count; i++ ) { var card = cards[i]; var angleTwist = firstAngle + i * anglePerCard; var xPos = offsetX + cardWidth / 2; var yDistance = Mathf.Abs(angleTwist) * height; var yPos = pivot.position.y - yDistance; var rotation = new Vector3(0, 0, angleTwist); var position = new Vector3(xPos, yPos, card.transform.position.z); //card.transform.position = position; card.transform.rotation = Quaternion.Euler(rotation.x, rotation.y, rotation.z); CardRotation cardRotation = card.transform.GetComponent<CardRotation>(); if (cardRotation.cardState == Enums.CardState.FaceDown) { cardRotation.cardState = Enums.CardState.FaceUp; if (cardRotation.CardStateChangeDone) cardRotation.CardStateChangeDone = false; cardRotation.Flip(); } cardRotation.cardFront.transform.rotation = Quaternion.Euler( rotation.x, 0, rotation.z ); //if (cardRotation.cardFront.transform.rotation.eulerAngles.y == 180 || card.transform.rotation.eulerAngles.y == -180) //{ // cardRotation.cardFront.transform.rotation = Quaternion.Euler( // rotation.x, // 0, // rotation.z // ); //} card.transform.DOMove(position, 0.5f).SetEase(Ease.OutQuint).OnComplete(() => { VisualsEvents.current.UpdateDraggableOriginalPosition(card, -1f, -1f); }); card.transform.SetParent(parent, false); card.SetCardLocation(Enums.CardLocation.HandArea); offsetX += cardWidth + spacing; } }
public GameObject GetCard(int cardId) { Card findCard = GetCardsFromResource().Where(w => w.CardId == cardId).FirstOrDefault(); card = GetTypeOfCard(findCard); var cardDisplay = card.GetComponent <CardDisplay>(); var cardPreview = card.transform.Find("CardPreview"); var cardPreviewDisplay = cardPreview.GetComponent <CardPreviewDisplay>(); var canvas = card.transform.Find("Canvas"); var cardArt = canvas.transform.Find("ArtCard"); ArtCardPreviewDisplay cardArtPreviewDisplay = null; if (cardArt != null) { cardArtPreviewDisplay = cardArt.GetComponent <ArtCardPreviewDisplay>(); } if (findCard != null) { cardDisplay.card = findCard; cardPreviewDisplay.card = findCard; if (cardArtPreviewDisplay != null) { cardArtPreviewDisplay.card = findCard; } GameObject singleCard = Instantiate(card, new Vector3(0, 0, -0.01f), Quaternion.identity); CardRotation cardRotation = singleCard.transform.GetComponent <CardRotation>(); cardRotation.cardState = Enums.CardState.FaceDown; cardRotation.Flip(); return(singleCard); } return(null); }