Ejemplo n.º 1
0
    IEnumerator anim()
    {
        RectTransform me = gameObject.GetComponent <RectTransform>();

        me.SetAsLastSibling();
        IAnimInterface a1 = RectTransfer.Apply(gameObject, middle, flydur);

        a1.Run();
        IAnimInterface a2 = gameObject.GetComponent <CardFlip>();

        a2.Run();
        while (!a1.isDone || !a2.isDone)
        {
            yield return(null);
        }
        Destroy(a1 as Component);
        //a1=gameObject.GetComponent<CardFlip>();
        //a1.Run();
        //while(!a1.isDone) yield return null;
        //Destroy(a1 as Component);
        a1 = RectTransfer.Apply(gameObject, hand, flydur);
        a1.Run();
        while (!a1.isDone)
        {
            yield return(null);
        }
        Destroy(a1 as Component);
        done = true;
    }
Ejemplo n.º 2
0
    IEnumerator trans()
    {
        Debug.Log("trans");
        SingleGame.Conditional castCard = _game.hookData["castSource"] as SingleGame.Conditional;

        //SingleGame.Conditional targetCard=_game.hookData["castTarget"] as SingleGame.Conditional;
        if (castCard != null)
        {
            if (castCard["_Owner"] != player1)
            {
                hooks.Remove("transformation");
                SingleGame.GameManager.endHook();  yield break;
            }
            int handnum = -1;
            for (int i = 0; i < handCards.Count; i++)
            {
                if (castCard == handCards[i].cardData)
                {
                    handnum = i; break;
                }
            }
            if (handnum == -1)
            {
                Debug.Log("Some error");
            }
            else
            {
                CardControl   toMove   = handCards[handnum];
                RectTransform original = toMove.GetComponent <RectTransform>();
                RectTransform canv     = original.RootCanvasTransform();
                Vector4       posvec   = canv.getAnchorsFromCanvasRect(original.RootCanvasRect());
                handCards.Remove(toMove);
                List <IAnimInterface> anims = new List <IAnimInterface>();
                for (int j = 0; j < mpBody.Count; j++)
                {
                    CardReceptor cr = mpBody[j];
                    if (castCard.hasTag(cr.validTag))
                    {
                        GameObject  crd = Instantiate(card) as GameObject;
                        CardControl crc = crd.GetComponent <CardControl>();
                        crc.cardData = castCard;
                        crc.playerID = castCard["_Owner.playerID"] as string;
                        SpawnCardAnim todel = crd.GetComponent <SpawnCardAnim>();
                        Destroy(todel as Component);
                        CardFlip flp = crd.GetComponent <CardFlip>();
                        flp.Flip();
                        RectTransform ctr = crd.GetComponent <RectTransform>();
                        ctr.SetParent(canv, false);
                        ctr.SetAsLastSibling();
                        ctr.assignRectAnchors(posvec);
                        RectTransform  targpos = cr.gameObject.GetComponent <RectTransform>();
                        IAnimInterface an      = RectTransfer.Apply(crd, targpos, shiftdur);
                        an.Run();
                        anims.Add(an);
                        cr.cardData = castCard;
                    }
                }
                Destroy(toMove.gameObject);

                bool done = false;
                while (!done)
                {
                    done = true;
                    foreach (IAnimInterface anim in anims)
                    {
                        done = (done & anim.isDone);
                    }
                    yield return(null);
                }
                foreach (IAnimInterface anim in anims)
                {
                    RectTransfer rt = anim as RectTransfer;
                    Destroy(rt.gameObject);
                }
            }
        }
        hooks.Remove("transformation");
        SingleGame.GameManager.endHook();
        yield break;
    }