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; }
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; }
IEnumerator draw() { /*IAnimInterface a1=RectTransfer.Apply(gameObject,middle,flydur); * a1.Run(); * while(!a1.isDone) yield return null;*/ // Debug.Log(_game.hookData["_Owner"]); if (_game.hookData["_Owner"] != _game._GameData["Player1"]) { SingleGame.GameManager.endHook(); hooks.Remove("draw"); yield break; } /*if(postshuf) * { * SingleGame.Conditional dt= _game.hookData; * dt.logtags(); * }*/ collectTime = false; IList handlst = (_game._GameData["Player1"] as SingleGame.Conditional)["HAND"] as IList; List <CardControl> trem = new List <CardControl>(); List <IAnimInterface> anims = new List <IAnimInterface>(); for (int handc = 0; handc < handCards.Count; handc++) { int newp = -1; if (_game.hookData != handCards[handc].cardData) { for (int pos = 0; pos < handlst.Count; pos++) { if (handlst[pos] == handCards[handc].cardData) { newp = pos; break; } } } if (newp == -1) { trem.Add(handCards[handc]); } else { if (newp != handCards[handc].slotPos) { int dif = Mathf.Abs(newp - handCards[handc].slotPos); anims.Add(RectTransfer.Apply(handCards[handc].gameObject, handSlots[newp], shiftdur * dif)); handCards[handc].slotPos = newp; } } } foreach (CardControl td in trem) { handCards.Remove(td); Destroy(td.gameObject); } trem = null; foreach (IAnimInterface anim in anims) { anim.Run(); } bool done = false; while (!done) { done = true; foreach (IAnimInterface anim in anims) { done = (done & anim.isDone); } yield return(null); } RectTransform rt = deck.RootCanvasTransform(); GameObject crd = Instantiate(card) as GameObject; CardControl crc = crd.GetComponent <CardControl>(); crc.playerID = player1["playerID"] as string; crc.cardData = _game.hookData; crc.slotPos = 0; RectTransform crt = crd.GetComponent <RectTransform>(); crt.SetParent(rt, false); crt.SetAsLastSibling(); Rect rr = deck.RootCanvasRect(); Vector4 tovec = rt.getAnchorsFromCanvasRect(rr); //crt.SetInternalAnchors (new Vector4 (0, 0, 1, 1)); crt.assignRectAnchors(tovec); /*crt.anchorMin=new Vector2(tovec.x,tovec.y); * crt.anchorMax=new Vector2(tovec.z,tovec.w); * crt.offsetMax=Vector2.zero; * crt.offsetMin=Vector2.zero;*/ SpawnCardAnim can = crd.GetComponent <SpawnCardAnim>(); can.middle = flipper; handCards.Add(crc); int cnt = 0; if (cnt >= 7) { cnt = 6; } can.hand = handSlots[cnt]; while (!can.done) { yield return(null); } SingleGame.GameManager.endHook(); hooks.Remove("draw"); collectTime = true; yield break; }