Пример #1
0
 /// <summary>
 /// Comienza el drag de la carta.
 /// </summary>
 public override void OnStartDrag()
 {
     savedHandSlot            = whereIsCard.Slot;
     tempState                = whereIsCard.EstadoVisual;
     whereIsCard.EstadoVisual = VisualStates.Arrastrando;
     whereIsCard.TraerAlFrente();
     reset = false;
 }
Пример #2
0
    /// <summary>
    /// Instancia la carta visual del jugador y la reparte.
    /// </summary>
    /// <param name="c">C.</param>
    /// <param name="UniqueID">Unique I.</param>
    /// <param name="fast">If set to <c>true</c> fast.</param>
    /// <param name="fromDeck">If set to <c>true</c> from deck.</param>
    /// <param name="rotarDeCara">If set to <c>true</c> rotar de cara.</param>
    public void DarCartaJugador(CartaPartida c, int UniqueID, bool fast = false, bool fromDeck = true, bool rotarDeCara = false)
    {
        if (!rotarDeCara)
        {
            fast = true;
        }
        GameObject card;

        if (fromDeck)
        {
            card = CrearCartaPorPosicion(c, DeckTransform.position, new Vector3(0f, -179f, 0f));
        }
        else
        {
            card = CrearCartaPorPosicion(c, OtherCardDrawSourceTransform.position, new Vector3(0f, -179f, 0f));
        }
        // save this as visual representation in CardLogic
        // Player ownerPlayer = GlobalSettings.Instance.Players[owner];
        //Debug.Log(ownerPlayer);
        //Debug.Log(ownerPlayer.hand);
        //Debug.Log("CArdsInHand.Count: "+ ownerPlayer.hand.CardsInHand.Count);
        //Debug.Log("Attempted placeInHand: " +placeInHand);
        // ownerPlayer.hand.CardsInHand[0].VisualRepresentation = card;
        //Debug.Log(ownerPlayer.hand);
        // Set a tag to reflect where this card is
        foreach (Transform t in card.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Card";
        }
        // pass this card to HandVisual class
        AñadirCarta(card);
        // let the card know about its place in hand.
        WhereIsTheCardOrEntity w = card.GetComponent <WhereIsTheCardOrEntity>();

        w.TraerAlFrente();

        w.Slot         = 0;
        w.EstadoVisual = VisualStates.Transicion;
        // pass a unique ID to this card.
        IDHolder id = card.AddComponent <IDHolder>();

        id.UniqueID = UniqueID;

        // save this card to change its state to "Hand" when it arrives to the hand.
        LastDealtCard = card;
        if (card.GetComponent <AudioSource>() != null && ConfiguracionUsuario.Instance.Musica)
        {
            card.GetComponent <AudioSource>().Play();
        }
        // move card to the hand;
        Sequence s = DOTween.Sequence();

        if (!fast)
        {
            Debug.Log("Not fast!!!");
            s.Append(card.transform.DOMove(DrawPreviewSpot.position, ConfiguracionUsuario.Instance.CardTransitionTime));

            s.Insert(0f, card.transform.DORotate(Vector3.zero, ConfiguracionUsuario.Instance.CardTransitionTime));

            s.AppendInterval(ConfiguracionUsuario.Instance.CardPreviewTime);
            // displace the card so that we can select it in the scene easier.
            s.Append(card.transform.DOLocalMove(slots.Children[0].transform.localPosition, ConfiguracionUsuario.Instance.CardTransitionTime));
        }
        else
        {
            // displace the card so that we can select it in the scene easier.
            if (rotarDeCara)
            {
                s.Insert(0f, card.transform.DORotate(Vector3.zero, ConfiguracionUsuario.Instance.CardTransitionTime));
            }
            s.Append(card.transform.DOLocalMove(slots.Children[0].transform.localPosition, ConfiguracionUsuario.Instance.CardTransitionTime));
            //if (TakeCardsOpenly)
            //s.Insert(0f, card.transform.DORotate(Vector3.zero, DatosGenerales.Instance.CardTransitionTimeFast));
        }

        s.OnComplete(() => CambiarEstadoCartaAMano(card, w));
    }