void Awake() { // Connecting everything sr = GetComponent <SpriteRenderer>(); lr = GetComponentInChildren <LineRenderer>(); lr.sortingLayerName = "AboveEverything"; triangle = transform.Find("ArrowEnd"); triangleSR = triangle.GetComponent <SpriteRenderer>(); cardManager = GetComponentInParent <PlayedCreatureDisplay>(); whereIsTheCard = GetComponentInParent <WhereIsTheCard>(); }
// Used when the player has max cards and the drawn card needs to be show getting destroyed public void VisuallyShowCard(CardTemplate c, int UniqueID, bool fast = false, bool fromDeck = true) { GameObject card; if (fromDeck) { card = CreateACardAtPosition(c, DeckTransform.position, new Vector3(0f, -179f, 0f)); } else { card = CreateACardAtPosition(c, OtherCardDrawSourceTransform.position, new Vector3(0f, -179f, 0f)); } // Bring card to front while it travels fromd raw spot to hand WhereIsTheCard w = card.GetComponent <WhereIsTheCard>(); w.BringToFront(); w.Slot = 0; w.VisualState = VisualStates.Transition; IDHolder id = card.AddComponent <IDHolder>(); id.UniqueID = UniqueID; // Move card to the hand Sequence s = DOTween.Sequence(); { if (!fast) { // not fast s.Append(card.transform.DOMove(DrawPreviewSpot.position, GameManager.Instance.CardTransitionTimes)); if (TakeCardsOpenly) { s.Insert(0f, card.transform.DORotate(Vector3.zero, GameManager.Instance.CardTransitionTimes)); } s.AppendInterval(GameManager.Instance.CardPreviewTime); // displace the card so that we can select it in the scene easily s.Append(card.transform.DOLocalMove(slots.Slots[0].transform.localPosition, GameManager.Instance.CardTransitionTimes)); } else { // Displace the card so it can be selected in the scene more easily. s.Append(card.transform.DOLocalMove(slots.Slots[0].transform.localPosition, GameManager.Instance.CardTransitionTimes)); if (TakeCardsOpenly) { s.Insert(0f, card.transform.DORotate(Vector3.zero, GameManager.Instance.CardTransitionTimes)); } } s.OnComplete(() => ChangeLastCardStatusToInHand(card, w)); } }
// shift cards to new slots void PlaceCardOnSlot() { // For each card in cardsinhand foreach (GameObject g in CardsInHand) { // tween this card to new slot g.transform.DOLocalMoveX(slots.Slots[CardsInHand.IndexOf(g)].transform.localPosition.x, 0.2f); // Apply correct sorting order and handslot value for later WhereIsTheCard w = g.GetComponent <WhereIsTheCard>(); w.Slot = CardsInHand.IndexOf(g); w.SetHandSortingOrder(); } }
void ChangeLastCardStatusToInHand(GameObject card, WhereIsTheCard w) { if (owner == AreaPositions.Bottom) { w.VisualState = VisualStates.LowHand; } else { w.VisualState = VisualStates.TopHand; } w.SetHandSortingOrder(); // Action complete (allows other actions to be done) Action.ActionExecutionComplete(); }
// method to create a new creature and add it to the table public void AddCreatureAtIndex(CardTemplate ct, int UniqueID, int index) { // create a new creature from prefab GameObject creature = GameObject.Instantiate(GameManager.Instance.PlayedCreaturePrefab, slots.Slots[index].transform.position, Quaternion.identity) as GameObject; // apply the look from CardAsset PlayedCreatureDisplay manager = creature.GetComponent <PlayedCreatureDisplay>(); manager.cardTemplate = ct; manager.LoadCreature(); // add tag according to owner foreach (Transform t in creature.GetComponentsInChildren <Transform>()) { t.tag = owner.ToString() + "Creature"; } // parent a new creature gameObject to table slots creature.transform.SetParent(slots.transform); // add a new creature to the list CreaturesOnTable.Insert(index, creature); // let this creature know about its position WhereIsTheCard w = creature.GetComponent <WhereIsTheCard>(); w.Slot = index; if (owner == AreaPositions.Bottom) { w.VisualState = VisualStates.LowTable; } else { w.VisualState = VisualStates.TopTable; } // add our unique ID to this creature IDHolder id = creature.AddComponent <IDHolder>(); id.UniqueID = UniqueID; // after a new creature is added update placing of all the other creatures ShiftSlotsGameObjectAccordingToNumberOfCreatures(); PlaceCreaturesOnNewSlots(); // end command execution Action.ActionExecutionComplete(); }
void Awake() { whereIsTheCard = GetComponent <WhereIsTheCard>(); manager = GetComponent <CardDisplay>(); }
void Awake() { // Assigning cardManager = GetComponent <PlayedCreatureDisplay>(); whereIsTheCard = GetComponent <WhereIsTheCard>(); }